hw/arm/msf2-soc: Wire up refclk
[qemu.git] / ui / curses_keys.h
blob71e04acdc75689fbf4a5756a10edd77d978e21c8
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:
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
22 * THE SOFTWARE.
25 #ifndef QEMU_CURSES_KEYS_H
26 #define QEMU_CURSES_KEYS_H
28 #include <curses.h>
29 #include "keymaps.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
39 #define ALT_CODE 0x38
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_CHARS 0x100 /* Support latin1 only */
53 #define CURSES_KEYS KEY_MAX /* KEY_MAX defined in <curses.h> */
55 static const int _curses2keysym[CURSES_CHARS] = {
56 [0 ... (CURSES_CHARS - 1)] = -1,
58 [0x7f] = KEY_BACKSPACE,
59 ['\r'] = KEY_ENTER,
60 ['\n'] = KEY_ENTER,
61 [27] = 27,
64 static const int _curseskey2keysym[CURSES_KEYS] = {
65 [0 ... (CURSES_KEYS - 1)] = -1,
67 [KEY_BTAB] = '\t' | KEYSYM_SHIFT,
68 [KEY_SPREVIOUS] = KEY_PPAGE | KEYSYM_SHIFT,
69 [KEY_SNEXT] = KEY_NPAGE | KEYSYM_SHIFT,
72 static const int _curses2keycode[CURSES_CHARS] = {
73 [0 ... (CURSES_CHARS - 1)] = -1,
75 [0x01b] = 1, /* Escape */
76 ['1'] = 2,
77 ['2'] = 3,
78 ['3'] = 4,
79 ['4'] = 5,
80 ['5'] = 6,
81 ['6'] = 7,
82 ['7'] = 8,
83 ['8'] = 9,
84 ['9'] = 10,
85 ['0'] = 11,
86 ['-'] = 12,
87 ['='] = 13,
88 [0x07f] = 14, /* Backspace */
90 ['\t'] = 15, /* Tab */
91 ['q'] = 16,
92 ['w'] = 17,
93 ['e'] = 18,
94 ['r'] = 19,
95 ['t'] = 20,
96 ['y'] = 21,
97 ['u'] = 22,
98 ['i'] = 23,
99 ['o'] = 24,
100 ['p'] = 25,
101 ['['] = 26,
102 [']'] = 27,
103 ['\n'] = 28, /* Return */
104 ['\r'] = 28, /* Return */
106 ['a'] = 30,
107 ['s'] = 31,
108 ['d'] = 32,
109 ['f'] = 33,
110 ['g'] = 34,
111 ['h'] = 35,
112 ['j'] = 36,
113 ['k'] = 37,
114 ['l'] = 38,
115 [';'] = 39,
116 ['\''] = 40, /* Single quote */
117 ['`'] = 41,
118 ['\\'] = 43, /* Backslash */
120 ['z'] = 44,
121 ['x'] = 45,
122 ['c'] = 46,
123 ['v'] = 47,
124 ['b'] = 48,
125 ['n'] = 49,
126 ['m'] = 50,
127 [','] = 51,
128 ['.'] = 52,
129 ['/'] = 53,
131 [' '] = 57,
133 ['!'] = 2 | SHIFT,
134 ['@'] = 3 | SHIFT,
135 ['#'] = 4 | SHIFT,
136 ['$'] = 5 | SHIFT,
137 ['%'] = 6 | SHIFT,
138 ['^'] = 7 | SHIFT,
139 ['&'] = 8 | SHIFT,
140 ['*'] = 9 | SHIFT,
141 ['('] = 10 | SHIFT,
142 [')'] = 11 | SHIFT,
143 ['_'] = 12 | SHIFT,
144 ['+'] = 13 | SHIFT,
146 ['Q'] = 16 | SHIFT,
147 ['W'] = 17 | SHIFT,
148 ['E'] = 18 | SHIFT,
149 ['R'] = 19 | SHIFT,
150 ['T'] = 20 | SHIFT,
151 ['Y'] = 21 | SHIFT,
152 ['U'] = 22 | SHIFT,
153 ['I'] = 23 | SHIFT,
154 ['O'] = 24 | SHIFT,
155 ['P'] = 25 | SHIFT,
156 ['{'] = 26 | SHIFT,
157 ['}'] = 27 | SHIFT,
159 ['A'] = 30 | SHIFT,
160 ['S'] = 31 | SHIFT,
161 ['D'] = 32 | SHIFT,
162 ['F'] = 33 | SHIFT,
163 ['G'] = 34 | SHIFT,
164 ['H'] = 35 | SHIFT,
165 ['J'] = 36 | SHIFT,
166 ['K'] = 37 | SHIFT,
167 ['L'] = 38 | SHIFT,
168 [':'] = 39 | SHIFT,
169 ['"'] = 40 | SHIFT,
170 ['~'] = 41 | SHIFT,
171 ['|'] = 43 | SHIFT,
173 ['Z'] = 44 | SHIFT,
174 ['X'] = 45 | SHIFT,
175 ['C'] = 46 | SHIFT,
176 ['V'] = 47 | SHIFT,
177 ['B'] = 48 | SHIFT,
178 ['N'] = 49 | SHIFT,
179 ['M'] = 50 | SHIFT,
180 ['<'] = 51 | SHIFT,
181 ['>'] = 52 | SHIFT,
182 ['?'] = 53 | SHIFT,
184 ['Q' - '@'] = 16 | CNTRL, /* Control + q */
185 ['W' - '@'] = 17 | CNTRL, /* Control + w */
186 ['E' - '@'] = 18 | CNTRL, /* Control + e */
187 ['R' - '@'] = 19 | CNTRL, /* Control + r */
188 ['T' - '@'] = 20 | CNTRL, /* Control + t */
189 ['Y' - '@'] = 21 | CNTRL, /* Control + y */
190 ['U' - '@'] = 22 | CNTRL, /* Control + u */
191 /* Control + i collides with Tab */
192 ['O' - '@'] = 24 | CNTRL, /* Control + o */
193 ['P' - '@'] = 25 | CNTRL, /* Control + p */
195 ['A' - '@'] = 30 | CNTRL, /* Control + a */
196 ['S' - '@'] = 31 | CNTRL, /* Control + s */
197 ['D' - '@'] = 32 | CNTRL, /* Control + d */
198 ['F' - '@'] = 33 | CNTRL, /* Control + f */
199 ['G' - '@'] = 34 | CNTRL, /* Control + g */
200 ['H' - '@'] = 35 | CNTRL, /* Control + h */
201 /* Control + j collides with Return */
202 ['K' - '@'] = 37 | CNTRL, /* Control + k */
203 ['L' - '@'] = 38 | CNTRL, /* Control + l */
205 ['Z' - '@'] = 44 | CNTRL, /* Control + z */
206 ['X' - '@'] = 45 | CNTRL, /* Control + x */
207 ['C' - '@'] = 46 | CNTRL, /* Control + c */
208 ['V' - '@'] = 47 | CNTRL, /* Control + v */
209 ['B' - '@'] = 48 | CNTRL, /* Control + b */
210 ['N' - '@'] = 49 | CNTRL, /* Control + n */
211 /* Control + m collides with the keycode for Enter */
215 static const int _curseskey2keycode[CURSES_KEYS] = {
216 [0 ... (CURSES_KEYS - 1)] = -1,
218 [KEY_BACKSPACE] = 14, /* Backspace */
220 [KEY_ENTER] = 28, /* Return */
222 [KEY_F(1)] = 59, /* Function Key 1 */
223 [KEY_F(2)] = 60, /* Function Key 2 */
224 [KEY_F(3)] = 61, /* Function Key 3 */
225 [KEY_F(4)] = 62, /* Function Key 4 */
226 [KEY_F(5)] = 63, /* Function Key 5 */
227 [KEY_F(6)] = 64, /* Function Key 6 */
228 [KEY_F(7)] = 65, /* Function Key 7 */
229 [KEY_F(8)] = 66, /* Function Key 8 */
230 [KEY_F(9)] = 67, /* Function Key 9 */
231 [KEY_F(10)] = 68, /* Function Key 10 */
232 [KEY_F(11)] = 87, /* Function Key 11 */
233 [KEY_F(12)] = 88, /* Function Key 12 */
235 [KEY_HOME] = 71 | GREY, /* Home */
236 [KEY_UP] = 72 | GREY, /* Up Arrow */
237 [KEY_PPAGE] = 73 | GREY, /* Page Up */
238 [KEY_LEFT] = 75 | GREY, /* Left Arrow */
239 [KEY_RIGHT] = 77 | GREY, /* Right Arrow */
240 [KEY_END] = 79 | GREY, /* End */
241 [KEY_DOWN] = 80 | GREY, /* Down Arrow */
242 [KEY_NPAGE] = 81 | GREY, /* Page Down */
243 [KEY_IC] = 82 | GREY, /* Insert */
244 [KEY_DC] = 83 | GREY, /* Delete */
246 [KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */
247 [KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */
249 [KEY_BTAB] = 15 | SHIFT, /* Shift + Tab */
251 [KEY_F(13)] = 59 | SHIFT, /* Shift + Function Key 1 */
252 [KEY_F(14)] = 60 | SHIFT, /* Shift + Function Key 2 */
253 [KEY_F(15)] = 61 | SHIFT, /* Shift + Function Key 3 */
254 [KEY_F(16)] = 62 | SHIFT, /* Shift + Function Key 4 */
255 [KEY_F(17)] = 63 | SHIFT, /* Shift + Function Key 5 */
256 [KEY_F(18)] = 64 | SHIFT, /* Shift + Function Key 6 */
257 [KEY_F(19)] = 65 | SHIFT, /* Shift + Function Key 7 */
258 [KEY_F(20)] = 66 | SHIFT, /* Shift + Function Key 8 */
259 [KEY_F(21)] = 67 | SHIFT, /* Shift + Function Key 9 */
260 [KEY_F(22)] = 68 | SHIFT, /* Shift + Function Key 10 */
261 [KEY_F(23)] = 69 | SHIFT, /* Shift + Function Key 11 */
262 [KEY_F(24)] = 70 | SHIFT, /* Shift + Function Key 12 */
265 static const int _curses2qemu[CURSES_CHARS] = {
266 [0 ... (CURSES_CHARS - 1)] = -1,
268 ['\n'] = '\n',
269 ['\r'] = '\n',
271 [0x07f] = QEMU_KEY_BACKSPACE,
274 static const int _curseskey2qemu[CURSES_KEYS] = {
275 [0 ... (CURSES_KEYS - 1)] = -1,
277 [KEY_DOWN] = QEMU_KEY_DOWN,
278 [KEY_UP] = QEMU_KEY_UP,
279 [KEY_LEFT] = QEMU_KEY_LEFT,
280 [KEY_RIGHT] = QEMU_KEY_RIGHT,
281 [KEY_HOME] = QEMU_KEY_HOME,
282 [KEY_BACKSPACE] = QEMU_KEY_BACKSPACE,
284 [KEY_DC] = QEMU_KEY_DELETE,
285 [KEY_NPAGE] = QEMU_KEY_PAGEDOWN,
286 [KEY_PPAGE] = QEMU_KEY_PAGEUP,
287 [KEY_ENTER] = '\n',
288 [KEY_END] = QEMU_KEY_END,
292 static const name2keysym_t name2keysym[] = {
293 /* Plain ASCII */
294 { "space", 0x020 },
295 { "exclam", 0x021 },
296 { "quotedbl", 0x022 },
297 { "numbersign", 0x023 },
298 { "dollar", 0x024 },
299 { "percent", 0x025 },
300 { "ampersand", 0x026 },
301 { "apostrophe", 0x027 },
302 { "parenleft", 0x028 },
303 { "parenright", 0x029 },
304 { "asterisk", 0x02a },
305 { "plus", 0x02b },
306 { "comma", 0x02c },
307 { "minus", 0x02d },
308 { "period", 0x02e },
309 { "slash", 0x02f },
310 { "0", 0x030 },
311 { "1", 0x031 },
312 { "2", 0x032 },
313 { "3", 0x033 },
314 { "4", 0x034 },
315 { "5", 0x035 },
316 { "6", 0x036 },
317 { "7", 0x037 },
318 { "8", 0x038 },
319 { "9", 0x039 },
320 { "colon", 0x03a },
321 { "semicolon", 0x03b },
322 { "less", 0x03c },
323 { "equal", 0x03d },
324 { "greater", 0x03e },
325 { "question", 0x03f },
326 { "at", 0x040 },
327 { "A", 0x041 },
328 { "B", 0x042 },
329 { "C", 0x043 },
330 { "D", 0x044 },
331 { "E", 0x045 },
332 { "F", 0x046 },
333 { "G", 0x047 },
334 { "H", 0x048 },
335 { "I", 0x049 },
336 { "J", 0x04a },
337 { "K", 0x04b },
338 { "L", 0x04c },
339 { "M", 0x04d },
340 { "N", 0x04e },
341 { "O", 0x04f },
342 { "P", 0x050 },
343 { "Q", 0x051 },
344 { "R", 0x052 },
345 { "S", 0x053 },
346 { "T", 0x054 },
347 { "U", 0x055 },
348 { "V", 0x056 },
349 { "W", 0x057 },
350 { "X", 0x058 },
351 { "Y", 0x059 },
352 { "Z", 0x05a },
353 { "bracketleft", 0x05b },
354 { "backslash", 0x05c },
355 { "bracketright", 0x05d },
356 { "asciicircum", 0x05e },
357 { "underscore", 0x05f },
358 { "grave", 0x060 },
359 { "a", 0x061 },
360 { "b", 0x062 },
361 { "c", 0x063 },
362 { "d", 0x064 },
363 { "e", 0x065 },
364 { "f", 0x066 },
365 { "g", 0x067 },
366 { "h", 0x068 },
367 { "i", 0x069 },
368 { "j", 0x06a },
369 { "k", 0x06b },
370 { "l", 0x06c },
371 { "m", 0x06d },
372 { "n", 0x06e },
373 { "o", 0x06f },
374 { "p", 0x070 },
375 { "q", 0x071 },
376 { "r", 0x072 },
377 { "s", 0x073 },
378 { "t", 0x074 },
379 { "u", 0x075 },
380 { "v", 0x076 },
381 { "w", 0x077 },
382 { "x", 0x078 },
383 { "y", 0x079 },
384 { "z", 0x07a },
385 { "braceleft", 0x07b },
386 { "bar", 0x07c },
387 { "braceright", 0x07d },
388 { "asciitilde", 0x07e },
390 /* Latin-1 extensions */
391 { "nobreakspace", 0x0a0 },
392 { "exclamdown", 0x0a1 },
393 { "cent", 0x0a2 },
394 { "sterling", 0x0a3 },
395 { "currency", 0x0a4 },
396 { "yen", 0x0a5 },
397 { "brokenbar", 0x0a6 },
398 { "section", 0x0a7 },
399 { "diaeresis", 0x0a8 },
400 { "copyright", 0x0a9 },
401 { "ordfeminine", 0x0aa },
402 { "guillemotleft", 0x0ab },
403 { "notsign", 0x0ac },
404 { "hyphen", 0x0ad },
405 { "registered", 0x0ae },
406 { "macron", 0x0af },
407 { "degree", 0x0b0 },
408 { "plusminus", 0x0b1 },
409 { "twosuperior", 0x0b2 },
410 { "threesuperior", 0x0b3 },
411 { "acute", 0x0b4 },
412 { "mu", 0x0b5 },
413 { "paragraph", 0x0b6 },
414 { "periodcentered", 0x0b7 },
415 { "cedilla", 0x0b8 },
416 { "onesuperior", 0x0b9 },
417 { "masculine", 0x0ba },
418 { "guillemotright", 0x0bb },
419 { "onequarter", 0x0bc },
420 { "onehalf", 0x0bd },
421 { "threequarters", 0x0be },
422 { "questiondown", 0x0bf },
423 { "Agrave", 0x0c0 },
424 { "Aacute", 0x0c1 },
425 { "Acircumflex", 0x0c2 },
426 { "Atilde", 0x0c3 },
427 { "Adiaeresis", 0x0c4 },
428 { "Aring", 0x0c5 },
429 { "AE", 0x0c6 },
430 { "Ccedilla", 0x0c7 },
431 { "Egrave", 0x0c8 },
432 { "Eacute", 0x0c9 },
433 { "Ecircumflex", 0x0ca },
434 { "Ediaeresis", 0x0cb },
435 { "Igrave", 0x0cc },
436 { "Iacute", 0x0cd },
437 { "Icircumflex", 0x0ce },
438 { "Idiaeresis", 0x0cf },
439 { "ETH", 0x0d0 },
440 { "Eth", 0x0d0 },
441 { "Ntilde", 0x0d1 },
442 { "Ograve", 0x0d2 },
443 { "Oacute", 0x0d3 },
444 { "Ocircumflex", 0x0d4 },
445 { "Otilde", 0x0d5 },
446 { "Odiaeresis", 0x0d6 },
447 { "multiply", 0x0d7 },
448 { "Ooblique", 0x0d8 },
449 { "Oslash", 0x0d8 },
450 { "Ugrave", 0x0d9 },
451 { "Uacute", 0x0da },
452 { "Ucircumflex", 0x0db },
453 { "Udiaeresis", 0x0dc },
454 { "Yacute", 0x0dd },
455 { "THORN", 0x0de },
456 { "Thorn", 0x0de },
457 { "ssharp", 0x0df },
458 { "agrave", 0x0e0 },
459 { "aacute", 0x0e1 },
460 { "acircumflex", 0x0e2 },
461 { "atilde", 0x0e3 },
462 { "adiaeresis", 0x0e4 },
463 { "aring", 0x0e5 },
464 { "ae", 0x0e6 },
465 { "ccedilla", 0x0e7 },
466 { "egrave", 0x0e8 },
467 { "eacute", 0x0e9 },
468 { "ecircumflex", 0x0ea },
469 { "ediaeresis", 0x0eb },
470 { "igrave", 0x0ec },
471 { "iacute", 0x0ed },
472 { "icircumflex", 0x0ee },
473 { "idiaeresis", 0x0ef },
474 { "eth", 0x0f0 },
475 { "ntilde", 0x0f1 },
476 { "ograve", 0x0f2 },
477 { "oacute", 0x0f3 },
478 { "ocircumflex", 0x0f4 },
479 { "otilde", 0x0f5 },
480 { "odiaeresis", 0x0f6 },
481 { "division", 0x0f7 },
482 { "oslash", 0x0f8 },
483 { "ooblique", 0x0f8 },
484 { "ugrave", 0x0f9 },
485 { "uacute", 0x0fa },
486 { "ucircumflex", 0x0fb },
487 { "udiaeresis", 0x0fc },
488 { "yacute", 0x0fd },
489 { "thorn", 0x0fe },
490 { "ydiaeresis", 0x0ff },
492 /* Special keys */
493 { "BackSpace", KEY_BACKSPACE },
494 { "Tab", '\t' },
495 { "Return", KEY_ENTER },
496 { "Right", KEY_RIGHT },
497 { "Left", KEY_LEFT },
498 { "Up", KEY_UP },
499 { "Down", KEY_DOWN },
500 { "Next", KEY_NPAGE },
501 { "Page_Down", KEY_NPAGE },
502 { "Prior", KEY_PPAGE },
503 { "Page_Up", KEY_PPAGE },
504 { "Insert", KEY_IC },
505 { "Delete", KEY_DC },
506 { "Home", KEY_HOME },
507 { "End", KEY_END },
508 { "F1", KEY_F(1) },
509 { "F2", KEY_F(2) },
510 { "F3", KEY_F(3) },
511 { "F4", KEY_F(4) },
512 { "F5", KEY_F(5) },
513 { "F6", KEY_F(6) },
514 { "F7", KEY_F(7) },
515 { "F8", KEY_F(8) },
516 { "F9", KEY_F(9) },
517 { "F10", KEY_F(10) },
518 { "F11", KEY_F(11) },
519 { "F12", KEY_F(12) },
520 { "F13", KEY_F(13) },
521 { "F14", KEY_F(14) },
522 { "F15", KEY_F(15) },
523 { "F16", KEY_F(16) },
524 { "F17", KEY_F(17) },
525 { "F18", KEY_F(18) },
526 { "F19", KEY_F(19) },
527 { "F20", KEY_F(20) },
528 { "F21", KEY_F(21) },
529 { "F22", KEY_F(22) },
530 { "F23", KEY_F(23) },
531 { "F24", KEY_F(24) },
532 { "Escape", 27 },
534 { NULL, 0 },
537 #endif