comparison src/video/win32/SDL_win32keyboard.c @ 2308:514f7c1651fc

Untested Win32 keyboard scancode code.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 08 Feb 2008 08:35:49 +0000
parents c121d94672cb
children 54e21acfec5a
comparison
equal deleted inserted replaced
2307:47f8a579cd9b 2308:514f7c1651fc
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_win32video.h" 24 #include "SDL_win32video.h"
25 25
26 #include "../../events/SDL_keyboard_c.h" 26 #include "../../events/SDL_keyboard_c.h"
27 #include "../../events/scancodes_win32.h"
27 28
28 void 29 void
29 WIN_InitKeyboard(_THIS) 30 WIN_InitKeyboard(_THIS)
30 { 31 {
31 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; 32 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
32 SDL_Keyboard keyboard; 33 SDL_Keyboard keyboard;
33 34
35 data->key_layout = win32_scancode_table;
36
34 SDL_zero(keyboard); 37 SDL_zero(keyboard);
35 data->keyboard = SDL_AddKeyboard(&keyboard, -1); 38 data->keyboard = SDL_AddKeyboard(&keyboard, -1);
39 WIN_UpdateKeymap(_this);
40
41 SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
42 SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
43 SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
44 }
45
46 void
47 WIN_UpdateKeymap(_THIS)
48 {
49 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
50 int i;
51 SDL_scancode scancode;
52 SDLKey keymap[SDL_NUM_SCANCODES];
53
54 SDL_GetDefaultKeymap(keymap);
55
56 for (i = 0; i < SDL_arraysize(win32_scancode_table); i++) {
57
58 /* Make sure this scancode is a valid character scancode */
59 scancode = win32_scancode_table[i];
60 if (scancode == SDL_SCANCODE_UNKNOWN ||
61 (keymap[scancode] & SDLK_SCANCODE_MASK)) {
62 continue;
63 }
64 #ifndef MAPVK_VK_TO_CHAR
65 #define MAPVK_VK_TO_CHAR 2
66 #endif
67 keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
68 }
69 SDL_SetKeymap(data->keyboard, 0, keymap, SDL_NUM_SCANCODES);
36 } 70 }
37 71
38 void 72 void
39 WIN_QuitKeyboard(_THIS) 73 WIN_QuitKeyboard(_THIS)
40 { 74 {