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
32 #define KEY_MASK SCANCODE_KEYMASK
33 #define GREY_CODE 0xe0
34 #define GREY SCANCODE_GREY
35 #define SHIFT_CODE 0x2a
36 #define SHIFT SCANCODE_SHIFT
37 #define CNTRL_CODE 0x1d
38 #define CNTRL SCANCODE_CTRL
40 #define ALT SCANCODE_ALT
41 #define ALTGR SCANCODE_ALTGR
43 #define KEYSYM_MASK 0x0ffffff
44 #define KEYSYM_SHIFT (SCANCODE_SHIFT << 16)
45 #define KEYSYM_CNTRL (SCANCODE_CTRL << 16)
46 #define KEYSYM_ALT (SCANCODE_ALT << 16)
47 #define KEYSYM_ALTGR (SCANCODE_ALTGR << 16)
49 /* curses won't detect a Control + Alt + 1, so use Alt + 1 */
50 #define QEMU_KEY_CONSOLE0 (2 | ALT) /* (curses2keycode['1'] | ALT) */
52 #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
54 static const int curses2keysym
[CURSES_KEYS
] = {
55 [0 ... (CURSES_KEYS
- 1)] = -1,
57 [0x7f] = KEY_BACKSPACE
,
61 [KEY_BTAB
] = '\t' | KEYSYM_SHIFT
,
62 [KEY_SPREVIOUS
] = KEY_PPAGE
| KEYSYM_SHIFT
,
63 [KEY_SNEXT
] = KEY_NPAGE
| KEYSYM_SHIFT
,
66 static const int curses2keycode
[CURSES_KEYS
] = {
67 [0 ... (CURSES_KEYS
- 1)] = -1,
69 [0x01b] = 1, /* Escape */
82 [0x07f] = 14, /* Backspace */
83 [KEY_BACKSPACE
] = 14, /* Backspace */
85 ['\t'] = 15, /* Tab */
98 ['\n'] = 28, /* Return */
99 ['\r'] = 28, /* Return */
100 [KEY_ENTER
] = 28, /* Return */
112 ['\''] = 40, /* Single quote */
114 ['\\'] = 43, /* Backslash */
129 [KEY_F(1)] = 59, /* Function Key 1 */
130 [KEY_F(2)] = 60, /* Function Key 2 */
131 [KEY_F(3)] = 61, /* Function Key 3 */
132 [KEY_F(4)] = 62, /* Function Key 4 */
133 [KEY_F(5)] = 63, /* Function Key 5 */
134 [KEY_F(6)] = 64, /* Function Key 6 */
135 [KEY_F(7)] = 65, /* Function Key 7 */
136 [KEY_F(8)] = 66, /* Function Key 8 */
137 [KEY_F(9)] = 67, /* Function Key 9 */
138 [KEY_F(10)] = 68, /* Function Key 10 */
139 [KEY_F(11)] = 87, /* Function Key 11 */
140 [KEY_F(12)] = 88, /* Function Key 12 */
142 [KEY_HOME
] = 71 | GREY
, /* Home */
143 [KEY_UP
] = 72 | GREY
, /* Up Arrow */
144 [KEY_PPAGE
] = 73 | GREY
, /* Page Up */
145 [KEY_LEFT
] = 75 | GREY
, /* Left Arrow */
146 [KEY_RIGHT
] = 77 | GREY
, /* Right Arrow */
147 [KEY_END
] = 79 | GREY
, /* End */
148 [KEY_DOWN
] = 80 | GREY
, /* Down Arrow */
149 [KEY_NPAGE
] = 81 | GREY
, /* Page Down */
150 [KEY_IC
] = 82 | GREY
, /* Insert */
151 [KEY_DC
] = 83 | GREY
, /* Delete */
153 [KEY_SPREVIOUS
] = 73 | GREY
| SHIFT
, /* Shift + Page Up */
154 [KEY_SNEXT
] = 81 | GREY
| SHIFT
, /* Shift + Page Down */
169 [KEY_BTAB
] = 15 | SHIFT
, /* Shift + Tab */
208 [KEY_F(13)] = 59 | SHIFT
, /* Shift + Function Key 1 */
209 [KEY_F(14)] = 60 | SHIFT
, /* Shift + Function Key 2 */
210 [KEY_F(15)] = 61 | SHIFT
, /* Shift + Function Key 3 */
211 [KEY_F(16)] = 62 | SHIFT
, /* Shift + Function Key 4 */
212 [KEY_F(17)] = 63 | SHIFT
, /* Shift + Function Key 5 */
213 [KEY_F(18)] = 64 | SHIFT
, /* Shift + Function Key 6 */
214 [KEY_F(19)] = 65 | SHIFT
, /* Shift + Function Key 7 */
215 [KEY_F(20)] = 66 | SHIFT
, /* Shift + Function Key 8 */
216 [KEY_F(21)] = 67 | SHIFT
, /* Shift + Function Key 9 */
217 [KEY_F(22)] = 68 | SHIFT
, /* Shift + Function Key 10 */
218 [KEY_F(23)] = 69 | SHIFT
, /* Shift + Function Key 11 */
219 [KEY_F(24)] = 70 | SHIFT
, /* Shift + Function Key 12 */
221 ['Q' - '@'] = 16 | CNTRL
, /* Control + q */
222 ['W' - '@'] = 17 | CNTRL
, /* Control + w */
223 ['E' - '@'] = 18 | CNTRL
, /* Control + e */
224 ['R' - '@'] = 19 | CNTRL
, /* Control + r */
225 ['T' - '@'] = 20 | CNTRL
, /* Control + t */
226 ['Y' - '@'] = 21 | CNTRL
, /* Control + y */
227 ['U' - '@'] = 22 | CNTRL
, /* Control + u */
228 /* Control + i collides with Tab */
229 ['O' - '@'] = 24 | CNTRL
, /* Control + o */
230 ['P' - '@'] = 25 | CNTRL
, /* Control + p */
232 ['A' - '@'] = 30 | CNTRL
, /* Control + a */
233 ['S' - '@'] = 31 | CNTRL
, /* Control + s */
234 ['D' - '@'] = 32 | CNTRL
, /* Control + d */
235 ['F' - '@'] = 33 | CNTRL
, /* Control + f */
236 ['G' - '@'] = 34 | CNTRL
, /* Control + g */
237 ['H' - '@'] = 35 | CNTRL
, /* Control + h */
238 /* Control + j collides with Return */
239 ['K' - '@'] = 37 | CNTRL
, /* Control + k */
240 ['L' - '@'] = 38 | CNTRL
, /* Control + l */
242 ['Z' - '@'] = 44 | CNTRL
, /* Control + z */
243 ['X' - '@'] = 45 | CNTRL
, /* Control + x */
244 ['C' - '@'] = 46 | CNTRL
, /* Control + c */
245 ['V' - '@'] = 47 | CNTRL
, /* Control + v */
246 ['B' - '@'] = 48 | CNTRL
, /* Control + b */
247 ['N' - '@'] = 49 | CNTRL
, /* Control + n */
248 /* Control + m collides with the keycode for Enter */
252 static const int curses2qemu
[CURSES_KEYS
] = {
253 [0 ... (CURSES_KEYS
- 1)] = -1,
258 [0x07f] = QEMU_KEY_BACKSPACE
,
260 [KEY_DOWN
] = QEMU_KEY_DOWN
,
261 [KEY_UP
] = QEMU_KEY_UP
,
262 [KEY_LEFT
] = QEMU_KEY_LEFT
,
263 [KEY_RIGHT
] = QEMU_KEY_RIGHT
,
264 [KEY_HOME
] = QEMU_KEY_HOME
,
265 [KEY_BACKSPACE
] = QEMU_KEY_BACKSPACE
,
267 [KEY_DC
] = QEMU_KEY_DELETE
,
268 [KEY_NPAGE
] = QEMU_KEY_PAGEDOWN
,
269 [KEY_PPAGE
] = QEMU_KEY_PAGEUP
,
271 [KEY_END
] = QEMU_KEY_END
,
275 static const name2keysym_t name2keysym
[] = {
279 { "quotedbl", 0x022 },
280 { "numbersign", 0x023 },
282 { "percent", 0x025 },
283 { "ampersand", 0x026 },
284 { "apostrophe", 0x027 },
285 { "parenleft", 0x028 },
286 { "parenright", 0x029 },
287 { "asterisk", 0x02a },
304 { "semicolon", 0x03b },
307 { "greater", 0x03e },
308 { "question", 0x03f },
336 { "bracketleft", 0x05b },
337 { "backslash", 0x05c },
338 { "bracketright", 0x05d },
339 { "asciicircum", 0x05e },
340 { "underscore", 0x05f },
368 { "braceleft", 0x07b },
370 { "braceright", 0x07d },
371 { "asciitilde", 0x07e },
373 /* Latin-1 extensions */
374 { "nobreakspace", 0x0a0 },
375 { "exclamdown", 0x0a1 },
377 { "sterling", 0x0a3 },
378 { "currency", 0x0a4 },
380 { "brokenbar", 0x0a6 },
381 { "section", 0x0a7 },
382 { "diaeresis", 0x0a8 },
383 { "copyright", 0x0a9 },
384 { "ordfeminine", 0x0aa },
385 { "guillemotleft", 0x0ab },
386 { "notsign", 0x0ac },
388 { "registered", 0x0ae },
391 { "plusminus", 0x0b1 },
392 { "twosuperior", 0x0b2 },
393 { "threesuperior", 0x0b3 },
396 { "paragraph", 0x0b6 },
397 { "periodcentered", 0x0b7 },
398 { "cedilla", 0x0b8 },
399 { "onesuperior", 0x0b9 },
400 { "masculine", 0x0ba },
401 { "guillemotright", 0x0bb },
402 { "onequarter", 0x0bc },
403 { "onehalf", 0x0bd },
404 { "threequarters", 0x0be },
405 { "questiondown", 0x0bf },
408 { "Acircumflex", 0x0c2 },
410 { "Adiaeresis", 0x0c4 },
413 { "Ccedilla", 0x0c7 },
416 { "Ecircumflex", 0x0ca },
417 { "Ediaeresis", 0x0cb },
420 { "Icircumflex", 0x0ce },
421 { "Idiaeresis", 0x0cf },
427 { "Ocircumflex", 0x0d4 },
429 { "Odiaeresis", 0x0d6 },
430 { "multiply", 0x0d7 },
431 { "Ooblique", 0x0d8 },
435 { "Ucircumflex", 0x0db },
436 { "Udiaeresis", 0x0dc },
443 { "acircumflex", 0x0e2 },
445 { "adiaeresis", 0x0e4 },
448 { "ccedilla", 0x0e7 },
451 { "ecircumflex", 0x0ea },
452 { "ediaeresis", 0x0eb },
455 { "icircumflex", 0x0ee },
456 { "idiaeresis", 0x0ef },
461 { "ocircumflex", 0x0f4 },
463 { "odiaeresis", 0x0f6 },
464 { "division", 0x0f7 },
466 { "ooblique", 0x0f8 },
469 { "ucircumflex", 0x0fb },
470 { "udiaeresis", 0x0fc },
473 { "ydiaeresis", 0x0ff },
476 { "BackSpace", KEY_BACKSPACE
},
478 { "Return", KEY_ENTER
},
479 { "Right", KEY_RIGHT
},
480 { "Left", KEY_LEFT
},
482 { "Down", KEY_DOWN
},
483 { "Next", KEY_NPAGE
},
484 { "Page_Down", KEY_NPAGE
},
485 { "Prior", KEY_PPAGE
},
486 { "Page_Up", KEY_PPAGE
},
487 { "Insert", KEY_IC
},
488 { "Delete", KEY_DC
},
489 { "Home", KEY_HOME
},
500 { "F10", KEY_F(10) },
501 { "F11", KEY_F(11) },
502 { "F12", KEY_F(12) },
503 { "F13", KEY_F(13) },
504 { "F14", KEY_F(14) },
505 { "F15", KEY_F(15) },
506 { "F16", KEY_F(16) },
507 { "F17", KEY_F(17) },
508 { "F18", KEY_F(18) },
509 { "F19", KEY_F(19) },
510 { "F20", KEY_F(20) },
511 { "F21", KEY_F(21) },
512 { "F22", KEY_F(22) },
513 { "F23", KEY_F(23) },
514 { "F24", KEY_F(24) },