1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Christian Meyer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | #include <SDL/SDL.h> |
---|
16 | |
---|
17 | #include "keynames.h" |
---|
18 | |
---|
19 | #include <string.h> |
---|
20 | |
---|
21 | using namespace std; |
---|
22 | |
---|
23 | int buttonname_to_SDLB( char* name) |
---|
24 | { |
---|
25 | if( !strcmp (name, "BUTTON_LEFT")) return SDL_BUTTON_LEFT; |
---|
26 | if( !strcmp (name, "BUTTON_MIDDLE")) return SDL_BUTTON_MIDDLE; |
---|
27 | if( !strcmp (name, "BUTTON_RIGHT")) return SDL_BUTTON_RIGHT; |
---|
28 | // if( !strcmp (name, "BUTTON_WHEELUP")) return SDL_BUTTON_WHEELUP; |
---|
29 | // if( !strcmp (name, "BUTTON_WHEELDOWN")) return SDL_BUTTON_WHEELDOWN; |
---|
30 | return -1; |
---|
31 | } |
---|
32 | |
---|
33 | char* SDLB_to_buttonname( int button) |
---|
34 | { |
---|
35 | if( button == SDL_BUTTON_LEFT) return "BUTTON_LEFT"; |
---|
36 | if( button == SDL_BUTTON_MIDDLE) return "BUTTON_MIDDLE"; |
---|
37 | if( button == SDL_BUTTON_RIGHT) return "BUTTON_RIGHT"; |
---|
38 | // if( button == SDL_BUTTON_WHEELUP) return "BUTTON_WHEELUP"; |
---|
39 | // if( button == SDL_BUTTON_WHEELDOWN) return "BUTTON_WHEELDOWN"; |
---|
40 | return "UNKNOWN"; |
---|
41 | } |
---|
42 | |
---|
43 | int keyname_to_SDLK( char* name) |
---|
44 | { |
---|
45 | if( !strcmp (name, "BACKSPACE")) return SDLK_BACKSPACE; |
---|
46 | if( !strcmp (name, "TAB")) return SDLK_TAB; |
---|
47 | if( !strcmp (name, "CLEAR")) return SDLK_CLEAR; |
---|
48 | if( !strcmp (name, "RETURN")) return SDLK_RETURN; |
---|
49 | if( !strcmp (name, "ESCAPE")) return SDLK_ESCAPE; |
---|
50 | if( !strcmp (name, "SPACE")) return SDLK_SPACE; |
---|
51 | if( !strcmp (name, "EXCLAIM")) return SDLK_EXCLAIM; |
---|
52 | if( !strcmp (name, "QUOTEDBL")) return SDLK_QUOTEDBL; |
---|
53 | if( !strcmp (name, "HASH")) return SDLK_HASH; |
---|
54 | if( !strcmp (name, "PAUSE")) return SDLK_PAUSE; |
---|
55 | if( !strcmp (name, "DOLLAR")) return SDLK_DOLLAR; |
---|
56 | if( !strcmp (name, "AMPERSAND")) return SDLK_AMPERSAND; |
---|
57 | if( !strcmp (name, "QUOTE")) return SDLK_QUOTE; |
---|
58 | if( !strcmp (name, "LEFTPAREN")) return SDLK_LEFTPAREN; |
---|
59 | if( !strcmp (name, "RIGHTPAREN")) return SDLK_RIGHTPAREN; |
---|
60 | if( !strcmp (name, "ASTERISK")) return SDLK_ASTERISK; |
---|
61 | if( !strcmp (name, "PLUS")) return SDLK_PLUS; |
---|
62 | if( !strcmp (name, "COMMA")) return SDLK_COMMA; |
---|
63 | if( !strcmp (name, "MINUS")) return SDLK_MINUS; |
---|
64 | if( !strcmp (name, "PERIOD")) return SDLK_PERIOD; |
---|
65 | if( !strcmp (name, "SLASH")) return SDLK_SLASH; |
---|
66 | if( !strcmp (name, "0")) return SDLK_0; |
---|
67 | if( !strcmp (name, "1")) return SDLK_1; |
---|
68 | if( !strcmp (name, "2")) return SDLK_2; |
---|
69 | if( !strcmp (name, "3")) return SDLK_3; |
---|
70 | if( !strcmp (name, "4")) return SDLK_4; |
---|
71 | if( !strcmp (name, "5")) return SDLK_5; |
---|
72 | if( !strcmp (name, "6")) return SDLK_6; |
---|
73 | if( !strcmp (name, "7")) return SDLK_7; |
---|
74 | if( !strcmp (name, "8")) return SDLK_8; |
---|
75 | if( !strcmp (name, "9")) return SDLK_9; |
---|
76 | if( !strcmp (name, "COLON")) return SDLK_COLON; |
---|
77 | if( !strcmp (name, "SEMICOLON")) return SDLK_SEMICOLON; |
---|
78 | if( !strcmp (name, "LESS")) return SDLK_LESS; |
---|
79 | if( !strcmp (name, "EQUALS")) return SDLK_EQUALS; |
---|
80 | if( !strcmp (name, "GREATER")) return SDLK_GREATER; |
---|
81 | if( !strcmp (name, "QUESTION")) return SDLK_QUESTION; |
---|
82 | if( !strcmp (name, "AT")) return SDLK_AT; |
---|
83 | if( !strcmp (name, "LEFTBRACKET")) return SDLK_LEFTBRACKET; |
---|
84 | if( !strcmp (name, "BACKSLASH")) return SDLK_BACKSLASH; |
---|
85 | if( !strcmp (name, "RIGHTBRACKET")) return SDLK_RIGHTBRACKET; |
---|
86 | if( !strcmp (name, "CARET")) return SDLK_CARET; |
---|
87 | if( !strcmp (name, "UNDERSCORE")) return SDLK_UNDERSCORE; |
---|
88 | if( !strcmp (name, "BACKQUOTE")) return SDLK_BACKQUOTE; |
---|
89 | if( !strcmp (name, "a")) return SDLK_a; |
---|
90 | if( !strcmp (name, "b")) return SDLK_b; |
---|
91 | if( !strcmp (name, "c")) return SDLK_c; |
---|
92 | if( !strcmp (name, "d")) return SDLK_d; |
---|
93 | if( !strcmp (name, "e")) return SDLK_e; |
---|
94 | if( !strcmp (name, "f")) return SDLK_f; |
---|
95 | if( !strcmp (name, "g")) return SDLK_g; |
---|
96 | if( !strcmp (name, "h")) return SDLK_h; |
---|
97 | if( !strcmp (name, "i")) return SDLK_i; |
---|
98 | if( !strcmp (name, "j")) return SDLK_j; |
---|
99 | if( !strcmp (name, "k")) return SDLK_k; |
---|
100 | if( !strcmp (name, "l")) return SDLK_l; |
---|
101 | if( !strcmp (name, "m")) return SDLK_m; |
---|
102 | if( !strcmp (name, "n")) return SDLK_n; |
---|
103 | if( !strcmp (name, "o")) return SDLK_o; |
---|
104 | if( !strcmp (name, "p")) return SDLK_p; |
---|
105 | if( !strcmp (name, "q")) return SDLK_q; |
---|
106 | if( !strcmp (name, "r")) return SDLK_r; |
---|
107 | if( !strcmp (name, "s")) return SDLK_s; |
---|
108 | if( !strcmp (name, "t")) return SDLK_t; |
---|
109 | if( !strcmp (name, "u")) return SDLK_u; |
---|
110 | if( !strcmp (name, "v")) return SDLK_v; |
---|
111 | if( !strcmp (name, "w")) return SDLK_w; |
---|
112 | if( !strcmp (name, "x")) return SDLK_x; |
---|
113 | if( !strcmp (name, "y")) return SDLK_y; |
---|
114 | if( !strcmp (name, "z")) return SDLK_z; |
---|
115 | if( !strcmp (name, "DELETE")) return SDLK_DELETE; |
---|
116 | if( !strcmp (name, "KP0")) return SDLK_KP0; |
---|
117 | if( !strcmp (name, "KP1")) return SDLK_KP1; |
---|
118 | if( !strcmp (name, "KP2")) return SDLK_KP2; |
---|
119 | if( !strcmp (name, "KP3")) return SDLK_KP3; |
---|
120 | if( !strcmp (name, "KP4")) return SDLK_KP4; |
---|
121 | if( !strcmp (name, "KP5")) return SDLK_KP5; |
---|
122 | if( !strcmp (name, "KP6")) return SDLK_KP6; |
---|
123 | if( !strcmp (name, "KP7")) return SDLK_KP7; |
---|
124 | if( !strcmp (name, "KP8")) return SDLK_KP8; |
---|
125 | if( !strcmp (name, "KP9")) return SDLK_KP9; |
---|
126 | if( !strcmp (name, "KP_PERIOD")) return SDLK_KP_PERIOD; |
---|
127 | if( !strcmp (name, "KP_DIVIDE")) return SDLK_KP_DIVIDE; |
---|
128 | if( !strcmp (name, "KP_MULTIPLY")) return SDLK_KP_MULTIPLY; |
---|
129 | if( !strcmp (name, "KP_MINUS")) return SDLK_KP_MINUS; |
---|
130 | if( !strcmp (name, "KP_PLUS")) return SDLK_KP_PLUS; |
---|
131 | if( !strcmp (name, "KP_ENTER")) return SDLK_KP_ENTER; |
---|
132 | if( !strcmp (name, "KP_EQUALS")) return SDLK_KP_EQUALS; |
---|
133 | if( !strcmp (name, "UP")) return SDLK_UP; |
---|
134 | if( !strcmp (name, "DOWN")) return SDLK_DOWN; |
---|
135 | if( !strcmp (name, "RIGHT")) return SDLK_RIGHT; |
---|
136 | if( !strcmp (name, "LEFT")) return SDLK_LEFT; |
---|
137 | if( !strcmp (name, "INSERT")) return SDLK_INSERT; |
---|
138 | if( !strcmp (name, "HOME")) return SDLK_HOME; |
---|
139 | if( !strcmp (name, "END")) return SDLK_END; |
---|
140 | if( !strcmp (name, "PAGEUP")) return SDLK_PAGEUP; |
---|
141 | if( !strcmp (name, "PAGEDOWN")) return SDLK_PAGEDOWN; |
---|
142 | if( !strcmp (name, "F1")) return SDLK_F1; |
---|
143 | if( !strcmp (name, "F2")) return SDLK_F2; |
---|
144 | if( !strcmp (name, "F3")) return SDLK_F3; |
---|
145 | if( !strcmp (name, "F4")) return SDLK_F4; |
---|
146 | if( !strcmp (name, "F5")) return SDLK_F5; |
---|
147 | if( !strcmp (name, "F6")) return SDLK_F6; |
---|
148 | if( !strcmp (name, "F7")) return SDLK_F7; |
---|
149 | if( !strcmp (name, "F8")) return SDLK_F8; |
---|
150 | if( !strcmp (name, "F9")) return SDLK_F9; |
---|
151 | if( !strcmp (name, "F10")) return SDLK_F10; |
---|
152 | if( !strcmp (name, "F11")) return SDLK_F11; |
---|
153 | if( !strcmp (name, "F12")) return SDLK_F12; |
---|
154 | if( !strcmp (name, "F13")) return SDLK_F13; |
---|
155 | if( !strcmp (name, "F14")) return SDLK_F14; |
---|
156 | if( !strcmp (name, "F15")) return SDLK_F15; |
---|
157 | if( !strcmp (name, "NUMLOCK")) return SDLK_NUMLOCK; |
---|
158 | if( !strcmp (name, "CAPSLOCK")) return SDLK_CAPSLOCK; |
---|
159 | if( !strcmp (name, "SCROLLOCK")) return SDLK_SCROLLOCK; |
---|
160 | if( !strcmp (name, "RSHIFT")) return SDLK_RSHIFT; |
---|
161 | if( !strcmp (name, "LSHIFT")) return SDLK_LSHIFT; |
---|
162 | if( !strcmp (name, "RCTRL")) return SDLK_RCTRL; |
---|
163 | if( !strcmp (name, "LCTRL")) return SDLK_LCTRL; |
---|
164 | if( !strcmp (name, "RALT")) return SDLK_RALT; |
---|
165 | if( !strcmp (name, "LALT")) return SDLK_LALT; |
---|
166 | if( !strcmp (name, "RMETA")) return SDLK_RMETA; |
---|
167 | if( !strcmp (name, "LMETA")) return SDLK_LMETA; |
---|
168 | if( !strcmp (name, "LSUPER")) return SDLK_LSUPER; |
---|
169 | if( !strcmp (name, "RSUPER")) return SDLK_RSUPER; |
---|
170 | if( !strcmp (name, "MODE")) return SDLK_MODE; |
---|
171 | if( !strcmp (name, "HELP")) return SDLK_HELP; |
---|
172 | if( !strcmp (name, "PRINT")) return SDLK_PRINT; |
---|
173 | if( !strcmp (name, "SYSREQ")) return SDLK_SYSREQ; |
---|
174 | if( !strcmp (name, "BREAK")) return SDLK_BREAK; |
---|
175 | if( !strcmp (name, "MENU")) return SDLK_MENU; |
---|
176 | if( !strcmp (name, "POWER")) return SDLK_POWER; |
---|
177 | if( !strcmp (name, "EURO")) return SDLK_EURO; |
---|
178 | return -1; |
---|
179 | } |
---|
180 | |
---|
181 | char* SDLK_to_keyname( int key) |
---|
182 | { |
---|
183 | if( key == SDLK_BACKSPACE) return "BACKSPACE"; |
---|
184 | if( key == SDLK_TAB) return "TAB"; |
---|
185 | if( key == SDLK_CLEAR) return "CLEAR"; |
---|
186 | if( key == SDLK_RETURN) return "RETURN"; |
---|
187 | if( key == SDLK_SPACE) return "SPACE"; |
---|
188 | if( key == SDLK_ESCAPE) return "ESCAPE"; |
---|
189 | if( key == SDLK_EXCLAIM) return "EXCLAIM"; |
---|
190 | if( key == SDLK_QUOTEDBL) return "QUOTEDBL"; |
---|
191 | if( key == SDLK_HASH) return "HASH"; |
---|
192 | if( key == SDLK_PAUSE) return "PAUSE"; |
---|
193 | if( key == SDLK_DOLLAR) return "DOLLAR"; |
---|
194 | if( key == SDLK_AMPERSAND) return "AMPERSAND"; |
---|
195 | if( key == SDLK_QUOTE) return "QUOTE"; |
---|
196 | if( key == SDLK_LEFTPAREN) return "LEFTPAREN"; |
---|
197 | if( key == SDLK_RIGHTPAREN) return "RIGHTPAREN"; |
---|
198 | if( key == SDLK_ASTERISK) return "ASTERISK"; |
---|
199 | if( key == SDLK_PLUS) return "PLUS"; |
---|
200 | if( key == SDLK_COMMA) return "COMMA"; |
---|
201 | if( key == SDLK_MINUS) return "MINUS"; |
---|
202 | if( key == SDLK_PERIOD) return "PERIOD"; |
---|
203 | if( key == SDLK_SLASH) return "SLASH"; |
---|
204 | if( key == SDLK_0) return "0"; |
---|
205 | if( key == SDLK_1) return "1"; |
---|
206 | if( key == SDLK_2) return "2"; |
---|
207 | if( key == SDLK_3) return "3"; |
---|
208 | if( key == SDLK_4) return "4"; |
---|
209 | if( key == SDLK_5) return "5"; |
---|
210 | if( key == SDLK_6) return "6"; |
---|
211 | if( key == SDLK_7) return "7"; |
---|
212 | if( key == SDLK_8) return "8"; |
---|
213 | if( key == SDLK_9) return "9"; |
---|
214 | if( key == SDLK_COLON) return "COLON"; |
---|
215 | if( key == SDLK_SEMICOLON) return "SEMICOLON"; |
---|
216 | if( key == SDLK_LESS) return "LESS"; |
---|
217 | if( key == SDLK_EQUALS) return "EQUALS"; |
---|
218 | if( key == SDLK_GREATER) return "GREATER"; |
---|
219 | if( key == SDLK_QUESTION) return "QUESTION"; |
---|
220 | if( key == SDLK_AT) return "AT"; |
---|
221 | if( key == SDLK_LEFTBRACKET) return "LEFTBRACKET"; |
---|
222 | if( key == SDLK_BACKSLASH) return "BACKSLASH"; |
---|
223 | if( key == SDLK_RIGHTBRACKET) return "RIGHTBRACKET"; |
---|
224 | if( key == SDLK_CARET) return "CARET"; |
---|
225 | if( key == SDLK_UNDERSCORE) return "UNDERSCORE"; |
---|
226 | if( key == SDLK_BACKQUOTE) return "BACKQUOTE"; |
---|
227 | if( key == SDLK_a) return "a"; |
---|
228 | if( key == SDLK_b) return "b"; |
---|
229 | if( key == SDLK_c) return "c"; |
---|
230 | if( key == SDLK_d) return "d"; |
---|
231 | if( key == SDLK_e) return "e"; |
---|
232 | if( key == SDLK_f) return "f"; |
---|
233 | if( key == SDLK_g) return "g"; |
---|
234 | if( key == SDLK_h) return "h"; |
---|
235 | if( key == SDLK_i) return "i"; |
---|
236 | if( key == SDLK_j) return "j"; |
---|
237 | if( key == SDLK_k) return "k"; |
---|
238 | if( key == SDLK_l) return "l"; |
---|
239 | if( key == SDLK_m) return "m"; |
---|
240 | if( key == SDLK_n) return "n"; |
---|
241 | if( key == SDLK_o) return "o"; |
---|
242 | if( key == SDLK_p) return "p"; |
---|
243 | if( key == SDLK_q) return "q"; |
---|
244 | if( key == SDLK_r) return "r"; |
---|
245 | if( key == SDLK_s) return "s"; |
---|
246 | if( key == SDLK_t) return "t"; |
---|
247 | if( key == SDLK_u) return "u"; |
---|
248 | if( key == SDLK_v) return "v"; |
---|
249 | if( key == SDLK_w) return "w"; |
---|
250 | if( key == SDLK_x) return "x"; |
---|
251 | if( key == SDLK_y) return "y"; |
---|
252 | if( key == SDLK_z) return "z"; |
---|
253 | if( key == SDLK_DELETE) return "DELETE"; |
---|
254 | if( key == SDLK_KP0) return "KP0"; |
---|
255 | if( key == SDLK_KP1) return "KP1"; |
---|
256 | if( key == SDLK_KP2) return "KP2"; |
---|
257 | if( key == SDLK_KP3) return "KP3"; |
---|
258 | if( key == SDLK_KP4) return "KP4"; |
---|
259 | if( key == SDLK_KP5) return "KP5"; |
---|
260 | if( key == SDLK_KP6) return "KP6"; |
---|
261 | if( key == SDLK_KP7) return "KP7"; |
---|
262 | if( key == SDLK_KP8) return "KP8"; |
---|
263 | if( key == SDLK_KP9) return "KP9"; |
---|
264 | if( key == SDLK_KP_PERIOD) return "KP_PERIOD"; |
---|
265 | if( key == SDLK_KP_DIVIDE) return "KP_DIVIDE"; |
---|
266 | if( key == SDLK_KP_MULTIPLY) return "KP_MULTIPLY"; |
---|
267 | if( key == SDLK_KP_MINUS) return "KP_MINUS"; |
---|
268 | if( key == SDLK_KP_PLUS) return "KP_PLUS"; |
---|
269 | if( key == SDLK_KP_ENTER) return "KP_ENTER"; |
---|
270 | if( key == SDLK_KP_EQUALS) return "KP_EQUALS"; |
---|
271 | if( key == SDLK_UP) return "UP"; |
---|
272 | if( key == SDLK_DOWN) return "DOWN"; |
---|
273 | if( key == SDLK_RIGHT) return "RIGHT"; |
---|
274 | if( key == SDLK_LEFT) return "LEFT"; |
---|
275 | if( key == SDLK_INSERT) return "INSERT"; |
---|
276 | if( key == SDLK_HOME) return "HOME"; |
---|
277 | if( key == SDLK_END) return "END"; |
---|
278 | if( key == SDLK_PAGEUP) return "PAGEUP"; |
---|
279 | if( key == SDLK_PAGEDOWN) return "PAGEDOWN"; |
---|
280 | if( key == SDLK_F1) return "F1"; |
---|
281 | if( key == SDLK_F2) return "F2"; |
---|
282 | if( key == SDLK_F3) return "F3"; |
---|
283 | if( key == SDLK_F4) return "F4"; |
---|
284 | if( key == SDLK_F5) return "F5"; |
---|
285 | if( key == SDLK_F6) return "F6"; |
---|
286 | if( key == SDLK_F7) return "F7"; |
---|
287 | if( key == SDLK_F8) return "F8"; |
---|
288 | if( key == SDLK_F9) return "F9"; |
---|
289 | if( key == SDLK_F10) return "F10"; |
---|
290 | if( key == SDLK_F11) return "F11"; |
---|
291 | if( key == SDLK_F12) return "F12"; |
---|
292 | if( key == SDLK_F13) return "F13"; |
---|
293 | if( key == SDLK_F14) return "F14"; |
---|
294 | if( key == SDLK_F15) return "F15"; |
---|
295 | if( key == SDLK_NUMLOCK) return "NUMLOCK"; |
---|
296 | if( key == SDLK_CAPSLOCK) return "CAPSLOCK"; |
---|
297 | if( key == SDLK_SCROLLOCK) return "SCROLLOCK"; |
---|
298 | if( key == SDLK_RSHIFT) return "RSHIFT"; |
---|
299 | if( key == SDLK_LSHIFT) return "LSHIFT"; |
---|
300 | if( key == SDLK_RCTRL) return "RCTRL"; |
---|
301 | if( key == SDLK_LCTRL) return "LCTRL"; |
---|
302 | if( key == SDLK_RALT) return "RALT"; |
---|
303 | if( key == SDLK_LALT) return "LALT"; |
---|
304 | if( key == SDLK_RMETA) return "RMETA"; |
---|
305 | if( key == SDLK_LMETA) return "LMETA"; |
---|
306 | if( key == SDLK_LSUPER) return "LSUPER"; |
---|
307 | if( key == SDLK_RSUPER) return "RSUPER"; |
---|
308 | if( key == SDLK_MODE) return "MODE"; |
---|
309 | if( key == SDLK_HELP) return "HELP"; |
---|
310 | if( key == SDLK_PRINT) return "PRINT"; |
---|
311 | if( key == SDLK_SYSREQ) return "SYSREQ"; |
---|
312 | if( key == SDLK_BREAK) return "BREAK"; |
---|
313 | if( key == SDLK_MENU) return "MENU"; |
---|
314 | if( key == SDLK_POWER) return "POWER"; |
---|
315 | if( key == SDLK_EURO) return "EURO"; |
---|
316 | return "UNKNOWN"; |
---|
317 | } |
---|