You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
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:
@@ -38,41 +38,3 @@ Key godot_code_from_android_code(unsigned int p_code) {
|
||||
}
|
||||
return Key::UNKNOWN;
|
||||
}
|
||||
|
||||
Key godot_code_from_unicode(unsigned int p_code) {
|
||||
unsigned int code = p_code;
|
||||
if (code > 0xFF) {
|
||||
return Key::UNKNOWN;
|
||||
}
|
||||
// Known control codes.
|
||||
if (code == '\b') { // 0x08
|
||||
return Key::BACKSPACE;
|
||||
}
|
||||
if (code == '\t') { // 0x09
|
||||
return Key::TAB;
|
||||
}
|
||||
if (code == '\n') { // 0x0A
|
||||
return Key::ENTER;
|
||||
}
|
||||
if (code == 0x1B) {
|
||||
return Key::ESCAPE;
|
||||
}
|
||||
if (code == 0x1F) {
|
||||
return Key::KEY_DELETE;
|
||||
}
|
||||
// Unknown control codes.
|
||||
if (code <= 0x1F || (code >= 0x80 && code <= 0x9F)) {
|
||||
return Key::UNKNOWN;
|
||||
}
|
||||
// Convert to uppercase.
|
||||
if (code >= 'a' && code <= 'z') { // 0x61 - 0x7A
|
||||
code -= ('a' - 'A');
|
||||
}
|
||||
if (code >= u'à' && code <= u'ö') { // 0xE0 - 0xF6
|
||||
code -= (u'à' - u'À'); // 0xE0 - 0xC0
|
||||
}
|
||||
if (code >= u'ø' && code <= u'þ') { // 0xF8 - 0xFF
|
||||
code -= (u'ø' - u'Ø'); // 0xF8 - 0xD8
|
||||
}
|
||||
return Key(code);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user