comparison src/video/x11/SDL_x11keyboard.c @ 5224:c1a92e61907d

Renamed SDLKey and SDLMod for consistency
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Feb 2011 09:42:08 -0800
parents 572a73d71b5f
children 1fbe1c202501
comparison
equal deleted inserted replaced
5223:572a73d71b5f 5224:c1a92e61907d
32 #include "imKStoUCS.h" 32 #include "imKStoUCS.h"
33 33
34 /* *INDENT-OFF* */ 34 /* *INDENT-OFF* */
35 static const struct { 35 static const struct {
36 KeySym keysym; 36 KeySym keysym;
37 SDLKey sdlkey; 37 SDL_Key sdlkey;
38 } KeySymToSDLKey[] = { 38 } KeySymToSDLKey[] = {
39 { XK_Return, SDLK_RETURN }, 39 { XK_Return, SDLK_RETURN },
40 { XK_Escape, SDLK_ESCAPE }, 40 { XK_Escape, SDLK_ESCAPE },
41 { XK_BackSpace, SDLK_BACKSPACE }, 41 { XK_BackSpace, SDLK_BACKSPACE },
42 { XK_Tab, SDLK_TAB }, 42 { XK_Tab, SDLK_TAB },
141 { xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) }, 141 { xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
142 { xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) }, 142 { xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
143 }; 143 };
144 /* *INDENT-OFF* */ 144 /* *INDENT-OFF* */
145 145
146 static SDLKey 146 static SDL_Key
147 X11_KeyCodeToSDLKey(Display *display, KeyCode keycode) 147 X11_KeyCodeToSDLKey(Display *display, KeyCode keycode)
148 { 148 {
149 KeySym keysym; 149 KeySym keysym;
150 unsigned int ucs4; 150 unsigned int ucs4;
151 int i; 151 int i;
155 return SDLK_UNKNOWN; 155 return SDLK_UNKNOWN;
156 } 156 }
157 157
158 ucs4 = X11_KeySymToUcs4(keysym); 158 ucs4 = X11_KeySymToUcs4(keysym);
159 if (ucs4) { 159 if (ucs4) {
160 return (SDLKey) ucs4; 160 return (SDL_Key) ucs4;
161 } 161 }
162 162
163 for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) { 163 for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) {
164 if (keysym == KeySymToSDLKey[i].keysym) { 164 if (keysym == KeySymToSDLKey[i].keysym) {
165 return KeySymToSDLKey[i].sdlkey; 165 return KeySymToSDLKey[i].sdlkey;
220 break; 220 break;
221 } 221 }
222 } 222 }
223 223
224 if (!fingerprint_detected) { 224 if (!fingerprint_detected) {
225 SDLKey keymap[SDL_NUM_SCANCODES]; 225 SDL_Key keymap[SDL_NUM_SCANCODES];
226 226
227 printf 227 printf
228 ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n"); 228 ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n");
229 229
230 /* Determine key_layout - only works on US QWERTY layout */ 230 /* Determine key_layout - only works on US QWERTY layout */
231 SDL_GetDefaultKeymap(keymap); 231 SDL_GetDefaultKeymap(keymap);
232 for (i = min_keycode; i <= max_keycode; ++i) { 232 for (i = min_keycode; i <= max_keycode; ++i) {
233 KeySym sym; 233 KeySym sym;
234 sym = XKeycodeToKeysym(data->display, i, 0); 234 sym = XKeycodeToKeysym(data->display, i, 0);
235 if (sym != NoSymbol) { 235 if (sym != NoSymbol) {
236 SDLKey key; 236 SDL_Key key;
237 printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, 237 printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
238 (unsigned int) sym, XKeysymToString(sym)); 238 (unsigned int) sym, XKeysymToString(sym));
239 key = X11_KeyCodeToSDLKey(data->display, i); 239 key = X11_KeyCodeToSDLKey(data->display, i);
240 for (j = 0; j < SDL_arraysize(keymap); ++j) { 240 for (j = 0; j < SDL_arraysize(keymap); ++j) {
241 if (keymap[j] == key) { 241 if (keymap[j] == key) {
263 X11_UpdateKeymap(_THIS) 263 X11_UpdateKeymap(_THIS)
264 { 264 {
265 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 265 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
266 int i; 266 int i;
267 SDL_Scancode scancode; 267 SDL_Scancode scancode;
268 SDLKey keymap[SDL_NUM_SCANCODES]; 268 SDL_Key keymap[SDL_NUM_SCANCODES];
269 269
270 SDL_zero(keymap); 270 SDL_zero(keymap);
271 271
272 for (i = 0; i < SDL_arraysize(data->key_layout); i++) { 272 for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
273 273