]> icculus.org git repositories - taylor/freespace2.git/blob - include/key.h
Non working text code and fixed keys
[taylor/freespace2.git] / include / key.h
1 /*
2  * $Logfile: /Freespace2/code/Io/Key.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Include file for keyboard reading routines
8  *
9  * $Log$
10  * Revision 1.3  2002/05/29 23:17:49  theoddone33
11  * Non working text code and fixed keys
12  *
13  * Revision 1.2  2002/05/29 06:25:12  theoddone33
14  * Keyboard input, mouse tracking now work
15  *
16  * Revision 1.1.1.1  2002/05/03 03:28:12  root
17  * Initial import.
18  *
19  * 
20  * 2     10/07/98 10:53a Dave
21  * Initial checkin.
22  * 
23  * 1     10/07/98 10:49a Dave
24  * 
25  * 26    5/19/98 12:28a Mike
26  * Cheat stuff.
27  * 
28  * 25    5/18/98 11:01p Mike
29  * Adding support for cheat system.
30  * 
31  * 24    5/01/98 4:23p Lawrance
32  * Remap the scancode for the UK "\" key
33  * 
34  * 23    1/07/98 6:41p Lawrance
35  * Pass message latency to the keyboard lib.
36  * 
37  * 22    11/14/97 4:33p Mike
38  * Change Debug key to backquote (from F11).
39  * Balance a ton of subsystems in ships.tbl.
40  * Change "Heavy Laser" to "Disruptor".
41  * 
42  * 21    10/21/97 7:18p Hoffoss
43  * Overhauled the key/joystick control structure and usage throughout the
44  * entire FreeSpace code.  The whole system is very different now.
45  * 
46  * 20    9/13/97 9:30a Lawrance
47  * added ability to block certain keys from the keyboard
48  * 
49  * 19    9/10/97 6:02p Hoffoss
50  * Added code to check for key-pressed sexp operator in FreeSpace as part
51  * of training mission stuff.
52  * 
53  * 18    4/15/97 3:47p Allender
54  * moved type selection of list box items into actual UI code.  Made it
55  * behave more like windows listboxes do
56  * 
57  * 17    2/17/97 5:18p John
58  * Added a bunch of RCS headers to a bunch of old files that don't have
59  * them.
60  *
61  * $NoKeywords: $
62  */
63
64 #ifndef _KEY_H
65 #define _KEY_H
66
67 /*
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 */
72
73 #include "pstypes.h"
74
75 #ifndef PLAT_UNIX
76 #define NUM_KEYS 256
77 #else
78 #define NUM_KEYS SDLK_LAST
79 #endif
80
81 extern int shifted_ascii_table[];
82 extern int ascii_table[];
83
84 extern ubyte keyd_pressed[NUM_KEYS];
85
86 // O/S level hooks...
87 void key_init();
88 void key_level_init();
89 void key_lost_focus();
90 void key_got_focus();
91 void key_mark( uint code, int state, uint latency );
92 int key_getch();
93 void key_flush();
94
95 // Routines/data you can access:
96 //NOT USED! extern fix key_down_time( uint code );
97 float key_down_timef( uint code );
98
99 int key_to_ascii(int keycode );
100 int key_inkey();
101
102 // global flag that will enable/disable the backspace key from stopping execution
103 //extern int Backspace_debug;
104
105 uint key_get_shift_status();
106 int key_down_count(int scancode);
107 int key_up_count(int scancode);
108 int key_checkch();
109 int key_check(int key);
110
111 //      Put "key" back in the input buffer.
112 void key_outkey(int key);
113
114 // used to restrict keys that are read into keyboard buffer
115 void key_set_filter(int *filter_array, int num);
116 void key_clear_filter();
117
118 extern int Cheats_enabled;
119 extern int Key_normal_game;
120
121 #define KEY_SHIFTED     0x1000
122 #define KEY_ALTED       0x2000
123 #define KEY_CTRLED      0x4000
124 #define KEY_DEBUGGED            0x8000
125 #define KEY_DEBUGGED1   0x0800          //      Cheat bit in release version of game.
126 #define KEY_MASK                        0x00FF
127
128 #define KEY_DEBUG_KEY   0x29                    //      KEY_LAPOSTRO (shifted = tilde, near upper-left of keyboard)
129
130 #ifdef PLAT_UNIX
131 #define KEY_0           SDLK_0
132 #define KEY_1           SDLK_1
133 #define KEY_2           SDLK_2
134 #define KEY_3           SDLK_3
135 #define KEY_4           SDLK_4
136 #define KEY_5           SDLK_5
137 #define KEY_6           SDLK_6
138 #define KEY_7           SDLK_7
139 #define KEY_8           SDLK_8
140 #define KEY_9           SDLK_9
141
142 #define KEY_A           SDLK_a
143 #define KEY_B           SDLK_b
144 #define KEY_C           SDLK_c
145 #define KEY_D           SDLK_d
146 #define KEY_E           SDLK_e
147 #define KEY_F           SDLK_f
148 #define KEY_G           SDLK_g
149 #define KEY_H           SDLK_h
150 #define KEY_I           SDLK_i
151 #define KEY_J           SDLK_j
152 #define KEY_K           SDLK_k
153 #define KEY_L           SDLK_l
154 #define KEY_M           SDLK_m
155 #define KEY_N           SDLK_n
156 #define KEY_O           SDLK_o
157 #define KEY_P           SDLK_p
158 #define KEY_Q           SDLK_q
159 #define KEY_R           SDLK_r
160 #define KEY_S           SDLK_s
161 #define KEY_T           SDLK_t
162 #define KEY_U          SDLK_u
163 #define KEY_V           SDLK_v
164 #define KEY_W           SDLK_w
165 #define KEY_X           SDLK_x
166 #define KEY_Y           SDLK_y
167 #define KEY_Z           SDLK_z
168
169 #define KEY_MINUS      SDLK_MINUS
170 #define KEY_EQUAL      SDLK_EQUALS
171 #define KEY_DIVIDE    SDLK_SLASH
172 #define KEY_SLASH       SDLK_SLASH
173 #define KEY_SLASH_UK    SDLK_SLASH
174 #define KEY_COMMA       SDLK_COMMA
175 #define KEY_PERIOD      SDLK_PERIOD
176 #define KEY_SEMICOL     SDLK_SEMICOLON
177
178 #define KEY_LBRACKET    SDLK_LEFTBRACKET
179 #define KEY_RBRACKET   SDLK_RIGHTBRACKET
180
181 #define KEY_RAPOSTRO    SDLK_BACKQUOTE
182 #define KEY_LAPOSTRO    SDLK_QUOTE
183
184 #define KEY_ESC         SDLK_ESCAPE
185 #define KEY_ENTER       SDLK_RETURN
186 #define KEY_BACKSP      SDLK_BACKSPACE
187 #define KEY_TAB         SDLK_TAB
188 #define KEY_SPACEBAR    SDLK_SPACE
189
190 #define KEY_NUMLOCK     SDLK_NUMLOCK
191 #define KEY_SCROLLOCK   SDLK_SCROLLOCK
192 #define KEY_CAPSLOCK    SDLK_CAPSLOCK
193
194 #define KEY_LSHIFT      SDLK_LSHIFT
195 #define KEY_RSHIFT      SDLK_RSHIFT
196
197 #define KEY_LALT        SDLK_LALT
198 #define KEY_RALT        SDLK_RALT
199
200 #define KEY_LCTRL      SDLK_LCTRL
201 #define KEY_RCTRL       SDLK_RCTRL
202
203 #define KEY_F1          SDLK_F1
204 #define KEY_F2          SDLK_F2
205 #define KEY_F3          SDLK_F3
206 #define KEY_F4          SDLK_F4
207 #define KEY_F5          SDLK_F5
208 #define KEY_F6          SDLK_F6
209 #define KEY_F7          SDLK_F7
210 #define KEY_F8          SDLK_F8
211 #define KEY_F9          SDLK_F9
212 #define KEY_F10         SDLK_F10
213 #define KEY_F11         SDLK_F11
214 #define KEY_F12         SDLK_F12
215
216 #define KEY_PAD0        SDLK_KP0
217 #define KEY_PAD1        SDLK_KP1
218 #define KEY_PAD2        SDLK_KP2
219 #define KEY_PAD3        SDLK_KP3
220 #define KEY_PAD4        SDLK_KP4
221 #define KEY_PAD5        SDLK_KP5
222 #define KEY_PAD6        SDLK_KP6
223 #define KEY_PAD7        SDLK_KP7
224 #define KEY_PAD8        SDLK_KP8
225 #define KEY_PAD9        SDLK_KP9
226 #define KEY_PADMINUS    SDLK_KP_MINUS
227 #define KEY_PADPLUS     SDLK_KP_PLUS
228 #define KEY_PADPERIOD   SDLK_KP_PERIOD
229 #define KEY_PADDIVIDE   SDLK_KP_DIVIDE
230 #define KEY_PADMULTIPLY SDLK_KP_MULTIPLY
231 #define KEY_PADENTER    SDLK_KP_ENTER
232
233 #define KEY_INSERT      SDLK_INSERT
234 #define KEY_HOME        SDLK_HOME
235 #define KEY_PAGEUP      SDLK_PAGEUP
236 #define KEY_DELETE      SDLK_DELETE
237 #define KEY_END         SDLK_END
238 #define KEY_PAGEDOWN    SDLK_PAGEDOWN
239 #define KEY_UP          SDLK_UP
240 #define KEY_DOWN        SDLK_DOWN
241 #define KEY_LEFT        SDLK_LEFT
242 #define KEY_RIGHT       SDLK_RIGHT
243
244 #define KEY_PRINT_SCRN  SDLK_PRINT
245 #define KEY_PAUSE       SDLK_PAUSE
246 #define KEY_BREAK       SDLK_BREAK
247 #else
248 #define KEY_0           0x0B
249 #define KEY_1           0x02
250 #define KEY_2           0x03
251 #define KEY_3           0x04
252 #define KEY_4           0x05
253 #define KEY_5           0x06
254 #define KEY_6           0x07
255 #define KEY_7           0x08
256 #define KEY_8           0x09
257 #define KEY_9           0x0A
258
259 #define KEY_A           0x1E
260 #define KEY_B           0x30
261 #define KEY_C           0x2E
262 #define KEY_D           0x20
263 #define KEY_E           0x12
264 #define KEY_F           0x21
265 #define KEY_G           0x22
266 #define KEY_H           0x23
267 #define KEY_I           0x17
268 #define KEY_J           0x24
269 #define KEY_K           0x25
270 #define KEY_L           0x26
271 #define KEY_M           0x32
272 #define KEY_N           0x31
273 #define KEY_O           0x18
274 #define KEY_P           0x19
275 #define KEY_Q           0x10
276 #define KEY_R           0x13
277 #define KEY_S           0x1F
278 #define KEY_T           0x14
279 #define KEY_U           0x16
280 #define KEY_V           0x2F
281 #define KEY_W           0x11
282 #define KEY_X           0x2D
283 #define KEY_Y           0x15
284 #define KEY_Z           0x2C
285
286 #define KEY_MINUS       0x0C
287 #define KEY_EQUAL       0x0D
288 #define KEY_DIVIDE      0x35
289 #define KEY_SLASH       0x2B
290 #define KEY_SLASH_UK            0x56
291 #define KEY_COMMA       0x33
292 #define KEY_PERIOD      0x34
293 #define KEY_SEMICOL     0x27
294
295 #define KEY_LBRACKET    0x1A
296 #define KEY_RBRACKET    0x1B
297
298 #define KEY_RAPOSTRO    0x28
299 #define KEY_LAPOSTRO    0x29
300
301 #define KEY_ESC         0x01
302 #define KEY_ENTER       0x1C
303 #define KEY_BACKSP      0x0E
304 #define KEY_TAB         0x0F
305 #define KEY_SPACEBAR    0x39
306
307 #define KEY_NUMLOCK     0x45
308 #define KEY_SCROLLOCK   0x46
309 #define KEY_CAPSLOCK    0x3A
310
311 #define KEY_LSHIFT      0x2A
312 #define KEY_RSHIFT      0x36
313
314 #define KEY_LALT        0x38
315 #define KEY_RALT        0xB8
316
317 #define KEY_LCTRL       0x1D
318 #define KEY_RCTRL       0x9D
319
320 #define KEY_F1          0x3B
321 #define KEY_F2          0x3C
322 #define KEY_F3          0x3D
323 #define KEY_F4          0x3E
324 #define KEY_F5          0x3F
325 #define KEY_F6          0x40
326 #define KEY_F7          0x41
327 #define KEY_F8          0x42
328 #define KEY_F9          0x43
329 #define KEY_F10         0x44
330 #define KEY_F11         0x57
331 #define KEY_F12         0x58
332
333 #define KEY_PAD0        0x52
334 #define KEY_PAD1        0x4F
335 #define KEY_PAD2        0x50
336 #define KEY_PAD3        0x51
337 #define KEY_PAD4        0x4B
338 #define KEY_PAD5        0x4C
339 #define KEY_PAD6        0x4D
340 #define KEY_PAD7        0x47
341 #define KEY_PAD8        0x48
342 #define KEY_PAD9        0x49
343 #define KEY_PADMINUS    0x4A
344 #define KEY_PADPLUS     0x4E
345 #define KEY_PADPERIOD   0x53
346 #define KEY_PADDIVIDE   0xB5
347 #define KEY_PADMULTIPLY 0x37
348 #define KEY_PADENTER    0x9C
349
350 #define KEY_INSERT      0xD2
351 #define KEY_HOME        0xC7
352 #define KEY_PAGEUP      0xC9
353 #define KEY_DELETE      0xd3
354 #define KEY_END         0xCF
355 #define KEY_PAGEDOWN    0xD1
356 #define KEY_UP          0xC8
357 #define KEY_DOWN        0xD0
358 #define KEY_LEFT        0xCB
359 #define KEY_RIGHT       0xCD
360
361 #define KEY_PRINT_SCRN  0xB7
362 #define KEY_PAUSE                       0x45    //DOS: 0x61
363 #define KEY_BREAK                       0xc6
364
365 #endif
366 /*
367 #ifdef __cplusplus
368 }
369 #endif
370 */
371
372 #endif
373