src/video/win32/SDL_win32keyboard.c
changeset 4465 3e69e077cb95
parent 3697 f7b03b6838cb
child 4561 e4b2b7207f79
child 4747 5284a3b3217a
equal deleted inserted replaced
4464:fa77a6429698 4465:3e69e077cb95
    48 
    48 
    49 void
    49 void
    50 WIN_InitKeyboard(_THIS)
    50 WIN_InitKeyboard(_THIS)
    51 {
    51 {
    52     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    52     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    53     SDL_Keyboard keyboard;
       
    54     int i;
    53     int i;
    55 
    54 
    56     /* Make sure the alpha scancodes are correct.  T isn't usually remapped */
    55     /* Make sure the alpha scancodes are correct.  T isn't usually remapped */
    57     if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
    56     if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
    58 #if 0
    57 #if 0
    80         }
    79         }
    81     }
    80     }
    82 
    81 
    83     data->key_layout = win32_scancode_table;
    82     data->key_layout = win32_scancode_table;
    84 
    83 
    85     SDL_zero(keyboard);
    84     WIN_UpdateKeymap();
    86     data->keyboard = SDL_AddKeyboard(&keyboard, -1);
       
    87     WIN_UpdateKeymap(data->keyboard);
       
    88 
    85 
    89     SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
    86     SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu");
    90     SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
    87     SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows");
    91     SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
    88     SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows");
    92 }
    89 }
    93 
    90 
    94 void
    91 void
    95 WIN_UpdateKeymap(int keyboard)
    92 WIN_UpdateKeymap()
    96 {
    93 {
    97     int i;
    94     int i;
    98     SDL_scancode scancode;
    95     SDL_scancode scancode;
    99     SDLKey keymap[SDL_NUM_SCANCODES];
    96     SDLKey keymap[SDL_NUM_SCANCODES];
   100 
    97 
   115             keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
   112             keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
   116         } else {
   113         } else {
   117             keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
   114             keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
   118         }
   115         }
   119     }
   116     }
   120     SDL_SetKeymap(keyboard, 0, keymap, SDL_NUM_SCANCODES);
   117     SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
   121 }
   118 }
   122 
   119 
   123 void
   120 void
   124 WIN_QuitKeyboard(_THIS)
   121 WIN_QuitKeyboard(_THIS)
   125 {
   122 {
   126     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
       
   127 
       
   128     SDL_DelKeyboard(data->keyboard);
       
   129 }
   123 }
   130 
   124 
   131 /* vi: set ts=4 sw=4 expandtab: */
   125 /* vi: set ts=4 sw=4 expandtab: */