Skip to content

Commit

Permalink
Fix incorrect Unicode key mapping on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
buresu committed Jan 1, 2025
1 parent 2582793 commit 8c73194
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5787,7 +5787,12 @@ void DisplayServerWindows::_process_key_events() {
if (!(ke.lParam & (1 << 24)) && ToUnicodeEx(extended_code, (ke.lParam >> 16) & 0xFF, keyboard_state, chars, 255, 4, GetKeyboardLayout(0)) > 0) {
String keysym = String::utf16((char16_t *)chars, 255);
if (!keysym.is_empty()) {
key_label = fix_key_label(keysym[0], keycode);
char32_t unicode_value = keysym[0];
// For printable ASCII characters (0x20-0x7E), override the original keycode with the character value.
if (Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
keycode = fix_keycode(unicode_value, (Key)unicode_value);
}
key_label = fix_key_label(unicode_value, keycode);
}
}

Expand Down Expand Up @@ -5843,7 +5848,12 @@ void DisplayServerWindows::_process_key_events() {
if (!(ke.lParam & (1 << 24)) && ToUnicodeEx(extended_code, (ke.lParam >> 16) & 0xFF, keyboard_state, chars, 255, 4, GetKeyboardLayout(0)) > 0) {
String keysym = String::utf16((char16_t *)chars, 255);
if (!keysym.is_empty()) {
key_label = fix_key_label(keysym[0], keycode);
char32_t unicode_value = keysym[0];
// For printable ASCII characters (0x20-0x7E), override the original keycode with the character value.
if (Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
keycode = fix_keycode(unicode_value, (Key)unicode_value);
}
key_label = fix_key_label(unicode_value, keycode);
}
}

Expand Down

0 comments on commit 8c73194

Please sign in to comment.