From c2eea4bde05856d630e935f26d39b1d8ae862514 Mon Sep 17 00:00:00 2001 From: Eric Rybicki Date: Mon, 18 May 2020 14:47:54 +0200 Subject: [PATCH] Fix certain characters being recognized as special keys in Windows when using the us international layout (cherry picked from commit e460456e60b5129f89b4647d8bbb9c71a294c1ca) --- platform/windows/key_mapping_windows.cpp | 13 +++++++++++++ platform/windows/key_mapping_windows.h | 1 + platform/windows/os_windows.cpp | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index 6bf8a70d0f3..58daa220aea 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -251,3 +251,16 @@ unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) { return KEY_UNKNOWN; } + +bool KeyMappingWindows::is_extended_key(unsigned int p_code) { + return p_code == VK_INSERT || + p_code == VK_DELETE || + p_code == VK_HOME || + p_code == VK_END || + p_code == VK_PRIOR || + p_code == VK_NEXT || + p_code == VK_LEFT || + p_code == VK_UP || + p_code == VK_RIGHT || + p_code == VK_DOWN; +} diff --git a/platform/windows/key_mapping_windows.h b/platform/windows/key_mapping_windows.h index 0f9bdecde1e..5f2ea68ef25 100644 --- a/platform/windows/key_mapping_windows.h +++ b/platform/windows/key_mapping_windows.h @@ -43,6 +43,7 @@ class KeyMappingWindows { public: static unsigned int get_keysym(unsigned int p_code); + static bool is_extended_key(unsigned int p_code); }; #endif // KEY_MAPPING_WINDOWS_H diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 3eb953ecd04..eca5be4e498 100755 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1216,7 +1216,8 @@ void OS_Windows::process_key_events() { switch (ke.uMsg) { case WM_CHAR: { - if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) { + // extended keys should only be processed as WM_KEYDOWN message. + if (!KeyMappingWindows::is_extended_key(ke.wParam) && ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR))) { Ref k; k.instance();