§ Сканкоды/C
Думаю, в таком виде тоже неплохо будет.
1
2int kbd_scancode(int scancode, int release) {
3
4 release = (release ? 0x80 : 0x00);
5
6 switch (scancode) {
7
8
9 case SDL_SCANCODE_A: return 'A' | release;
10 case SDL_SCANCODE_B: return 'B' | release;
11 case SDL_SCANCODE_C: return 'C' | release;
12 case SDL_SCANCODE_D: return 'D' | release;
13 case SDL_SCANCODE_E: return 'E' | release;
14 case SDL_SCANCODE_F: return 'F' | release;
15 case SDL_SCANCODE_G: return 'G' | release;
16 case SDL_SCANCODE_H: return 'H' | release;
17 case SDL_SCANCODE_I: return 'I' | release;
18 case SDL_SCANCODE_J: return 'J' | release;
19 case SDL_SCANCODE_K: return 'K' | release;
20 case SDL_SCANCODE_L: return 'L' | release;
21 case SDL_SCANCODE_M: return 'M' | release;
22 case SDL_SCANCODE_N: return 'N' | release;
23 case SDL_SCANCODE_O: return 'O' | release;
24 case SDL_SCANCODE_P: return 'P' | release;
25 case SDL_SCANCODE_Q: return 'Q' | release;
26 case SDL_SCANCODE_R: return 'E' | release;
27 case SDL_SCANCODE_S: return 'S' | release;
28 case SDL_SCANCODE_T: return 'T' | release;
29 case SDL_SCANCODE_U: return 'U' | release;
30 case SDL_SCANCODE_V: return 'V' | release;
31 case SDL_SCANCODE_W: return 'W' | release;
32 case SDL_SCANCODE_X: return 'X' | release;
33 case SDL_SCANCODE_Y: return 'Y' | release;
34 case SDL_SCANCODE_Z: return 'Z' | release;
35
36
37 case SDL_SCANCODE_0: return '0' | release;
38 case SDL_SCANCODE_1: return '1' | release;
39 case SDL_SCANCODE_2: return '2' | release;
40 case SDL_SCANCODE_3: return '3' | release;
41 case SDL_SCANCODE_4: return '4' | release;
42 case SDL_SCANCODE_5: return '5' | release;
43 case SDL_SCANCODE_6: return '6' | release;
44 case SDL_SCANCODE_7: return '7' | release;
45 case SDL_SCANCODE_8: return '8' | release;
46 case SDL_SCANCODE_9: return '9' | release;
47
48
49 case SDL_SCANCODE_KP_0: return '0' | release;
50 case SDL_SCANCODE_KP_1: return '1' | release;
51 case SDL_SCANCODE_KP_2: return '2' | release;
52 case SDL_SCANCODE_KP_3: return '3' | release;
53 case SDL_SCANCODE_KP_4: return '4' | release;
54 case SDL_SCANCODE_KP_5: return '5' | release;
55 case SDL_SCANCODE_KP_6: return '6' | release;
56 case SDL_SCANCODE_KP_7: return '7' | release;
57 case SDL_SCANCODE_KP_8: return '8' | release;
58 case SDL_SCANCODE_KP_9: return '9' | release;
59
60 case SDL_SCANCODE_GRAVE: return '`' | release;
61 case SDL_SCANCODE_MINUS: return '-' | release;
62 case SDL_SCANCODE_EQUALS: return '=' | release;
63 case SDL_SCANCODE_BACKSLASH: return '\\'| release;
64 case SDL_SCANCODE_LEFTBRACKET: return '[' | release;
65 case SDL_SCANCODE_RIGHTBRACKET: return ']' | release;
66 case SDL_SCANCODE_SEMICOLON: return ';' | release;
67 case SDL_SCANCODE_APOSTROPHE: return '\'' | release;
68 case SDL_SCANCODE_COMMA: return ',' | release;
69 case SDL_SCANCODE_PERIOD: return '.' | release;
70 case SDL_SCANCODE_KP_DIVIDE:
71 case SDL_SCANCODE_SLASH: return '/' | release;
72 case SDL_SCANCODE_BACKSPACE: return key_BS | release;
73 case SDL_SCANCODE_SPACE: return ' ' | release;
74 case SDL_SCANCODE_TAB: return key_TAB | release;
75 case SDL_SCANCODE_LSHIFT:
76 case SDL_SCANCODE_RSHIFT: return key_LSHIFT | release;
77 case SDL_SCANCODE_LCTRL:
78 case SDL_SCANCODE_RCTRL: return key_LCTRL | release;
79 case SDL_SCANCODE_LALT:
80 case SDL_SCANCODE_RALT: return key_LALT | release;
81 case SDL_SCANCODE_KP_ENTER:
82 case SDL_SCANCODE_KP_MULTIPLY: return '*' | release;
83 case SDL_SCANCODE_KP_MINUS: return '-' | release;
84 case SDL_SCANCODE_KP_PLUS: return '+' | release;
85 case SDL_SCANCODE_KP_PERIOD: return '.' | release;
86 case SDL_SCANCODE_RETURN: return key_ENTER | release;
87 case SDL_SCANCODE_ESCAPE: return key_ESC | release;
88 case SDL_SCANCODE_NUMLOCKCLEAR: return key_NL | release;
89 case SDL_SCANCODE_APPLICATION: return key_APP | release;
90
91
92 case SDL_SCANCODE_F1: return key_F1 | release;
93 case SDL_SCANCODE_F2: return key_F2 | release;
94 case SDL_SCANCODE_F3: return key_F3 | release;
95 case SDL_SCANCODE_F4: return key_F4 | release;
96 case SDL_SCANCODE_F5: return key_F5 | release;
97 case SDL_SCANCODE_F6: return key_F6 | release;
98 case SDL_SCANCODE_F7: return key_F7 | release;
99 case SDL_SCANCODE_F8: return key_F8 | release;
100 case SDL_SCANCODE_F9: return key_F9 | release;
101 case SDL_SCANCODE_F10: return key_F10 | release;
102 case SDL_SCANCODE_F11: return key_F11 | release;
103 case SDL_SCANCODE_F12: return key_F12 | release;
104
105
106 case SDL_SCANCODE_UP: return key_UP | release;
107 case SDL_SCANCODE_DOWN: return key_DN | release;
108 case SDL_SCANCODE_LEFT: return key_LF | release;
109 case SDL_SCANCODE_RIGHT: return key_RT | release;
110 case SDL_SCANCODE_INSERT: return key_INS | release;
111 case SDL_SCANCODE_HOME: return key_HOME | release;
112 case SDL_SCANCODE_END: return key_END | release;
113 case SDL_SCANCODE_PAGEUP: return key_PGUP | release;
114 case SDL_SCANCODE_PAGEDOWN: return key_PGDN | release;
115 case SDL_SCANCODE_DELETE: return key_DEL | release;
116 }
117
118 return 0;
119}
§ Специальные клавиши
1enum KEY_ASCII {
2
3 key_LSHIFT = 0x01,
4 key_LALT = 0x02,
5 key_LCTRL = 0x03,
6 key_UP = 0x04,
7 key_DN = 0x05,
8 key_LF = 0x06,
9 key_RT = 0x07,
10 key_BS = 0x08,
11 key_TAB = 0x09,
12 key_ENTER = 0x0A,
13 key_HOME = 0x0B,
14 key_END = 0x0C,
15 key_PGUP = 0x0D,
16 key_PGDN = 0x0E,
17 key_DEL = 0x0F,
18 key_F1 = 0x10,
19 key_F2 = 0x11,
20 key_F3 = 0x12,
21 key_F4 = 0x13,
22 key_F5 = 0x14,
23 key_F6 = 0x15,
24 key_F7 = 0x16,
25 key_F8 = 0x17,
26 key_F9 = 0x18,
27 key_F10 = 0x19,
28 key_F11 = 0x1A,
29 key_ESC = 0x1B,
30 key_INS = 0x1C,
31 key_NL = 0x1D,
32 key_F12 = 0x1E,
33 key_APP = 0x1F
34};