diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/display_server_android.cpp | 4 | ||||
-rw-r--r-- | platform/iphone/display_server_iphone.h | 2 | ||||
-rw-r--r-- | platform/iphone/display_server_iphone.mm | 2 | ||||
-rw-r--r-- | platform/iphone/keyboard_input_view.mm | 4 | ||||
-rw-r--r-- | platform/javascript/display_server_javascript.cpp | 2 | ||||
-rw-r--r-- | platform/javascript/dom_keys.inc | 8 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 18 | ||||
-rw-r--r-- | platform/linuxbsd/key_mapping_x11.cpp | 16 | ||||
-rw-r--r-- | platform/linuxbsd/key_mapping_x11.h | 4 | ||||
-rw-r--r-- | platform/osx/display_server_osx.h | 2 | ||||
-rw-r--r-- | platform/osx/display_server_osx.mm | 18 | ||||
-rw-r--r-- | platform/uwp/os_uwp.cpp | 2 | ||||
-rw-r--r-- | platform/uwp/os_uwp.h | 2 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 8 | ||||
-rw-r--r-- | platform/windows/key_mapping_windows.cpp | 4 |
15 files changed, 50 insertions, 46 deletions
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index af8829324b..d200d024c5 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -538,8 +538,8 @@ void DisplayServerAndroid::process_key_event(int p_keycode, int p_scancode, int meta_mem = p_pressed; } - ev->set_keycode(keycode); - ev->set_physical_keycode(phy_keycode); + ev->set_keycode((Key)keycode); + ev->set_physical_keycode((Key)phy_keycode); ev->set_unicode(val); ev->set_pressed(p_pressed); diff --git a/platform/iphone/display_server_iphone.h b/platform/iphone/display_server_iphone.h index 8ba7a69a4f..cd2de550f1 100644 --- a/platform/iphone/display_server_iphone.h +++ b/platform/iphone/display_server_iphone.h @@ -105,7 +105,7 @@ public: // MARK: Keyboard - void key(uint32_t p_key, bool p_pressed); + void key(Key p_key, bool p_pressed); // MARK: Motion diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index b4f0a32027..e18448fb6d 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -254,7 +254,7 @@ void DisplayServerIPhone::touches_cancelled(int p_idx) { // MARK: Keyboard -void DisplayServerIPhone::key(uint32_t p_key, bool p_pressed) { +void DisplayServerIPhone::key(Key p_key, bool p_pressed) { Ref<InputEventKey> ev; ev.instantiate(); ev->set_echo(false); diff --git a/platform/iphone/keyboard_input_view.mm b/platform/iphone/keyboard_input_view.mm index 0e5a98a3e6..e2bd0acff4 100644 --- a/platform/iphone/keyboard_input_view.mm +++ b/platform/iphone/keyboard_input_view.mm @@ -138,8 +138,8 @@ break; } - DisplayServerIPhone::get_singleton()->key(character, true); - DisplayServerIPhone::get_singleton()->key(character, false); + DisplayServerIPhone::get_singleton()->key((Key)character, true); + DisplayServerIPhone::get_singleton()->key((Key)character, false); } } diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index 8df81bb8cc..fda18a5c19 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -172,7 +172,7 @@ EM_BOOL DisplayServerJavaScript::keyup_callback(int p_event_type, const Emscript Ref<InputEventKey> ev = setup_key_event(p_event); ev->set_pressed(false); Input::get_singleton()->parse_input_event(ev); - return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != 0; + return ev->get_keycode() != KEY_UNKNOWN && ev->get_keycode() != (Key)0; } // Mouse diff --git a/platform/javascript/dom_keys.inc b/platform/javascript/dom_keys.inc index 69340ff58c..0e62776923 100644 --- a/platform/javascript/dom_keys.inc +++ b/platform/javascript/dom_keys.inc @@ -31,7 +31,7 @@ #include "core/os/keyboard.h" // See https://w3c.github.io/uievents-code/#code-value-tables -int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) { +Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) { #define DOM2GODOT(p_str, p_godot_code) \ if (memcmp((const void *)p_str, (void *)p_code, strlen(p_str) + 1) == 0) { \ return KEY_##p_godot_code; \ @@ -79,7 +79,7 @@ int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b if (b0 > 0x60 && b0 < 0x7B) { // Lowercase ASCII. b0 -= 32; } - return b0; + return (Key)b0; } #define _U_2BYTES_MASK 0xE0 @@ -88,11 +88,11 @@ int dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b if (b2 == 0 && (b0 & _U_2BYTES_MASK) == _U_2BYTES) { // 2-bytes utf8, only known latin. uint32_t key = ((b0 & ~_U_2BYTES_MASK) << 6) | (b1 & 0x3F); if (key >= 0xA0 && key <= 0xDF) { - return key; + return (Key)key; } if (key >= 0xE0 && key <= 0xFF) { // Lowercase known latin. key -= 0x20; - return key; + return (Key)key; } } #undef _U_2BYTES_MASK diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 4a32dd9646..5b26b23806 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -2207,7 +2207,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, if (status == XLookupChars) { bool keypress = xkeyevent->type == KeyPress; - unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode); + Key keycode = KeyMappingX11::get_keycode(keysym_keycode); unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); if (keycode >= 'a' && keycode <= 'z') { @@ -2224,7 +2224,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, } if (keycode == 0) { - keycode = physical_keycode; + keycode = (Key)physical_keycode; } _get_key_modifier_state(xkeyevent->state, k); @@ -2236,7 +2236,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_keycode(keycode); - k->set_physical_keycode(physical_keycode); + k->set_physical_keycode((Key)physical_keycode); k->set_echo(false); @@ -2271,7 +2271,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // KeyMappingX11 just translated the X11 keysym to a PIGUI // keysym, so it works in all platforms the same. - unsigned int keycode = KeyMappingX11::get_keycode(keysym_keycode); + Key keycode = KeyMappingX11::get_keycode(keysym_keycode); unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); /* Phase 3, obtain a unicode character from the keysym */ @@ -2292,12 +2292,12 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, bool keypress = xkeyevent->type == KeyPress; - if (physical_keycode == 0 && keycode == 0 && unicode == 0) { + if (physical_keycode == 0 && keycode == KEY_NONE && unicode == 0) { return; } - if (keycode == 0) { - keycode = physical_keycode; + if (keycode == KEY_NONE) { + keycode = (Key)physical_keycode; } /* Phase 5, determine modifier mask */ @@ -2360,11 +2360,11 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_pressed(keypress); if (keycode >= 'a' && keycode <= 'z') { - keycode -= 'a' - 'A'; + keycode -= int('a' - 'A'); } k->set_keycode(keycode); - k->set_physical_keycode(physical_keycode); + k->set_physical_keycode((Key)physical_keycode); k->set_unicode(unicode); k->set_echo(p_echo); diff --git a/platform/linuxbsd/key_mapping_x11.cpp b/platform/linuxbsd/key_mapping_x11.cpp index 74257a7e61..a1ef28234d 100644 --- a/platform/linuxbsd/key_mapping_x11.cpp +++ b/platform/linuxbsd/key_mapping_x11.cpp @@ -34,7 +34,7 @@ struct _XTranslatePair { KeySym keysym; - unsigned int keycode; + Key keycode; }; static _XTranslatePair _xkeysym_to_keycode[] = { @@ -176,7 +176,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = { { XF86XK_LaunchC, KEY_LAUNCHE }, { XF86XK_LaunchD, KEY_LAUNCHF }, - { 0, 0 } + { 0, KEY_NONE } }; struct _TranslatePair { @@ -309,11 +309,11 @@ unsigned int KeyMappingX11::get_scancode(unsigned int p_code) { return keycode; } -unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) { +Key KeyMappingX11::get_keycode(KeySym p_keysym) { // kinda bruteforce.. could optimize. if (p_keysym < 0x100) { // Latin 1, maps 1-1 - return p_keysym; + return (Key)p_keysym; } // look for special key @@ -323,14 +323,14 @@ unsigned int KeyMappingX11::get_keycode(KeySym p_keysym) { } } - return 0; + return KEY_NONE; } -KeySym KeyMappingX11::get_keysym(unsigned int p_code) { +KeySym KeyMappingX11::get_keysym(Key p_code) { // kinda bruteforce.. could optimize. if (p_code < 0x100) { // Latin 1, maps 1-1 - return p_code; + return (KeySym)p_code; } // look for special key @@ -340,7 +340,7 @@ KeySym KeyMappingX11::get_keysym(unsigned int p_code) { } } - return 0; + return (KeySym)KEY_NONE; } /***** UNICODE CONVERSION ******/ diff --git a/platform/linuxbsd/key_mapping_x11.h b/platform/linuxbsd/key_mapping_x11.h index 163a8e21db..598db1c45a 100644 --- a/platform/linuxbsd/key_mapping_x11.h +++ b/platform/linuxbsd/key_mapping_x11.h @@ -44,9 +44,9 @@ class KeyMappingX11 { KeyMappingX11() {} public: - static unsigned int get_keycode(KeySym p_keysym); + static Key get_keycode(KeySym p_keysym); static unsigned int get_scancode(unsigned int p_code); - static KeySym get_keysym(unsigned int p_code); + static KeySym get_keysym(Key p_code); static unsigned int get_unicode_from_keysym(KeySym p_keysym); static KeySym get_keysym_from_unicode(unsigned int p_unicode); }; diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index 6b1b777224..06b14f1c14 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -85,7 +85,7 @@ public: bool pressed = false; bool echo = false; bool raw = false; - uint32_t keycode = 0; + Key keycode = KEY_NONE; uint32_t physical_keycode = 0; uint32_t unicode = 0; }; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 974f4d3018..cc8400980a 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -585,7 +585,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; ke.pressed = true; ke.echo = false; ke.raw = false; // IME input event - ke.keycode = 0; + ke.keycode = KEY_NONE; ke.physical_keycode = 0; ke.unicode = codepoint; @@ -928,9 +928,9 @@ static bool isNumpadKey(unsigned int key) { // Translates a OS X keycode to a Godot keycode // -static int translateKey(unsigned int key) { +static Key translateKey(unsigned int key) { // Keyboard symbol translation table - static const unsigned int table[128] = { + static const Key table[128] = { /* 00 */ KEY_A, /* 01 */ KEY_S, /* 02 */ KEY_D, @@ -1070,7 +1070,7 @@ static int translateKey(unsigned int key) { struct _KeyCodeMap { UniChar kchar; - int kcode; + Key kcode; }; static const _KeyCodeMap _keycodes[55] = { @@ -1131,7 +1131,7 @@ static const _KeyCodeMap _keycodes[55] = { { '/', KEY_SLASH } }; -static int remapKey(unsigned int key, unsigned int state) { +static Key remapKey(unsigned int key, unsigned int state) { if (isNumpadKey(key)) { return translateKey(key); } @@ -3271,7 +3271,7 @@ void DisplayServerOSX::_process_key_events() { k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); - k->set_physical_keycode(ke.physical_keycode); + k->set_physical_keycode((Key)ke.physical_keycode); k->set_unicode(ke.unicode); _push_input(k); @@ -3284,8 +3284,8 @@ void DisplayServerOSX::_process_key_events() { _get_key_modifier_state(ke.osx_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); - k->set_keycode(0); - k->set_physical_keycode(0); + k->set_keycode(KEY_NONE); + k->set_physical_keycode(KEY_NONE); k->set_unicode(ke.unicode); _push_input(k); @@ -3298,7 +3298,7 @@ void DisplayServerOSX::_process_key_events() { k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); - k->set_physical_keycode(ke.physical_keycode); + k->set_physical_keycode((Key)ke.physical_keycode); if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) { k->set_unicode(key_event_buffer[i + 1].unicode); diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index e26e204f5f..6ac5b55156 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -566,7 +566,7 @@ void OS_UWP::process_key_events() { key_event->set_ctrl_pressed(kev.control); key_event->set_echo(kev.echo); key_event->set_keycode(kev.keycode); - key_event->set_physical_keycode(kev.physical_keycode); + key_event->set_physical_keycode((Key)kev.physical_keycode); key_event->set_unicode(kev.unicode); key_event->set_pressed(kev.pressed); diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 3a735889b0..c9b2600c8e 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -58,7 +58,7 @@ public: bool alt = false, shift = false, control = false; MessageType type = KEY_EVENT_MESSAGE; bool pressed = false; - unsigned int keycode = 0; + Key keycode = KEY_NONE; unsigned int physical_keycode = 0; unsigned int unicode = 0; bool echo = false; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4be95487b8..42a517879b 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -2855,8 +2855,8 @@ void DisplayServerWindows::_process_key_events() { k->set_ctrl_pressed(ke.control); k->set_meta_pressed(ke.meta); k->set_pressed(true); - k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam)); - k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24))); + k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam)); + k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)))); k->set_unicode(unicode); if (k->get_unicode() && gr_mem) { k->set_alt_pressed(false); @@ -2888,10 +2888,10 @@ void DisplayServerWindows::_process_key_events() { // Special case for Numpad Enter key k->set_keycode(KEY_KP_ENTER); } else { - k->set_keycode(KeyMappingWindows::get_keysym(ke.wParam)); + k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam)); } - k->set_physical_keycode(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24))); + k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)))); if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) { char32_t unicode = key_event_buffer[i + 1].wParam; diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index c367c69826..db99d6c122 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -365,6 +365,8 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended case KEY_CAPSLOCK: { keycode = KEY_KP_ADD; } break; + default: + break; } } else { switch (keycode) { @@ -404,6 +406,8 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended case KEY_PRINT: { keycode = KEY_KP_MULTIPLY; } break; + default: + break; } } |