2 * Keycode and keysyms conversion tables for curses
4 * Copyright (c) 2005 Andrzej Zaborowski <balrog@zabor.org>
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
24 #define KEY_RELEASE 0x80
26 #define SHIFT_CODE 0x2a
28 #define GREY_CODE 0xe0
30 #define CNTRL_CODE 0x1d
35 /* curses won't detect a Control + Alt + 1, so use Alt + 1 */
36 #define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */
38 #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
40 static int curses2keycode
[CURSES_KEYS
] = {
41 [0 ... (CURSES_KEYS
- 1)] = -1,
43 [0x01b] = 1, /* Escape */
56 [0x07f] = 14, /* Backspace */
57 [0x107] = 14, /* Backspace */
59 ['\t'] = 15, /* Tab */
72 ['\n'] = 28, /* Return */
73 ['\r'] = 28, /* Return */
74 [0x157] = 28, /* Return */
86 ['\''] = 40, /* Single quote */
88 ['\\'] = 43, /* Backslash */
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 */
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 */
140 [0x161] = 15 | SHIFT
, /* Shift + Tab */
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 */
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 */
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 */
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 */
219 static int curses2keysym
[CURSES_KEYS
] = {
220 [0 ... (CURSES_KEYS
- 1)] = -1,
225 [0x07f] = QEMU_KEY_BACKSPACE
,
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
,
234 [0x14a] = QEMU_KEY_DELETE
,
235 [0x152] = QEMU_KEY_PAGEDOWN
,
236 [0x153] = QEMU_KEY_PAGEUP
,
238 [0x168] = QEMU_KEY_END
,
247 static name2keysym_t name2keysym
[] = {
251 { "quotedbl", 0x022 },
252 { "numbersign", 0x023 },
254 { "percent", 0x025 },
255 { "ampersand", 0x026 },
256 { "apostrophe", 0x027 },
257 { "parenleft", 0x028 },
258 { "parenright", 0x029 },
259 { "asterisk", 0x02a },
276 { "semicolon", 0x03b },
279 { "greater", 0x03e },
280 { "question", 0x03f },
308 { "bracketleft", 0x05b },
309 { "backslash", 0x05c },
310 { "bracketright", 0x05d },
311 { "asciicircum", 0x05e },
312 { "underscore", 0x05f },
340 { "braceleft", 0x07b },
342 { "braceright", 0x07d },
343 { "asciitilde", 0x07e },
345 /* Latin-1 extensions */
346 { "nobreakspace", 0x0a0 },
347 { "exclamdown", 0x0a1 },
349 { "sterling", 0x0a3 },
350 { "currency", 0x0a4 },
352 { "brokenbar", 0x0a6 },
353 { "section", 0x0a7 },
354 { "diaeresis", 0x0a8 },
355 { "copyright", 0x0a9 },
356 { "ordfeminine", 0x0aa },
357 { "guillemotleft", 0x0ab },
358 { "notsign", 0x0ac },
360 { "registered", 0x0ae },
363 { "plusminus", 0x0b1 },
364 { "twosuperior", 0x0b2 },
365 { "threesuperior", 0x0b3 },
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 },
380 { "Acircumflex", 0x0c2 },
382 { "Adiaeresis", 0x0c4 },
385 { "Ccedilla", 0x0c7 },
388 { "Ecircumflex", 0x0ca },
389 { "Ediaeresis", 0x0cb },
392 { "Icircumflex", 0x0ce },
393 { "Idiaeresis", 0x0cf },
399 { "Ocircumflex", 0x0d4 },
401 { "Odiaeresis", 0x0d6 },
402 { "multiply", 0x0d7 },
403 { "Ooblique", 0x0d8 },
407 { "Ucircumflex", 0x0db },
408 { "Udiaeresis", 0x0dc },
415 { "acircumflex", 0x0e2 },
417 { "adiaeresis", 0x0e4 },
420 { "ccedilla", 0x0e7 },
423 { "ecircumflex", 0x0ea },
424 { "ediaeresis", 0x0eb },
427 { "icircumflex", 0x0ee },
428 { "idiaeresis", 0x0ef },
433 { "ocircumflex", 0x0f4 },
435 { "odiaeresis", 0x0f6 },
436 { "division", 0x0f7 },
438 { "ooblique", 0x0f8 },
441 { "ucircumflex", 0x0fb },
442 { "udiaeresis", 0x0fc },
445 { "ydiaeresis", 0x0ff },
448 { "BackSpace", 0x07f },
455 { "Page_Down", 0x152 },
456 { "Page_Up", 0x153 },