]> icculus.org git repositories - btb/d2x.git/blob - arch/win32/include/key.h
move old per-file change logs into new file ChangeLog-old
[btb/d2x.git] / arch / win32 / include / key.h
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13 /*
14  * $Source: /cvs/cvsroot/d2x/arch/win32/include/key.h,v $
15  * $Revision: 1.2 $
16  * $Author: schaffner $
17  * $Date: 2004-08-28 23:17:45 $
18  *
19  * Header for keyboard functions
20  *
21  * $Log: not supported by cvs2svn $
22  * Revision 1.1.1.1  2001/01/19 03:30:15  bradleyb
23  * Import of d2x-0.0.8
24  *
25  * Revision 1.1.1.1  1999/06/14 22:01:23  donut
26  * Import of d1x 1.37 source.
27  *
28  */
29
30 #ifndef _KEY_H
31 #define _KEY_H 
32
33 #include "fix.h"
34 #include "types.h"
35 #include <ctype.h> // For 'toupper'
36
37 //==========================================================================
38 // This installs the int9 vector and initializes the keyboard in buffered
39 // ASCII mode. key_close simply undoes that.
40 extern void key_init();
41 extern void key_close();
42
43 //==========================================================================
44 // These are configuration parameters to setup how the buffer works.
45 // set keyd_buffer_type to 0 for no key buffering.
46 // set it to 1 and it will buffer scancodes.
47 extern unsigned char keyd_buffer_type;
48 extern unsigned char keyd_repeat;        // 1=allow repeating, 0=dont allow repeat
49
50 // keyd_editor_mode... 0=game mode, 1=editor mode.
51 // Editor mode makes key_down_time always return 0 if modifiers are down.
52 extern unsigned char keyd_editor_mode;
53
54 // Time in seconds when last key was pressed...
55 extern volatile int keyd_time_when_last_pressed;
56
57 //==========================================================================
58 // These are the "buffered" keypress routines.  Use them by setting the
59 // "keyd_buffer_type" variable.
60
61 extern void key_flush();    // Clears the 256 char buffer
62 extern int key_checkch();   // Returns 1 if a char is waiting
63 extern int key_getch();     // Gets key if one waiting other waits for one.
64 extern int key_inkey();     // Gets key if one, other returns 0.
65 extern int key_inkey_time(fix *time);     // Same as inkey, but returns the time the key was pressed down.
66 extern int key_peekkey();   // Same as inkey, but doesn't remove key from buffer.
67
68 extern unsigned char key_to_ascii(int keycode );
69 extern char *key_name(int keycode); // Convert keycode to the name of the key
70
71 extern void key_debug();    // Does an INT3
72
73 //==========================================================================
74 // These are the unbuffered routines. Index by the keyboard scancode.
75
76 // Set to 1 if the key is currently down, else 0
77 extern volatile unsigned char keyd_pressed[];
78 extern volatile unsigned char keyd_last_pressed;
79 extern volatile unsigned char keyd_last_released;
80
81 // Returns the seconds this key has been down since last call.
82 extern fix key_down_time(int scancode);
83
84 // Returns number of times key has went from up to down since last call.
85 extern unsigned int key_down_count(int scancode);
86
87 // Returns number of times key has went from down to up since last call.
88 extern unsigned int key_up_count(int scancode);
89
90 // Clears the times & counts used by the above functions
91 // Took out... use key_flush();
92 //void key_clear_times();
93 //void key_clear_counts();
94
95 extern char * key_text[256];
96
97 #define KEY_SHIFTED     0x100
98 #define KEY_ALTED       0x200
99 #define KEY_CTRLED      0x400
100 #define KEY_DEBUGGED    0x800
101
102 #define KEY_0           11
103 #define KEY_1           2
104 #define KEY_2           3
105 #define KEY_3           4
106 #define KEY_4           5
107 #define KEY_5           6
108 #define KEY_6           7
109 #define KEY_7           8
110 #define KEY_8           9
111 #define KEY_9           10
112
113 #define KEY_A           30
114 #define KEY_B           48
115 #define KEY_C           46
116 #define KEY_D           32
117 #define KEY_E           18
118 #define KEY_F           33
119 #define KEY_G           34
120 #define KEY_H           35
121 #define KEY_I           23
122 #define KEY_J           36
123 #define KEY_K           37
124 #define KEY_L           38
125 #define KEY_M           50
126 #define KEY_N           49
127 #define KEY_O           24
128 #define KEY_P           25
129 #define KEY_Q           16
130 #define KEY_R           19
131 #define KEY_S           31
132 #define KEY_T           20
133 #define KEY_U           22
134 #define KEY_V           47
135 #define KEY_W           17
136 #define KEY_X           45
137 #define KEY_Y           21
138 #define KEY_Z           44
139
140 #define KEY_MINUS       12
141 #define KEY_EQUAL       13
142 #define KEY_DIVIDE      43
143 #define KEY_SLASH       28
144 #define KEY_COMMA       51
145 #define KEY_PERIOD      52
146 #define KEY_SEMICOL     39
147
148 #define KEY_LBRACKET    26
149 #define KEY_RBRACKET    27
150
151 #define KEY_RAPOSTRO    40
152 #define KEY_LAPOSTRO    41
153
154 #define KEY_ESC         1
155 #define KEY_ENTER       28
156 #define KEY_BACKSP      14
157 #define KEY_TAB         15
158 #define KEY_SPACEBAR    57
159
160 #define KEY_NUMLOCK     69
161 #define KEY_SCROLLOCK   70
162 #define KEY_CAPSLOCK    58
163
164 #define KEY_LSHIFT      42
165 #define KEY_RSHIFT      54
166
167 #define KEY_LALT        56
168 #define KEY_RALT        194
169
170 #define KEY_LCTRL       29
171 #define KEY_RCTRL       157
172
173 #define KEY_F1          59
174 #define KEY_F2          60
175 #define KEY_F3          61
176 #define KEY_F4          62
177 #define KEY_F5          63
178 #define KEY_F6          64
179 #define KEY_F7          65
180 #define KEY_F8          66
181 #define KEY_F9          67
182 #define KEY_F10         68
183 #define KEY_F11         87
184 #define KEY_F12         88
185
186 #define KEY_PAD0        82
187 #define KEY_PAD1        79
188 #define KEY_PAD2        80
189 #define KEY_PAD3        81
190 #define KEY_PAD4        75
191 #define KEY_PAD5        76
192 #define KEY_PAD6        77
193 #define KEY_PAD7        71
194 #define KEY_PAD8        72
195 #define KEY_PAD9        73
196 #define KEY_PADMINUS    74
197 #define KEY_PADPLUS     78
198 #define KEY_PADPERIOD   83
199 #define KEY_PADDIVIDE   81
200 #define KEY_PADMULTIPLY 55
201 #define KEY_PADENTER    156
202
203 #define KEY_INSERT      210
204 #define KEY_HOME        209
205 #define KEY_PAGEUP      221
206 #define KEY_DELETE      211
207 #define KEY_END         217
208 #define KEY_PAGEDOWN    219
209 #define KEY_UP          200
210 #define KEY_DOWN        208
211 #define KEY_LEFT        203
212 #define KEY_RIGHT       205
213
214 #define KEY_PRINT_SCREEN        165
215 #define KEY_PAUSE               143
216
217 #endif