WinRT: made use of Win32 key codes if and when a documented WinRT key code can't be found

This commit is contained in:
David Ludwig 2013-01-23 08:44:12 -05:00
parent 37f50a4f25
commit fe5d1f4c32

View file

@ -8,6 +8,7 @@ extern "C" {
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_windowevents_c.h"
#include "../../events/scancodes_windows.h"
#include "SDL_events.h"
#include "SDL_log.h"
}
@ -462,10 +463,20 @@ static SDL_Scancode WinRT_Keycodes[] = {
static SDL_Scancode
TranslateKeycode(int keycode)
{
/* Try to get a documented, WinRT, 'VirtualKey' first (as documented at
http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ).
If that fails, try to get a Win32 virtual key.
*/
// TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
if (keycode < SDL_arraysize(WinRT_Keycodes)) {
scancode = WinRT_Keycodes[keycode];
}
if (scancode == SDL_SCANCODE_UNKNOWN) {
if (keycode < SDL_arraysize(windows_scancode_table)) {
scancode = windows_scancode_table[keycode];
}
}
if (scancode == SDL_SCANCODE_UNKNOWN) {
SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
}