Skip to content

Commit ccb8ea6

Browse files
ErezShahafakien-mga
authored andcommitted
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.
1 parent 5fb9ff9 commit ccb8ea6

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

core/input/input.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -697,29 +697,28 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
697697
for (const KeyValue<StringName, InputMap::Action> &E : InputMap::get_singleton()->get_action_map()) {
698698
if (InputMap::get_singleton()->event_is_action(p_event, E.key)) {
699699
Action &action = action_state[E.key];
700+
bool is_joypad_axis = jm.is_valid();
700701
bool is_pressed = false;
701-
702702
if (!p_event->is_echo()) {
703703
if (p_event->is_action_pressed(E.key)) {
704-
if (jm.is_valid()) {
705-
// If axis is already pressed, don't increase the pressed counter.
704+
bool is_joypad_axis_valid_zone_enter = false;
705+
if (is_joypad_axis) {
706706
if (!action.axis_pressed) {
707+
is_joypad_axis_valid_zone_enter = true;
707708
action.pressed++;
708709
action.axis_pressed = true;
709710
}
710711
} else {
711712
action.pressed++;
712713
}
713-
714-
is_pressed = true;
715-
if (action.pressed == 1) {
714+
if (action.pressed == 1 && (is_joypad_axis_valid_zone_enter || !is_joypad_axis)) {
716715
action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames();
717716
action.pressed_process_frame = Engine::get_singleton()->get_process_frames();
718717
}
718+
is_pressed = true;
719719
} else {
720720
bool is_released = true;
721-
if (jm.is_valid()) {
722-
// Same as above. Don't release axis when not pressed.
721+
if (is_joypad_axis) {
723722
if (action.axis_pressed) {
724723
action.axis_pressed = false;
725724
} else {

0 commit comments

Comments
 (0)