diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 17 | ||||
-rw-r--r-- | core/input/input_event.cpp | 3 | ||||
-rw-r--r-- | core/input/input_event.h | 5 | ||||
-rw-r--r-- | core/input/input_map.cpp | 4 | ||||
-rw-r--r-- | core/input/input_map.h | 5 |
5 files changed, 21 insertions, 13 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 7951ee9edd..6e897e4d2d 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -495,6 +495,7 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack, bool p_replace_f } void ProjectSettings::_convert_to_last_version(int p_from_version) { +#ifndef DISABLE_DEPRECATED if (p_from_version <= 3) { // Converts the actions from array to dictionary (array of events to dictionary with deadzone + events) for (KeyValue<StringName, ProjectSettings::VariantContainer> &E : props) { @@ -508,6 +509,22 @@ void ProjectSettings::_convert_to_last_version(int p_from_version) { } } } + if (p_from_version <= 5) { + // Converts the device in events from -1 (emulated events) to -3 (all events). + for (KeyValue<StringName, ProjectSettings::VariantContainer> &E : props) { + if (String(E.key).begins_with("input/")) { + Dictionary action = E.value.variant; + Array events = action["events"]; + for (int i = 0; i < events.size(); i++) { + Ref<InputEvent> x = events[i]; + if (x->get_device() == -1) { // -1 was the previous value (GH-97707). + x->set_device(InputEvent::DEVICE_ID_ALL_DEVICES); + } + } + } + } + } +#endif // DISABLE_DEPRECATED } /* diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 905526bbbd..d125bad252 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -35,9 +35,6 @@ #include "core/os/keyboard.h" #include "core/os/os.h" -const int InputEvent::DEVICE_ID_EMULATION = -1; -const int InputEvent::DEVICE_ID_INTERNAL = -2; - void InputEvent::set_device(int p_device) { device = p_device; emit_changed(); diff --git a/core/input/input_event.h b/core/input/input_event.h index 19176f748e..80bca28fbf 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -62,8 +62,9 @@ protected: static void _bind_methods(); public: - static const int DEVICE_ID_EMULATION; - static const int DEVICE_ID_INTERNAL; + inline static constexpr int DEVICE_ID_EMULATION = -1; + inline static constexpr int DEVICE_ID_INTERNAL = -2; + inline static constexpr int DEVICE_ID_ALL_DEVICES = -3; // Signify that a given Action can be triggered by any device. void set_device(int p_device); int get_device() const; diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 9a772c87c9..726653c92e 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -38,8 +38,6 @@ InputMap *InputMap::singleton = nullptr; -int InputMap::ALL_DEVICES = -1; - void InputMap::_bind_methods() { ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action); ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions); @@ -162,7 +160,7 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re int i = 0; for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) { int device = E->get()->get_device(); - if (device == ALL_DEVICES || device == p_event->get_device()) { + if (device == InputEvent::DEVICE_ID_ALL_DEVICES || device == p_event->get_device()) { if (E->get()->action_match(p_event, p_exact_match, p_action.deadzone, r_pressed, r_strength, r_raw_strength)) { if (r_event_index) { *r_event_index = i; diff --git a/core/input/input_map.h b/core/input/input_map.h index 3774a131e6..ad4a8ae1a5 100644 --- a/core/input/input_map.h +++ b/core/input/input_map.h @@ -43,11 +43,6 @@ class InputMap : public Object { GDCLASS(InputMap, Object); public: - /** - * A special value used to signify that a given Action can be triggered by any device - */ - static int ALL_DEVICES; - struct Action { int id; float deadzone; |