Skip to content

Commit

Permalink
Fix certain characters being recognized as special keys in Windows wh…
Browse files Browse the repository at this point in the history
…en using the us international layout

(cherry picked from commit e460456)
  • Loading branch information
ericrybick authored and akien-mga committed May 19, 2020
1 parent 75f6d2e commit c2eea4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions platform/windows/key_mapping_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions platform/windows/key_mapping_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputEventKey> k;
k.instance();

Expand Down

0 comments on commit c2eea4b

Please sign in to comment.