home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / TECLADO / TCKEY.ZIP / TCKEY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  4.0 KB  |  102 lines

  1. /* tckey.h
  2.  * Object code is in mylib.lib
  3.  * Taken from Inside Turbo C, Special Issue
  4.  * header file for TCKEY.C and programs that use it
  5.  *
  6.  * Uses DOS Interrupt 16 basic (0) or extended (10h) service.  Extended
  7.  * adds F11 & F12 and the additional cursor control keys.
  8.  *
  9.  * KbdEnhanced lets an application program toggle TCKEY's use of the
  10.  * extended services (default is FALSE, use standard services).
  11.  * KbdEnhanced(TRUE) to toggle.
  12.  *
  13.  * KbdGetChar is a replacement for getch, but retrieves both the next
  14.  * character and the Scan code. The Scan code is in the upper 8 bits and
  15.  * the character code in the lower 8 bits.  Then use the macros defined
  16.  * in tckey.h to retrieve the portion you want. KbdChar retrives the
  17.  * character, KbdScan the Scan code, KbdNoScan shift the Scan code to the
  18.  * lower 8 bits, while KbdMakeScan shift the 8 lower bits up to the upper
  19.  * 8 bits to compare to a Scan code as in;
  20.  *    c = KbdGetChar();
  21.  *    if (KbdScan(c) == KbdMakeScan(73)   where 73 is a Scan code
  22.  *
  23.  * KbdHit replaces kbhit. KbdHit return TRUE or FALSE.
  24.  *
  25.  * KbdFlags returns the status of the keyboard flags.  Use the status
  26.  * code detection and the Enhanced Keyboard status code macros to find
  27.  * the status. KbdFlags returns _AL or _AX if enhanced.  For example,
  28.  * if (RightShift(KbdFlags) == TRUE)
  29.  *
  30.  * KbdCharIn returns the character code, Scan code, and state of the
  31.  * of the keyboard flags in a single call.  For example,
  32.  *
  33.  * unsigned flags, keys;
  34.  * KbdCharIn(&key, &flags, TRUE);
  35.  * if (RightShift(flags))
  36.  *
  37.  */
  38.  
  39. #if !defined(TRUE)
  40. #define TRUE 1
  41. #endif
  42.  
  43. #if !defined(FALSE)
  44. #define FALSE 0
  45. #endif
  46.  
  47. #define KEYINT  0x16
  48.  
  49. /* Status code detection: */
  50. #define RightShift(val)             (val & 0x0001)
  51. #define LeftShift(val)              (val & 0x0002)
  52. #define CtrlKey(val)                (val & 0x0004)
  53. #define AltKey(val)                 (val & 0x0008)
  54. #define ScrollLockToggle(val)       (val & 0x0010)
  55. #define NumLockToggle(val)          (val & 0x0020)
  56. #define CapsLockToggle(val)         (val & 0x0040)
  57. #define InsertToggle(val)           (val & 0x0080)
  58.  
  59. /* Enhanced Keyboard status codes: */
  60. #define LeftCtrlKey(val)            (val & 0x0100)
  61. #define LeftAltKey(val)             (val & 0x0200)
  62. #define RightCtrlKey(val)           (val & 0x0400)
  63. #define RightAltKey(val)            (val & 0x0800)
  64. #define Scroll(val)                 (val & 0x1000)
  65. #define NumLock(val)                (val & 0x2000)
  66. #define CapsLock(val)               (val & 0x4000)
  67.  
  68. /* Essential keyboard macros: */
  69. #define KbdChar(value)              (value & 0x00ff)
  70. #define KbdScan(value)              (value & 0xff00)
  71. #define KbdMakeScan(value)          (value << 8)
  72. #define KbdNoScan(value)            (value >> 8)
  73.  
  74. #define Ctrl(value)                 (value - 'A' + 1)
  75. #define F1                          KbdMakeScan(59)
  76. #define F2                          KbdMakeScan(60)
  77. #define F3                          KbdMakeScan(61)
  78. #define F4                          KbdMakeScan(62)
  79. #define F5                          KbdMakeScan(63)
  80. #define F6                          KbdMakeScan(64)
  81. #define F7                          KbdMakeScan(65)
  82. #define F8                          KbdMakeScan(66)
  83. #define F9                          KbdMakeScan(67)
  84. #define F10                         KbdMakeScan(68)
  85. #define F11                         KbdMakeScan(133)
  86. #define F12                         KbdMakeScan(134)
  87.  
  88. #define HOME                        KbdMakeScan(71)
  89. #define END                         KbdMakeScan(79)
  90. #define PGUP                        KbdMakeScan(73)
  91. #define PGDN                        KbdMakeScan(81)
  92. #define UPARROW                     KbdMakeScan(72)
  93. #define DOWNARROW                   KbdMakeScan(80)
  94. #define LEFTARROW                   KbdMakeScan(75)
  95. #define RIGHTARROW                  KbdMakeScan(77)
  96.  
  97. void KbdEnhanced(int is_enhanced);
  98. unsigned KbdGetChar(void);
  99. unsigned KbdFlags(void);
  100. void KbdCharIn(unsigned *character, unsigned *flags, unsigned wait);
  101. int KbdHit(void);
  102.