diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/core_constants.cpp | 80 | ||||
-rw-r--r-- | core/input/input.cpp | 14 | ||||
-rw-r--r-- | core/input/input.h | 2 | ||||
-rw-r--r-- | core/input/input_event.cpp | 115 | ||||
-rw-r--r-- | core/input/input_event.h | 8 | ||||
-rw-r--r-- | core/io/marshalls.h | 2 | ||||
-rw-r--r-- | core/math/a_star.cpp | 26 | ||||
-rw-r--r-- | core/math/a_star.h | 2 | ||||
-rw-r--r-- | core/math/a_star_grid_2d.cpp | 2 | ||||
-rw-r--r-- | core/math/bvh_abb.h | 2 | ||||
-rw-r--r-- | core/math/bvh_split.inc | 8 | ||||
-rw-r--r-- | core/math/color.cpp | 2 | ||||
-rw-r--r-- | core/math/expression.cpp | 9 | ||||
-rw-r--r-- | core/os/keyboard.cpp | 119 | ||||
-rw-r--r-- | core/os/keyboard.h | 87 | ||||
-rw-r--r-- | core/variant/variant_call.cpp | 2 |
16 files changed, 203 insertions, 277 deletions
diff --git a/core/core_constants.cpp b/core/core_constants.cpp index edb72f73cb..e28f7bfc4f 100644 --- a/core/core_constants.cpp +++ b/core/core_constants.cpp @@ -274,14 +274,9 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_7); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_8); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KP_9); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SUPER_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SUPER_R); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MENU); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER_R); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPER); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HELP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIRECTION_L); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIRECTION_R); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BACK); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, FORWARD); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, STOP); @@ -289,11 +284,6 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEDOWN); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEMUTE); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, VOLUMEUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSBOOST); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BASSDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TREBLEUP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TREBLEDOWN); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIAPLAY); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIASTOP); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MEDIAPREVIOUS); @@ -392,72 +382,12 @@ void register_global_constants() { BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BAR); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BRACERIGHT); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ASCIITILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NOBREAKSPACE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EXCLAMDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CENT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, STERLING); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CURRENCY); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YEN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, BROKENBAR); BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SECTION); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, COPYRIGHT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ORDFEMININE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GUILLEMOTLEFT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NOTSIGN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, HYPHEN); - BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(Key, KEY_REGISTERED, KEY_REGISTERED); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MACRON); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DEGREE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PLUSMINUS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, TWOSUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THREESUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MU); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PARAGRAPH); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, PERIODCENTERED); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CEDILLA); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONESUPERIOR); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MASCULINE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GUILLEMOTRIGHT); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONEQUARTER); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ONEHALF); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THREEQUARTERS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, QUESTIONDOWN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ACIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ATILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ADIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ARING); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, AE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, CCEDILLA); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ECIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, EDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ICIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, IDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ETH); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, NTILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OCIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OTILDE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, ODIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, MULTIPLY); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, OOBLIQUE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UGRAVE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UCIRCUMFLEX); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, UDIAERESIS); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YACUTE); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, THORN); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, SSHARP); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, DIVISION); - BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, YDIAERESIS); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, GLOBE); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, KEYBOARD); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, JIS_EISU); + BIND_CORE_ENUM_CLASS_CONSTANT(Key, KEY, JIS_KANA); BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(KeyModifierMask, KEY_CODE_MASK, CODE_MASK); BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(KeyModifierMask, KEY_MODIFIER_MASK, MODIFIER_MASK); diff --git a/core/input/input.cpp b/core/input/input.cpp index 0afa004515..1ea9f00fee 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -93,6 +93,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("is_anything_pressed"), &Input::is_anything_pressed); ClassDB::bind_method(D_METHOD("is_key_pressed", "keycode"), &Input::is_key_pressed); ClassDB::bind_method(D_METHOD("is_physical_key_pressed", "keycode"), &Input::is_physical_key_pressed); + ClassDB::bind_method(D_METHOD("is_key_label_pressed", "keycode"), &Input::is_key_label_pressed); ClassDB::bind_method(D_METHOD("is_mouse_button_pressed", "button"), &Input::is_mouse_button_pressed); ClassDB::bind_method(D_METHOD("is_joy_button_pressed", "device", "button"), &Input::is_joy_button_pressed); ClassDB::bind_method(D_METHOD("is_action_pressed", "action", "exact_match"), &Input::is_action_pressed, DEFVAL(false)); @@ -250,6 +251,11 @@ bool Input::is_physical_key_pressed(Key p_keycode) const { return physical_keys_pressed.has(p_keycode); } +bool Input::is_key_label_pressed(Key p_keycode) const { + _THREAD_SAFE_METHOD_ + return key_label_pressed.has(p_keycode); +} + bool Input::is_mouse_button_pressed(MouseButton p_button) const { _THREAD_SAFE_METHOD_ return mouse_button_mask.has_flag(mouse_button_to_mask(p_button)); @@ -499,6 +505,13 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em physical_keys_pressed.erase(k->get_physical_keycode()); } } + if (k.is_valid() && !k->is_echo() && k->get_key_label() != Key::NONE) { + if (k->is_pressed()) { + key_label_pressed.insert(k->get_key_label()); + } else { + key_label_pressed.erase(k->get_key_label()); + } + } Ref<InputEventMouseButton> mb = p_event; @@ -919,6 +932,7 @@ void Input::release_pressed_events() { keys_pressed.clear(); physical_keys_pressed.clear(); + key_label_pressed.clear(); joy_buttons_pressed.clear(); _joy_axis.clear(); diff --git a/core/input/input.h b/core/input/input.h index 0915588700..f2de56b6b9 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -84,6 +84,7 @@ public: private: BitField<MouseButtonMask> mouse_button_mask; + RBSet<Key> key_label_pressed; RBSet<Key> physical_keys_pressed; RBSet<Key> keys_pressed; RBSet<JoyButton> joy_buttons_pressed; @@ -247,6 +248,7 @@ public: bool is_anything_pressed() const; bool is_key_pressed(Key p_keycode) const; bool is_physical_key_pressed(Key p_keycode) const; + bool is_key_label_pressed(Key p_keycode) const; bool is_mouse_button_pressed(MouseButton p_button) const; bool is_joy_button_pressed(int p_device, JoyButton p_button) const; bool is_action_pressed(const StringName &p_action, bool p_exact = false) const; diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 0dd7fdc19b..dbe9b55ee3 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -285,6 +285,8 @@ void InputEventWithModifiers::_bind_methods() { ClassDB::bind_method(D_METHOD("set_meta_pressed", "pressed"), &InputEventWithModifiers::set_meta_pressed); ClassDB::bind_method(D_METHOD("is_meta_pressed"), &InputEventWithModifiers::is_meta_pressed); + ClassDB::bind_method(D_METHOD("get_modifiers_mask"), &InputEventWithModifiers::get_modifiers_mask); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command_or_control_autoremap"), "set_command_or_control_autoremap", "is_command_or_control_autoremap"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "alt_pressed"), "set_alt_pressed", "is_alt_pressed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shift_pressed"), "set_shift_pressed", "is_shift_pressed"); @@ -328,6 +330,15 @@ Key InputEventKey::get_keycode() const { return keycode; } +void InputEventKey::set_key_label(Key p_key_label) { + key_label = p_key_label; + emit_changed(); +} + +Key InputEventKey::get_key_label() const { + return key_label; +} + void InputEventKey::set_physical_keycode(Key p_keycode) { physical_keycode = p_keycode; emit_changed(); @@ -363,13 +374,72 @@ Key InputEventKey::get_physical_keycode_with_modifiers() const { return physical_keycode | (int64_t)get_modifiers_mask(); } +Key InputEventKey::get_key_label_with_modifiers() const { + return key_label | get_modifiers_mask(); +} + +String InputEventKey::as_text_physical_keycode() const { + String kc; + + if (physical_keycode != Key::NONE) { + kc = keycode_get_string(physical_keycode); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + +String InputEventKey::as_text_keycode() const { + String kc; + + if (keycode != Key::NONE) { + kc = keycode_get_string(keycode); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + +String InputEventKey::as_text_key_label() const { + String kc; + + if (key_label != Key::NONE) { + kc = keycode_get_string(key_label); + } else { + kc = "(" + RTR("Unset") + ")"; + } + + if (kc.is_empty()) { + return kc; + } + + String mods_text = InputEventWithModifiers::as_text(); + return mods_text.is_empty() ? kc : mods_text + "+" + kc; +} + String InputEventKey::as_text() const { String kc; - if (keycode == Key::NONE) { + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + kc = keycode_get_string(key_label) + " (Unicode)"; + } else if (keycode != Key::NONE) { + kc = keycode_get_string(keycode); + } else if (physical_keycode != Key::NONE) { kc = keycode_get_string(physical_keycode) + " (" + RTR("Physical") + ")"; } else { - kc = keycode_get_string(keycode); + kc = "(" + RTR("Unset") + ")"; } if (kc.is_empty()) { @@ -386,11 +456,16 @@ String InputEventKey::to_string() { String kc = ""; String physical = "false"; - if (keycode == Key::NONE) { + + if (keycode == Key::NONE && physical_keycode == Key::NONE && unicode != 0) { + kc = "U+" + String::num_uint64(unicode, 16) + " (" + String::chr(unicode) + ")"; + } else if (keycode != Key::NONE) { + kc = itos((int64_t)keycode) + " (" + keycode_get_string(keycode) + ")"; + } else if (physical_keycode != Key::NONE) { kc = itos((int64_t)physical_keycode) + " (" + keycode_get_string(physical_keycode) + ")"; physical = "true"; } else { - kc = itos((int64_t)keycode) + " (" + keycode_get_string(keycode) + ")"; + kc = "(" + RTR("Unset") + ")"; } String mods = InputEventWithModifiers::as_text(); @@ -403,6 +478,7 @@ Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode) { Ref<InputEventKey> ie; ie.instantiate(); ie->set_keycode(p_keycode & KeyModifierMask::CODE_MASK); + ie->set_key_label(p_keycode & KeyModifierMask::CODE_MASK); ie->set_unicode(char32_t(p_keycode & KeyModifierMask::CODE_MASK)); if ((p_keycode & KeyModifierMask::SHIFT) != Key::NONE) { @@ -435,11 +511,16 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma } bool match; - if (keycode != Key::NONE) { + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + match = key_label == key->key_label; + } else if (keycode != Key::NONE) { match = keycode == key->keycode; + } else if (physical_keycode != Key::NONE) { + match = physical_keycode == key->physical_keycode; } else { - match = get_physical_keycode() == key->get_physical_keycode(); + match = false; } + Key action_mask = (Key)(int64_t)get_modifiers_mask(); Key key_mask = (Key)(int64_t)key->get_modifiers_mask(); if (key->is_pressed()) { @@ -470,12 +551,17 @@ bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) return false; } - if (keycode == Key::NONE) { - return physical_keycode == key->physical_keycode && + if (keycode == Key::NONE && physical_keycode == Key::NONE && key_label != Key::NONE) { + return (key_label == key->key_label) && (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); - } else { - return keycode == key->keycode && + } else if (keycode != Key::NONE) { + return (keycode == key->keycode) && (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); + } else if (physical_keycode != Key::NONE) { + return (physical_keycode == key->physical_keycode) && + (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); + } else { + return false; } } @@ -488,6 +574,9 @@ void InputEventKey::_bind_methods() { ClassDB::bind_method(D_METHOD("set_physical_keycode", "physical_keycode"), &InputEventKey::set_physical_keycode); ClassDB::bind_method(D_METHOD("get_physical_keycode"), &InputEventKey::get_physical_keycode); + ClassDB::bind_method(D_METHOD("set_key_label", "key_label"), &InputEventKey::set_key_label); + ClassDB::bind_method(D_METHOD("get_key_label"), &InputEventKey::get_key_label); + ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode); ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode); @@ -495,10 +584,16 @@ void InputEventKey::_bind_methods() { ClassDB::bind_method(D_METHOD("get_keycode_with_modifiers"), &InputEventKey::get_keycode_with_modifiers); ClassDB::bind_method(D_METHOD("get_physical_keycode_with_modifiers"), &InputEventKey::get_physical_keycode_with_modifiers); + ClassDB::bind_method(D_METHOD("get_key_label_with_modifiers"), &InputEventKey::get_key_label_with_modifiers); + + ClassDB::bind_method(D_METHOD("as_text_keycode"), &InputEventKey::as_text_keycode); + ClassDB::bind_method(D_METHOD("as_text_physical_keycode"), &InputEventKey::as_text_physical_keycode); + ClassDB::bind_method(D_METHOD("as_text_key_label"), &InputEventKey::as_text_key_label); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); ADD_PROPERTY(PropertyInfo(Variant::INT, "keycode"), "set_keycode", "get_keycode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "physical_keycode"), "set_physical_keycode", "get_physical_keycode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "key_label"), "set_key_label", "get_key_label"); ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo"); } diff --git a/core/input/input_event.h b/core/input/input_event.h index 2d7a72e327..797761b208 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -153,6 +153,7 @@ class InputEventKey : public InputEventWithModifiers { Key keycode = Key::NONE; // Key enum, without modifier masks. Key physical_keycode = Key::NONE; + Key key_label = Key::NONE; uint32_t unicode = 0; ///unicode bool echo = false; /// true if this is an echo key @@ -170,6 +171,9 @@ public: void set_physical_keycode(Key p_keycode); Key get_physical_keycode() const; + void set_key_label(Key p_key_label); + Key get_key_label() const; + void set_unicode(char32_t p_unicode); char32_t get_unicode() const; @@ -178,12 +182,16 @@ public: Key get_keycode_with_modifiers() const; Key get_physical_keycode_with_modifiers() const; + Key get_key_label_with_modifiers() const; virtual bool action_match(const Ref<InputEvent> &p_event, bool p_exact_match, float p_deadzone, bool *r_pressed, float *r_strength, float *r_raw_strength) const override; virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } + virtual String as_text_physical_keycode() const; + virtual String as_text_keycode() const; + virtual String as_text_key_label() const; virtual String as_text() const override; virtual String to_string() override; diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 5e760c7565..6f015ac386 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -44,7 +44,7 @@ typedef uint32_t uintr_t; #endif /** - * Miscellaneous helpers for marshalling data types, and encoding + * Miscellaneous helpers for marshaling data types, and encoding * in an endian independent way */ diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 9bfe46727b..646bdea758 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -106,11 +106,11 @@ void AStar3D::remove_point(int64_t p_id) { bool p_exists = points.lookup(p_id, p); ERR_FAIL_COND_MSG(!p_exists, vformat("Can't remove point. Point with id: %d doesn't exist.", p_id)); - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { Segment s(p_id, (*it.key)); segments.erase(s); - (*it.value)->neighbours.remove(p->id); + (*it.value)->neighbors.remove(p->id); (*it.value)->unlinked_neighbours.remove(p->id); } @@ -118,7 +118,7 @@ void AStar3D::remove_point(int64_t p_id) { Segment s(p_id, (*it.key)); segments.erase(s); - (*it.value)->neighbours.remove(p->id); + (*it.value)->neighbors.remove(p->id); (*it.value)->unlinked_neighbours.remove(p->id); } @@ -138,10 +138,10 @@ void AStar3D::connect_points(int64_t p_id, int64_t p_with_id, bool bidirectional bool to_exists = points.lookup(p_with_id, b); ERR_FAIL_COND_MSG(!to_exists, vformat("Can't connect points. Point with id: %d doesn't exist.", p_with_id)); - a->neighbours.set(b->id, b); + a->neighbors.set(b->id, b); if (bidirectional) { - b->neighbours.set(a->id, a); + b->neighbors.set(a->id, a); } else { b->unlinked_neighbours.set(a->id, a); } @@ -155,7 +155,7 @@ void AStar3D::connect_points(int64_t p_id, int64_t p_with_id, bool bidirectional if (element) { s.direction |= element->direction; if (s.direction == Segment::BIDIRECTIONAL) { - // Both are neighbours of each other now + // Both are neighbors of each other now a->unlinked_neighbours.remove(b->id); b->unlinked_neighbours.remove(a->id); } @@ -183,9 +183,9 @@ void AStar3D::disconnect_points(int64_t p_id, int64_t p_with_id, bool bidirectio // Erase the directions to be removed s.direction = (element->direction & ~remove_direction); - a->neighbours.remove(b->id); + a->neighbors.remove(b->id); if (bidirectional) { - b->neighbours.remove(a->id); + b->neighbors.remove(a->id); if (element->direction != Segment::BIDIRECTIONAL) { a->unlinked_neighbours.remove(b->id); b->unlinked_neighbours.remove(a->id); @@ -226,7 +226,7 @@ Vector<int64_t> AStar3D::get_point_connections(int64_t p_id) { Vector<int64_t> point_list; - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { point_list.push_back((*it.key)); } @@ -346,8 +346,8 @@ bool AStar3D::_solve(Point *begin_point, Point *end_point) { open_list.remove_at(open_list.size() - 1); p->closed_pass = pass; // Mark the point as closed - for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { - Point *e = *(it.value); // The neighbour point + for (OAHashMap<int64_t, Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { + Point *e = *(it.value); // The neighbor point if (!e->enabled || e->closed_pass == pass) { continue; @@ -813,8 +813,8 @@ bool AStar2D::_solve(AStar3D::Point *begin_point, AStar3D::Point *end_point) { open_list.remove_at(open_list.size() - 1); p->closed_pass = astar.pass; // Mark the point as closed. - for (OAHashMap<int64_t, AStar3D::Point *>::Iterator it = p->neighbours.iter(); it.valid; it = p->neighbours.next_iter(it)) { - AStar3D::Point *e = *(it.value); // The neighbour point. + for (OAHashMap<int64_t, AStar3D::Point *>::Iterator it = p->neighbors.iter(); it.valid; it = p->neighbors.next_iter(it)) { + AStar3D::Point *e = *(it.value); // The neighbor point. if (!e->enabled || e->closed_pass == astar.pass) { continue; diff --git a/core/math/a_star.h b/core/math/a_star.h index a475e4f2fc..fc4bb09f03 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -52,7 +52,7 @@ class AStar3D : public RefCounted { real_t weight_scale = 0; bool enabled = false; - OAHashMap<int64_t, Point *> neighbours = 4u; + OAHashMap<int64_t, Point *> neighbors = 4u; OAHashMap<int64_t, Point *> unlinked_neighbours = 4u; // Used for pathfinding. diff --git a/core/math/a_star_grid_2d.cpp b/core/math/a_star_grid_2d.cpp index 30d50073d7..677e609763 100644 --- a/core/math/a_star_grid_2d.cpp +++ b/core/math/a_star_grid_2d.cpp @@ -401,7 +401,7 @@ bool AStarGrid2D::_solve(Point *p_begin_point, Point *p_end_point) { List<Point *> nbors; _get_nbors(p, nbors); for (List<Point *>::Element *E = nbors.front(); E; E = E->next()) { - Point *e = E->get(); // The neighbour point. + Point *e = E->get(); // The neighbor point. real_t weight_scale = 1.0; if (jumping_enabled) { diff --git a/core/math/bvh_abb.h b/core/math/bvh_abb.h index 32b011bd3b..fb0207e0bd 100644 --- a/core/math/bvh_abb.h +++ b/core/math/bvh_abb.h @@ -87,7 +87,7 @@ struct BVH_ABB { return -neg_max - min; } - POINT calculate_centre() const { + POINT calculate_center() const { return POINT((calculate_size() * 0.5) + min); } diff --git a/core/math/bvh_split.inc b/core/math/bvh_split.inc index 180bbfb511..875abedb70 100644 --- a/core/math/bvh_split.inc +++ b/core/math/bvh_split.inc @@ -25,7 +25,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u return; } - POINT centre = full_bound.calculate_centre(); + POINT center = full_bound.calculate_center(); POINT size = full_bound.calculate_size(); int order[POINT::AXIS_COUNT]; @@ -43,7 +43,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { // add to b group_b[num_b++] = ind; @@ -75,7 +75,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { count++; } } @@ -100,7 +100,7 @@ void _split_leaf_sort_groups_simple(int &num_a, int &num_b, uint16_t *group_a, u for (int a = 0; a < num_a; a++) { uint32_t ind = group_a[a]; - if (temp_bounds[ind].min.coord[split_axis] > centre.coord[split_axis]) { + if (temp_bounds[ind].min.coord[split_axis] > center.coord[split_axis]) { // add to b group_b[num_b++] = ind; diff --git a/core/math/color.cpp b/core/math/color.cpp index 5bae8d25d6..3e5fa7b402 100644 --- a/core/math/color.cpp +++ b/core/math/color.cpp @@ -194,7 +194,7 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { a = p_alpha; if (p_s == 0.0f) { - // Achromatic (grey) + // Achromatic (gray) r = g = b = p_v; return; } diff --git a/core/math/expression.cpp b/core/math/expression.cpp index da52bb9465..d1ec987d56 100644 --- a/core/math/expression.cpp +++ b/core/math/expression.cpp @@ -434,14 +434,13 @@ Error Expression::_get_token(Token &r_token) { } return OK; - } else if (is_ascii_char(cchar) || is_underscore(cchar)) { - String id; - bool first = true; + } else if (is_unicode_identifier_start(cchar)) { + String id = String::chr(cchar); + cchar = GET_CHAR(); - while (is_ascii_char(cchar) || is_underscore(cchar) || (!first && is_digit(cchar))) { + while (is_unicode_identifier_continue(cchar)) { id += String::chr(cchar); cchar = GET_CHAR(); - first = false; } str_ofs--; //go back one diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 5183b77cb1..25a4b320cd 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -127,14 +127,9 @@ static const _KeyCodeText _keycodes[] = { {Key::KP_7 ,"Kp 7"}, {Key::KP_8 ,"Kp 8"}, {Key::KP_9 ,"Kp 9"}, - {Key::SUPER_L ,"Super L"}, - {Key::SUPER_R ,"Super R"}, {Key::MENU ,"Menu"}, - {Key::HYPER_L ,"Hyper L"}, - {Key::HYPER_R ,"Hyper R"}, + {Key::HYPER ,"Hyper"}, {Key::HELP ,"Help"}, - {Key::DIRECTION_L ,"Direction L"}, - {Key::DIRECTION_R ,"Direction R"}, {Key::BACK ,"Back"}, {Key::FORWARD ,"Forward"}, {Key::STOP ,"Stop"}, @@ -142,11 +137,6 @@ static const _KeyCodeText _keycodes[] = { {Key::VOLUMEDOWN ,"VolumeDown"}, {Key::VOLUMEMUTE ,"VolumeMute"}, {Key::VOLUMEUP ,"VolumeUp"}, - {Key::BASSBOOST ,"BassBoost"}, - {Key::BASSUP ,"BassUp"}, - {Key::BASSDOWN ,"BassDown"}, - {Key::TREBLEUP ,"TrebleUp"}, - {Key::TREBLEDOWN ,"TrebleDown"}, {Key::MEDIAPLAY ,"MediaPlay"}, {Key::MEDIASTOP ,"MediaStop"}, {Key::MEDIAPREVIOUS ,"MediaPrevious"}, @@ -174,6 +164,10 @@ static const _KeyCodeText _keycodes[] = { {Key::LAUNCHD ,"LaunchD"}, {Key::LAUNCHE ,"LaunchE"}, {Key::LAUNCHF ,"LaunchF"}, + {Key::GLOBE ,"Globe"}, + {Key::KEYBOARD ,"On-screen keyboard"}, + {Key::JIS_EISU ,"JIS Eisu"}, + {Key::JIS_KANA ,"JIS Kana"}, {Key::UNKNOWN ,"Unknown"}, {Key::SPACE ,"Space"}, {Key::EXCLAM ,"Exclam"}, @@ -244,72 +238,6 @@ static const _KeyCodeText _keycodes[] = { {Key::BAR ,"Bar"}, {Key::BRACERIGHT ,"BraceRight"}, {Key::ASCIITILDE ,"AsciiTilde"}, - {Key::NOBREAKSPACE ,"NoBreakSpace"}, - {Key::EXCLAMDOWN ,"ExclamDown"}, - {Key::CENT ,"Cent"}, - {Key::STERLING ,"Sterling"}, - {Key::CURRENCY ,"Currency"}, - {Key::YEN ,"Yen"}, - {Key::BROKENBAR ,"BrokenBar"}, - {Key::SECTION ,"Section"}, - {Key::DIAERESIS ,"Diaeresis"}, - {Key::COPYRIGHT ,"Copyright"}, - {Key::ORDFEMININE ,"Ordfeminine"}, - {Key::GUILLEMOTLEFT ,"GuillemotLeft"}, - {Key::NOTSIGN ,"NotSign"}, - {Key::HYPHEN ,"Hyphen"}, - {Key::KEY_REGISTERED ,"Registered"}, - {Key::MACRON ,"Macron"}, - {Key::DEGREE ,"Degree"}, - {Key::PLUSMINUS ,"PlusMinus"}, - {Key::TWOSUPERIOR ,"TwoSuperior"}, - {Key::THREESUPERIOR ,"ThreeSuperior"}, - {Key::ACUTE ,"Acute"}, - {Key::MU ,"Mu"}, - {Key::PARAGRAPH ,"Paragraph"}, - {Key::PERIODCENTERED ,"PeriodCentered"}, - {Key::CEDILLA ,"Cedilla"}, - {Key::ONESUPERIOR ,"OneSuperior"}, - {Key::MASCULINE ,"Masculine"}, - {Key::GUILLEMOTRIGHT ,"GuillemotRight"}, - {Key::ONEQUARTER ,"OneQuarter"}, - {Key::ONEHALF ,"OneHalf"}, - {Key::THREEQUARTERS ,"ThreeQuarters"}, - {Key::QUESTIONDOWN ,"QuestionDown"}, - {Key::AGRAVE ,"Agrave"}, - {Key::AACUTE ,"Aacute"}, - {Key::ACIRCUMFLEX ,"AcircumFlex"}, - {Key::ATILDE ,"Atilde"}, - {Key::ADIAERESIS ,"Adiaeresis"}, - {Key::ARING ,"Aring"}, - {Key::AE ,"Ae"}, - {Key::CCEDILLA ,"Ccedilla"}, - {Key::EGRAVE ,"Egrave"}, - {Key::EACUTE ,"Eacute"}, - {Key::ECIRCUMFLEX ,"Ecircumflex"}, - {Key::EDIAERESIS ,"Ediaeresis"}, - {Key::IGRAVE ,"Igrave"}, - {Key::IACUTE ,"Iacute"}, - {Key::ICIRCUMFLEX ,"Icircumflex"}, - {Key::IDIAERESIS ,"Idiaeresis"}, - {Key::ETH ,"Eth"}, - {Key::NTILDE ,"Ntilde"}, - {Key::OGRAVE ,"Ograve"}, - {Key::OACUTE ,"Oacute"}, - {Key::OCIRCUMFLEX ,"Ocircumflex"}, - {Key::OTILDE ,"Otilde"}, - {Key::ODIAERESIS ,"Odiaeresis"}, - {Key::MULTIPLY ,"Multiply"}, - {Key::OOBLIQUE ,"Ooblique"}, - {Key::UGRAVE ,"Ugrave"}, - {Key::UACUTE ,"Uacute"}, - {Key::UCIRCUMFLEX ,"Ucircumflex"}, - {Key::UDIAERESIS ,"Udiaeresis"}, - {Key::YACUTE ,"Yacute"}, - {Key::THORN ,"Thorn"}, - {Key::SSHARP ,"Ssharp"}, - {Key::DIVISION ,"Division"}, - {Key::YDIAERESIS ,"Ydiaeresis"}, {Key::NONE ,nullptr} /* clang-format on */ }; @@ -378,14 +306,9 @@ bool keycode_has_unicode(Key p_keycode) { case Key::F33: case Key::F34: case Key::F35: - case Key::SUPER_L: - case Key::SUPER_R: case Key::MENU: - case Key::HYPER_L: - case Key::HYPER_R: + case Key::HYPER: case Key::HELP: - case Key::DIRECTION_L: - case Key::DIRECTION_R: case Key::BACK: case Key::FORWARD: case Key::STOP: @@ -393,11 +316,6 @@ bool keycode_has_unicode(Key p_keycode) { case Key::VOLUMEDOWN: case Key::VOLUMEMUTE: case Key::VOLUMEUP: - case Key::BASSBOOST: - case Key::BASSUP: - case Key::BASSDOWN: - case Key::TREBLEUP: - case Key::TREBLEDOWN: case Key::MEDIAPLAY: case Key::MEDIASTOP: case Key::MEDIAPREVIOUS: @@ -426,6 +344,10 @@ bool keycode_has_unicode(Key p_keycode) { case Key::LAUNCHD: case Key::LAUNCHE: case Key::LAUNCHF: + case Key::GLOBE: + case Key::KEYBOARD: + case Key::JIS_EISU: + case Key::JIS_KANA: return false; default: { } @@ -522,3 +444,24 @@ int keycode_get_value_by_index(int p_index) { const char *keycode_get_name_by_index(int p_index) { return _keycodes[p_index].text; } + +char32_t fix_unicode(char32_t p_char) { + if (p_char >= 0x20 && p_char != 0x7F) { + return p_char; + } + return 0; +} + +Key fix_keycode(char32_t p_char, Key p_key) { + if (p_char >= 0x20 && p_char <= 0x7E) { + return (Key)String::char_uppercase(p_char); + } + return p_key; +} + +Key fix_key_label(char32_t p_char, Key p_key) { + if (p_char >= 0x20 && p_char != 0x7F) { + return (Key)String::char_uppercase(p_char); + } + return p_key; +} diff --git a/core/os/keyboard.h b/core/os/keyboard.h index c78fa2a631..6315356510 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -127,11 +127,8 @@ enum class Key { SUPER_L = SPECIAL | 0x40, SUPER_R = SPECIAL | 0x41, MENU = SPECIAL | 0x42, - HYPER_L = SPECIAL | 0x43, - HYPER_R = SPECIAL | 0x44, + HYPER = SPECIAL | 0x43, HELP = SPECIAL | 0x45, - DIRECTION_L = SPECIAL | 0x46, - DIRECTION_R = SPECIAL | 0x47, BACK = SPECIAL | 0x48, FORWARD = SPECIAL | 0x49, STOP = SPECIAL | 0x4A, @@ -139,11 +136,6 @@ enum class Key { VOLUMEDOWN = SPECIAL | 0x4C, VOLUMEMUTE = SPECIAL | 0x4D, VOLUMEUP = SPECIAL | 0x4E, - BASSBOOST = SPECIAL | 0x4F, - BASSUP = SPECIAL | 0x50, - BASSDOWN = SPECIAL | 0x51, - TREBLEUP = SPECIAL | 0x52, - TREBLEDOWN = SPECIAL | 0x53, MEDIAPLAY = SPECIAL | 0x54, MEDIASTOP = SPECIAL | 0x55, MEDIAPREVIOUS = SPECIAL | 0x56, @@ -173,7 +165,12 @@ enum class Key { LAUNCHE = SPECIAL | 0x6E, LAUNCHF = SPECIAL | 0x6F, - UNKNOWN = SPECIAL | 0xFFFFFF, + GLOBE = SPECIAL | 0x70, + KEYBOARD = SPECIAL | 0x71, + JIS_EISU = SPECIAL | 0x72, + JIS_KANA = SPECIAL | 0x73, + + UNKNOWN = SPECIAL | 0x7FFFFF, /* PRINTABLE LATIN 1 CODES */ @@ -246,74 +243,8 @@ enum class Key { BAR = 0x007C, BRACERIGHT = 0x007D, ASCIITILDE = 0x007E, - NOBREAKSPACE = 0x00A0, - EXCLAMDOWN = 0x00A1, - CENT = 0x00A2, - STERLING = 0x00A3, - CURRENCY = 0x00A4, YEN = 0x00A5, - BROKENBAR = 0x00A6, SECTION = 0x00A7, - DIAERESIS = 0x00A8, - COPYRIGHT = 0x00A9, - ORDFEMININE = 0x00AA, - GUILLEMOTLEFT = 0x00AB, - NOTSIGN = 0x00AC, - HYPHEN = 0x00AD, - KEY_REGISTERED = 0x00AE, // "REGISTERED" is a reserved word on Windows. - MACRON = 0x00AF, - DEGREE = 0x00B0, - PLUSMINUS = 0x00B1, - TWOSUPERIOR = 0x00B2, - THREESUPERIOR = 0x00B3, - ACUTE = 0x00B4, - MU = 0x00B5, - PARAGRAPH = 0x00B6, - PERIODCENTERED = 0x00B7, - CEDILLA = 0x00B8, - ONESUPERIOR = 0x00B9, - MASCULINE = 0x00BA, - GUILLEMOTRIGHT = 0x00BB, - ONEQUARTER = 0x00BC, - ONEHALF = 0x00BD, - THREEQUARTERS = 0x00BE, - QUESTIONDOWN = 0x00BF, - AGRAVE = 0x00C0, - AACUTE = 0x00C1, - ACIRCUMFLEX = 0x00C2, - ATILDE = 0x00C3, - ADIAERESIS = 0x00C4, - ARING = 0x00C5, - AE = 0x00C6, - CCEDILLA = 0x00C7, - EGRAVE = 0x00C8, - EACUTE = 0x00C9, - ECIRCUMFLEX = 0x00CA, - EDIAERESIS = 0x00CB, - IGRAVE = 0x00CC, - IACUTE = 0x00CD, - ICIRCUMFLEX = 0x00CE, - IDIAERESIS = 0x00CF, - ETH = 0x00D0, - NTILDE = 0x00D1, - OGRAVE = 0x00D2, - OACUTE = 0x00D3, - OCIRCUMFLEX = 0x00D4, - OTILDE = 0x00D5, - ODIAERESIS = 0x00D6, - MULTIPLY = 0x00D7, - OOBLIQUE = 0x00D8, - UGRAVE = 0x00D9, - UACUTE = 0x00DA, - UCIRCUMFLEX = 0x00DB, - UDIAERESIS = 0x00DC, - YACUTE = 0x00DD, - THORN = 0x00DE, - SSHARP = 0x00DF, - - DIVISION = 0x00F7, - YDIAERESIS = 0x00FF, - END_LATIN1 = 0x0100, }; enum class KeyModifierMask { @@ -407,4 +338,8 @@ int keycode_get_count(); int keycode_get_value_by_index(int p_index); const char *keycode_get_name_by_index(int p_index); +char32_t fix_unicode(char32_t p_char); +Key fix_keycode(char32_t p_char, Key p_key); +Key fix_key_label(char32_t p_char, Key p_key); + #endif // KEYBOARD_H diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 2cc0b3a8d7..9e8c6fccb3 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -2135,7 +2135,7 @@ static void _register_variant_builtin_methods() { bind_static_method(Projection, create_depth_correction, sarray("flip_y"), varray()); bind_static_method(Projection, create_light_atlas_rect, sarray("rect"), varray()); bind_static_method(Projection, create_perspective, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); - bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", " convergence_dist"), varray()); + bind_static_method(Projection, create_perspective_hmd, sarray("fovy", "aspect", "z_near", "z_far", "flip_fov", "eye", "intraocular_dist", "convergence_dist"), varray()); bind_static_method(Projection, create_for_hmd, sarray("eye", "aspect", "intraocular_dist", "display_width", "display_to_lens", "oversample", "z_near", "z_far"), varray()); bind_static_method(Projection, create_orthogonal, sarray("left", "right", "bottom", "top", "z_near", "z_far"), varray()); bind_static_method(Projection, create_orthogonal_aspect, sarray("size", "aspect", "z_near", "z_far", "flip_fov"), varray(false)); |