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 <raulsntos@gmail.com>
This commit is contained in:
bruvzg 2022-12-11 01:21:22 +02:00
parent 9937915ad7
commit daad4aed62
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
61 changed files with 4464 additions and 3655 deletions

View file

@ -56,7 +56,7 @@ void AndroidInputHandler::_set_key_modifier_state(Ref<InputEventWithModifiers> 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);