home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / keycodes.h__ < prev    next >
Text File  |  1993-11-28  |  10KB  |  273 lines

  1. /*
  2.     SPHINX Programming (C) 1993
  3.     NAME:  KEYCODES.H--
  4.     DESCRIPTION:  This file contains constant definitions for keyboard
  5.                   related operations, and the some of the procedures that
  6.                   may use these definitions.
  7.     LAST MODIFIED:  29 Nov 1993
  8.     PROCEDURES DEFINED IN THIS FILE:
  9.         : word BIOSEKEYCHECK()
  10.         : word BIOSEREADKEY()
  11.         : word BIOSKEYCHECK()
  12.         : byte BIOSPUSHKEY(keycode)
  13.         : word BIOSREADKEY()
  14.         : byte BIOSSHIFT()
  15. */
  16.  
  17.  
  18. : word BIOSEKEYCHECK ()
  19. /* Returns the scan code of the next key waiting on the keyboard
  20.    buffer, but does not remove the key from the buffer.
  21.    Returns 0 if no key strokes are waiting to be read.
  22.    This function handles enchanced keys like <F11> and <F12>, but AT or
  23.    higher BIOS is required to use this function.
  24. */
  25. {
  26. AH = 0x11;
  27. $ INT 0x16
  28. IF( ZEROFLAG )
  29.     AX = 0;
  30. }
  31.  
  32.  
  33. : word BIOSEREADKEY ()
  34. /* Returns the scan code of the next key waiting on the keyboard
  35.    buffer, and removes the key from the buffer.
  36.    If no key strokes are waiting to be read, this function will
  37.    wait until one is available.
  38.    This function handles enchanced keys like <F11> and <F12>, but AT or
  39.    higher BIOS is required to use this function.
  40. */
  41. {
  42. AH = 0x10;
  43. $ INT 0x16
  44. }
  45.  
  46.  
  47. : word BIOSKEYCHECK ()
  48. /* Returns the scan code of the next key waiting on the keyboard
  49.    buffer, but does not remove the key from the buffer.
  50.    Returns 0 if no key strokes are waiting to be read.
  51. */
  52. {
  53. AH = 0x1;
  54. $ INT 0x16
  55. IF( ZEROFLAG )
  56.     AX = 0;
  57. }
  58.  
  59.  
  60. : byte BIOSPUSHKEY ()    // AX = scan code of key to push
  61. /* Pushes a scan code of a key onto the keyboard buffer.
  62.    Returns 0 if the key was successfully added to the buffer, or 1 if the
  63.    keyboard buffer is full and the key could not be added.
  64.    This function handles enchanced keys like <F11> and <F12>.
  65.    AT or higher BIOS is required to use this function.
  66. */
  67. {
  68. CX = AX;
  69. AH = 0x5;
  70. $ INT 0x16
  71. }
  72.  
  73.  
  74. : word BIOSREADKEY ()
  75. /* Returns the scan code of the next key waiting on the keyboard
  76.    buffer, and removes the key from the buffer.
  77.    If no key strokes are waiting to be read, this function will
  78.    wait until one is available.
  79. */
  80. {
  81. AH = 0x0;
  82. $ INT 0x16
  83. }
  84.  
  85.  
  86. : byte BIOSSHIFT ()
  87. /* Returns the status of the shift keys.
  88.    AL will be set as follows:
  89.       bit   significance (if set)
  90.        0    right shift key is down   
  91.        1    left shift key is down   
  92.        2    ctrl key is down   
  93.        3    alt key is down   
  94.        4    scroll lock is on   
  95.        5    num lock is on   
  96.        6    caps lock is on   
  97.        7    insert is on   
  98. */
  99. {
  100. AH = 0x2;
  101. $ INT 0x16
  102. }
  103.  
  104.  
  105.  
  106. // 16 bit key scan code values
  107.  
  108. ?define  k_up         18432
  109. ?define  k_down       20480
  110. ?define  k_left       19200
  111. ?define  k_right      19712
  112. ?define  k_home       18176
  113. ?define  k_end        20224
  114. ?define  k_pageup     18688
  115. ?define  k_pagedown   20736
  116.  
  117. ?define  k_num1      0x4F31
  118. ?define  k_num2      0x5032
  119. ?define  k_num3      0x5133
  120. ?define  k_num4      0x4B34
  121. ?define  k_num5      0x4C35
  122. ?define  k_num6      0x4D36
  123. ?define  k_num7      0x4737
  124. ?define  k_num8      0x4838
  125. ?define  k_num9      0x4939
  126. ?define  k_num0      0x5230
  127. ?define  k_numminus  0x4A2D
  128. ?define  k_numplus   0x4E2B
  129. ?define  k_numperiod 0x532E
  130.  
  131. ?define  k_esc               283
  132. ?define  k_return           7181
  133. ?define  k_ctrlreturn     0x1C0A
  134. ?define  k_backspace        3592
  135. ?define  k_ctrlbackspace  0x0E7F
  136. ?define  k_delete          21248
  137. ?define  k_tab              3849
  138. ?define  k_shifttab       0x0F00
  139. ?define  k_space           14624
  140. ?define  k_insert          20992
  141.  
  142. ?define  k_F1       15104
  143. ?define  k_F2       15360
  144. ?define  k_F3       15616
  145. ?define  k_F4       15872
  146. ?define  k_F5       16128
  147. ?define  k_F6       16384
  148. ?define  k_F7       16640
  149. ?define  k_F8       16896
  150. ?define  k_F9       17152
  151. ?define  k_F10      17408
  152. ?define  k_F11      34048   // BIOSEREADKEY required, not BIOSREADKEY
  153. ?define  k_F12      34304   // BIOSEREADKEY required, not BIOSREADKEY
  154.  
  155. ?define  k_1          561
  156. ?define  k_2          818
  157. ?define  k_3         1075
  158. ?define  k_4         1332
  159. ?define  k_5         1589
  160. ?define  k_6         1846
  161. ?define  k_7         2103
  162. ?define  k_8         2360
  163. ?define  k_9         2617
  164. ?define  k_0         2864
  165.  
  166.  
  167. /*
  168.     Key      Normal         Shift          Control        Alt
  169.  
  170.     1!       0231 '1'       0221 '!'        --            7800
  171.     2@       0332 '2'       0340 '@'       0300           7900
  172.     3#       0433 '3'       0423 '#'        --            7A00
  173.     4$       0534 '4'       0524 '$'        --            7B00
  174.     5%       0635 '5'       0625 '%'        --            7C00
  175.     6^       0736 '6'       075E '^'       071E           7D00
  176.     7&       0837 '7'       0826 '&'        --            7E00
  177.     8*       0938 '8'       092A '*'        --            7F00
  178.     9(       0A39 '9'       0A28 '('        --            8000
  179.     0)       0B30 '0'       0B29 ')'        --            8100
  180.     -_       0C2D '-'       0C5F '_'       0C1F           8200
  181.     =+       0D3D '='       0D2B '+'        --            8300
  182.     q        1071 'q'       1051 'Q'       1011           1000
  183.     w        1177 'w'       1157 'W'       1117           1100
  184.     e        1265 'e'       1245 'E'       1205           1200
  185.     r        1372 'r'       1352 'R'       1312           1300
  186.     t        1474 't'       1454 'T'       1414           1400
  187.     y        1579 'y'       1559 'Y'       1519           1500
  188.     u        1675 'u'       1655 'U'       1615           1600
  189.     i        1769 'i'       1749 'I'       1709           1700
  190.     o        186F 'o'       184F 'O'       180F           1800
  191.     p        1970 'p'       1950 'P'       1910           1900
  192.     [{       1A5B '['       1A7B '{'       1A1B            --
  193.     ]}       1B5D ']'       1B7D '}'       1B1D            --
  194.     a        1E61 'a'       1E41 'A'       1E01           1E00
  195.     s        1F73 's'       1F53 'S'       1F13           1F00
  196.     d        2064 'd'       2044 'D'       2004           2000
  197.     f        2166 'f'       2146 'F'       2106           2100
  198.     g        2267 'g'       2247 'G'       2207           2200
  199.     h        2368 'h'       2348 'H'       2308           2300
  200.     j        246A 'j'       244A 'J'       240A           2400
  201.     k        256B 'k'       254B 'K'       250B           2500
  202.     l        266C 'l'       264C 'L'       260C           2600
  203.     ;:       273B ';'       273A ':'        --             --
  204.     '"       2827 '''       2822 '"'        --             --
  205.     `~       2960 '`'       297E '~'        --             --
  206.     \|       2B5C '\'       2B7C '|'       2B1C            --
  207.     z        2C7A 'z'       2C5A 'Z'       2C1A           2C00
  208.     x        2D78 'x'       2D58 'X'       2D18           2D00
  209.     c        2E63 'c'       2E43 'C'       2E03           2E00
  210.     v        2F76 'v'       2F56 'V'       2F16           2F00
  211.     b        3062 'b'       3042 'B'       3002           3000
  212.     n        316E 'n'       314E 'N'       310E           3100
  213.     m        326D 'm'       324D 'M'       320D           3200
  214.     ,<       332C ','       333C '<'        --             --
  215.     .>       342E '.'       343E '>'        --             --
  216.     /?       352F '/'       353F '?'        --             --
  217.     PrtSc    372A '*'        --            7200            --
  218.     F1       3B00           5400           5E00           6800
  219.     F2       3C00           5500           5F00           6900
  220.     F3       3D00           5600           6000           6A00
  221.     F4       3E00           5700           6100           6B00
  222.     F5       3F00           5800           6200           6C00
  223.     F6       4000           5900           6300           6D00
  224.     F7       4100           5A00           6400           6E00
  225.     F8       4200           5B00           6500           6F00
  226.     F9       4300           5C00           6600           7000
  227.     F10      4400           5D00           6700           7100
  228. */
  229.  
  230.  
  231.  
  232. ?define  KEYBOARD_INT    0x9
  233. ?define  KEYBOARD_PORT  0x60
  234.  
  235.  
  236. // define the keyboard port 0x60 key make (depress) scan codes
  237.  
  238. enum { s_esc=1,s_1,s_2,s_3,s_4,s_5,s_6,s_7,s_8,s_9,s_0,s_minus,s_equals,
  239.        s_backspace,s_tab,s_q,s_w,s_e,s_r,s_t,s_y,s_u,s_i,s_o,s_p,
  240.        s_opensquare,s_closesquare,s_return,s_ctrl,s_a,s_s,s_d,s_f,s_g,
  241.        s_h,s_j,s_k,s_l,s_semicolon,s_quote,s_tilda,s_leftshift,
  242.        s_backslash,s_z,s_x,s_c,s_v,s_b,s_n,s_m,s_camma,s_period,s_slash,
  243.        s_rightshift,s_printscreen,s_alt,s_space,s_capslock,
  244.        s_f1,s_f2,s_f3,s_f4,s_f5,s_f6,s_f7,s_f8,s_f9,s_f10,
  245.        s_numlock,s_scrolllock,s_home,s_up,s_pageup,s_numminus,s_left,
  246.        s_num5,s_right,s_numplus,s_end,s_down,s_pagedown,s_insert,
  247.        s_delete,s_f11=87,s_f12=88 };
  248.  
  249. // define the keyboard port 0x60 key break (release) scan codes
  250.  
  251. enum { sr_esc=129,sr_1,sr_2,sr_3,sr_4,sr_5,sr_6,sr_7,sr_8,sr_9,sr_0,
  252.        sr_minus,sr_equals,sr_backspace,sr_tab,sr_q,sr_w,sr_e,sr_r,sr_t,
  253.        sr_y,sr_u,sr_i,sr_o,sr_p,sr_opensquare,sr_closesquare,sr_return,
  254.        sr_ctrl,sr_a,sr_s,sr_d,sr_f,sr_g,sr_h,sr_j,sr_k,sr_l,sr_semicolon,
  255.        sr_quote,sr_tilda,sr_leftshift,sr_backslash,sr_z,sr_x,sr_c,sr_v,
  256.        sr_b,sr_n,sr_m,sr_camma,sr_period,sr_slash,sr_rightshift,
  257.        sr_printscreen,sr_alt,sr_space,sr_capslock,sr_f1,sr_f2,sr_f3,sr_f4,
  258.        sr_f5,sr_f6,sr_f7,sr_f8,sr_f9,sr_f10,sr_numlock,sr_scrolllock,
  259.        sr_home,sr_up,sr_pageup,sr_numminus,sr_left,sr_num5,sr_right,
  260.        sr_numplus,sr_end,sr_down,sr_pagedown,sr_insert,sr_delete,
  261.        sr_f11=87+128,sr_f12=88+128 };
  262.  
  263.  
  264. // define some ASCII values
  265.  
  266. enum { ascii_bell=7, ascii_backspace, ascii_tab, ascii_linefeed,
  267.        ascii_formfeed=12, ascii_return,
  268.        ascii_EOF=26, ascii_escape,
  269.        ascii_space=32,
  270.        ascii_delete=127 };
  271.  
  272.  
  273. /* end of KEYCODES.H-- */