diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/input_event.cpp | 10 | ||||
-rw-r--r-- | core/os/input_event.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index fc23012281..2bd62927b0 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -173,6 +173,16 @@ bool InputEvent::is_action(const String& p_action) const { return InputMap::get_singleton()->event_is_action(*this,p_action); } +bool InputEvent::is_action_pressed(const String& p_action) const { + + return is_action(p_action) && is_pressed() && !is_echo(); +} + +bool InputEvent::is_action_released(const String& p_action) const { + + return is_action(p_action) && !is_pressed(); +} + uint32_t InputEventKey::get_scancode_with_modifiers() const { uint32_t sc=scancode; diff --git a/core/os/input_event.h b/core/os/input_event.h index 811d5504d5..4bb122ebc1 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -287,6 +287,8 @@ struct InputEvent { bool is_pressed() const; bool is_action(const String& p_action) const; + bool is_action_pressed(const String& p_action) const; + bool is_action_released(const String& p_action) const; bool is_echo() const; void set_as_action(const String& p_action, bool p_pressed); |