1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

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 afa89c9eea
This commit is contained in:
Mai Lavelle
2021-08-16 00:53:01 -04:00
parent 1ed00dca88
commit ce43781cb3
2 changed files with 15 additions and 10 deletions

View File

@@ -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;
}