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