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
28 #define KEY_RELEASE 0x80
30 #define SHIFT_CODE 0x2a
32 #define GREY_CODE 0xe0
34 #define CNTRL_CODE 0x1d
39 /* curses won't detect a Control + Alt + 1, so use Alt + 1 */
40 #define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */
42 #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
44 static const int curses2keycode
[CURSES_KEYS
] = {
45 [0 ... (CURSES_KEYS
- 1)] = -1,
47 [0x01b] = 1, /* Escape */
60 [0x07f] = 14, /* Backspace */
61 [0x107] = 14, /* Backspace */
63 ['\t'] = 15, /* Tab */
76 ['\n'] = 28, /* Return */
77 ['\r'] = 28, /* Return */
78 [0x157] = 28, /* Return */
90 ['\''] = 40, /* Single quote */
92 ['\\'] = 43, /* Backslash */
107 [0x109] = 59, /* Function Key 1 */
108 [0x10a] = 60, /* Function Key 2 */
109 [0x10b] = 61, /* Function Key 3 */
110 [0x10c] = 62, /* Function Key 4 */
111 [0x10d] = 63, /* Function Key 5 */
112 [0x10e] = 64, /* Function Key 6 */
113 [0x10f] = 65, /* Function Key 7 */
114 [0x110] = 66, /* Function Key 8 */
115 [0x111] = 67, /* Function Key 9 */
116 [0x112] = 68, /* Function Key 10 */
117 [0x113] = 87, /* Function Key 11 */
118 [0x114] = 88, /* Function Key 12 */
120 [0x106] = 71 | GREY
, /* Home */
121 [0x103] = 72 | GREY
, /* Up Arrow */
122 [0x153] = 73 | GREY
, /* Page Up */
123 [0x104] = 75 | GREY
, /* Left Arrow */
124 [0x105] = 77 | GREY
, /* Right Arrow */
125 [0x168] = 79 | GREY
, /* End */
126 [0x102] = 80 | GREY
, /* Down Arrow */
127 [0x152] = 81 | GREY
, /* Page Down */
128 [0x14b] = 82 | GREY
, /* Insert */
129 [0x14a] = 83 | GREY
, /* Delete */
144 [0x161] = 15 | SHIFT
, /* Shift + Tab */
183 [0x115] = 59 | SHIFT
, /* Shift + Function Key 1 */
184 [0x116] = 60 | SHIFT
, /* Shift + Function Key 2 */
185 [0x117] = 61 | SHIFT
, /* Shift + Function Key 3 */
186 [0x118] = 62 | SHIFT
, /* Shift + Function Key 4 */
187 [0x119] = 63 | SHIFT
, /* Shift + Function Key 5 */
188 [0x11a] = 64 | SHIFT
, /* Shift + Function Key 6 */
189 [0x11b] = 65 | SHIFT
, /* Shift + Function Key 7 */
190 [0x11c] = 66 | SHIFT
, /* Shift + Function Key 8 */
192 [0x011] = 16 | CNTRL
, /* Control + q */
193 [0x017] = 17 | CNTRL
, /* Control + w */
194 [0x005] = 18 | CNTRL
, /* Control + e */
195 [0x012] = 19 | CNTRL
, /* Control + r */
196 [0x014] = 20 | CNTRL
, /* Control + t */
197 [0x019] = 21 | CNTRL
, /* Control + y */
198 [0x015] = 22 | CNTRL
, /* Control + u */
199 /* Control + i collides with Tab */
200 [0x00f] = 24 | CNTRL
, /* Control + o */
201 [0x010] = 25 | CNTRL
, /* Control + p */
203 [0x001] = 30 | CNTRL
, /* Control + a */
204 [0x013] = 31 | CNTRL
, /* Control + s */
205 [0x004] = 32 | CNTRL
, /* Control + d */
206 [0x006] = 33 | CNTRL
, /* Control + f */
207 [0x007] = 34 | CNTRL
, /* Control + g */
208 [0x008] = 35 | CNTRL
, /* Control + h */
209 [0x00a] = 36 | CNTRL
, /* Control + j */
210 [0x00b] = 37 | CNTRL
, /* Control + k */
211 [0x00c] = 38 | CNTRL
, /* Control + l */
213 [0x01a] = 44 | CNTRL
, /* Control + z */
214 [0x018] = 45 | CNTRL
, /* Control + x */
215 [0x003] = 46 | CNTRL
, /* Control + c */
216 [0x016] = 47 | CNTRL
, /* Control + v */
217 [0x002] = 48 | CNTRL
, /* Control + b */
218 [0x00e] = 49 | CNTRL
, /* Control + n */
219 /* Control + m collides with the keycode for Enter */
223 static const int curses2keysym
[CURSES_KEYS
] = {
224 [0 ... (CURSES_KEYS
- 1)] = -1,
229 [0x07f] = QEMU_KEY_BACKSPACE
,
231 [0x102] = QEMU_KEY_DOWN
,
232 [0x103] = QEMU_KEY_UP
,
233 [0x104] = QEMU_KEY_LEFT
,
234 [0x105] = QEMU_KEY_RIGHT
,
235 [0x106] = QEMU_KEY_HOME
,
236 [0x107] = QEMU_KEY_BACKSPACE
,
238 [0x14a] = QEMU_KEY_DELETE
,
239 [0x152] = QEMU_KEY_PAGEDOWN
,
240 [0x153] = QEMU_KEY_PAGEUP
,
242 [0x168] = QEMU_KEY_END
,
246 static const name2keysym_t name2keysym
[] = {
250 { "quotedbl", 0x022 },
251 { "numbersign", 0x023 },
253 { "percent", 0x025 },
254 { "ampersand", 0x026 },
255 { "apostrophe", 0x027 },
256 { "parenleft", 0x028 },
257 { "parenright", 0x029 },
258 { "asterisk", 0x02a },
275 { "semicolon", 0x03b },
278 { "greater", 0x03e },
279 { "question", 0x03f },
307 { "bracketleft", 0x05b },
308 { "backslash", 0x05c },
309 { "bracketright", 0x05d },
310 { "asciicircum", 0x05e },
311 { "underscore", 0x05f },
339 { "braceleft", 0x07b },
341 { "braceright", 0x07d },
342 { "asciitilde", 0x07e },
344 /* Latin-1 extensions */
345 { "nobreakspace", 0x0a0 },
346 { "exclamdown", 0x0a1 },
348 { "sterling", 0x0a3 },
349 { "currency", 0x0a4 },
351 { "brokenbar", 0x0a6 },
352 { "section", 0x0a7 },
353 { "diaeresis", 0x0a8 },
354 { "copyright", 0x0a9 },
355 { "ordfeminine", 0x0aa },
356 { "guillemotleft", 0x0ab },
357 { "notsign", 0x0ac },
359 { "registered", 0x0ae },
362 { "plusminus", 0x0b1 },
363 { "twosuperior", 0x0b2 },
364 { "threesuperior", 0x0b3 },
367 { "paragraph", 0x0b6 },
368 { "periodcentered", 0x0b7 },
369 { "cedilla", 0x0b8 },
370 { "onesuperior", 0x0b9 },
371 { "masculine", 0x0ba },
372 { "guillemotright", 0x0bb },
373 { "onequarter", 0x0bc },
374 { "onehalf", 0x0bd },
375 { "threequarters", 0x0be },
376 { "questiondown", 0x0bf },
379 { "Acircumflex", 0x0c2 },
381 { "Adiaeresis", 0x0c4 },
384 { "Ccedilla", 0x0c7 },
387 { "Ecircumflex", 0x0ca },
388 { "Ediaeresis", 0x0cb },
391 { "Icircumflex", 0x0ce },
392 { "Idiaeresis", 0x0cf },
398 { "Ocircumflex", 0x0d4 },
400 { "Odiaeresis", 0x0d6 },
401 { "multiply", 0x0d7 },
402 { "Ooblique", 0x0d8 },
406 { "Ucircumflex", 0x0db },
407 { "Udiaeresis", 0x0dc },
414 { "acircumflex", 0x0e2 },
416 { "adiaeresis", 0x0e4 },
419 { "ccedilla", 0x0e7 },
422 { "ecircumflex", 0x0ea },
423 { "ediaeresis", 0x0eb },
426 { "icircumflex", 0x0ee },
427 { "idiaeresis", 0x0ef },
432 { "ocircumflex", 0x0f4 },
434 { "odiaeresis", 0x0f6 },
435 { "division", 0x0f7 },
437 { "ooblique", 0x0f8 },
440 { "ucircumflex", 0x0fb },
441 { "udiaeresis", 0x0fc },
444 { "ydiaeresis", 0x0ff },
447 { "BackSpace", 0x07f },
454 { "Page_Down", 0x152 },
455 { "Page_Up", 0x153 },