From daad4aed62bfa471421f960179f0ac0fd78e8040 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Sun, 11 Dec 2022 01:21:22 +0200 Subject: Cleanup and unify keyboard input. - Unify keycode values (secondary label printed on a key), remove unused hardcoded Latin-1 codes. - Unify IME behaviour, add inline composition string display on Windows and X11. - Add key_label (localized label printed on a key) value to the key events, and allow mapping actions to the unshifted Unicode events. - Add support for physical keyboard (Bluetooth or Sidecar) handling on iOS. - Add support for media key handling on macOS. Co-authored-by: Raul Santos --- platform/android/android_input_handler.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'platform/android/android_input_handler.cpp') diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index e3f93086dc..277195a054 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -56,7 +56,7 @@ void AndroidInputHandler::_set_key_modifier_state(Ref e ev->set_ctrl_pressed(control_mem); } -void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycode, int p_unicode, bool p_pressed) { +void AndroidInputHandler::process_key_event(int p_physical_keycode, int p_unicode, int p_key_label, bool p_pressed) { static char32_t prev_wc = 0; char32_t unicode = p_unicode; if ((p_unicode & 0xfffffc00) == 0xd800) { @@ -80,10 +80,7 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycod ev.instantiate(); Key physical_keycode = godot_code_from_android_code(p_physical_keycode); - Key keycode = physical_keycode; - if (p_keycode != 0) { - keycode = godot_code_from_unicode(p_keycode); - } + Key keycode = fix_keycode(unicode, physical_keycode); switch (physical_keycode) { case Key::SHIFT: { @@ -104,7 +101,8 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycod ev->set_keycode(keycode); ev->set_physical_keycode(physical_keycode); - ev->set_unicode(unicode); + ev->set_key_label(fix_key_label(p_key_label, keycode)); + ev->set_unicode(fix_unicode(unicode)); ev->set_pressed(p_pressed); _set_key_modifier_state(ev); -- cgit v1.2.3