diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-05 18:04:39 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-05 18:04:39 +0200 |
| commit | f00c971b81748497cae111654ec8980684b623c1 (patch) | |
| tree | 2aee2004ec0725b1faebfba66cca312d86b5c52f /core | |
| parent | 0f76ff2115ae56e6638e1e2bdb8851d470e6e0e3 (diff) | |
| parent | 166ca77f201c86e22d7a6c737729976d2affdbd5 (diff) | |
| download | redot-engine-f00c971b81748497cae111654ec8980684b623c1.tar.gz | |
Merge pull request #63168 from Levrault/master
Fix: InputEventJoypadMotion should trigger only once on a vslider
Diffstat (limited to 'core')
| -rw-r--r-- | core/input/input_event.cpp | 9 | ||||
| -rw-r--r-- | core/input/input_event.h | 2 | ||||
| -rw-r--r-- | core/input/input_map.cpp | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 95be01bc65..6010c2a2b4 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -1109,6 +1109,15 @@ String InputEventJoypadMotion::to_string() { return vformat("InputEventJoypadMotion: axis=%d, axis_value=%.2f", axis, axis_value); } +Ref<InputEventJoypadMotion> InputEventJoypadMotion::create_reference(JoyAxis p_axis, float p_value) { + Ref<InputEventJoypadMotion> ie; + ie.instantiate(); + ie->set_axis(p_axis); + ie->set_axis_value(p_value); + + return ie; +} + void InputEventJoypadMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis); ClassDB::bind_method(D_METHOD("get_axis"), &InputEventJoypadMotion::get_axis); diff --git a/core/input/input_event.h b/core/input/input_event.h index 59a87239bd..e9d4fb8325 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -319,6 +319,8 @@ public: virtual String as_text() const override; virtual String to_string() override; + static Ref<InputEventJoypadMotion> create_reference(JoyAxis p_axis, float p_value); + InputEventJoypadMotion() {} }; diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 910778324c..ddfde0e7cd 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -399,21 +399,25 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() { inputs = List<Ref<InputEvent>>(); inputs.push_back(InputEventKey::create_reference(Key::LEFT)); inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_LEFT)); + inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_X, -1.0)); default_builtin_cache.insert("ui_left", inputs); inputs = List<Ref<InputEvent>>(); inputs.push_back(InputEventKey::create_reference(Key::RIGHT)); inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_RIGHT)); + inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_X, 1.0)); default_builtin_cache.insert("ui_right", inputs); inputs = List<Ref<InputEvent>>(); inputs.push_back(InputEventKey::create_reference(Key::UP)); inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_UP)); + inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_Y, -1.0)); default_builtin_cache.insert("ui_up", inputs); inputs = List<Ref<InputEvent>>(); inputs.push_back(InputEventKey::create_reference(Key::DOWN)); inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::DPAD_DOWN)); + inputs.push_back(InputEventJoypadMotion::create_reference(JoyAxis::LEFT_Y, 1.0)); default_builtin_cache.insert("ui_down", inputs); inputs = List<Ref<InputEvent>>(); |
