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