diff options
Diffstat (limited to 'core/input')
-rw-r--r-- | core/input/input.cpp | 40 | ||||
-rw-r--r-- | core/input/input.h | 18 | ||||
-rw-r--r-- | core/input/input_map.cpp | 4 |
3 files changed, 31 insertions, 31 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index 3a2e50a674..4befdfac58 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -227,8 +227,8 @@ Input::VelocityTrack::VelocityTrack() { bool Input::is_anything_pressed() const { _THREAD_SAFE_METHOD_ - for (Map<StringName, Input::Action>::Element *E = action_state.front(); E; E = E->next()) { - if (E->get().pressed) { + for (const KeyValue<StringName, Input::Action> &E : action_state) { + if (E.value.pressed) { return true; } } @@ -272,65 +272,65 @@ bool Input::is_action_pressed(const StringName &p_action, bool p_exact) const { bool Input::is_action_just_pressed(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action)); - const Map<StringName, Action>::Element *E = action_state.find(p_action); + HashMap<StringName, Action>::ConstIterator E = action_state.find(p_action); if (!E) { return false; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return false; } if (Engine::get_singleton()->is_in_physics_frame()) { - return E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); + return E->value.pressed && E->value.physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); + return E->value.pressed && E->value.process_frame == Engine::get_singleton()->get_process_frames(); } } bool Input::is_action_just_released(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), false, InputMap::get_singleton()->suggest_actions(p_action)); - const Map<StringName, Action>::Element *E = action_state.find(p_action); + HashMap<StringName, Action>::ConstIterator E = action_state.find(p_action); if (!E) { return false; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return false; } if (Engine::get_singleton()->is_in_physics_frame()) { - return !E->get().pressed && E->get().physics_frame == Engine::get_singleton()->get_physics_frames(); + return !E->value.pressed && E->value.physics_frame == Engine::get_singleton()->get_physics_frames(); } else { - return !E->get().pressed && E->get().process_frame == Engine::get_singleton()->get_process_frames(); + return !E->value.pressed && E->value.process_frame == Engine::get_singleton()->get_process_frames(); } } float Input::get_action_strength(const StringName &p_action, bool p_exact) const { ERR_FAIL_COND_V_MSG(!InputMap::get_singleton()->has_action(p_action), 0.0, InputMap::get_singleton()->suggest_actions(p_action)); - const Map<StringName, Action>::Element *E = action_state.find(p_action); + HashMap<StringName, Action>::ConstIterator E = action_state.find(p_action); if (!E) { return 0.0f; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return 0.0f; } - return E->get().strength; + return E->value.strength; } float Input::get_action_raw_strength(const StringName &p_action, bool p_exact) const { - const Map<StringName, Action>::Element *E = action_state.find(p_action); + HashMap<StringName, Action>::ConstIterator E = action_state.find(p_action); if (!E) { return 0.0f; } - if (p_exact && E->get().exact == false) { + if (p_exact && E->value.exact == false) { return 0.0f; } - return E->get().raw_strength; + return E->value.raw_strength; } float Input::get_axis(const StringName &p_negative_action, const StringName &p_positive_action) const { @@ -1403,12 +1403,12 @@ String Input::get_joy_guid(int p_device) const { Array Input::get_connected_joypads() { Array ret; - Map<int, Joypad>::Element *elem = joy_names.front(); + HashMap<int, Joypad>::Iterator elem = joy_names.begin(); while (elem) { - if (elem->get().connected) { - ret.push_back(elem->key()); + if (elem->value.connected) { + ret.push_back(elem->key); } - elem = elem->next(); + ++elem; } return ret; } diff --git a/core/input/input.h b/core/input/input.h index 5a7cb84ece..7bb7889a43 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -82,11 +82,11 @@ public: private: MouseButton mouse_button_mask = MouseButton::NONE; - Set<Key> physical_keys_pressed; - Set<Key> keys_pressed; - Set<JoyButton> joy_buttons_pressed; - Map<JoyAxis, float> _joy_axis; - //Map<StringName,int> custom_action_press; + RBSet<Key> physical_keys_pressed; + RBSet<Key> keys_pressed; + RBSet<JoyButton> joy_buttons_pressed; + RBMap<JoyAxis, float> _joy_axis; + //RBMap<StringName,int> custom_action_press; Vector3 gravity; Vector3 accelerometer; Vector3 magnetometer; @@ -103,7 +103,7 @@ private: float raw_strength; }; - Map<StringName, Action> action_state; + HashMap<StringName, Action> action_state; bool emulate_touch_from_mouse = false; bool emulate_mouse_from_touch = false; @@ -137,8 +137,8 @@ private: }; VelocityTrack mouse_velocity_track; - Map<int, VelocityTrack> touch_velocity_track; - Map<int, Joypad> joy_names; + HashMap<int, VelocityTrack> touch_velocity_track; + HashMap<int, Joypad> joy_names; int fallback_mapping = -1; CursorShape default_shape = CURSOR_ARROW; @@ -231,7 +231,7 @@ protected: uint64_t timestamp; }; - Map<int, VibrationInfo> joy_vibration; + HashMap<int, VibrationInfo> joy_vibration; static void _bind_methods(); diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 51c1cf9608..942c5248df 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -691,12 +691,12 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins_with_featur return default_builtin_with_overrides_cache; } - HashMap<String, List<Ref<InputEvent>>> builtins = get_builtins(); + const HashMap<String, List<Ref<InputEvent>>> &builtins = get_builtins(); // Get a list of all built in inputs which are valid overrides for the OS // Key = builtin name (e.g. ui_accept) // Value = override/feature names (e.g. macos, if it was defined as "ui_accept.macos" and the platform supports that feature) - Map<String, Vector<String>> builtins_with_overrides; + HashMap<String, Vector<String>> builtins_with_overrides; for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) { String fullname = E.key; |