From 9bac42e973cef4a5d4c18c8be56d817c395f66ab Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sun, 5 May 2013 10:27:14 -0400 Subject: [PATCH] WinRT: added additional, optional code to aid with keyboard event debugging --- src/video/windowsrt/SDL_WinRTApp.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/video/windowsrt/SDL_WinRTApp.cpp b/src/video/windowsrt/SDL_WinRTApp.cpp index a7461e3b2..8fa12b3fb 100644 --- a/src/video/windowsrt/SDL_WinRTApp.cpp +++ b/src/video/windowsrt/SDL_WinRTApp.cpp @@ -749,8 +749,10 @@ TranslateKeycode(int keycode) void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) { + SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey); #if 0 - SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, scan code=%d, was down?=%s, vkey=%d\n", + SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode); + SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n", (args->Handled ? "1" : "0"), (args->KeyStatus.IsExtendedKey ? "1" : "0"), (args->KeyStatus.IsKeyReleased ? "1" : "0"), @@ -758,17 +760,23 @@ void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI: args->KeyStatus.RepeatCount, args->KeyStatus.ScanCode, (args->KeyStatus.WasKeyDown ? "1" : "0"), - args->VirtualKey); + args->VirtualKey, + sdlScancode, + SDL_GetScancodeName(sdlScancode), + keycode, + SDL_GetKeyName(keycode)); //args->Handled = true; //VirtualKey vkey = args->VirtualKey; #endif - SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode((int)args->VirtualKey)); + SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode); } void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) { + SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey); #if 0 - SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, scan code=%d, was down?=%s, vkey=%d\n", + SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode); + SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n", (args->Handled ? "1" : "0"), (args->KeyStatus.IsExtendedKey ? "1" : "0"), (args->KeyStatus.IsKeyReleased ? "1" : "0"), @@ -776,10 +784,14 @@ void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::C args->KeyStatus.RepeatCount, args->KeyStatus.ScanCode, (args->KeyStatus.WasKeyDown ? "1" : "0"), - args->VirtualKey); + args->VirtualKey, + sdlScancode, + SDL_GetScancodeName(sdlScancode), + keycode, + SDL_GetKeyName(keycode)); //args->Handled = true; #endif - SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode((int)args->VirtualKey)); + SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode); } void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)