home *** CD-ROM | disk | FTP | other *** search
- /*******************************
- ** **
- ** Keyboard.h **
- ** **
- ** A set of useful routines **
- ** for controlling keyboard **
- ** settings and information. **
- ** **
- ** (C) 1994 by Sean Werkema **
- ** Revision 2.0 7/4/1994 **
- ** **
- *******************************/
-
- #ifndef K_LANG
- #ifdef __cplusplus
- #define K_LANG "C"
- #else
- #define K_LANG
- #endif
- #endif
-
- /************************************************************************
- Version 2.0 data & functions 7/10/1994
- ************************************************************************/
-
- /*
- ** Function prototypes
- */
-
- extern K_LANG int KeyASCII();
- /* Holds last ASCII value read from keyboard. Changes with each read,
- ** but does not change with each call.
- */
- extern K_LANG int KeyScan();
- /* Holds last scan code value read from keyboard. Changes with each read,
- ** but does not change with each call.
- */
- extern K_LANG int GetCursorStart(void);
- /* Returns value corresponding to top of cursor, usually 0-7.
- */
- extern K_LANG int GetCursorEnd(void);
- /* Returns value corresponding to bottom of cursor, usually 0-7.
- */
- extern K_LANG void SetCursorSize(int Start, int End);
- /* Adjusts cursor size to top and bottom values (usually from 0-7).
- */
- extern K_LANG int GetCursorX(int page);
- /* Returns horizontal position of cursor, ranging from 1 to <scrn width>.
- ** If page is -1, the currently displayed page will be used.
- */
- extern K_LANG int GetCursorY(int page);
- /* Returns vertical position of cursor, ranging from 1 to <scrn height>.
- ** If page is -1, the currently displayed page will be used.
- */
- extern K_LANG void SetCursorPos(int page, int X, int Y);
- /* Moves cursor to specified coordinates, with the origin at 1.
- ** If page is -1, the currently displayed page will be used.
- */
- extern K_LANG int ReadKeyASCII(void);
- /* Waits for a key to be pressed, then returns the ASCII value of that
- ** key. KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- */
- extern K_LANG int ReadKeyScan(void);
- /* Waits for a key to be pressed, then returns the scan code of that
- ** key. KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- */
- extern K_LANG int KeyStatus(void);
- /* Returns 1 if a keypress is waiting, and 0 if no keypress is waiting. If
- ** 1, KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- */
- extern K_LANG int KeyFlags(void);
- /* Returns keyboard flags: L Shf, R Shf, Ctrl, Alt, Caps, Num, Scrl, Ins.
- */
- extern K_LANG int EReadKeyASCII(void);
- /* Waits for a key to be pressed, then returns the ASCII value of that
- ** key. KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- ** Same as ReadKeyASCII, except can detect extended keys.
- */
- extern K_LANG int EReadKeyScan(void);
- /* Waits for a key to be pressed, then returns the scan code of that
- ** key. KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- ** Same as ReadKeyScan, except can detect extended keys.
- */
- extern K_LANG int EKeyStatus(void);
- /* Returns 1 if a keypress is waiting, and 0 if no keypress is waiting. If
- ** 1, KeyASCII and KeyScan are set to the key's ASCII value & scan code.
- ** Same as KeyStatus, except can detect extended keys.
- */
- extern K_LANG int EKeyFlags(void);
- /* Returns keyboard flags: L Shf, R Shf, L Ctrl, R Ctrl, L Alt, R Alt,
- ** Caps, Num, Scrl, Ins, SysReq.
- ** Same as KeyFlags, except can detect extended keys.
- */
- extern K_LANG int IsEKeybd(void);
- /* Returns 0 if not an Extended Keyboard, 1 if is an Extended Keyboard.
- */
-
- /************************************************************************
- Version 2.0 data & functions 7/4/1994
- ************************************************************************/
-
- /*
- ** Special keyboard control functions
- */
-
- extern K_LANG void NewKeyboard(void);
- /* Initializes special keyboard data control functions.
- ** Standard functions will not work when special functions are
- ** active, but the special functions allow more versatile control
- ** of keyboard data. Accepts no values, returns no values.
- */
- extern K_LANG void OldKeyboard(void);
- /* Deactivates special keyboard functions, allowing normal
- ** functions to be used instead. If special functions have
- ** been activated, deactivate them before exiting program
- ** or attempting to use normal functions. Accepts no values,
- ** returns no values.
- */
- extern K_LANG unsigned int GetStroke(void);
- /* Special function that returns a scan code corresponding to
- ** a key press or release, both of which are stored in a FIFO
- ** buffer from which this function reads its information. If
- ** the upper byte of the returned integer contains 0xE0 the
- ** key press/release was from a key on the Extended Keyboard
- ** (Gray Insert/Delete/Home/End/PgUp/PgDn/Arrows/Enter/Slash or Right
- ** Ctrl/Alt). If bit 7 is set (high bit of low byte) the value
- ** indicates a key release; if bit 7 is clear, the value indicates
- ** a key press. If the returned integer is 0, no keystrokes are
- ** waiting. Low 7 bits contain scan code corresponding to
- ** the key, as per the following table:
- **
- ** Scan Code Table (Hexadecimal values given)
- ** ┌───┐ ┌──┬──┬──┬──┐┌──┬──┬──┬──┐ ┌──┬──┬──┬──┐ ┌──┬──┬──┐
- ** │01 │ │3B│3C│3D│3E││3F│40│41│42│ │43│44│57│58│ │12│46│E1│
- ** │Esc│ │F1│F2│F3│F4││F5│F6│F7│F8│ │F9│10│11│12│ │PS│SL│Pz│
- ** └───┘ └──┴──┴──┴──┘└──┴──┴──┴──┘ └──┴──┴──┴──┘ └──┴──┴──┘
- ** ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ ┌──┬──┬──┐ ┌──┬──┬──┬──┐
- ** │29│02│03│04│05│06│07│08│09│0A│0B│0C│0D│2B│0E│ │52│47│48│ │45│35│37│4A│
- ** │` │1 │2 │3 │4 │5 │6 │7 │8 │9 │0 │- │= │\ │-│ │In│Hm│PU│ │NL│/ │* │- │
- ** ├──┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴──┤ ├──┼──┼──┤ ├──┼──┼──┼──┤
- ** │0F │10│11│12│13│14│15│16│17│18│19│1A│AB│ │ │53│4F│49│ │47│48│49│4E│
- ** │Tab│Q │W │E │R │T │Y │U │I │O │P │[ │] │ │ │Dl│En│PD│ │7 │8 │9 │ │
- ** ├───┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┘ 1C │ └──┴──┴──┘ ├──┼──┼──┤+ │
- ** │3A │1E│1F│20│21│22│23│24│25│26│27│28│ │ │4B│4C│4D│ │
- ** │Caps│A │S │D │F │G │H │J │K │L │; │' │ ─┘ │ │4 │5 │6 │ │
- ** ├────┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴──────┤ ┌──┐ ├──┼──┼──┼──┤
- ** │ 2A │2C│2D│2E│2F│30│31│32│33│34│35│ 36 │ │48│ │4F│50│51│1C│
- ** │ Shift│Z │X │C │V │B │N │M │, │. │/ │ Shift │ │ │ │1 │2 │3 │ │
- ** ├────┬─┴┬─┴─┬┴──┴──┴──┴──┴──┴──┴─┬┴──┼──┬────┤ ┌──┼──┼──┐ ├──┴──┼──┤E │
- ** │ 1D │ │38 │ 39 │38 │ │1D │ │4B│50│4D│ │52 │53│n │
- ** │Ctrl│ │Alt│ Spacebar │Alt│ │Ctrl│ │ │ │ │ │0 │. │t │
- ** └────┘ └───┴────────────────────┴───┘ └────┘ └──┴──┴──┘ └─────┴──┴──┘
- ** NOTE: The following keys' scan codes are preceded by a 0xE0:
- ** Right Alt; Right Ctrl; Grey Arrows,/,Ins,Home,Del,End,PgUp,PgDn,Enter.
- */
- extern K_LANG unsigned int TranASCII(int value);
- /* Translates a scan code into an unshifted (as if neither shift key
- ** were held down) ASCII code. Passed value is the same as that returned
- ** by GetStroke, ReadKeyScan, or contained in KeyScan. Returned value
- ** is corresponding ASCII code.
- */
- extern K_LANG unsigned int TranASCII2(int value);
- /* Translates a scan code into a shifted (as if either shift key were
- ** held down) ASCII code. Passed value is the same as that returned
- ** by GetStroke, ReadKeyScan, or contained in KeyScan. Returned value
- ** is corresponding ASCII code.
- */
-