From ed2fff6bef778d1627ef4efd56fc0c5732a747ca Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sat, 25 Oct 2014 08:50:41 -0400 Subject: [PATCH] WinRT: fallback to scancode key detection, if VirtualKey/VK detection fails --- src/video/winrt/SDL_winrtkeyboard.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/video/winrt/SDL_winrtkeyboard.cpp b/src/video/winrt/SDL_winrtkeyboard.cpp index bcf4b73d0e410..7e7049e99d354 100644 --- a/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/src/video/winrt/SDL_winrtkeyboard.cpp @@ -292,6 +292,7 @@ TranslateKeycode(int keycode, unsigned int nativeScancode) /* Try to get a documented, WinRT, 'VirtualKey' next (as documented at http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ). If that fails, fall back to a Win32 virtual key. + If that fails, attempt to fall back to a scancode-derived key. */ if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) { scancode = WinRT_Official_Keycodes[keycode]; @@ -299,6 +300,11 @@ TranslateKeycode(int keycode, unsigned int nativeScancode) if (scancode == SDL_SCANCODE_UNKNOWN) { scancode = WINRT_TranslateUnofficialKeycode(keycode); } + if (scancode == SDL_SCANCODE_UNKNOWN) { + if (nativeScancode < SDL_arraysize(windows_scancode_table)) { + scancode = windows_scancode_table[nativeScancode]; + } + } if (scancode == SDL_SCANCODE_UNKNOWN) { SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode); }