diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2018-04-05 20:59:35 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2020-02-25 12:30:33 +0200 |
commit | 1af06d3d4608b17c74caed951cd9579ccbba229d (patch) | |
tree | a0d57c6cd3c00614a5a30290085e91a6097e78b6 /platform/osx/os_osx.mm | |
parent | 376a8255a9b65b016fcd81634bfd54fb7fa029df (diff) |
Rename `scancode` to `keycode`.
Add `physical_keycode` (keyboard layout independent keycodes) to InputEventKey and InputMap.
Fix non-latin keyboard layout keycodes on Linux/X11 (fallback to physical keycodes).
Diffstat (limited to 'platform/osx/os_osx.mm')
-rw-r--r-- | platform/osx/os_osx.mm | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f2e5f9369c..952360c6aa 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -157,7 +157,8 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) { get_key_modifier_state([event modifierFlags], k); k->set_pressed(true); - k->set_scancode(KEY_PERIOD); + k->set_keycode(KEY_PERIOD); + k->set_physical_keycode(KEY_PERIOD); k->set_echo([event isARepeat]); OS_OSX::singleton->push_input(k); @@ -635,7 +636,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; ke.pressed = true; ke.echo = false; ke.raw = false; // IME input event - ke.scancode = 0; + ke.keycode = 0; + ke.physical_keycode = 0; ke.unicode = codepoint; push_to_key_event_buffer(ke); @@ -1158,7 +1160,8 @@ static int remapKey(unsigned int key, unsigned int state) { ke.osx_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.scancode = remapKey([event keyCode], [event modifierFlags]); + ke.keycode = remapKey([event keyCode], [event modifierFlags]); + ke.physical_keycode = translateKey([event keyCode]); ke.raw = true; ke.unicode = [characters characterAtIndex:i]; @@ -1170,7 +1173,8 @@ static int remapKey(unsigned int key, unsigned int state) { ke.osx_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.scancode = remapKey([event keyCode], [event modifierFlags]); + ke.keycode = remapKey([event keyCode], [event modifierFlags]); + ke.physical_keycode = translateKey([event keyCode]); ke.raw = false; ke.unicode = 0; @@ -1228,7 +1232,8 @@ static int remapKey(unsigned int key, unsigned int state) { } ke.osx_state = mod; - ke.scancode = remapKey(key, mod); + ke.keycode = remapKey(key, mod); + ke.physical_keycode = translateKey(key); ke.unicode = 0; push_to_key_event_buffer(ke); @@ -1250,7 +1255,8 @@ static int remapKey(unsigned int key, unsigned int state) { ke.osx_state = [event modifierFlags]; ke.pressed = false; ke.echo = [event isARepeat]; - ke.scancode = remapKey([event keyCode], [event modifierFlags]); + ke.keycode = remapKey([event keyCode], [event modifierFlags]); + ke.physical_keycode = translateKey([event keyCode]); ke.raw = true; ke.unicode = [characters characterAtIndex:i]; @@ -1262,7 +1268,8 @@ static int remapKey(unsigned int key, unsigned int state) { ke.osx_state = [event modifierFlags]; ke.pressed = false; ke.echo = [event isARepeat]; - ke.scancode = remapKey([event keyCode], [event modifierFlags]); + ke.keycode = remapKey([event keyCode], [event modifierFlags]); + ke.physical_keycode = translateKey([event keyCode]); ke.raw = true; ke.unicode = 0; @@ -2845,32 +2852,35 @@ void OS_OSX::process_key_events() { get_key_modifier_state(ke.osx_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); - k->set_scancode(ke.scancode); + k->set_keycode(ke.keycode); + k->set_physical_keycode(ke.physical_keycode); k->set_unicode(ke.unicode); push_input(k); } else { // IME input - if ((i == 0 && ke.scancode == 0) || (i > 0 && key_event_buffer[i - 1].scancode == 0)) { + if ((i == 0 && ke.keycode == 0) || (i > 0 && key_event_buffer[i - 1].keycode == 0)) { k.instance(); get_key_modifier_state(ke.osx_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); - k->set_scancode(0); + k->set_keycode(0); + k->set_physical_keycode(0); k->set_unicode(ke.unicode); push_input(k); } - if (ke.scancode != 0) { + if (ke.keycode != 0) { k.instance(); get_key_modifier_state(ke.osx_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); - k->set_scancode(ke.scancode); + k->set_keycode(ke.keycode); + k->set_physical_keycode(ke.physical_keycode); - if (i + 1 < key_event_pos && key_event_buffer[i + 1].scancode == 0) { + if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) { k->set_unicode(key_event_buffer[i + 1].unicode); } |