From 32d4e740ce12e28aa7ce488b329a70207de49e53 Mon Sep 17 00:00:00 2001 From: Zoran Vuckovic Date: Tue, 30 May 2017 22:59:31 +0200 Subject: [PATCH] Fix keyboard key translation issue --- gfx/common/win32_common.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 953ca0bf8e..157b9da1e7 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -362,8 +362,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { - unsigned scancode = (lparam >> 16) & 0xff; - unsigned keycode = input_keymaps_translate_keysym_to_rk(scancode); + unsigned keycode; uint16_t mod = 0; bool keydown = true; @@ -398,9 +397,14 @@ static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, if (message == WM_KEYUP || message == WM_SYSKEYUP) keydown = false; - /* DirectInput uses scancodes directly. */ - input_keyboard_event(keydown, keycode, 0, mod, - RETRO_DEVICE_KEYBOARD); +#if _WIN32_WINNT >= 0x0501 + if (string_is_equal_fast(config_get_ptr()->arrays.input_driver, "raw", 4)) + keycode = input_keymaps_translate_keysym_to_rk((unsigned)(wparam)); + else +#endif + keycode = input_keymaps_translate_keysym_to_rk((lparam >> 16) & 0xff); + + input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD); if (message == WM_SYSKEYDOWN) {