home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / MCOMM530.ZIP / KEYS.H < prev    next >
C/C++ Source or Header  |  1990-06-22  |  11KB  |  397 lines

  1.  
  2. /*  K E Y S . H   --  k e y   d e f i n i t i o n   h e a d e r
  3.  
  4.             Mike Dumdei, 6 Holly Lane, Texarkana TX 75503
  5.  
  6.     NOTE:  EXTENDED KEY HANDLING OPTIONS
  7.         This header allows keys with extended codes to be defined 3
  8.         different ways depending on what is defined when the file
  9.         is included in the source.
  10.  
  11.         KEY_INT defined:
  12.             The scan code of the key is returned as the high byte
  13.             and the NUL char is returned as the low byte.  This is
  14.             exactly as the the BIOS read key routine returns extended
  15.             keys.   Ex:  F1 == 0x3b00
  16.  
  17.         KEY_CH defined:
  18.             Extended keys are defined as the value of the scan code.
  19.             This method works well when using the getch() functions --
  20.             on the first call a NUL is returned, on the 2nd the values
  21.             defined using this method is returned.
  22.                 Ex:  F1 == 0x3b
  23.  
  24.         KEY_NEG defined:       * * *  this is the default  * * *
  25.             Extended keys are defined as the inverse of the scan code.
  26.             Use this if you have a function that returns the 'scan code/char'
  27.             for normal keys but returns negative scan values for extended
  28.             keys.  The advantage of this method is if the value returned is
  29.             less than 0, you know an extended key was pressed since the
  30.             scan codes/char combinations don't have negative integer values.
  31.                 Ex:  F1 == (0 - 0x3b)
  32. */
  33.  
  34.  
  35. #if !defined(KEY_INT)
  36.     #if !defined(KEY_CH)
  37.         #if !defined(KEY_NEG)
  38.             #define KEY_NEG          /* you get this if nothing else is    */
  39.         #endif                       /*  defined when keydef.h is included */
  40.     #endif
  41. #endif
  42.  
  43. /* these are the same no matter what is defined */
  44.  
  45.    /* no scan code version */
  46. #define SPC         0x20
  47. #define ESC         0x1b
  48. #define BKSP        0x08
  49. #define TAB         0x09
  50. #define ENTER       0x0d
  51. #define SHFT_TAB    0x0f
  52. #define CTL_ENTER   0x0a
  53. #define CTL_BKSP    0x7f
  54.  
  55.     /* with scan codes (X == extended code) */
  56. #define X_SPC       0x3920
  57. #define X_ESC       0x011b
  58. #define X_BKSP      0x0e08
  59. #define X_TAB       0x0f09
  60. #define X_ENTER     0x1c0d
  61. #define X_SHFT_TAB  0x0f0f
  62. #define X_CTL_ENTER 0x1c0a
  63. #define X_CTL_BKSP  0x0e7f
  64.  
  65. #define GREY_AST    0x372a
  66. #define GREY_MIN    0x4a2d
  67. #define GREY_PLS    0x4e2b
  68. #define C_GREY_AST  0x3710
  69. #define S_GREY_PLS  0x4e2b
  70. #define S_GREY_MIN  0x4a2d
  71.  
  72.  
  73. /* this is the scan/char combination for extended keys */
  74.  
  75. #ifdef KEY_INT
  76.  
  77. /* No Ctl, Shft, or Alt codes */
  78. #define F1          0x3b00
  79. #define F2          0x3c00
  80. #define F3          0x3d00
  81. #define F4          0x3e00
  82. #define F5          0x3f00
  83. #define F6          0x4000
  84. #define F7          0x4100
  85. #define F8          0x4200
  86. #define F9          0x4300
  87. #define F10         0x4400
  88. #define HOME        0x4700
  89. #define UPARO       0x4800
  90. #define PGUP        0x4900
  91. #define LFTARO      0x4b00
  92. #define RGTARO      0x4d00
  93. #define END         0x4f00
  94. #define DNARO       0x5000
  95. #define PGDN        0x5100
  96. #define INS         0x5200
  97. #define DEL         0x5300
  98.  
  99. /* Shft pressed */
  100. #define SHFT_F1     0x5400
  101. #define SHFT_F2     0x5500
  102. #define SHFT_F3     0x5600
  103. #define SHFT_F4     0x5700
  104. #define SHFT_F5     0x5800
  105. #define SHFT_F6     0x5900
  106. #define SHFT_F7     0x5a00
  107. #define SHFT_F8     0x5b00
  108. #define SHFT_F9     0x5c00
  109. #define SHFT_F10    0x5d00
  110.  
  111. /* Ctl pressed */
  112. #define CTL_F1      0x5e00
  113. #define CTL_F2      0x5f00
  114. #define CTL_F3      0x6000
  115. #define CTL_F4      0x6100
  116. #define CTL_F5      0x6200
  117. #define CTL_F6      0x6300
  118. #define CTL_F7      0x6400
  119. #define CTL_F8      0x6500
  120. #define CTL_F9      0x6600
  121. #define CTL_F10     0x6700
  122. #define CTL_HOME    0x7700
  123. #define CTL_PGUP    0x8400
  124. #define CTL_LFTARO  0x7300
  125. #define CTL_RGTARO  0x7400
  126. #define CTL_END     0x7500
  127. #define CTL_PGDN    0x7600
  128.  
  129. /* Alt pressed */
  130. #define ALT_F1      0x6800
  131. #define ALT_F2      0x6900
  132. #define ALT_F3      0x6a00
  133. #define ALT_F4      0x6b00
  134. #define ALT_F5      0x6c00
  135. #define ALT_F6      0x6d00
  136. #define ALT_F7      0x6e00
  137. #define ALT_F8      0x6f00
  138. #define ALT_F9      0x7000
  139. #define ALT_F10     0x7100
  140. #define ALT_1       0x7800
  141. #define ALT_2       0x7900
  142. #define ALT_3       0x7a00
  143. #define ALT_4       0x7b00
  144. #define ALT_5       0x7c00
  145. #define ALT_6       0x7d00
  146. #define ALT_7       0x7e00
  147. #define ALT_8       0x7f00
  148. #define ALT_9       0x8000
  149. #define ALT_0       0x8100
  150. #define ALT_MIN     0x8200
  151. #define ALT_EQU     0x8300
  152. #define ALT_A       0x1e00
  153. #define ALT_B       0x3000
  154. #define ALT_C       0x2e00
  155. #define ALT_D       0x2000
  156. #define ALT_E       0x1200
  157. #define ALT_F       0x2100
  158. #define ALT_G       0x2200
  159. #define ALT_H       0x2300
  160. #define ALT_I       0x1700
  161. #define ALT_J       0x2400
  162. #define ALT_K       0x2500
  163. #define ALT_L       0x2600
  164. #define ALT_M       0x3200
  165. #define ALT_N       0x3100
  166. #define ALT_O       0x1800
  167. #define ALT_P       0x1900
  168. #define ALT_Q       0x1000
  169. #define ALT_R       0x1300
  170. #define ALT_S       0x1f00
  171. #define ALT_T       0x1400
  172. #define ALT_U       0x1600
  173. #define ALT_V       0x2f00
  174. #define ALT_W       0x1100
  175. #define ALT_X       0x2d00
  176. #define ALT_Y       0x1500
  177. #define ALT_Z       0x2c00
  178.  
  179. #endif
  180.  
  181. /* this is the scan code only version of key definitions */
  182.  
  183. #ifdef  KEY_CH
  184.  
  185. /* No Ctl, Shft, or Alt codes */
  186. #define F1          0x3b
  187. #define F2          0x3c
  188. #define F3          0x3d
  189. #define F4          0x3e
  190. #define F5          0x3f
  191. #define F6          0x40
  192. #define F7          0x41
  193. #define F8          0x42
  194. #define F9          0x43
  195. #define F10         0x44
  196. #define HOME        0x47
  197. #define UPARO       0x48
  198. #define PGUP        0x49
  199. #define LFTARO      0x4b
  200. #define RGTARO      0x4d
  201. #define END         0x4f
  202. #define DNARO       0x50
  203. #define PGDN        0x51
  204. #define INS         0x52
  205. #define DEL         0x53
  206.  
  207. /* Shft pressed */
  208. #define SHFT_F1     0x54
  209. #define SHFT_F2     0x55
  210. #define SHFT_F3     0x56
  211. #define SHFT_F4     0x57
  212. #define SHFT_F5     0x58
  213. #define SHFT_F6     0x59
  214. #define SHFT_F7     0x5a
  215. #define SHFT_F8     0x5b
  216. #define SHFT_F9     0x5c
  217. #define SHFT_F10    0x5d
  218.  
  219. /* Ctl pressed */
  220. #define CTL_F1      0x5e
  221. #define CTL_F2      0x5f
  222. #define CTL_F3      0x60
  223. #define CTL_F4      0x61
  224. #define CTL_F5      0x62
  225. #define CTL_F6      0x63
  226. #define CTL_F7      0x64
  227. #define CTL_F8      0x65
  228. #define CTL_F9      0x66
  229. #define CTL_F10     0x67
  230. #define CTL_HOME    0x77
  231. #define CTL_PGUP    0x84
  232. #define CTL_LFTARO  0x73
  233. #define CTL_RGTARO  0x74
  234. #define CTL_END     0x75
  235. #define CTL_PGDN    0x76
  236.  
  237. /* Alt pressed */
  238. #define ALT_F1      0x68
  239. #define ALT_F2      0x69
  240. #define ALT_F3      0x6a
  241. #define ALT_F4      0x6b
  242. #define ALT_F5      0x6c
  243. #define ALT_F6      0x6d
  244. #define ALT_F7      0x6e
  245. #define ALT_F8      0x6f
  246. #define ALT_F9      0x70
  247. #define ALT_F10     0x71
  248. #define ALT_1       0x78
  249. #define ALT_2       0x79
  250. #define ALT_3       0x7a
  251. #define ALT_4       0x7b
  252. #define ALT_5       0x7c
  253. #define ALT_6       0x7d
  254. #define ALT_7       0x7e
  255. #define ALT_8       0x7f
  256. #define ALT_9       0x80
  257. #define ALT_0       0x81
  258. #define ALT_MIN     0x82
  259. #define ALT_EQU     0x83
  260. #define ALT_A       0x1e
  261. #define ALT_B       0x30
  262. #define ALT_C       0x2e
  263. #define ALT_D       0x20
  264. #define ALT_E       0x12
  265. #define ALT_F       0x21
  266. #define ALT_G       0x22
  267. #define ALT_H       0x23
  268. #define ALT_I       0x17
  269. #define ALT_J       0x24
  270. #define ALT_K       0x25
  271. #define ALT_L       0x26
  272. #define ALT_M       0x32
  273. #define ALT_N       0x31
  274. #define ALT_O       0x18
  275. #define ALT_P       0x19
  276. #define ALT_Q       0x10
  277. #define ALT_R       0x13
  278. #define ALT_S       0x1f
  279. #define ALT_T       0x14
  280. #define ALT_U       0x16
  281. #define ALT_V       0x2f
  282. #define ALT_W       0x11
  283. #define ALT_X       0x2d
  284. #define ALT_Y       0x15
  285. #define ALT_Z       0x2c
  286.  
  287. #endif
  288.  
  289. /* this is the inverse scan code definitions */
  290.  
  291. #ifdef KEY_NEG
  292.  
  293. /* No Ctl, Shft, or Alt codes */
  294. #define F1          (0 - 0x3b)
  295. #define F2          (0 - 0x3c)
  296. #define F3          (0 - 0x3d)
  297. #define F4          (0 - 0x3e)
  298. #define F5          (0 - 0x3f)
  299. #define F6          (0 - 0x40)
  300. #define F7          (0 - 0x41)
  301. #define F8          (0 - 0x42)
  302. #define F9          (0 - 0x43)
  303. #define F10         (0 - 0x44)
  304. #define HOME        (0 - 0x47)
  305. #define UPARO       (0 - 0x48)
  306. #define PGUP        (0 - 0x49)
  307. #define LFTARO      (0 - 0x4b)
  308. #define RGTARO      (0 - 0x4d)
  309. #define END         (0 - 0x4f)
  310. #define DNARO       (0 - 0x50)
  311. #define PGDN        (0 - 0x51)
  312. #define INS         (0 - 0x52)
  313. #define DEL         (0 - 0x53)
  314.  
  315. /* Shft pressed */
  316. #define SHFT_F1     (0 - 0x54)
  317. #define SHFT_F2     (0 - 0x55)
  318. #define SHFT_F3     (0 - 0x56)
  319. #define SHFT_F4     (0 - 0x57)
  320. #define SHFT_F5     (0 - 0x58)
  321. #define SHFT_F6     (0 - 0x59)
  322. #define SHFT_F7     (0 - 0x5a)
  323. #define SHFT_F8     (0 - 0x5b)
  324. #define SHFT_F9     (0 - 0x5c)
  325. #define SHFT_F10    (0 - 0x5d)
  326.  
  327. /* Ctl pressed */
  328. #define CTL_F1      (0 - 0x5e)
  329. #define CTL_F2      (0 - 0x5f)
  330. #define CTL_F3      (0 - 0x60)
  331. #define CTL_F4      (0 - 0x61)
  332. #define CTL_F5      (0 - 0x62)
  333. #define CTL_F6      (0 - 0x63)
  334. #define CTL_F7      (0 - 0x64)
  335. #define CTL_F8      (0 - 0x65)
  336. #define CTL_F9      (0 - 0x66)
  337. #define CTL_F10     (0 - 0x67)
  338. #define CTL_HOME    (0 - 0x77)
  339. #define CTL_PGUP    (0 - 0x84)
  340. #define CTL_LFTARO  (0 - 0x73)
  341. #define CTL_RGTARO  (0 - 0x74)
  342. #define CTL_END     (0 - 0x75)
  343. #define CTL_PGDN    (0 - 0x76)
  344.  
  345. /* Alt pressed */
  346. #define ALT_F1      (0 - 0x68)
  347. #define ALT_F2      (0 - 0x69)
  348. #define ALT_F3      (0 - 0x6a)
  349. #define ALT_F4      (0 - 0x6b)
  350. #define ALT_F5      (0 - 0x6c)
  351. #define ALT_F6      (0 - 0x6d)
  352. #define ALT_F7      (0 - 0x6e)
  353. #define ALT_F8      (0 - 0x6f)
  354. #define ALT_F9      (0 - 0x70)
  355. #define ALT_F10     (0 - 0x71)
  356. #define ALT_1       (0 - 0x78)
  357. #define ALT_2       (0 - 0x79)
  358. #define ALT_3       (0 - 0x7a)
  359. #define ALT_4       (0 - 0x7b)
  360. #define ALT_5       (0 - 0x7c)
  361. #define ALT_6       (0 - 0x7d)
  362. #define ALT_7       (0 - 0x7e)
  363. #define ALT_8       (0 - 0x7f)
  364. #define ALT_9       (0 - 0x80)
  365. #define ALT_0       (0 - 0x81)
  366. #define ALT_MIN     (0 - 0x82)
  367. #define ALT_EQU     (0 - 0x83)
  368. #define ALT_A       (0 - 0x1e)
  369. #define ALT_B       (0 - 0x30)
  370. #define ALT_C       (0 - 0x2e)
  371. #define ALT_D       (0 - 0x20)
  372. #define ALT_E       (0 - 0x12)
  373. #define ALT_F       (0 - 0x21)
  374. #define ALT_G       (0 - 0x22)
  375. #define ALT_H       (0 - 0x23)
  376. #define ALT_I       (0 - 0x17)
  377. #define ALT_J       (0 - 0x24)
  378. #define ALT_K       (0 - 0x25)
  379. #define ALT_L       (0 - 0x26)
  380. #define ALT_M       (0 - 0x32)
  381. #define ALT_N       (0 - 0x31)
  382. #define ALT_O       (0 - 0x18)
  383. #define ALT_P       (0 - 0x19)
  384. #define ALT_Q       (0 - 0x10)
  385. #define ALT_R       (0 - 0x13)
  386. #define ALT_S       (0 - 0x1f)
  387. #define ALT_T       (0 - 0x14)
  388. #define ALT_U       (0 - 0x16)
  389. #define ALT_V       (0 - 0x2f)
  390. #define ALT_W       (0 - 0x11)
  391. #define ALT_X       (0 - 0x2d)
  392. #define ALT_Y       (0 - 0x15)
  393. #define ALT_Z       (0 - 0x2c)
  394.  
  395. #endif
  396.  
  397.