diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/input_event.cpp | 13 | ||||
-rw-r--r-- | core/os/input_event.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index a072017353..9c5066da3d 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -1010,6 +1010,14 @@ bool InputEventAction::is_pressed() const { return pressed; } +void InputEventAction::set_strength(float p_strength) { + strength = CLAMP(p_strength, 0.0f, 1.0f); +} + +float InputEventAction::get_strength() const { + return strength; +} + bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const { if (p_event.is_null()) return false; @@ -1051,14 +1059,19 @@ void InputEventAction::_bind_methods() { ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed); //ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed); + ClassDB::bind_method(D_METHOD("set_strength", "strength"), &InputEventAction::set_strength); + ClassDB::bind_method(D_METHOD("get_strength"), &InputEventAction::get_strength); + // ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action); ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_strength", "get_strength"); } InputEventAction::InputEventAction() { pressed = false; + strength = 1.0f; } ///////////////////////////// diff --git a/core/os/input_event.h b/core/os/input_event.h index ba01516519..7a9a1f71c3 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -475,6 +475,7 @@ class InputEventAction : public InputEvent { StringName action; bool pressed; + float strength; protected: static void _bind_methods(); @@ -486,6 +487,9 @@ public: void set_pressed(bool p_pressed); virtual bool is_pressed() const; + void set_strength(float p_strength); + float get_strength() const; + virtual bool is_action(const StringName &p_action) const; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const; |