34 static const char *unknown_key_name =
"SomeUnknownKey";
36 static int keyMappingTableSize = 0;
39 { SDL_SCANCODE_1, 0x31,
"1" },
40 { SDL_SCANCODE_2, 0x36,
"2" },
41 { SDL_SCANCODE_3, 0x35,
"3" },
42 { SDL_SCANCODE_4, 0x33,
"4" },
43 { SDL_SCANCODE_5, 0x34,
"5" },
44 { SDL_SCANCODE_6, 0x32,
"6" },
45 { SDL_SCANCODE_7, 0x30,
"7" },
46 { SDL_SCANCODE_8, 0x50,
"8" },
47 { SDL_SCANCODE_9, 0x52,
"9" },
48 { SDL_SCANCODE_0, 0x54,
"0" },
49 { SDL_SCANCODE_Q, 0x21,
"Q" },
50 { SDL_SCANCODE_W, 0x26,
"W" },
51 { SDL_SCANCODE_E, 0x25,
"E" },
52 { SDL_SCANCODE_R, 0x23,
"R" },
53 { SDL_SCANCODE_T, 0x24,
"T" },
54 { SDL_SCANCODE_Y, 0x22,
"Y" },
55 { SDL_SCANCODE_U, 0x20,
"U" },
56 { SDL_SCANCODE_I, 0x90,
"I" },
57 { SDL_SCANCODE_O, 0x92,
"O" },
58 { SDL_SCANCODE_P, 0x94,
"P" },
59 { SDL_SCANCODE_A, 0x16,
"A" },
60 { SDL_SCANCODE_S, 0x15,
"S" },
61 { SDL_SCANCODE_D, 0x13,
"D" },
62 { SDL_SCANCODE_F, 0x14,
"F" },
63 { SDL_SCANCODE_G, 0x12,
"G" },
64 { SDL_SCANCODE_H, 0x10,
"H" },
65 { SDL_SCANCODE_J, 0x60,
"J" },
66 { SDL_SCANCODE_K, 0x62,
"K" },
67 { SDL_SCANCODE_L, 0x64,
"L" },
68 { SDL_SCANCODE_RETURN, 0x76,
"ENTER" },
69 { SDL_SCANCODE_LSHIFT, 0x07,
"L-SHIFT" },
70 { SDL_SCANCODE_RSHIFT, 0x85,
"R-SHIFT" },
71 { SDL_SCANCODE_CAPSLOCK, 0x11,
"CAPS" },
72 { SDL_SCANCODE_Z, 0x06,
"Z" },
73 { SDL_SCANCODE_X, 0x05,
"X" },
74 { SDL_SCANCODE_C, 0x03,
"C" },
75 { SDL_SCANCODE_V, 0x04,
"V" },
76 { SDL_SCANCODE_B, 0x02,
"B" },
77 { SDL_SCANCODE_N, 0x00,
"N" },
78 { SDL_SCANCODE_M, 0x80,
"M" },
79 { SDL_SCANCODE_LCTRL, 0x17,
"CTRL" },
80 { SDL_SCANCODE_SPACE, 0x86,
"SPACE" },
81 { SDL_SCANCODE_SEMICOLON, 0x63,
";" },
82 { SDL_SCANCODE_LEFTBRACKET, 0x95,
"[" },
83 { SDL_SCANCODE_RIGHTBRACKET, 0x66,
"]" },
84 { SDL_SCANCODE_APOSTROPHE, 0x65,
":" },
85 { SDL_SCANCODE_MINUS, 0x53,
"-" },
86 { SDL_SCANCODE_BACKSLASH, 0x01,
"\\" },
87 { SDL_SCANCODE_TAB, 0x27,
"TAB" },
88 { SDL_SCANCODE_ESCAPE, 0x37,
"ESC" },
89 { SDL_SCANCODE_INSERT, 0x87,
"INS" },
90 { SDL_SCANCODE_BACKSPACE, 0x56,
"ERASE" },
91 { SDL_SCANCODE_DELETE, 0x81,
"DEL" },
92 { SDL_SCANCODE_LEFT, 0x75,
"LEFT" },
93 { SDL_SCANCODE_RIGHT, 0x72,
"RIGHT" },
94 { SDL_SCANCODE_UP, 0x73,
"UP" },
95 { SDL_SCANCODE_DOWN, 0x71,
"DOWN" },
96 { SDL_SCANCODE_SLASH, 0x83,
"/" },
97 { SDL_SCANCODE_PERIOD, 0x84,
"." },
98 { SDL_SCANCODE_COMMA, 0x82,
"," },
99 { SDL_SCANCODE_EQUALS, 0x93,
"@" },
100 { SDL_SCANCODE_F1, 0x47,
"F1" },
101 { SDL_SCANCODE_F2, 0x46,
"F2" },
102 { SDL_SCANCODE_F3, 0x42,
"F3" },
103 { SDL_SCANCODE_F4, 0x40,
"F4" },
104 { SDL_SCANCODE_F5, 0x44,
"F5" },
105 { SDL_SCANCODE_F6, 0x43,
"F6" },
106 { SDL_SCANCODE_F7, 0x45,
"F7" },
107 { SDL_SCANCODE_F8, 0x41,
"F8" },
109 { SDL_SCANCODE_HOME, 0x74,
"HOLD" },
110 { SDL_SCANCODE_END, 0x70,
"STOP" },
112 { SDL_SCANCODE_KP_5, 0xA0,
"ExtJoy FIRE" },
113 { SDL_SCANCODE_KP_8, 0xA1,
"ExtJoy UP" },
114 { SDL_SCANCODE_KP_2, 0xA2,
"ExtJoy DOWN" },
115 { SDL_SCANCODE_KP_4, 0xA3,
"ExtJoy LEFT" },
116 { SDL_SCANCODE_KP_6, 0xA4,
"ExtJoy RIGHT" },
118 { SDL_SCANCODE_F11, 0xFF,
"EMU fullscreen" },
119 { SDL_SCANCODE_F9, 0xFE,
"EMU exit" },
120 { SDL_SCANCODE_F10, 0xFD,
"EMU screenshot" },
121 { SDL_SCANCODE_PAUSE, 0xFC,
"EMU reset" },
122 { SDL_SCANCODE_PAGEDOWN, 0xFB,
"EMU slower-cpu" },
123 { SDL_SCANCODE_PAGEUP, 0xFA,
"EMU faster-cpu" },
124 { SDL_SCANCODE_GRAVE, 0xF9,
"EMU osd-replay" },
125 { SDL_SCANCODE_KP_MINUS, 0xF8,
"EMU console" },
133 static void keymap_set_key ( SDL_Scancode
code,
int posep )
135 int n = keyMappingTableSize;
143 keyMappingTable = realloc(keyMappingTable, (keyMappingTableSize + 1) *
sizeof(
struct keyMappingTable_st));
145 p = keyMappingTable + (keyMappingTableSize++);
151 if (q->
pos == posep) {
164 SDL_Scancode
code = SDL_GetScancodeFromName(
name);
165 if (
code == SDL_SCANCODE_UNKNOWN)
167 keymap_set_key(
code, posep);
176 while (p->
pos != -1) {
177 keymap_set_key(p->
code, p->
pos);
186 int n = keyMappingTableSize;
189 "# Note: key names are SDL scan codes! Sometimes it's nothing to do with the letters" NL
190 "# on your keyboard (eg some national layout, like Hungarian etc) but the \"physical\"" NL
191 "# scan code assignment, eg the right neighbour of key \"L\" is \";\" even if your layout" NL
192 "# means something different there!" NL NL
195 const char *
name = SDL_GetScancodeName(p->
code);
197 fprintf(fp,
"# WARNING: cannot get SDL key name for epkey@%02x with SDL scan code of %d!" NL, p->
posep, p->
code);
209 int n = keyMappingTableSize;
211 DEBUG(
"KBD: SEARCH: scan=%d sym=%d (map size=%d)" NL, sym.scancode, sym.sym, n);
213 if (p->
code == sym.scancode) {