gtk: add translation support (v5)
[qemu/cris-port.git] / ui / curses_keys.h
blob18ce6dceeed598971bb980d4b9fe0ec004961629
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 1
28 #include <curses.h>
29 #include "keymaps.h"
32 #define KEY_RELEASE 0x80
33 #define KEY_MASK 0x7f
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
40 #define ALT_CODE 0x38
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,
59 ['\r'] = KEY_ENTER,
60 ['\n'] = KEY_ENTER,
61 [27] = 27,
62 [KEY_BTAB] = '\t' | KEYSYM_SHIFT,
65 static const int curses2keycode[CURSES_KEYS] = {
66 [0 ... (CURSES_KEYS - 1)] = -1,
68 [0x01b] = 1, /* Escape */
69 ['1'] = 2,
70 ['2'] = 3,
71 ['3'] = 4,
72 ['4'] = 5,
73 ['5'] = 6,
74 ['6'] = 7,
75 ['7'] = 8,
76 ['8'] = 9,
77 ['9'] = 10,
78 ['0'] = 11,
79 ['-'] = 12,
80 ['='] = 13,
81 [0x07f] = 14, /* Backspace */
82 [KEY_BACKSPACE] = 14, /* Backspace */
84 ['\t'] = 15, /* Tab */
85 ['q'] = 16,
86 ['w'] = 17,
87 ['e'] = 18,
88 ['r'] = 19,
89 ['t'] = 20,
90 ['y'] = 21,
91 ['u'] = 22,
92 ['i'] = 23,
93 ['o'] = 24,
94 ['p'] = 25,
95 ['['] = 26,
96 [']'] = 27,
97 ['\n'] = 28, /* Return */
98 ['\r'] = 28, /* Return */
99 [KEY_ENTER] = 28, /* Return */
101 ['a'] = 30,
102 ['s'] = 31,
103 ['d'] = 32,
104 ['f'] = 33,
105 ['g'] = 34,
106 ['h'] = 35,
107 ['j'] = 36,
108 ['k'] = 37,
109 ['l'] = 38,
110 [';'] = 39,
111 ['\''] = 40, /* Single quote */
112 ['`'] = 41,
113 ['\\'] = 43, /* Backslash */
115 ['z'] = 44,
116 ['x'] = 45,
117 ['c'] = 46,
118 ['v'] = 47,
119 ['b'] = 48,
120 ['n'] = 49,
121 ['m'] = 50,
122 [','] = 51,
123 ['.'] = 52,
124 ['/'] = 53,
126 [' '] = 57,
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 */
152 ['!'] = 2 | SHIFT,
153 ['@'] = 3 | SHIFT,
154 ['#'] = 4 | SHIFT,
155 ['$'] = 5 | SHIFT,
156 ['%'] = 6 | SHIFT,
157 ['^'] = 7 | SHIFT,
158 ['&'] = 8 | SHIFT,
159 ['*'] = 9 | SHIFT,
160 ['('] = 10 | SHIFT,
161 [')'] = 11 | SHIFT,
162 ['_'] = 12 | SHIFT,
163 ['+'] = 13 | SHIFT,
165 [KEY_BTAB] = 15 | SHIFT, /* Shift + Tab */
166 ['Q'] = 16 | SHIFT,
167 ['W'] = 17 | SHIFT,
168 ['E'] = 18 | SHIFT,
169 ['R'] = 19 | SHIFT,
170 ['T'] = 20 | SHIFT,
171 ['Y'] = 21 | SHIFT,
172 ['U'] = 22 | SHIFT,
173 ['I'] = 23 | SHIFT,
174 ['O'] = 24 | SHIFT,
175 ['P'] = 25 | SHIFT,
176 ['{'] = 26 | SHIFT,
177 ['}'] = 27 | SHIFT,
179 ['A'] = 30 | SHIFT,
180 ['S'] = 31 | SHIFT,
181 ['D'] = 32 | SHIFT,
182 ['F'] = 33 | SHIFT,
183 ['G'] = 34 | SHIFT,
184 ['H'] = 35 | SHIFT,
185 ['J'] = 36 | SHIFT,
186 ['K'] = 37 | SHIFT,
187 ['L'] = 38 | SHIFT,
188 [':'] = 39 | SHIFT,
189 ['"'] = 40 | SHIFT,
190 ['~'] = 41 | SHIFT,
191 ['|'] = 43 | SHIFT,
193 ['Z'] = 44 | SHIFT,
194 ['X'] = 45 | SHIFT,
195 ['C'] = 46 | SHIFT,
196 ['V'] = 47 | SHIFT,
197 ['B'] = 48 | SHIFT,
198 ['N'] = 49 | SHIFT,
199 ['M'] = 50 | SHIFT,
200 ['<'] = 51 | SHIFT,
201 ['>'] = 52 | SHIFT,
202 ['?'] = 53 | SHIFT,
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,
251 ['\n'] = '\n',
252 ['\r'] = '\n',
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,
266 [KEY_ENTER] = '\n',
267 [KEY_END] = QEMU_KEY_END,
271 static const name2keysym_t name2keysym[] = {
272 /* Plain ASCII */
273 { "space", 0x020 },
274 { "exclam", 0x021 },
275 { "quotedbl", 0x022 },
276 { "numbersign", 0x023 },
277 { "dollar", 0x024 },
278 { "percent", 0x025 },
279 { "ampersand", 0x026 },
280 { "apostrophe", 0x027 },
281 { "parenleft", 0x028 },
282 { "parenright", 0x029 },
283 { "asterisk", 0x02a },
284 { "plus", 0x02b },
285 { "comma", 0x02c },
286 { "minus", 0x02d },
287 { "period", 0x02e },
288 { "slash", 0x02f },
289 { "0", 0x030 },
290 { "1", 0x031 },
291 { "2", 0x032 },
292 { "3", 0x033 },
293 { "4", 0x034 },
294 { "5", 0x035 },
295 { "6", 0x036 },
296 { "7", 0x037 },
297 { "8", 0x038 },
298 { "9", 0x039 },
299 { "colon", 0x03a },
300 { "semicolon", 0x03b },
301 { "less", 0x03c },
302 { "equal", 0x03d },
303 { "greater", 0x03e },
304 { "question", 0x03f },
305 { "at", 0x040 },
306 { "A", 0x041 },
307 { "B", 0x042 },
308 { "C", 0x043 },
309 { "D", 0x044 },
310 { "E", 0x045 },
311 { "F", 0x046 },
312 { "G", 0x047 },
313 { "H", 0x048 },
314 { "I", 0x049 },
315 { "J", 0x04a },
316 { "K", 0x04b },
317 { "L", 0x04c },
318 { "M", 0x04d },
319 { "N", 0x04e },
320 { "O", 0x04f },
321 { "P", 0x050 },
322 { "Q", 0x051 },
323 { "R", 0x052 },
324 { "S", 0x053 },
325 { "T", 0x054 },
326 { "U", 0x055 },
327 { "V", 0x056 },
328 { "W", 0x057 },
329 { "X", 0x058 },
330 { "Y", 0x059 },
331 { "Z", 0x05a },
332 { "bracketleft", 0x05b },
333 { "backslash", 0x05c },
334 { "bracketright", 0x05d },
335 { "asciicircum", 0x05e },
336 { "underscore", 0x05f },
337 { "grave", 0x060 },
338 { "a", 0x061 },
339 { "b", 0x062 },
340 { "c", 0x063 },
341 { "d", 0x064 },
342 { "e", 0x065 },
343 { "f", 0x066 },
344 { "g", 0x067 },
345 { "h", 0x068 },
346 { "i", 0x069 },
347 { "j", 0x06a },
348 { "k", 0x06b },
349 { "l", 0x06c },
350 { "m", 0x06d },
351 { "n", 0x06e },
352 { "o", 0x06f },
353 { "p", 0x070 },
354 { "q", 0x071 },
355 { "r", 0x072 },
356 { "s", 0x073 },
357 { "t", 0x074 },
358 { "u", 0x075 },
359 { "v", 0x076 },
360 { "w", 0x077 },
361 { "x", 0x078 },
362 { "y", 0x079 },
363 { "z", 0x07a },
364 { "braceleft", 0x07b },
365 { "bar", 0x07c },
366 { "braceright", 0x07d },
367 { "asciitilde", 0x07e },
369 /* Latin-1 extensions */
370 { "nobreakspace", 0x0a0 },
371 { "exclamdown", 0x0a1 },
372 { "cent", 0x0a2 },
373 { "sterling", 0x0a3 },
374 { "currency", 0x0a4 },
375 { "yen", 0x0a5 },
376 { "brokenbar", 0x0a6 },
377 { "section", 0x0a7 },
378 { "diaeresis", 0x0a8 },
379 { "copyright", 0x0a9 },
380 { "ordfeminine", 0x0aa },
381 { "guillemotleft", 0x0ab },
382 { "notsign", 0x0ac },
383 { "hyphen", 0x0ad },
384 { "registered", 0x0ae },
385 { "macron", 0x0af },
386 { "degree", 0x0b0 },
387 { "plusminus", 0x0b1 },
388 { "twosuperior", 0x0b2 },
389 { "threesuperior", 0x0b3 },
390 { "acute", 0x0b4 },
391 { "mu", 0x0b5 },
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 },
402 { "Agrave", 0x0c0 },
403 { "Aacute", 0x0c1 },
404 { "Acircumflex", 0x0c2 },
405 { "Atilde", 0x0c3 },
406 { "Adiaeresis", 0x0c4 },
407 { "Aring", 0x0c5 },
408 { "AE", 0x0c6 },
409 { "Ccedilla", 0x0c7 },
410 { "Egrave", 0x0c8 },
411 { "Eacute", 0x0c9 },
412 { "Ecircumflex", 0x0ca },
413 { "Ediaeresis", 0x0cb },
414 { "Igrave", 0x0cc },
415 { "Iacute", 0x0cd },
416 { "Icircumflex", 0x0ce },
417 { "Idiaeresis", 0x0cf },
418 { "ETH", 0x0d0 },
419 { "Eth", 0x0d0 },
420 { "Ntilde", 0x0d1 },
421 { "Ograve", 0x0d2 },
422 { "Oacute", 0x0d3 },
423 { "Ocircumflex", 0x0d4 },
424 { "Otilde", 0x0d5 },
425 { "Odiaeresis", 0x0d6 },
426 { "multiply", 0x0d7 },
427 { "Ooblique", 0x0d8 },
428 { "Oslash", 0x0d8 },
429 { "Ugrave", 0x0d9 },
430 { "Uacute", 0x0da },
431 { "Ucircumflex", 0x0db },
432 { "Udiaeresis", 0x0dc },
433 { "Yacute", 0x0dd },
434 { "THORN", 0x0de },
435 { "Thorn", 0x0de },
436 { "ssharp", 0x0df },
437 { "agrave", 0x0e0 },
438 { "aacute", 0x0e1 },
439 { "acircumflex", 0x0e2 },
440 { "atilde", 0x0e3 },
441 { "adiaeresis", 0x0e4 },
442 { "aring", 0x0e5 },
443 { "ae", 0x0e6 },
444 { "ccedilla", 0x0e7 },
445 { "egrave", 0x0e8 },
446 { "eacute", 0x0e9 },
447 { "ecircumflex", 0x0ea },
448 { "ediaeresis", 0x0eb },
449 { "igrave", 0x0ec },
450 { "iacute", 0x0ed },
451 { "icircumflex", 0x0ee },
452 { "idiaeresis", 0x0ef },
453 { "eth", 0x0f0 },
454 { "ntilde", 0x0f1 },
455 { "ograve", 0x0f2 },
456 { "oacute", 0x0f3 },
457 { "ocircumflex", 0x0f4 },
458 { "otilde", 0x0f5 },
459 { "odiaeresis", 0x0f6 },
460 { "division", 0x0f7 },
461 { "oslash", 0x0f8 },
462 { "ooblique", 0x0f8 },
463 { "ugrave", 0x0f9 },
464 { "uacute", 0x0fa },
465 { "ucircumflex", 0x0fb },
466 { "udiaeresis", 0x0fc },
467 { "yacute", 0x0fd },
468 { "thorn", 0x0fe },
469 { "ydiaeresis", 0x0ff },
471 /* Special keys */
472 { "BackSpace", KEY_BACKSPACE },
473 { "Tab", '\t' },
474 { "Return", KEY_ENTER },
475 { "Right", KEY_RIGHT },
476 { "Left", KEY_LEFT },
477 { "Up", KEY_UP },
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 },
484 { "End", KEY_END },
485 { "F1", KEY_F(1) },
486 { "F2", KEY_F(2) },
487 { "F3", KEY_F(3) },
488 { "F4", KEY_F(4) },
489 { "F5", KEY_F(5) },
490 { "F6", KEY_F(6) },
491 { "F7", KEY_F(7) },
492 { "F8", KEY_F(8) },
493 { "F9", KEY_F(9) },
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) },
509 { "Escape", 27 },
511 { NULL, 0 },
514 #endif