Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X11: is_action_pressed returns incorrect value when key was pressed during scene loading #82262

Closed
eldidou opened this issue Sep 24, 2023 · 6 comments · Fixed by #84685
Closed

Comments

@eldidou
Copy link
Contributor

eldidou commented Sep 24, 2023

Godot version

Godot_v4.2-dev4_linux.x86_64

System information

Ubuntu 22.04 Vulkan Forward+

Issue description

If an action is pressed during the loading of a scene, even if the key is released, is_action_pressed() will always consider it pressed afterward.
The behavior is the same for is_action_pressed and get_vector, get_axis. On the other hand is_key_pressed is working as expected.
On 4.2-dev4 and 4.2-dev5, I was able to reproduce it relatively easily (50% of the time). I could not with 4.2-dev3 or earlier or with 4.1.
I've seen it during the first loading of a scene as well as during a reload_current_scene().

Steps to reproduce

  • map an input to a key
  • launch a scene
  • while the scene is still launching, pressed the action key
  • after the scene is launched, release the key
  • print the is_action_pressed and is_key_pressed, it the issue occurs, they are not consistent

note: On a minimal project the scene is loading fast, so it's easy to miss the time window.

Minimal reproduction project

action_pressed_bug.zip

@echowarp
Copy link

New to this, but from my testing is a one shot at the beginning of the press, but and are continuously triggered, but I don't think this is clearly spelled out in the documentation.

Continuously True:

  • Input.is_action_pressed()
  • Input.is_key_pressed()
  • InputEvent.is_action()

One-shot at start:

  • Input.is_action_just_pressed()
  • InputEvent.is_action_pressed()

I wonder if something is mixed up between Input and InputEvent since the event version of is_action_pressed() is single-pass while the identically named other version is continuous.
It makes sense that perhaps a one-shot version might be ignored on scene load because it needs to see the transition from released to pressed.

@rsubtil
Copy link
Contributor

rsubtil commented Sep 25, 2023

I wonder if something is mixed up between Input and InputEvent since the event version of is_action_pressed() is single-pass while the identically named other version is continuous.

This is because InputEvents only exist on _input callbacks, which are only triggered on input changes, and not continuously like in _process (check this for more info).

@rsubtil
Copy link
Contributor

rsubtil commented Sep 25, 2023

Bisected to ad1abca #80859 (cc @KoBeWi)

@KoBeWi
Copy link
Member

KoBeWi commented Sep 25, 2023

Can't reproduce in dev5 and later. Tested on Windows.

@rsubtil
Copy link
Contributor

rsubtil commented Sep 25, 2023

Haven't had the chance to test on a Windows machine yet, but when running it on Linux under Wine I can't reproduce either. So it seems that this is a Linux-specific issue.

@akien-mga
Copy link
Member

akien-mga commented Nov 9, 2023

Confirmed reproducible on Linux/X11 as of 4.2-beta5 / e5bacbc.

@akien-mga akien-mga changed the title is_action_pressed return incorrect value when is was pressed during scene loading X11: is_action_pressed returns incorrect value when it was pressed during scene loading Nov 9, 2023
@akien-mga akien-mga changed the title X11: is_action_pressed returns incorrect value when it was pressed during scene loading X11: is_action_pressed returns incorrect value when key was pressed during scene loading Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment