WinRT: fallback to scancode key detection, if VirtualKey/VK detection fails
authorDavid Ludwig <dludwig@pobox.com>
Sat, 25 Oct 2014 08:50:41 -0400
changeset 9191 7a728256c5f5
parent 9190 ff12797f287b
child 9192 50b888469010
WinRT: fallback to scancode key detection, if VirtualKey/VK detection fails
src/video/winrt/SDL_winrtkeyboard.cpp
--- a/src/video/winrt/SDL_winrtkeyboard.cpp	Sat Oct 25 08:43:51 2014 -0400
+++ b/src/video/winrt/SDL_winrtkeyboard.cpp	Sat Oct 25 08:50:41 2014 -0400
@@ -292,6 +292,7 @@
     /* 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];
@@ -300,6 +301,11 @@
         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);
     }
     return scancode;