]> icculus.org git repositories - taylor/freespace2.git/blob - include/key.h
make numlock not overlap with pause
[taylor/freespace2.git] / include / key.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Io/Key.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Include file for keyboard reading routines
16  *
17  * $Log$
18  * Revision 1.9  2002/08/04 02:31:00  relnev
19  * make numlock not overlap with pause
20  *
21  * Revision 1.8  2002/06/09 04:41:13  relnev
22  * added copyright header
23  *
24  * Revision 1.7  2002/05/31 03:34:02  theoddone33
25  * Fix Keyboard
26  * Add titlebar
27  *
28  * Revision 1.6  2002/05/30 23:46:29  theoddone33
29  * some minor key changes (not necessarily fixes)
30  *
31  * Revision 1.5  2002/05/30 22:02:30  theoddone33
32  * More gl changes
33  *
34  * Revision 1.4  2002/05/30 16:50:24  theoddone33
35  * Keyboard partially fixed
36  *
37  * Revision 1.3  2002/05/29 23:17:49  theoddone33
38  * Non working text code and fixed keys
39  *
40  * Revision 1.2  2002/05/29 06:25:12  theoddone33
41  * Keyboard input, mouse tracking now work
42  *
43  * Revision 1.1.1.1  2002/05/03 03:28:12  root
44  * Initial import.
45  *
46  * 
47  * 2     10/07/98 10:53a Dave
48  * Initial checkin.
49  * 
50  * 1     10/07/98 10:49a Dave
51  * 
52  * 26    5/19/98 12:28a Mike
53  * Cheat stuff.
54  * 
55  * 25    5/18/98 11:01p Mike
56  * Adding support for cheat system.
57  * 
58  * 24    5/01/98 4:23p Lawrance
59  * Remap the scancode for the UK "\" key
60  * 
61  * 23    1/07/98 6:41p Lawrance
62  * Pass message latency to the keyboard lib.
63  * 
64  * 22    11/14/97 4:33p Mike
65  * Change Debug key to backquote (from F11).
66  * Balance a ton of subsystems in ships.tbl.
67  * Change "Heavy Laser" to "Disruptor".
68  * 
69  * 21    10/21/97 7:18p Hoffoss
70  * Overhauled the key/joystick control structure and usage throughout the
71  * entire FreeSpace code.  The whole system is very different now.
72  * 
73  * 20    9/13/97 9:30a Lawrance
74  * added ability to block certain keys from the keyboard
75  * 
76  * 19    9/10/97 6:02p Hoffoss
77  * Added code to check for key-pressed sexp operator in FreeSpace as part
78  * of training mission stuff.
79  * 
80  * 18    4/15/97 3:47p Allender
81  * moved type selection of list box items into actual UI code.  Made it
82  * behave more like windows listboxes do
83  * 
84  * 17    2/17/97 5:18p John
85  * Added a bunch of RCS headers to a bunch of old files that don't have
86  * them.
87  *
88  * $NoKeywords: $
89  */
90
91 #ifndef _KEY_H
92 #define _KEY_H
93
94 /*
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 */
99
100 #include "pstypes.h"
101
102 #define NUM_KEYS 256
103
104 extern int shifted_ascii_table[];
105 extern int ascii_table[];
106
107 extern ubyte keyd_pressed[NUM_KEYS];
108
109 // O/S level hooks...
110 void key_init();
111 void key_level_init();
112 void key_lost_focus();
113 void key_got_focus();
114 void key_mark( uint code, int state, uint latency );
115 int key_getch();
116 void key_flush();
117
118 // Routines/data you can access:
119 //NOT USED! extern fix key_down_time( uint code );
120 float key_down_timef( uint code );
121
122 int key_to_ascii(int keycode );
123 int key_inkey();
124
125 // global flag that will enable/disable the backspace key from stopping execution
126 //extern int Backspace_debug;
127
128 uint key_get_shift_status();
129 int key_down_count(int scancode);
130 int key_up_count(int scancode);
131 int key_checkch();
132 int key_check(int key);
133
134 //      Put "key" back in the input buffer.
135 void key_outkey(int key);
136
137 // used to restrict keys that are read into keyboard buffer
138 void key_set_filter(int *filter_array, int num);
139 void key_clear_filter();
140
141 extern int Cheats_enabled;
142 extern int Key_normal_game;
143
144 #define KEY_SHIFTED     0x1000
145 #define KEY_ALTED       0x2000
146 #define KEY_CTRLED      0x4000
147 #define KEY_DEBUGGED            0x8000
148 #define KEY_DEBUGGED1   0x0800          //      Cheat bit in release version of game.
149 #define KEY_MASK                        0x00FF
150
151 #define KEY_DEBUG_KEY   0x29                    //      KEY_LAPOSTRO (shifted = tilde, near upper-left of keyboard)
152
153 #define KEY_0           0x0B
154 #define KEY_1           0x02
155 #define KEY_2           0x03
156 #define KEY_3           0x04
157 #define KEY_4           0x05
158 #define KEY_5           0x06
159 #define KEY_6           0x07
160 #define KEY_7           0x08
161 #define KEY_8           0x09
162 #define KEY_9           0x0A
163
164 #define KEY_A           0x1E
165 #define KEY_B           0x30
166 #define KEY_C           0x2E
167 #define KEY_D           0x20
168 #define KEY_E           0x12
169 #define KEY_F           0x21
170 #define KEY_G           0x22
171 #define KEY_H           0x23
172 #define KEY_I           0x17
173 #define KEY_J           0x24
174 #define KEY_K           0x25
175 #define KEY_L           0x26
176 #define KEY_M           0x32
177 #define KEY_N           0x31
178 #define KEY_O           0x18
179 #define KEY_P           0x19
180 #define KEY_Q           0x10
181 #define KEY_R           0x13
182 #define KEY_S           0x1F
183 #define KEY_T           0x14
184 #define KEY_U           0x16
185 #define KEY_V           0x2F
186 #define KEY_W           0x11
187 #define KEY_X           0x2D
188 #define KEY_Y           0x15
189 #define KEY_Z           0x2C
190
191 #define KEY_MINUS       0x0C
192 #define KEY_EQUAL       0x0D
193 #define KEY_DIVIDE      0x35
194 #define KEY_SLASH       0x2B
195 #define KEY_SLASH_UK            0x56
196 #define KEY_COMMA       0x33
197 #define KEY_PERIOD      0x34
198 #define KEY_SEMICOL     0x27
199
200 #define KEY_LBRACKET    0x1A
201 #define KEY_RBRACKET    0x1B
202
203 #define KEY_RAPOSTRO    0x28
204 #define KEY_LAPOSTRO    0x29
205
206 #define KEY_ESC         0x01
207 #define KEY_ENTER       0x1C
208 #define KEY_BACKSP      0x0E
209 #define KEY_TAB         0x0F
210 #define KEY_SPACEBAR    0x39
211
212 #ifndef PLAT_UNIX
213 #define KEY_NUMLOCK     0x45
214 #else
215 #define KEY_NUMLOCK     0x61    /* remapped to an unused value, since pause is 45 */
216 #endif
217
218 #define KEY_SCROLLOCK   0x46
219 #define KEY_CAPSLOCK    0x3A
220
221 #define KEY_LSHIFT      0x2A
222 #define KEY_RSHIFT      0x36
223
224 #define KEY_LALT        0x38
225 #define KEY_RALT        0xB8
226
227 #define KEY_LCTRL       0x1D
228 #define KEY_RCTRL       0x9D
229
230 #define KEY_F1          0x3B
231 #define KEY_F2          0x3C
232 #define KEY_F3          0x3D
233 #define KEY_F4          0x3E
234 #define KEY_F5          0x3F
235 #define KEY_F6          0x40
236 #define KEY_F7          0x41
237 #define KEY_F8          0x42
238 #define KEY_F9          0x43
239 #define KEY_F10         0x44
240 #define KEY_F11         0x57
241 #define KEY_F12         0x58
242
243 #define KEY_PAD0        0x52
244 #define KEY_PAD1        0x4F
245 #define KEY_PAD2        0x50
246 #define KEY_PAD3        0x51
247 #define KEY_PAD4        0x4B
248 #define KEY_PAD5        0x4C
249 #define KEY_PAD6        0x4D
250 #define KEY_PAD7        0x47
251 #define KEY_PAD8        0x48
252 #define KEY_PAD9        0x49
253 #define KEY_PADMINUS    0x4A
254 #define KEY_PADPLUS     0x4E
255 #define KEY_PADPERIOD   0x53
256 #define KEY_PADDIVIDE   0xB5
257 #define KEY_PADMULTIPLY 0x37
258 #define KEY_PADENTER    0x9C
259
260 #define KEY_INSERT      0xD2
261 #define KEY_HOME        0xC7
262 #define KEY_PAGEUP      0xC9
263 #define KEY_DELETE      0xd3
264 #define KEY_END         0xCF
265 #define KEY_PAGEDOWN    0xD1
266 #define KEY_UP          0xC8
267 #define KEY_DOWN        0xD0
268 #define KEY_LEFT        0xCB
269 #define KEY_RIGHT       0xCD
270
271 #define KEY_PRINT_SCRN  0xB7
272 #define KEY_PAUSE                       0x45    //DOS: 0x61
273 #define KEY_BREAK                       0xc6
274
275 /*
276 #ifdef __cplusplus
277 }
278 #endif
279 */
280
281 #endif
282