diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2021-08-16 00:53:01 -0400 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2021-08-16 00:53:01 -0400 |
commit | ce43781cb37adc5fd25555864b1001b9ab23de94 (patch) | |
tree | 0df7b531fc803b235adf6daeb556feaf5e907088 /core/input/input_map.cpp | |
parent | 1ed00dca882118598d14eae315f608af9de758cf (diff) | |
download | redot-engine-ce43781cb37adc5fd25555864b1001b9ab23de94.tar.gz |
Fix input methods returning zero strength when pressed status not requested
Fixes behavior of these methods:
`InputMap::event_get_action_status`
`InputEvent*::action_match`
Previously when `p_pressed` was `nullptr`, `p_strength` would be set to
`0.0f` regardless of event strength. This affected `InputEventAction` events
processed by `Input.parse_input_event` for example.
Regression found in afa89c9eea5c99
Diffstat (limited to 'core/input/input_map.cpp')
-rw-r--r-- | core/input/input_map.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 15be0f1e36..83ec70757e 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -222,11 +222,12 @@ bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const Str Ref<InputEventAction> input_event_action = p_event; if (input_event_action.is_valid()) { + bool pressed = input_event_action->is_pressed(); if (p_pressed != nullptr) { - *p_pressed = input_event_action->is_pressed(); + *p_pressed = pressed; } if (p_strength != nullptr) { - *p_strength = (p_pressed != nullptr && *p_pressed) ? input_event_action->get_strength() : 0.0f; + *p_strength = pressed ? input_event_action->get_strength() : 0.0f; } return input_event_action->get_action() == p_action; } |