1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +00:00

Fix Input.is_action_just_pressed flicker on joypad axes

Pressed tick assignments were in the wrong scope, resulting in updating
`pressed_frame` even when it shouldn't and therefore the `just_pressed`
would return true every time that the strength changes and not only when
there's a new valid press.

Fixes #81975.
This commit is contained in:
ErezShahaf
2023-09-21 18:06:59 +03:00
committed by Rémi Verschelde
parent 5fb9ff9986
commit ccb8ea613a

View File

@@ -697,29 +697,28 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
for (const KeyValue<StringName, InputMap::Action> &E : InputMap::get_singleton()->get_action_map()) { for (const KeyValue<StringName, InputMap::Action> &E : InputMap::get_singleton()->get_action_map()) {
if (InputMap::get_singleton()->event_is_action(p_event, E.key)) { if (InputMap::get_singleton()->event_is_action(p_event, E.key)) {
Action &action = action_state[E.key]; Action &action = action_state[E.key];
bool is_joypad_axis = jm.is_valid();
bool is_pressed = false; bool is_pressed = false;
if (!p_event->is_echo()) { if (!p_event->is_echo()) {
if (p_event->is_action_pressed(E.key)) { if (p_event->is_action_pressed(E.key)) {
if (jm.is_valid()) { bool is_joypad_axis_valid_zone_enter = false;
// If axis is already pressed, don't increase the pressed counter. if (is_joypad_axis) {
if (!action.axis_pressed) { if (!action.axis_pressed) {
is_joypad_axis_valid_zone_enter = true;
action.pressed++; action.pressed++;
action.axis_pressed = true; action.axis_pressed = true;
} }
} else { } else {
action.pressed++; action.pressed++;
} }
if (action.pressed == 1 && (is_joypad_axis_valid_zone_enter || !is_joypad_axis)) {
is_pressed = true;
if (action.pressed == 1) {
action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames(); action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames();
action.pressed_process_frame = Engine::get_singleton()->get_process_frames(); action.pressed_process_frame = Engine::get_singleton()->get_process_frames();
} }
is_pressed = true;
} else { } else {
bool is_released = true; bool is_released = true;
if (jm.is_valid()) { if (is_joypad_axis) {
// Same as above. Don't release axis when not pressed.
if (action.axis_pressed) { if (action.axis_pressed) {
action.axis_pressed = false; action.axis_pressed = false;
} else { } else {