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
25 #ifndef QEMU_CURSES_KEYS_H
26 #define QEMU_CURSES_KEYS_H 1
32 #define KEY_RELEASE 0x80
34 #define GREY_CODE 0xe0
35 #define GREY SCANCODE_GREY
36 #define SHIFT_CODE 0x2a
37 #define SHIFT SCANCODE_SHIFT
38 #define CNTRL_CODE 0x1d
39 #define CNTRL SCANCODE_CTRL
41 #define ALT SCANCODE_ALT
42 #define ALTGR SCANCODE_ALTGR
44 #define KEYSYM_MASK 0x0ffffff
45 #define KEYSYM_SHIFT (SCANCODE_SHIFT << 16)
46 #define KEYSYM_CNTRL (SCANCODE_CTRL << 16)
47 #define KEYSYM_ALT (SCANCODE_ALT << 16)
48 #define KEYSYM_ALTGR (SCANCODE_ALTGR << 16)
50 /* curses won't detect a Control + Alt + 1, so use Alt + 1 */
51 #define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */
53 #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
55 static const int curses2keysym
[CURSES_KEYS
] = {
56 [0 ... (CURSES_KEYS
- 1)] = -1,
58 [0x7f] = KEY_BACKSPACE
,
62 [KEY_BTAB
] = '\t' | KEYSYM_SHIFT
,
65 static const int curses2keycode
[CURSES_KEYS
] = {
66 [0 ... (CURSES_KEYS
- 1)] = -1,
68 [0x01b] = 1, /* Escape */
81 [0x07f] = 14, /* Backspace */
82 [KEY_BACKSPACE
] = 14, /* Backspace */
84 ['\t'] = 15, /* Tab */
97 ['\n'] = 28, /* Return */
98 ['\r'] = 28, /* Return */
99 [KEY_ENTER
] = 28, /* Return */
111 ['\''] = 40, /* Single quote */
113 ['\\'] = 43, /* Backslash */
128 [KEY_F(1)] = 59, /* Function Key 1 */
129 [KEY_F(2)] = 60, /* Function Key 2 */
130 [KEY_F(3)] = 61, /* Function Key 3 */
131 [KEY_F(4)] = 62, /* Function Key 4 */
132 [KEY_F(5)] = 63, /* Function Key 5 */
133 [KEY_F(6)] = 64, /* Function Key 6 */
134 [KEY_F(7)] = 65, /* Function Key 7 */
135 [KEY_F(8)] = 66, /* Function Key 8 */
136 [KEY_F(9)] = 67, /* Function Key 9 */
137 [KEY_F(10)] = 68, /* Function Key 10 */
138 [KEY_F(11)] = 87, /* Function Key 11 */
139 [KEY_F(12)] = 88, /* Function Key 12 */
141 [KEY_HOME
] = 71 | GREY
, /* Home */
142 [KEY_UP
] = 72 | GREY
, /* Up Arrow */
143 [KEY_PPAGE
] = 73 | GREY
, /* Page Up */
144 [KEY_LEFT
] = 75 | GREY
, /* Left Arrow */
145 [KEY_RIGHT
] = 77 | GREY
, /* Right Arrow */
146 [KEY_END
] = 79 | GREY
, /* End */
147 [KEY_DOWN
] = 80 | GREY
, /* Down Arrow */
148 [KEY_NPAGE
] = 81 | GREY
, /* Page Down */
149 [KEY_IC
] = 82 | GREY
, /* Insert */
150 [KEY_DC
] = 83 | GREY
, /* Delete */
165 [KEY_BTAB
] = 15 | SHIFT
, /* Shift + Tab */
204 [KEY_F(13)] = 59 | SHIFT
, /* Shift + Function Key 1 */
205 [KEY_F(14)] = 60 | SHIFT
, /* Shift + Function Key 2 */
206 [KEY_F(15)] = 61 | SHIFT
, /* Shift + Function Key 3 */
207 [KEY_F(16)] = 62 | SHIFT
, /* Shift + Function Key 4 */
208 [KEY_F(17)] = 63 | SHIFT
, /* Shift + Function Key 5 */
209 [KEY_F(18)] = 64 | SHIFT
, /* Shift + Function Key 6 */
210 [KEY_F(19)] = 65 | SHIFT
, /* Shift + Function Key 7 */
211 [KEY_F(20)] = 66 | SHIFT
, /* Shift + Function Key 8 */
212 [KEY_F(21)] = 67 | SHIFT
, /* Shift + Function Key 9 */
213 [KEY_F(22)] = 68 | SHIFT
, /* Shift + Function Key 10 */
214 [KEY_F(23)] = 69 | SHIFT
, /* Shift + Function Key 11 */
215 [KEY_F(24)] = 70 | SHIFT
, /* Shift + Function Key 12 */
217 ['Q' - '@'] = 16 | CNTRL
, /* Control + q */
218 ['W' - '@'] = 17 | CNTRL
, /* Control + w */
219 ['E' - '@'] = 18 | CNTRL
, /* Control + e */
220 ['R' - '@'] = 19 | CNTRL
, /* Control + r */
221 ['T' - '@'] = 20 | CNTRL
, /* Control + t */
222 ['Y' - '@'] = 21 | CNTRL
, /* Control + y */
223 ['U' - '@'] = 22 | CNTRL
, /* Control + u */
224 /* Control + i collides with Tab */
225 ['O' - '@'] = 24 | CNTRL
, /* Control + o */
226 ['P' - '@'] = 25 | CNTRL
, /* Control + p */
228 ['A' - '@'] = 30 | CNTRL
, /* Control + a */
229 ['S' - '@'] = 31 | CNTRL
, /* Control + s */
230 ['D' - '@'] = 32 | CNTRL
, /* Control + d */
231 ['F' - '@'] = 33 | CNTRL
, /* Control + f */
232 ['G' - '@'] = 34 | CNTRL
, /* Control + g */
233 ['H' - '@'] = 35 | CNTRL
, /* Control + h */
234 /* Control + j collides with Return */
235 ['K' - '@'] = 37 | CNTRL
, /* Control + k */
236 ['L' - '@'] = 38 | CNTRL
, /* Control + l */
238 ['Z' - '@'] = 44 | CNTRL
, /* Control + z */
239 ['X' - '@'] = 45 | CNTRL
, /* Control + x */
240 ['C' - '@'] = 46 | CNTRL
, /* Control + c */
241 ['V' - '@'] = 47 | CNTRL
, /* Control + v */
242 ['B' - '@'] = 48 | CNTRL
, /* Control + b */
243 ['N' - '@'] = 49 | CNTRL
, /* Control + n */
244 /* Control + m collides with the keycode for Enter */
248 static const int curses2qemu
[CURSES_KEYS
] = {
249 [0 ... (CURSES_KEYS
- 1)] = -1,
254 [0x07f] = QEMU_KEY_BACKSPACE
,
256 [KEY_DOWN
] = QEMU_KEY_DOWN
,
257 [KEY_UP
] = QEMU_KEY_UP
,
258 [KEY_LEFT
] = QEMU_KEY_LEFT
,
259 [KEY_RIGHT
] = QEMU_KEY_RIGHT
,
260 [KEY_HOME
] = QEMU_KEY_HOME
,
261 [KEY_BACKSPACE
] = QEMU_KEY_BACKSPACE
,
263 [KEY_DC
] = QEMU_KEY_DELETE
,
264 [KEY_NPAGE
] = QEMU_KEY_PAGEDOWN
,
265 [KEY_PPAGE
] = QEMU_KEY_PAGEUP
,
267 [KEY_END
] = QEMU_KEY_END
,
271 static const name2keysym_t name2keysym
[] = {
275 { "quotedbl", 0x022 },
276 { "numbersign", 0x023 },
278 { "percent", 0x025 },
279 { "ampersand", 0x026 },
280 { "apostrophe", 0x027 },
281 { "parenleft", 0x028 },
282 { "parenright", 0x029 },
283 { "asterisk", 0x02a },
300 { "semicolon", 0x03b },
303 { "greater", 0x03e },
304 { "question", 0x03f },
332 { "bracketleft", 0x05b },
333 { "backslash", 0x05c },
334 { "bracketright", 0x05d },
335 { "asciicircum", 0x05e },
336 { "underscore", 0x05f },
364 { "braceleft", 0x07b },
366 { "braceright", 0x07d },
367 { "asciitilde", 0x07e },
369 /* Latin-1 extensions */
370 { "nobreakspace", 0x0a0 },
371 { "exclamdown", 0x0a1 },
373 { "sterling", 0x0a3 },
374 { "currency", 0x0a4 },
376 { "brokenbar", 0x0a6 },
377 { "section", 0x0a7 },
378 { "diaeresis", 0x0a8 },
379 { "copyright", 0x0a9 },
380 { "ordfeminine", 0x0aa },
381 { "guillemotleft", 0x0ab },
382 { "notsign", 0x0ac },
384 { "registered", 0x0ae },
387 { "plusminus", 0x0b1 },
388 { "twosuperior", 0x0b2 },
389 { "threesuperior", 0x0b3 },
392 { "paragraph", 0x0b6 },
393 { "periodcentered", 0x0b7 },
394 { "cedilla", 0x0b8 },
395 { "onesuperior", 0x0b9 },
396 { "masculine", 0x0ba },
397 { "guillemotright", 0x0bb },
398 { "onequarter", 0x0bc },
399 { "onehalf", 0x0bd },
400 { "threequarters", 0x0be },
401 { "questiondown", 0x0bf },
404 { "Acircumflex", 0x0c2 },
406 { "Adiaeresis", 0x0c4 },
409 { "Ccedilla", 0x0c7 },
412 { "Ecircumflex", 0x0ca },
413 { "Ediaeresis", 0x0cb },
416 { "Icircumflex", 0x0ce },
417 { "Idiaeresis", 0x0cf },
423 { "Ocircumflex", 0x0d4 },
425 { "Odiaeresis", 0x0d6 },
426 { "multiply", 0x0d7 },
427 { "Ooblique", 0x0d8 },
431 { "Ucircumflex", 0x0db },
432 { "Udiaeresis", 0x0dc },
439 { "acircumflex", 0x0e2 },
441 { "adiaeresis", 0x0e4 },
444 { "ccedilla", 0x0e7 },
447 { "ecircumflex", 0x0ea },
448 { "ediaeresis", 0x0eb },
451 { "icircumflex", 0x0ee },
452 { "idiaeresis", 0x0ef },
457 { "ocircumflex", 0x0f4 },
459 { "odiaeresis", 0x0f6 },
460 { "division", 0x0f7 },
462 { "ooblique", 0x0f8 },
465 { "ucircumflex", 0x0fb },
466 { "udiaeresis", 0x0fc },
469 { "ydiaeresis", 0x0ff },
472 { "BackSpace", KEY_BACKSPACE
},
474 { "Return", KEY_ENTER
},
475 { "Right", KEY_RIGHT
},
476 { "Left", KEY_LEFT
},
478 { "Down", KEY_DOWN
},
479 { "Page_Down", KEY_NPAGE
},
480 { "Page_Up", KEY_PPAGE
},
481 { "Insert", KEY_IC
},
482 { "Delete", KEY_DC
},
483 { "Home", KEY_HOME
},
494 { "F10", KEY_F(10) },
495 { "F11", KEY_F(11) },
496 { "F12", KEY_F(12) },
497 { "F13", KEY_F(13) },
498 { "F14", KEY_F(14) },
499 { "F15", KEY_F(15) },
500 { "F16", KEY_F(16) },
501 { "F17", KEY_F(17) },
502 { "F18", KEY_F(18) },
503 { "F19", KEY_F(19) },
504 { "F20", KEY_F(20) },
505 { "F21", KEY_F(21) },
506 { "F22", KEY_F(22) },
507 { "F23", KEY_F(23) },
508 { "F24", KEY_F(24) },