1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 KEYDEF.H                                  */
4 /*                                                                           */
5 /* (C) 1993-95  Ullrich von Bassewitz                                        */
6 /*              Zwehrenbuehlstrasse 33                                       */
7 /*              D-72070 Tuebingen                                            */
8 /* EMail:       uz@ibb.schwaben.com                                          */
9 /*                                                                           */
10 /*****************************************************************************/
11 
12 
13 
14 // $Id$
15 //
16 // $Log$
17 //
18 //
19 
20 
21 
22 #ifndef __KEYDEF_H
23 #define __KEYDEF_H
24 
25 
26 
27 #include "machine.h"
28 
29 
30 
31 /*****************************************************************************/
32 /*                                 Keycodes                                  */
33 /*****************************************************************************/
34 
35 
36 
37 // Type of a key
38 typedef u16     Key;
39 
40 
41 
42 // "Special" key
43 static const Key        kbNoKey         = 0x0000;
44 
45 
46 
47 /*****************************************************************************/
48 /*                             "Plain" Keycodes                              */
49 /*****************************************************************************/
50 
51 
52 
53 // Keys without any modifiers
54 static const Key        kbEnter         = 0x000D;
55 static const Key        kbEsc           = 0x001B;
56 static const Key        kbBack          = 0x0008;
57 
58 static const Key        kbTab           = 0x0009;
59 
60 
61 
62 // Keys with ctrl modifier
63 static const Key        kbCtrlA         = 0x0001;
64 static const Key        kbCtrlB         = 0x0002;
65 static const Key        kbCtrlC         = 0x0003;
66 static const Key        kbCtrlD         = 0x0004;
67 static const Key        kbCtrlE         = 0x0005;
68 static const Key        kbCtrlF         = 0x0006;
69 static const Key        kbCtrlG         = 0x0007;
70 static const Key        kbCtrlH         = 0x0008;
71 static const Key        kbCtrlI         = 0x0009;
72 static const Key        kbCtrlJ         = 0x000A;
73 static const Key        kbCtrlK         = 0x000B;
74 static const Key        kbCtrlL         = 0x000C;
75 static const Key        kbCtrlM         = 0x000D;
76 static const Key        kbCtrlN         = 0x000E;
77 static const Key        kbCtrlO         = 0x000F;
78 static const Key        kbCtrlP         = 0x0010;
79 static const Key        kbCtrlQ         = 0x0011;
80 static const Key        kbCtrlR         = 0x0012;
81 static const Key        kbCtrlS         = 0x0013;
82 static const Key        kbCtrlT         = 0x0014;
83 static const Key        kbCtrlU         = 0x0015;
84 static const Key        kbCtrlV         = 0x0016;
85 static const Key        kbCtrlW         = 0x0017;
86 static const Key        kbCtrlX         = 0x0018;
87 static const Key        kbCtrlY         = 0x0019;
88 static const Key        kbCtrlZ         = 0x001A;
89 
90 
91 
IsPlainKey(Key K)92 inline int IsPlainKey (Key K)
93 // Determine if K is a normal keycode
94 {
95     return ((K & 0xFF00) == 0x0000);
96 }
97 
98 
99 
100 /*****************************************************************************/
101 /*                             Extended Keycodes                             */
102 /*****************************************************************************/
103 
104 
105 
106 static const Key        kbF1            = 0x013B;
107 static const Key        kbF2            = 0x013C;
108 static const Key        kbF3            = 0x013D;
109 static const Key        kbF4            = 0x013E;
110 static const Key        kbF5            = 0x013F;
111 static const Key        kbF6            = 0x0140;
112 static const Key        kbF7            = 0x0141;
113 static const Key        kbF8            = 0x0142;
114 static const Key        kbF9            = 0x0143;
115 static const Key        kbF10           = 0x0144;
116 static const Key        kbF11           = 0x0185;
117 static const Key        kbF12           = 0x0186;
118 
119 static const Key        kbUp            = 0x0148;
120 static const Key        kbDown          = 0x0150;
121 static const Key        kbLeft          = 0x014B;
122 static const Key        kbRight         = 0x014D;
123 static const Key        kbPgDn          = 0x0151;
124 static const Key        kbPgUp          = 0x0149;
125 static const Key        kbIns           = 0x0152;
126 static const Key        kbDel           = 0x0153;
127 static const Key        kbHome          = 0x0147;
128 static const Key        kbEnd           = 0x014F;
129 
130 
131 
132 static const Key        kbCtrlF1        = 0x015E;
133 static const Key        kbCtrlF2        = 0x015F;
134 static const Key        kbCtrlF3        = 0x0160;
135 static const Key        kbCtrlF4        = 0x0161;
136 static const Key        kbCtrlF5        = 0x0162;
137 static const Key        kbCtrlF6        = 0x0163;
138 static const Key        kbCtrlF7        = 0x0164;
139 static const Key        kbCtrlF8        = 0x0165;
140 static const Key        kbCtrlF9        = 0x0166;
141 static const Key        kbCtrlF10       = 0x0167;
142 static const Key        kbCtrlF11       = 0x0189;
143 static const Key        kbCtrlF12       = 0x018A;
144 
145 static const Key        kbCtrlTab       = 0x0194;
146 static const Key        kbCtrlUp        = 0x018D;
147 static const Key        kbCtrlDown      = 0x0191;
148 static const Key        kbCtrlLeft      = 0x0173;
149 static const Key        kbCtrlRight     = 0x0174;
150 static const Key        kbCtrlPgDn      = 0x0176;
151 static const Key        kbCtrlPgUp      = 0x0184;
152 
153 static const Key        kbCtrlIns       = 0x0104;
154 static const Key        kbCtrlDel       = 0x0106;
155 static const Key        kbCtrlHome      = 0x0177;
156 static const Key        kbCtrlEnd       = 0x0175;
157 
158 
159 // Keys with meta prefix
160 static const Key        kbMeta1         = 0x0178;
161 static const Key        kbMeta2         = 0x0179;
162 static const Key        kbMeta3         = 0x017A;
163 static const Key        kbMeta4         = 0x017B;
164 static const Key        kbMeta5         = 0x017C;
165 static const Key        kbMeta6         = 0x017D;
166 static const Key        kbMeta7         = 0x017E;
167 static const Key        kbMeta8         = 0x017F;
168 static const Key        kbMeta9         = 0x0180;
169 static const Key        kbMeta0         = 0x0181;
170 
171 static const Key        kbMetaA         = 0x011E;
172 static const Key        kbMetaB         = 0x0130;
173 static const Key        kbMetaC         = 0x012E;
174 static const Key        kbMetaD         = 0x0120;
175 static const Key        kbMetaE         = 0x0112;
176 static const Key        kbMetaF         = 0x0121;
177 static const Key        kbMetaG         = 0x0122;
178 static const Key        kbMetaH         = 0x0123;
179 static const Key        kbMetaI         = 0x0117;
180 static const Key        kbMetaJ         = 0x0124;
181 static const Key        kbMetaK         = 0x0125;
182 static const Key        kbMetaL         = 0x0126;
183 static const Key        kbMetaM         = 0x0132;
184 static const Key        kbMetaN         = 0x0131;
185 static const Key        kbMetaO         = 0x0118;
186 static const Key        kbMetaP         = 0x0119;
187 static const Key        kbMetaQ         = 0x0110;
188 static const Key        kbMetaR         = 0x0113;
189 static const Key        kbMetaS         = 0x011F;
190 static const Key        kbMetaT         = 0x0114;
191 static const Key        kbMetaU         = 0x0116;
192 static const Key        kbMetaV         = 0x012F;
193 static const Key        kbMetaW         = 0x0111;
194 static const Key        kbMetaX         = 0x012D;
195 static const Key        kbMetaY         = 0x0115;
196 static const Key        kbMetaZ         = 0x012C;
197 
198 
199 static const Key        kbMetaF1        = 0x0168;
200 static const Key        kbMetaF2        = 0x0169;
201 static const Key        kbMetaF3        = 0x016A;
202 static const Key        kbMetaF4        = 0x016B;
203 static const Key        kbMetaF5        = 0x016C;
204 static const Key        kbMetaF6        = 0x016D;
205 static const Key        kbMetaF7        = 0x016E;
206 static const Key        kbMetaF8        = 0x016F;
207 static const Key        kbMetaF9        = 0x0170;
208 static const Key        kbMetaF10       = 0x0171;
209 static const Key        kbMetaF11       = 0x018B;
210 static const Key        kbMetaF12       = 0x018C;
211 
212 static const Key        kbMetaEsc       = 0x0101;
213 static const Key        kbMetaSpace     = 0x0102;
214 static const Key        kbMetaTab       = 0x01A5;
215 static const Key        kbMetaPgDn      = 0x01A1;
216 static const Key        kbMetaPgUp      = 0x0199;
217 
218 static const Key        kbMetaIns       = 0x01A2;
219 static const Key        kbMetaDel       = 0x01A3;
220 static const Key        kbMetaHome      = 0x0197;
221 static const Key        kbMetaEnd       = 0x019F;
222 
223 static const Key        kbMetaLeft      = 0x019B;
224 static const Key        kbMetaRight     = 0x019D;
225 static const Key        kbMetaUp        = 0x0198;
226 static const Key        kbMetaDown      = 0x01A0;
227 
228 
229 // Keys with shift modifier
230 static const Key        kbShiftF1       = 0x0154;
231 static const Key        kbShiftF2       = 0x0155;
232 static const Key        kbShiftF3       = 0x0156;
233 static const Key        kbShiftF4       = 0x0157;
234 static const Key        kbShiftF5       = 0x0158;
235 static const Key        kbShiftF6       = 0x0159;
236 static const Key        kbShiftF7       = 0x015A;
237 static const Key        kbShiftF8       = 0x015B;
238 static const Key        kbShiftF9       = 0x015C;
239 static const Key        kbShiftF10      = 0x015D;
240 static const Key        kbShiftF11      = 0x0187;
241 static const Key        kbShiftF12      = 0x0188;
242 
243 static const Key        kbShiftTab      = 0x010F;
244 
245 static const Key        kbShiftIns      = 0x0105;
246 static const Key        kbShiftDel      = 0x0107;
247 
248 
249 
250 // Some keys used in linux. Note: Those are not supported by the PC hardware
251 // but mapped by key sequences from the key mapper. They are used to define
252 // virtual keys when the corresponding extended keys are not available.
253 // Beware: Don't use numbers defined above!
254 
255 static const Key        kbEscCtrlA      = 0x01B0;
256 static const Key        kbEscCtrlB      = 0x01B1;
257 static const Key        kbEscCtrlC      = 0x01B2;
258 static const Key        kbEscCtrlD      = 0x01B3;
259 static const Key        kbEscCtrlE      = 0x01B4;
260 static const Key        kbEscCtrlF      = 0x01B5;
261 static const Key        kbEscCtrlG      = 0x01B6;
262 static const Key        kbEscCtrlH      = 0x01B7;
263 static const Key        kbEscCtrlI      = 0x01B8;
264 static const Key        kbEscCtrlJ      = 0x01B9;
265 static const Key        kbEscCtrlK      = 0x01BA;
266 static const Key        kbEscCtrlL      = 0x01BB;
267 static const Key        kbEscCtrlM      = 0x01BC;
268 static const Key        kbEscCtrlN      = 0x01BD;
269 static const Key        kbEscCtrlO      = 0x01BE;
270 static const Key        kbEscCtrlP      = 0x01BF;
271 static const Key        kbEscCtrlQ      = 0x01C0;
272 static const Key        kbEscCtrlR      = 0x01C1;
273 static const Key        kbEscCtrlS      = 0x01C2;
274 static const Key        kbEscCtrlT      = 0x01C3;
275 static const Key        kbEscCtrlU      = 0x01C4;
276 static const Key        kbEscCtrlV      = 0x01C5;
277 static const Key        kbEscCtrlW      = 0x01C6;
278 static const Key        kbEscCtrlX      = 0x01C7;
279 static const Key        kbEscCtrlY      = 0x01C8;
280 static const Key        kbEscCtrlZ      = 0x01C9;
281 
282 static const Key        kbEscEsc        = 0x01CA;       // Mapped to vkAbort
283 
284 static const Key        kbCtrlQS        = 0x01CB;       // Mapped to vkHome
285 static const Key        kbCtrlQD        = 0x01CC;       // Mapped to vkEnd
286 static const Key        kbCtrlQR        = 0x01CD;       // Mapped to vkCtrlPgUp
287 static const Key        kbCtrlQC        = 0x01CE;       // Mapped to vkCtrlPgDn
288 static const Key        kbCtrlQE        = 0x01CF;       // Mapped to vkCtrlHome
289 static const Key        kbCtrlQX        = 0x01D0;       // Mapped to vkCtrlEnd
290 
291 
292 
IsExtendedKey(Key K)293 inline int IsExtendedKey (Key K)
294 // Determine if K is a extended keycode
295 {
296     return ((K & 0xFF00) == 0x0100);
297 }
298 
299 
300 
301 /*****************************************************************************/
302 /*                             Virtual Keycodes                              */
303 /*****************************************************************************/
304 
305 
306 
307 // The following keys are garantied to exist
308 static const Key        vkAbort         = 0x0201;
309 static const Key        vkHelp          = 0x0202;
310 static const Key        vkAccept        = 0x0203;
311 
312 static const Key        vkPgUp          = 0x0210;
313 static const Key        vkPgDn          = 0x0211;
314 static const Key        vkCtrlPgUp      = 0x0212;
315 static const Key        vkCtrlPgDn      = 0x0213;
316 
317 static const Key        vkUp            = 0x0214;
318 static const Key        vkDown          = 0x0215;
319 static const Key        vkLeft          = 0x0216;
320 static const Key        vkRight         = 0x0217;
321 static const Key        vkCtrlUp        = 0x0218;
322 static const Key        vkCtrlDown      = 0x0219;
323 static const Key        vkCtrlLeft      = 0x021A;
324 static const Key        vkCtrlRight     = 0x021B;
325 
326 static const Key        vkIns           = 0x021C;
327 static const Key        vkDel           = 0x021D;
328 static const Key        vkHome          = 0x021E;
329 static const Key        vkEnd           = 0x021F;
330 static const Key        vkCtrlIns       = 0x0220;
331 static const Key        vkCtrlDel       = 0x0221;
332 static const Key        vkCtrlHome      = 0x0222;
333 static const Key        vkCtrlEnd       = 0x0223;
334 
335 static const Key        vkZoom          = 0x0230;
336 static const Key        vkClose         = 0x0231;
337 static const Key        vkOpen          = 0x0232;
338 static const Key        vkResize        = 0x0233;
339 static const Key        vkQuit          = 0x0234;
340 static const Key        vkSave          = 0x0235;
341 
342 
343 
IsVirtualKey(Key K)344 inline int IsVirtualKey (Key K)
345 // Determine if K is a virtual keycode
346 {
347     return ((K & 0xFF00) == 0x0200);
348 }
349 
350 
351 
352 /*****************************************************************************/
353 /*                                   Code                                    */
354 /*****************************************************************************/
355 
356 
357 
358 Key GetMetaCode (Key K);
359 // Return the "meta version" of the given key K or kbNoKey if none exists
360 
361 
362 
363 Key GetMetaKey (Key K);
364 // Return the "normal key" of the meta key given key K or kbNoKey if none
365 // exists
366 
367 
368 
369 // End of KEYDEF.H
370 
371 #endif
372 
373