root / curses_keys.h @ ed23fbd9
History | View | Annotate | Download (12.4 kB)
1 |
/*
|
---|---|
2 |
* Keycode and keysyms conversion tables for curses
|
3 |
*
|
4 |
* Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
|
5 |
*
|
6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
* of this software and associated documentation files (the "Software"), to deal
|
8 |
* in the Software without restriction, including without limitation the rights
|
9 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
* copies of the Software, and to permit persons to whom the Software is
|
11 |
* furnished to do so, subject to the following conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be included in
|
14 |
* all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 |
* THE SOFTWARE.
|
23 |
*/
|
24 |
#define KEY_RELEASE 0x80 |
25 |
#define KEY_MASK 0x7f |
26 |
#define SHIFT_CODE 0x2a |
27 |
#define SHIFT 0x0080 |
28 |
#define GREY_CODE 0xe0 |
29 |
#define GREY 0x0100 |
30 |
#define CNTRL_CODE 0x1d |
31 |
#define CNTRL 0x0200 |
32 |
#define ALT_CODE 0x38 |
33 |
#define ALT 0x0400 |
34 |
|
35 |
/* curses won't detect a Control + Alt + 1, so use Alt + 1 */
|
36 |
#define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */ |
37 |
|
38 |
#define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */ |
39 |
|
40 |
int curses2keycode[CURSES_KEYS] = {
|
41 |
[0 ... (CURSES_KEYS - 1)] = -1, |
42 |
|
43 |
[0x01b] = 1, /* Escape */ |
44 |
['1'] = 2, |
45 |
['2'] = 3, |
46 |
['3'] = 4, |
47 |
['4'] = 5, |
48 |
['5'] = 6, |
49 |
['6'] = 7, |
50 |
['7'] = 8, |
51 |
['8'] = 9, |
52 |
['9'] = 10, |
53 |
['0'] = 11, |
54 |
['-'] = 12, |
55 |
['='] = 13, |
56 |
[0x07f] = 14, /* Backspace */ |
57 |
[0x107] = 14, /* Backspace */ |
58 |
|
59 |
['\t'] = 15, /* Tab */ |
60 |
['q'] = 16, |
61 |
['w'] = 17, |
62 |
['e'] = 18, |
63 |
['r'] = 19, |
64 |
['t'] = 20, |
65 |
['y'] = 21, |
66 |
['u'] = 22, |
67 |
['i'] = 23, |
68 |
['o'] = 24, |
69 |
['p'] = 25, |
70 |
['['] = 26, |
71 |
[']'] = 27, |
72 |
['\n'] = 28, /* Return */ |
73 |
['\r'] = 28, /* Return */ |
74 |
[0x157] = 28, /* Return */ |
75 |
|
76 |
['a'] = 30, |
77 |
['s'] = 31, |
78 |
['d'] = 32, |
79 |
['f'] = 33, |
80 |
['g'] = 34, |
81 |
['h'] = 35, |
82 |
['j'] = 36, |
83 |
['k'] = 37, |
84 |
['l'] = 38, |
85 |
[';'] = 39, |
86 |
['\''] = 40, /* Single quote */ |
87 |
['`'] = 41, |
88 |
['\\'] = 43, /* Backslash */ |
89 |
|
90 |
['z'] = 44, |
91 |
['x'] = 45, |
92 |
['c'] = 46, |
93 |
['v'] = 47, |
94 |
['b'] = 48, |
95 |
['n'] = 49, |
96 |
['m'] = 50, |
97 |
[','] = 51, |
98 |
['.'] = 52, |
99 |
['/'] = 53, |
100 |
|
101 |
[' '] = 57, |
102 |
|
103 |
[0x109] = 59, /* Function Key 1 */ |
104 |
[0x10a] = 60, /* Function Key 2 */ |
105 |
[0x10b] = 61, /* Function Key 3 */ |
106 |
[0x10c] = 62, /* Function Key 4 */ |
107 |
[0x10d] = 63, /* Function Key 5 */ |
108 |
[0x10e] = 64, /* Function Key 6 */ |
109 |
[0x10f] = 65, /* Function Key 7 */ |
110 |
[0x110] = 66, /* Function Key 8 */ |
111 |
[0x111] = 67, /* Function Key 9 */ |
112 |
[0x112] = 68, /* Function Key 10 */ |
113 |
[0x113] = 87, /* Function Key 11 */ |
114 |
[0x114] = 88, /* Function Key 12 */ |
115 |
|
116 |
[0x106] = 71 | GREY, /* Home */ |
117 |
[0x103] = 72 | GREY, /* Up Arrow */ |
118 |
[0x153] = 73 | GREY, /* Page Up */ |
119 |
[0x104] = 75 | GREY, /* Left Arrow */ |
120 |
[0x105] = 77 | GREY, /* Right Arrow */ |
121 |
[0x168] = 79 | GREY, /* End */ |
122 |
[0x102] = 80 | GREY, /* Down Arrow */ |
123 |
[0x152] = 81 | GREY, /* Page Down */ |
124 |
[0x14b] = 82 | GREY, /* Insert */ |
125 |
[0x14a] = 83 | GREY, /* Delete */ |
126 |
|
127 |
['!'] = 2 | SHIFT, |
128 |
['@'] = 3 | SHIFT, |
129 |
['#'] = 4 | SHIFT, |
130 |
['$'] = 5 | SHIFT, |
131 |
['%'] = 6 | SHIFT, |
132 |
['^'] = 7 | SHIFT, |
133 |
['&'] = 8 | SHIFT, |
134 |
['*'] = 9 | SHIFT, |
135 |
['('] = 10 | SHIFT, |
136 |
[')'] = 11 | SHIFT, |
137 |
['_'] = 12 | SHIFT, |
138 |
['+'] = 13 | SHIFT, |
139 |
|
140 |
[0x161] = 15 | SHIFT, /* Shift + Tab */ |
141 |
['Q'] = 16 | SHIFT, |
142 |
['W'] = 17 | SHIFT, |
143 |
['E'] = 18 | SHIFT, |
144 |
['R'] = 19 | SHIFT, |
145 |
['T'] = 20 | SHIFT, |
146 |
['Y'] = 21 | SHIFT, |
147 |
['U'] = 22 | SHIFT, |
148 |
['I'] = 23 | SHIFT, |
149 |
['O'] = 24 | SHIFT, |
150 |
['P'] = 25 | SHIFT, |
151 |
['{'] = 26 | SHIFT, |
152 |
['}'] = 27 | SHIFT, |
153 |
|
154 |
['A'] = 30 | SHIFT, |
155 |
['S'] = 31 | SHIFT, |
156 |
['D'] = 32 | SHIFT, |
157 |
['F'] = 33 | SHIFT, |
158 |
['G'] = 34 | SHIFT, |
159 |
['H'] = 35 | SHIFT, |
160 |
['J'] = 36 | SHIFT, |
161 |
['K'] = 37 | SHIFT, |
162 |
['L'] = 38 | SHIFT, |
163 |
[':'] = 39 | SHIFT, |
164 |
['"'] = 40 | SHIFT, |
165 |
['~'] = 41 | SHIFT, |
166 |
['|'] = 43 | SHIFT, |
167 |
|
168 |
['Z'] = 44 | SHIFT, |
169 |
['X'] = 45 | SHIFT, |
170 |
['C'] = 46 | SHIFT, |
171 |
['V'] = 47 | SHIFT, |
172 |
['B'] = 48 | SHIFT, |
173 |
['N'] = 49 | SHIFT, |
174 |
['M'] = 50 | SHIFT, |
175 |
['<'] = 51 | SHIFT, |
176 |
['>'] = 52 | SHIFT, |
177 |
['?'] = 53 | SHIFT, |
178 |
|
179 |
[0x115] = 59 | SHIFT, /* Shift + Function Key 1 */ |
180 |
[0x116] = 60 | SHIFT, /* Shift + Function Key 2 */ |
181 |
[0x117] = 61 | SHIFT, /* Shift + Function Key 3 */ |
182 |
[0x118] = 62 | SHIFT, /* Shift + Function Key 4 */ |
183 |
[0x119] = 63 | SHIFT, /* Shift + Function Key 5 */ |
184 |
[0x11a] = 64 | SHIFT, /* Shift + Function Key 6 */ |
185 |
[0x11b] = 65 | SHIFT, /* Shift + Function Key 7 */ |
186 |
[0x11c] = 66 | SHIFT, /* Shift + Function Key 8 */ |
187 |
|
188 |
[0x011] = 16 | CNTRL, /* Control + q */ |
189 |
[0x017] = 17 | CNTRL, /* Control + w */ |
190 |
[0x005] = 18 | CNTRL, /* Control + e */ |
191 |
[0x012] = 19 | CNTRL, /* Control + r */ |
192 |
[0x014] = 20 | CNTRL, /* Control + t */ |
193 |
[0x019] = 21 | CNTRL, /* Control + y */ |
194 |
[0x015] = 22 | CNTRL, /* Control + u */ |
195 |
[0x009] = 23 | CNTRL, /* Control + i */ |
196 |
[0x00f] = 24 | CNTRL, /* Control + o */ |
197 |
[0x010] = 25 | CNTRL, /* Control + p */ |
198 |
|
199 |
[0x001] = 30 | CNTRL, /* Control + a */ |
200 |
[0x013] = 31 | CNTRL, /* Control + s */ |
201 |
[0x004] = 32 | CNTRL, /* Control + d */ |
202 |
[0x006] = 33 | CNTRL, /* Control + f */ |
203 |
[0x007] = 34 | CNTRL, /* Control + g */ |
204 |
[0x008] = 35 | CNTRL, /* Control + h */ |
205 |
[0x00a] = 36 | CNTRL, /* Control + j */ |
206 |
[0x00b] = 37 | CNTRL, /* Control + k */ |
207 |
[0x00c] = 38 | CNTRL, /* Control + l */ |
208 |
|
209 |
[0x01a] = 44 | CNTRL, /* Control + z */ |
210 |
[0x018] = 45 | CNTRL, /* Control + x */ |
211 |
[0x003] = 46 | CNTRL, /* Control + c */ |
212 |
[0x016] = 47 | CNTRL, /* Control + v */ |
213 |
[0x002] = 48 | CNTRL, /* Control + b */ |
214 |
[0x00e] = 49 | CNTRL, /* Control + n */ |
215 |
/* Control + m collides with the keycode for Enter */
|
216 |
|
217 |
}; |
218 |
|
219 |
int curses2keysym[CURSES_KEYS] = {
|
220 |
[0 ... (CURSES_KEYS - 1)] = -1, |
221 |
|
222 |
['\n'] = '\n', |
223 |
['\r'] = '\n', |
224 |
|
225 |
[0x07f] = QEMU_KEY_BACKSPACE,
|
226 |
|
227 |
[0x102] = QEMU_KEY_DOWN,
|
228 |
[0x103] = QEMU_KEY_UP,
|
229 |
[0x104] = QEMU_KEY_LEFT,
|
230 |
[0x105] = QEMU_KEY_RIGHT,
|
231 |
[0x106] = QEMU_KEY_HOME,
|
232 |
[0x107] = QEMU_KEY_BACKSPACE,
|
233 |
|
234 |
[0x14a] = QEMU_KEY_DELETE,
|
235 |
[0x152] = QEMU_KEY_PAGEDOWN,
|
236 |
[0x153] = QEMU_KEY_PAGEUP,
|
237 |
[0x157] = '\n', |
238 |
[0x168] = QEMU_KEY_END,
|
239 |
|
240 |
}; |
241 |
|
242 |
typedef struct { |
243 |
const char* name; |
244 |
int keysym;
|
245 |
} name2keysym_t; |
246 |
|
247 |
static name2keysym_t name2keysym[] = {
|
248 |
/* Plain ASCII */
|
249 |
{ "space", 0x020 }, |
250 |
{ "exclam", 0x021 }, |
251 |
{ "quotedbl", 0x022 }, |
252 |
{ "numbersign", 0x023 }, |
253 |
{ "dollar", 0x024 }, |
254 |
{ "percent", 0x025 }, |
255 |
{ "ampersand", 0x026 }, |
256 |
{ "apostrophe", 0x027 }, |
257 |
{ "parenleft", 0x028 }, |
258 |
{ "parenright", 0x029 }, |
259 |
{ "asterisk", 0x02a }, |
260 |
{ "plus", 0x02b }, |
261 |
{ "comma", 0x02c }, |
262 |
{ "minus", 0x02d }, |
263 |
{ "period", 0x02e }, |
264 |
{ "slash", 0x02f }, |
265 |
{ "0", 0x030 }, |
266 |
{ "1", 0x031 }, |
267 |
{ "2", 0x032 }, |
268 |
{ "3", 0x033 }, |
269 |
{ "4", 0x034 }, |
270 |
{ "5", 0x035 }, |
271 |
{ "6", 0x036 }, |
272 |
{ "7", 0x037 }, |
273 |
{ "8", 0x038 }, |
274 |
{ "9", 0x039 }, |
275 |
{ "colon", 0x03a }, |
276 |
{ "semicolon", 0x03b }, |
277 |
{ "less", 0x03c }, |
278 |
{ "equal", 0x03d }, |
279 |
{ "greater", 0x03e }, |
280 |
{ "question", 0x03f }, |
281 |
{ "at", 0x040 }, |
282 |
{ "A", 0x041 }, |
283 |
{ "B", 0x042 }, |
284 |
{ "C", 0x043 }, |
285 |
{ "D", 0x044 }, |
286 |
{ "E", 0x045 }, |
287 |
{ "F", 0x046 }, |
288 |
{ "G", 0x047 }, |
289 |
{ "H", 0x048 }, |
290 |
{ "I", 0x049 }, |
291 |
{ "J", 0x04a }, |
292 |
{ "K", 0x04b }, |
293 |
{ "L", 0x04c }, |
294 |
{ "M", 0x04d }, |
295 |
{ "N", 0x04e }, |
296 |
{ "O", 0x04f }, |
297 |
{ "P", 0x050 }, |
298 |
{ "Q", 0x051 }, |
299 |
{ "R", 0x052 }, |
300 |
{ "S", 0x053 }, |
301 |
{ "T", 0x054 }, |
302 |
{ "U", 0x055 }, |
303 |
{ "V", 0x056 }, |
304 |
{ "W", 0x057 }, |
305 |
{ "X", 0x058 }, |
306 |
{ "Y", 0x059 }, |
307 |
{ "Z", 0x05a }, |
308 |
{ "bracketleft", 0x05b }, |
309 |
{ "backslash", 0x05c }, |
310 |
{ "bracketright", 0x05d }, |
311 |
{ "asciicircum", 0x05e }, |
312 |
{ "underscore", 0x05f }, |
313 |
{ "grave", 0x060 }, |
314 |
{ "a", 0x061 }, |
315 |
{ "b", 0x062 }, |
316 |
{ "c", 0x063 }, |
317 |
{ "d", 0x064 }, |
318 |
{ "e", 0x065 }, |
319 |
{ "f", 0x066 }, |
320 |
{ "g", 0x067 }, |
321 |
{ "h", 0x068 }, |
322 |
{ "i", 0x069 }, |
323 |
{ "j", 0x06a }, |
324 |
{ "k", 0x06b }, |
325 |
{ "l", 0x06c }, |
326 |
{ "m", 0x06d }, |
327 |
{ "n", 0x06e }, |
328 |
{ "o", 0x06f }, |
329 |
{ "p", 0x070 }, |
330 |
{ "q", 0x071 }, |
331 |
{ "r", 0x072 }, |
332 |
{ "s", 0x073 }, |
333 |
{ "t", 0x074 }, |
334 |
{ "u", 0x075 }, |
335 |
{ "v", 0x076 }, |
336 |
{ "w", 0x077 }, |
337 |
{ "x", 0x078 }, |
338 |
{ "y", 0x079 }, |
339 |
{ "z", 0x07a }, |
340 |
{ "braceleft", 0x07b }, |
341 |
{ "bar", 0x07c }, |
342 |
{ "braceright", 0x07d }, |
343 |
{ "asciitilde", 0x07e }, |
344 |
|
345 |
/* Latin-1 extensions */
|
346 |
{ "nobreakspace", 0x0a0 }, |
347 |
{ "exclamdown", 0x0a1 }, |
348 |
{ "cent", 0x0a2 }, |
349 |
{ "sterling", 0x0a3 }, |
350 |
{ "currency", 0x0a4 }, |
351 |
{ "yen", 0x0a5 }, |
352 |
{ "brokenbar", 0x0a6 }, |
353 |
{ "section", 0x0a7 }, |
354 |
{ "diaeresis", 0x0a8 }, |
355 |
{ "copyright", 0x0a9 }, |
356 |
{ "ordfeminine", 0x0aa }, |
357 |
{ "guillemotleft", 0x0ab }, |
358 |
{ "notsign", 0x0ac }, |
359 |
{ "hyphen", 0x0ad }, |
360 |
{ "registered", 0x0ae }, |
361 |
{ "macron", 0x0af }, |
362 |
{ "degree", 0x0b0 }, |
363 |
{ "plusminus", 0x0b1 }, |
364 |
{ "twosuperior", 0x0b2 }, |
365 |
{ "threesuperior", 0x0b3 }, |
366 |
{ "acute", 0x0b4 }, |
367 |
{ "mu", 0x0b5 }, |
368 |
{ "paragraph", 0x0b6 }, |
369 |
{ "periodcentered", 0x0b7 }, |
370 |
{ "cedilla", 0x0b8 }, |
371 |
{ "onesuperior", 0x0b9 }, |
372 |
{ "masculine", 0x0ba }, |
373 |
{ "guillemotright", 0x0bb }, |
374 |
{ "onequarter", 0x0bc }, |
375 |
{ "onehalf", 0x0bd }, |
376 |
{ "threequarters", 0x0be }, |
377 |
{ "questiondown", 0x0bf }, |
378 |
{ "Agrave", 0x0c0 }, |
379 |
{ "Aacute", 0x0c1 }, |
380 |
{ "Acircumflex", 0x0c2 }, |
381 |
{ "Atilde", 0x0c3 }, |
382 |
{ "Adiaeresis", 0x0c4 }, |
383 |
{ "Aring", 0x0c5 }, |
384 |
{ "AE", 0x0c6 }, |
385 |
{ "Ccedilla", 0x0c7 }, |
386 |
{ "Egrave", 0x0c8 }, |
387 |
{ "Eacute", 0x0c9 }, |
388 |
{ "Ecircumflex", 0x0ca }, |
389 |
{ "Ediaeresis", 0x0cb }, |
390 |
{ "Igrave", 0x0cc }, |
391 |
{ "Iacute", 0x0cd }, |
392 |
{ "Icircumflex", 0x0ce }, |
393 |
{ "Idiaeresis", 0x0cf }, |
394 |
{ "ETH", 0x0d0 }, |
395 |
{ "Eth", 0x0d0 }, |
396 |
{ "Ntilde", 0x0d1 }, |
397 |
{ "Ograve", 0x0d2 }, |
398 |
{ "Oacute", 0x0d3 }, |
399 |
{ "Ocircumflex", 0x0d4 }, |
400 |
{ "Otilde", 0x0d5 }, |
401 |
{ "Odiaeresis", 0x0d6 }, |
402 |
{ "multiply", 0x0d7 }, |
403 |
{ "Ooblique", 0x0d8 }, |
404 |
{ "Oslash", 0x0d8 }, |
405 |
{ "Ugrave", 0x0d9 }, |
406 |
{ "Uacute", 0x0da }, |
407 |
{ "Ucircumflex", 0x0db }, |
408 |
{ "Udiaeresis", 0x0dc }, |
409 |
{ "Yacute", 0x0dd }, |
410 |
{ "THORN", 0x0de }, |
411 |
{ "Thorn", 0x0de }, |
412 |
{ "ssharp", 0x0df }, |
413 |
{ "agrave", 0x0e0 }, |
414 |
{ "aacute", 0x0e1 }, |
415 |
{ "acircumflex", 0x0e2 }, |
416 |
{ "atilde", 0x0e3 }, |
417 |
{ "adiaeresis", 0x0e4 }, |
418 |
{ "aring", 0x0e5 }, |
419 |
{ "ae", 0x0e6 }, |
420 |
{ "ccedilla", 0x0e7 }, |
421 |
{ "egrave", 0x0e8 }, |
422 |
{ "eacute", 0x0e9 }, |
423 |
{ "ecircumflex", 0x0ea }, |
424 |
{ "ediaeresis", 0x0eb }, |
425 |
{ "igrave", 0x0ec }, |
426 |
{ "iacute", 0x0ed }, |
427 |
{ "icircumflex", 0x0ee }, |
428 |
{ "idiaeresis", 0x0ef }, |
429 |
{ "eth", 0x0f0 }, |
430 |
{ "ntilde", 0x0f1 }, |
431 |
{ "ograve", 0x0f2 }, |
432 |
{ "oacute", 0x0f3 }, |
433 |
{ "ocircumflex", 0x0f4 }, |
434 |
{ "otilde", 0x0f5 }, |
435 |
{ "odiaeresis", 0x0f6 }, |
436 |
{ "division", 0x0f7 }, |
437 |
{ "oslash", 0x0f8 }, |
438 |
{ "ooblique", 0x0f8 }, |
439 |
{ "ugrave", 0x0f9 }, |
440 |
{ "uacute", 0x0fa }, |
441 |
{ "ucircumflex", 0x0fb }, |
442 |
{ "udiaeresis", 0x0fc }, |
443 |
{ "yacute", 0x0fd }, |
444 |
{ "thorn", 0x0fe }, |
445 |
{ "ydiaeresis", 0x0ff }, |
446 |
|
447 |
/* Special keys */
|
448 |
{ "BackSpace", 0x07f }, |
449 |
{ "Tab", '\t' }, |
450 |
{ "Return", '\r' }, |
451 |
{ "Right", 0x105 }, |
452 |
{ "Left", 0x104 }, |
453 |
{ "Up", 0x103 }, |
454 |
{ "Down", 0x102 }, |
455 |
{ "Page_Down", 0x152 }, |
456 |
{ "Page_Up", 0x153 }, |
457 |
{ "Insert", 0x14b }, |
458 |
{ "Delete", 0x14a }, |
459 |
{ "Home", 0x106 }, |
460 |
{ "End", 0x168 }, |
461 |
{ "F1", 0x109 }, |
462 |
{ "F2", 0x10a }, |
463 |
{ "F3", 0x10b }, |
464 |
{ "F4", 0x10c }, |
465 |
{ "F5", 0x10d }, |
466 |
{ "F6", 0x10e }, |
467 |
{ "F7", 0x10f }, |
468 |
{ "F8", 0x110 }, |
469 |
{ "F9", 0x111 }, |
470 |
{ "F10", 0x112 }, |
471 |
{ "F11", 0x113 }, |
472 |
{ "F12", 0x114 }, |
473 |
{ "F13", 0x115 }, |
474 |
{ "F14", 0x116 }, |
475 |
{ "F15", 0x117 }, |
476 |
{ "F16", 0x118 }, |
477 |
{ "F17", 0x119 }, |
478 |
{ "F18", 0x11a }, |
479 |
{ "F19", 0x11b }, |
480 |
{ "F20", 0x11c }, |
481 |
{ "Escape", 27 }, |
482 |
|
483 |
{ 0, 0 }, |
484 |
}; |