Skip to content

Commit ca3e268

Browse files
committed
Merge pull request godotengine#101754 from bruvzg/vk_oem_only
[Windows] Override key codes with Unicode values for OEM keys only.
2 parents 0b6a717 + d65c07d commit ca3e268

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

platform/windows/display_server_windows.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5887,7 +5887,9 @@ void DisplayServerWindows::_process_key_events() {
58875887
Ref<InputEventKey> k;
58885888
k.instantiate();
58895889

5890-
Key keycode = KeyMappingWindows::get_keysym(MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK));
5890+
UINT vk = MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK);
5891+
bool is_oem = (vk >= 0xB8) && (vk <= 0xE6);
5892+
Key keycode = KeyMappingWindows::get_keysym(vk);
58915893
Key key_label = keycode;
58925894
Key physical_keycode = KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24));
58935895

@@ -5900,7 +5902,7 @@ void DisplayServerWindows::_process_key_events() {
59005902
if (!keysym.is_empty()) {
59015903
char32_t unicode_value = keysym[0];
59025904
// For printable ASCII characters (0x20-0x7E), override the original keycode with the character value.
5903-
if (Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
5905+
if (is_oem && Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
59045906
keycode = fix_keycode(unicode_value, (Key)unicode_value);
59055907
}
59065908
key_label = fix_key_label(unicode_value, keycode);
@@ -5943,6 +5945,7 @@ void DisplayServerWindows::_process_key_events() {
59435945
k->set_window_id(ke.window_id);
59445946
k->set_pressed(ke.uMsg == WM_KEYDOWN);
59455947

5948+
bool is_oem = (ke.wParam >= 0xB8) && (ke.wParam <= 0xE6);
59465949
Key keycode = KeyMappingWindows::get_keysym(ke.wParam);
59475950
if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) {
59485951
// Special case for Numpad Enter key.
@@ -5961,7 +5964,7 @@ void DisplayServerWindows::_process_key_events() {
59615964
if (!keysym.is_empty()) {
59625965
char32_t unicode_value = keysym[0];
59635966
// For printable ASCII characters (0x20-0x7E), override the original keycode with the character value.
5964-
if (Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
5967+
if (is_oem && Key::SPACE <= (Key)unicode_value && (Key)unicode_value <= Key::ASCIITILDE) {
59655968
keycode = fix_keycode(unicode_value, (Key)unicode_value);
59665969
}
59675970
key_label = fix_key_label(unicode_value, keycode);

0 commit comments

Comments
 (0)