home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / BATTLE.ZIP / INSTALL.ZIP / INPUT.H < prev    next >
Text File  |  1996-04-06  |  13KB  |  328 lines

  1.  
  2. // Header File for Library Module BLACK5.C
  3.  
  4. // D E F I N E S  ////////////////////////////////////////////////////////////
  5.  
  6. // defines for the keyboard interface
  7.  
  8. #define KEYBOARD_INTERRUPT  0x09  // the keyboard interrupt number
  9. #define KEY_BUFFER          0x60  // the port of the keyboard buffer
  10. #define KEY_CONTROL         0x61  // the port of the keyboard controller
  11. #define PIC_PORT            0x20  // the port of the programmable
  12.                                   // interrupt controller (PIC)
  13.  
  14. // bitmasks for the "shift state"
  15.  
  16. // note there is a difference between "on" and "down"
  17.  
  18. #define SHIFT_RIGHT         0x0001    // right shift
  19. #define SHIFT_LEFT          0x0002    // left shift
  20. #define CTRL                0x0004    // control key
  21. #define ALT                 0x0008    // alternate key
  22. #define SCROLL_LOCK_ON      0x0010    // the scroll lock is on
  23. #define NUM_LOCK_ON         0x0020    // the numeric lock is on
  24. #define CAPS_LOCK_ON        0x0040    // the capitals lock is on
  25. #define INSERT_MODE         0x0080    // insert or overlay mode
  26. #define CTRL_LEFT           0x0100    // the left control key is pressed
  27. #define ALT_LEFT            0x0200    // the left alternate key is pressed
  28. #define CTRL_RIGHT          0x0400    // the right control key is pressed
  29. #define ALT_RIGHT           0x0800    // the right alternate key is pressed
  30. #define SCROLL_LOCK_DOWN    0x1000    // the scroll lock key is pressed
  31. #define NUM_LOCK_DOWN       0x2000    // the numeric lock is pressed
  32. #define CAPS_LOCK_DOWN      0x4000    // the captials lock key is pressed
  33. #define SYS_REQ_DOWN        0x8000    // the system request key is pressed
  34.  
  35. // these are the scan codes for the keys on the keyboard, note they are all
  36. // from 0-127 and hence are the "make" scan codes, 128-255 are for the break
  37. // scan codes and are computed simply by adding 128 to each of the make codes
  38.  
  39. #define MAKE_ESC              1
  40. #define MAKE_1                2
  41. #define MAKE_2                3
  42. #define MAKE_3                4
  43. #define MAKE_4                5
  44. #define MAKE_5                6
  45. #define MAKE_6                7
  46. #define MAKE_7                8
  47. #define MAKE_8                9
  48. #define MAKE_9                10
  49. #define MAKE_0                11
  50. #define MAKE_MINUS            12
  51. #define MAKE_EQUALS           13
  52. #define MAKE_BKSP             14
  53. #define MAKE_TAB              15
  54. #define MAKE_Q                16
  55. #define MAKE_W                17
  56. #define MAKE_E                18
  57. #define MAKE_R                19
  58. #define MAKE_T                20
  59. #define MAKE_Y                21
  60. #define MAKE_U                22
  61. #define MAKE_I                23
  62. #define MAKE_O                24
  63. #define MAKE_P                25
  64. #define MAKE_LFT_BRACKET      26
  65. #define MAKE_RGT_BRACKET      27
  66. #define MAKE_ENTER            28
  67. #define MAKE_CTRL             29
  68. #define MAKE_A                30
  69. #define MAKE_S                31
  70. #define MAKE_D                32
  71. #define MAKE_F                33
  72. #define MAKE_G                34
  73. #define MAKE_H                35
  74. #define MAKE_J                36
  75. #define MAKE_K                37
  76. #define MAKE_L                38
  77. #define MAKE_SEMI             39
  78. #define MAKE_APOS             40
  79. #define MAKE_TILDE            41
  80. #define MAKE_LEFT_SHIFT       42
  81. #define MAKE_BACK_SLASH       43
  82. #define MAKE_Z                44
  83. #define MAKE_X                45
  84. #define MAKE_C                46
  85. #define MAKE_V                47
  86. #define MAKE_B                48
  87. #define MAKE_N                49
  88. #define MAKE_M                50
  89. #define MAKE_COMMA            51
  90. #define MAKE_PERIOD           52
  91. #define MAKE_FOWARD_SLASH     53
  92. #define MAKE_RIGHT_SHIFT      54
  93. #define MAKE_PRT_SCRN         55
  94. #define MAKE_ALT              56
  95. #define MAKE_SPACE            57
  96. #define MAKE_CAPS_LOCK        58
  97. #define MAKE_F1               59
  98. #define MAKE_F2               60
  99. #define MAKE_F3               61
  100. #define MAKE_F4               62
  101. #define MAKE_F5               63
  102. #define MAKE_F6               64
  103. #define MAKE_F7               65
  104. #define MAKE_F8               66
  105. #define MAKE_F9               67
  106. #define MAKE_F10              68
  107. #define MAKE_F11              87
  108. #define MAKE_F12              88
  109. #define MAKE_NUM_LOCK         69
  110. #define MAKE_SCROLL_LOCK      70
  111. #define MAKE_HOME             71
  112. #define MAKE_UP               72
  113. #define MAKE_PGUP             73
  114. #define MAKE_KEYPAD_MINUS     74
  115. #define MAKE_LEFT             75
  116. #define MAKE_CENTER           76
  117. #define MAKE_RIGHT            77
  118. #define MAKE_KEYPAD_PLUS      78
  119. #define MAKE_END              79
  120. #define MAKE_DOWN             80
  121. #define MAKE_PGDWN            81
  122. #define MAKE_INS              82
  123. #define MAKE_DEL              83
  124.  
  125. // these are the defines for the break codes, they are computed by adding 128
  126. // to each of the make codes
  127.  
  128. #define BREAK_ESC              (1 +128)
  129. #define BREAK_1                (2 +128)
  130. #define BREAK_2                (3 +128)
  131. #define BREAK_3                (4 +128)
  132. #define BREAK_4                (5 +128)
  133. #define BREAK_5                (6 +128)
  134. #define BREAK_6                (7 +128)
  135. #define BREAK_7                (8 +128)
  136. #define BREAK_8                (9 +128)
  137. #define BREAK_9                (10+128)
  138. #define BREAK_0                (11+128)
  139. #define BREAK_MINUS            (12+128)
  140. #define BREAK_EQUALS           (13+128)
  141. #define BREAK_BKSP             (14+128)
  142. #define BREAK_TAB              (15+128)
  143. #define BREAK_Q                (16+128)
  144. #define BREAK_W                (17+128)
  145. #define BREAK_E                (18+128)
  146. #define BREAK_R                (19+128)
  147. #define BREAK_T                (20+128)
  148. #define BREAK_Y                (21+128)
  149. #define BREAK_U                (22+128)
  150. #define BREAK_I                (23+128)
  151. #define BREAK_O                (24+128)
  152. #define BREAK_P                (25+128)
  153. #define BREAK_LFT_BRACKET      (26+128)
  154. #define BREAK_RGT_BRACKET      (27+128)
  155. #define BREAK_ENTER            (28+128)
  156. #define BREAK_CTRL             (29+128)
  157. #define BREAK_A                (30+128)
  158. #define BREAK_S                (31+128)
  159. #define BREAK_D                (32+128)
  160. #define BREAK_F                (33+128)
  161. #define BREAK_G                (34+128)
  162. #define BREAK_H                (35+128)
  163. #define BREAK_J                (36+128)
  164. #define BREAK_K                (37+128)
  165. #define BREAK_L                (38+128)
  166. #define BREAK_SEMI             (39+128)
  167. #define BREAK_APOS             (40+128)
  168. #define BREAK_TILDE            (41+128)
  169. #define BREAK_LEFT_SHIFT       (42+128)
  170. #define BREAK_BACK_SLASH       (43+128)
  171. #define BREAK_Z                (44+128)
  172. #define BREAK_X                (45+128)
  173. #define BREAK_C                (46+128)
  174. #define BREAK_V                (47+128)
  175. #define BREAK_B                (48+128)
  176. #define BREAK_N                (49+128)
  177. #define BREAK_M                (50+128)
  178. #define BREAK_COMMA            (51+128)
  179. #define BREAK_PERIOD           (52+128)
  180. #define BREAK_FOWARD_SLASH     (53+128)
  181. #define BREAK_RIGHT_SHIFT      (54+128)
  182. #define BREAK_PRT_SCRN         (55+128)
  183. #define BREAK_ALT              (56+128)
  184. #define BREAK_SPACE            (57+128)
  185. #define BREAK_CAPS_LOCK        (58+128)
  186. #define BREAK_F1               (59+128)
  187. #define BREAK_F2               (60+128)
  188. #define BREAK_F3               (61+128)
  189. #define BREAK_F4               (62+128)
  190. #define BREAK_F5               (63+128)
  191. #define BREAK_F6               (64+128)
  192. #define BREAK_F7               (65+128)
  193. #define BREAK_F8               (66+128)
  194. #define BREAK_F9               (67+128)
  195. #define BREAK_F10              (68+128)
  196. #define BREAK_F11              (87+128)
  197. #define BREAK_F12              (88+128)
  198. #define BREAK_NUM_LOCK         (69+128)
  199. #define BREAK_SCROLL_LOCK      (70+128)
  200. #define BREAK_HOME             (71+128)
  201. #define BREAK_UP               (72+128)
  202. #define BREAK_PGUP             (73+128)
  203. #define BREAK_KEYPAD_MINUS     (74+128)
  204. #define BREAK_LEFT             (75+128)
  205. #define BREAK_CENTER           (76+128)
  206. #define BREAK_RIGHT            (77+128)
  207. #define BREAK_KEYPAD_PLUS      (78+128)
  208. #define BREAK_END              (79+128)
  209. #define BREAK_DOWN             (80+128)
  210. #define BREAK_PGDWN            (81+128)
  211. #define BREAK_INS              (82+128)
  212. #define BREAK_DEL              (83+128)
  213.  
  214. #define KEY_UP                 0
  215. #define KEY_DOWN               1
  216.  
  217. // defines for the joystick interface
  218.  
  219. #define JOYPORT               0x201  // joyport is at 201 hex
  220.  
  221. #define JOYSTICK_BUTTON_1_1   0x10   // joystick 1, button 1
  222. #define JOYSTICK_BUTTON_1_2   0x20   // joystick 1, button 2
  223. #define JOYSTICK_BUTTON_2_1   0x40   // joystick 2, button 1
  224. #define JOYSTICK_BUTTON_2_2   0x80   // joystick 2, button 2
  225.  
  226. #define JOYSTICK_1            0x01   // joystick 1
  227. #define JOYSTICK_2            0x02   // joystick 2
  228.  
  229. #define JOYSTICK_1_X          0x01   // joystick 1, x axis
  230. #define JOYSTICK_1_Y          0x02   // joystick 1, y axis
  231. #define JOYSTICK_2_X          0x04   // joystick 2, x axis
  232. #define JOYSTICK_2_Y          0x08   // joystick 2, y axis
  233.  
  234. #define USE_BIOS              0      // command to use BIOS version of something
  235. #define USE_LOW_LEVEL         1      // command to use our own low level version
  236.  
  237. // defines for mouse interface
  238.  
  239. #define MOUSE_INTERRUPT          0x33 //mouse interrupt number
  240. #define MOUSE_RESET              0x00 // reset the mouse
  241. #define MOUSE_SHOW               0x01 // show the mouse
  242. #define MOUSE_HIDE               0x02 // hide the mouse
  243. #define MOUSE_POSITION_BUTTONS   0x03 // get buttons and postion
  244. #define MOUSE_MOTION_REL         0x0B // query motion counters to compute
  245.                                       // relative motion
  246. #define MOUSE_SET_SENSITIVITY    0x1A // set the sensitivity of mouse
  247.  
  248.  
  249. // mouse button bitmasks
  250.  
  251. #define MOUSE_LEFT_BUTTON        0x01 // left mouse button mask
  252. #define MOUSE_MIDDLE_BUTTON      0x04 // middle mouse button mask
  253. #define MOUSE_RIGHT_BUTTON       0x02 // right mouse button mask
  254.  
  255. // E X T E R N A L S /////////////////////////////////////////////////////////
  256.  
  257. extern void (_interrupt _far *Old_Keyboard_ISR)();  // holds old keyboard interrupt handler
  258.  
  259. extern int raw_scan_code;  // the global keyboard scan code
  260.  
  261. // this holds the keyboard state table which tracks the state of every key
  262. // on the keyboard, if any element is a one then the key is down
  263.  
  264. extern int keyboard_state[128];
  265.  
  266. // this tracks the number of keys that are currently pressed, helps
  267. // with keyboard testing logic
  268.  
  269. extern int keys_active;
  270.  
  271. // these values hold the maximum, minimum and neutral joystick values for
  272. // both joysticks
  273.  
  274. extern unsigned int joystick_1_max_x,     // maximum deflection of X axis joy 1
  275.                     joystick_1_max_y,     // maximum deflection of Y axis joy 1
  276.                     joystick_1_min_x,     // minimum deflection of X axis joy 1
  277.                     joystick_1_min_y,     // minimum deflection of Y axis joy 1
  278.                     joystick_1_neutral_x, // neutral or center of X axis joy 1
  279.                     joystick_1_neutral_y, // neutral or center of Y axis joy 1
  280.  
  281.                     joystick_2_max_x,     // maximum deflection of X axis joy 2
  282.                     joystick_2_max_y,     // maximum deflection of Y axis joy 2
  283.                     joystick_2_min_x,     // minimum deflection of X axis joy 2
  284.                     joystick_2_min_y,     // minimum deflection of Y axis joy 2
  285.                     joystick_2_neutral_x, // neutral or center of X axis joy 2
  286.                     joystick_2_neutral_y; // neutral or center of Y axis joy 2
  287.  
  288. // P R O T O T Y P E S ////////////////////////////////////////////////////////
  289.  
  290. // keyboard stuff
  291.  
  292. void _interrupt _far Keyboard_Driver();
  293.  
  294. void Keyboard_Install_Driver(void);
  295.  
  296. void Keyboard_Remove_Driver(void);
  297.  
  298. unsigned char Get_Key(void);
  299.  
  300. unsigned int Get_Control_Keys(unsigned int mask);
  301.  
  302. unsigned char Get_Scan_Code(void);
  303.  
  304. extern void get_raw_key (void);
  305.  
  306. extern int bios_scan_code (void);
  307.  
  308.  
  309. // joystick stuff
  310.  
  311. unsigned char Joystick_Buttons(unsigned char button);
  312.  
  313. unsigned int Joystick(unsigned char joystick);
  314.  
  315. unsigned int Joystick_Bios(unsigned char joystick);
  316.  
  317. unsigned char Buttons_Bios(unsigned char button);
  318.  
  319. void Joystick_Calibrate(int joystick,int method);
  320.  
  321. int Joystick_Available(int joystick);
  322.  
  323. // mouse stuff
  324.  
  325. int Mouse_Control(int command, int *x, int *y,int *buttons);
  326.  
  327.  
  328.