home *** CD-ROM | disk | FTP | other *** search
/ Quake++ for Quake / Quake++.iso / quake / qube / keyboard.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-06  |  7.6 KB  |  168 lines

  1. /*******************************
  2. **                  **
  3. **       Keyboard.h          **
  4. **                  **
  5. **  A set of useful routines  **
  6. **  for controlling keyboard  **
  7. **  settings and information. **
  8. **                  **
  9. **  (C) 1994 by Sean Werkema  **
  10. **  Revision 2.0    7/4/1994  **
  11. **                  **
  12. *******************************/
  13.  
  14. #ifndef K_LANG
  15. #ifdef __cplusplus
  16. #define K_LANG "C"
  17. #else
  18. #define K_LANG
  19. #endif
  20. #endif
  21.  
  22. /************************************************************************
  23.               Version 2.0 data & functions        7/10/1994
  24. ************************************************************************/
  25.  
  26. /*
  27. **  Function prototypes
  28. */
  29.  
  30. extern K_LANG int KeyASCII();
  31. /*     Holds last ASCII value read from keyboard.  Changes with each read,
  32. **     but does not change with each call.
  33. */
  34. extern K_LANG int KeyScan();
  35. /*     Holds last scan code value read from keyboard.  Changes with each read,
  36. **     but does not change with each call.
  37. */
  38. extern K_LANG int GetCursorStart(void);
  39. /*     Returns value corresponding to top of cursor, usually 0-7.
  40. */
  41. extern K_LANG int GetCursorEnd(void);
  42. /*     Returns value corresponding to bottom of cursor, usually 0-7.
  43. */
  44. extern K_LANG void SetCursorSize(int Start, int End);
  45. /*     Adjusts cursor size to top and bottom values (usually from 0-7).
  46. */
  47. extern K_LANG int GetCursorX(int page);
  48. /*     Returns horizontal position of cursor, ranging from 1 to <scrn width>.
  49. **     If page is -1, the currently displayed page will be used.
  50. */
  51. extern K_LANG int GetCursorY(int page);
  52. /*     Returns vertical position of cursor, ranging from 1 to <scrn height>.
  53. **     If page is -1, the currently displayed page will be used.
  54. */
  55. extern K_LANG void SetCursorPos(int page, int X, int Y);
  56. /*     Moves cursor to specified coordinates, with the origin at 1.
  57. **     If page is -1, the currently displayed page will be used.
  58. */
  59. extern K_LANG int ReadKeyASCII(void);
  60. /*     Waits for a key to be pressed, then returns the ASCII value of that
  61. **     key.  KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  62. */
  63. extern K_LANG int ReadKeyScan(void);
  64. /*     Waits for a key to be pressed, then returns the scan code of that
  65. **     key.  KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  66. */
  67. extern K_LANG int KeyStatus(void);
  68. /*     Returns 1 if a keypress is waiting, and 0 if no keypress is waiting.  If
  69. **     1, KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  70. */
  71. extern K_LANG int KeyFlags(void);
  72. /*     Returns keyboard flags: L Shf, R Shf, Ctrl, Alt, Caps, Num, Scrl, Ins.
  73. */
  74. extern K_LANG int EReadKeyASCII(void);
  75. /*     Waits for a key to be pressed, then returns the ASCII value of that
  76. **     key.  KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  77. **     Same as ReadKeyASCII, except can detect extended keys.
  78. */
  79. extern K_LANG int EReadKeyScan(void);
  80. /*     Waits for a key to be pressed, then returns the scan code of that
  81. **     key.  KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  82. **     Same as ReadKeyScan, except can detect extended keys.
  83. */
  84. extern K_LANG int EKeyStatus(void);
  85. /*     Returns 1 if a keypress is waiting, and 0 if no keypress is waiting.  If
  86. **     1, KeyASCII and KeyScan are set to the key's ASCII value & scan code.
  87. **     Same as KeyStatus, except can detect extended keys.
  88. */
  89. extern K_LANG int EKeyFlags(void);
  90. /*     Returns keyboard flags: L Shf, R Shf, L Ctrl, R Ctrl, L Alt, R Alt,
  91. **     Caps, Num, Scrl, Ins, SysReq.
  92. **     Same as KeyFlags, except can detect extended keys.
  93. */
  94. extern K_LANG int IsEKeybd(void);
  95. /*     Returns 0 if not an Extended Keyboard, 1 if is an Extended Keyboard.
  96. */
  97.  
  98. /************************************************************************
  99.               Version 2.0 data & functions         7/4/1994
  100. ************************************************************************/
  101.  
  102. /*
  103. **     Special keyboard control functions
  104. */
  105.  
  106. extern K_LANG void NewKeyboard(void);
  107. /*     Initializes special keyboard data control functions.
  108. **     Standard functions will not work when special functions are
  109. **     active, but the special functions allow more versatile control
  110. **     of keyboard data.  Accepts no values, returns no values.
  111. */
  112. extern K_LANG void OldKeyboard(void);
  113. /*     Deactivates special keyboard functions, allowing normal
  114. **     functions to be used instead.  If special functions have
  115. **     been activated, deactivate them before exiting program
  116. **     or attempting to use normal functions.  Accepts no values,
  117. **     returns no values.
  118. */
  119. extern K_LANG unsigned int GetStroke(void);
  120. /*     Special function that returns a scan code corresponding to
  121. **     a key press or release, both of which are stored in a FIFO
  122. **     buffer from which this function reads its information.  If
  123. **     the upper byte of the returned integer contains 0xE0 the
  124. **     key press/release was from a key on the Extended Keyboard
  125. **     (Gray Insert/Delete/Home/End/PgUp/PgDn/Arrows/Enter/Slash or Right
  126. **     Ctrl/Alt).  If bit 7 is set (high bit of low byte) the value
  127. **     indicates a key release; if bit 7 is clear, the value indicates
  128. **     a key press.  If the returned integer is 0, no keystrokes are
  129. **     waiting.  Low 7 bits contain scan code corresponding to
  130. **     the key, as per the following table:
  131. **
  132. **            Scan Code Table (Hexadecimal values given)
  133. **     ┌───┐ ┌──┬──┬──┬──┐┌──┬──┬──┬──┐ ┌──┬──┬──┬──┐ ┌──┬──┬──┐
  134. **     │01 │ │3B│3C│3D│3E││3F│40│41│42│ │43│44│57│58│ │12│46│E1│
  135. **     │Esc│ │F1│F2│F3│F4││F5│F6│F7│F8│ │F9│10│11│12│ │PS│SL│Pz│
  136. **     └───┘ └──┴──┴──┴──┘└──┴──┴──┴──┘ └──┴──┴──┴──┘ └──┴──┴──┘
  137. **     ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ ┌──┬──┬──┐ ┌──┬──┬──┬──┐
  138. **     │29│02│03│04│05│06│07│08│09│0A│0B│0C│0D│2B│0E│ │52│47│48│ │45│35│37│4A│
  139. **     │` │1 │2 │3 │4 │5 │6 │7 │8 │9 │0 │- │= │\ │-│ │In│Hm│PU│ │NL│/ │* │- │
  140. **     ├──┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴──┤ ├──┼──┼──┤ ├──┼──┼──┼──┤
  141. **     │0F │10│11│12│13│14│15│16│17│18│19│1A│AB│    │ │53│4F│49│ │47│48│49│4E│
  142. **     │Tab│Q │W │E │R │T │Y │U │I │O │P │[ │] │    │ │Dl│En│PD│ │7 │8 │9 │  │
  143. **     ├───┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┴┬─┘ 1C │ └──┴──┴──┘ ├──┼──┼──┤+ │
  144. **     │3A  │1E│1F│20│21│22│23│24│25│26│27│28│        │         │4B│4C│4D│  │
  145. **     │Caps│A │S │D │F │G │H │J │K │L │; │' │  ─┘ │            │4 │5 │6 │  │
  146. **     ├────┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴─┬┴──────┤     ┌──┐     ├──┼──┼──┼──┤
  147. **     │ 2A   │2C│2D│2E│2F│30│31│32│33│34│35│ 36    │     │48│     │4F│50│51│1C│
  148. **     │ Shift│Z │X │C │V │B │N │M │, │. │/ │ Shift │     │ │     │1 │2 │3 │  │
  149. **     ├────┬─┴┬─┴─┬┴──┴──┴──┴──┴──┴──┴─┬┴──┼──┬────┤ ┌──┼──┼──┐ ├──┴──┼──┤E │
  150. **     │ 1D │  │38 │    39        │38 │  │1D  │ │4B│50│4D│ │52   │53│n │
  151. **     │Ctrl│  │Alt│    Spacebar    │Alt│  │Ctrl│ │ │ │ │ │0    │. │t │
  152. **     └────┘  └───┴────────────────────┴───┘  └────┘ └──┴──┴──┘ └─────┴──┴──┘
  153. **     NOTE: The following keys' scan codes are preceded by a 0xE0:
  154. **     Right Alt;  Right Ctrl;    Grey Arrows,/,Ins,Home,Del,End,PgUp,PgDn,Enter.
  155. */
  156. extern K_LANG unsigned int TranASCII(int value);
  157. /*     Translates a scan code into an unshifted (as if neither shift key
  158. **     were held down) ASCII code.  Passed value is the same as that returned
  159. **     by GetStroke, ReadKeyScan, or contained in KeyScan.  Returned value
  160. **     is corresponding ASCII code.
  161. */
  162. extern K_LANG unsigned int TranASCII2(int value);
  163. /*     Translates a scan code into a shifted (as if either shift key were
  164. **     held down) ASCII code.  Passed value is the same as that returned
  165. **     by GetStroke, ReadKeyScan, or contained in KeyScan.  Returned value
  166. **     is corresponding ASCII code.
  167. */
  168.