Merge pull request #38820 from ericrybick/master

Fix certain characters being recognized as special keys on Windows when using the us international layout
This commit is contained in:
Rémi Verschelde 2020-05-18 16:33:18 +02:00 committed by GitHub
commit 9844cd45e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View file

@ -2658,7 +2658,8 @@ void DisplayServerWindows::_process_key_events() {
KeyEvent &ke = key_event_buffer[i]; KeyEvent &ke = key_event_buffer[i];
switch (ke.uMsg) { switch (ke.uMsg) {
case WM_CHAR: { 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<InputEventKey> k; Ref<InputEventKey> k;
k.instance(); k.instance();

View file

@ -411,3 +411,16 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended
return keycode; return keycode;
} }
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;
}

View file

@ -43,6 +43,7 @@ class KeyMappingWindows {
public: public:
static unsigned int get_keysym(unsigned int p_code); static unsigned int get_keysym(unsigned int p_code);
static unsigned int get_scansym(unsigned int p_code, bool p_extended); static unsigned int get_scansym(unsigned int p_code, bool p_extended);
static bool is_extended_key(unsigned int p_code);
}; };
#endif // KEY_MAPPING_WINDOWS_H #endif // KEY_MAPPING_WINDOWS_H