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

Controller Triggers stay pressed on Android #79263

Closed
Insane-Owl opened this issue Jul 10, 2023 · 9 comments · Fixed by #81322
Closed

Controller Triggers stay pressed on Android #79263

Insane-Owl opened this issue Jul 10, 2023 · 9 comments · Fixed by #81322

Comments

@Insane-Owl
Copy link

Insane-Owl commented Jul 10, 2023

Godot version

4.1.stable

System information

Android 12, OneUI 4.1, Galaxy S10e | Godot 4.1.stable

Issue description

Description

On Android, Controller Triggers once pressed, stay pressed until the game is restarted

Video:

On Windows - everything works as intended.
https://github.com/godotengine/godot/assets/78328941/ee7976ab-b35a-4f91-888b-f3774c42e1b0

On Android - Once a Trigger is pressed, it stays pressed (Inverted triggers is a separate issue).
https://github.com/godotengine/godot/assets/78328941/981b514a-1c17-4490-9313-f72d89dec4d4

The Setup

Input Map
Screenshot 2023-07-09 190118

Scene
Screenshot 2023-07-09 190138
Screenshot 2023-07-09 190131

Code
Screenshot 2023-07-09 190148

Steps to reproduce

  1. Set up triggers in Input Map
  2. Make them do anything...
  3. Export to Android
  4. Press the Trigger, and thing only happens once, even if pressed multiple times.

Minimal reproduction project

controller trigger test.zip

@Calinou
Copy link
Member

Calinou commented Jul 10, 2023

Which controller model are you using on desktop and Android? Is it the same controller model on both platforms?

@Insane-Owl
Copy link
Author

I've tested it using both an XBox Series controller, and the 8BitDo Pro 2. The staying-pressed issue persists with both controllers, however it seems only the XBox controller has the Inverted Triggers problem (LT being RT, and RT being LT).

@Calinou
Copy link
Member

Calinou commented Jul 10, 2023

Note that the swapped triggers issue on an Xbox controller was already reported in #56181.

@Insane-Owl Insane-Owl changed the title Controller Triggers don't work correctly on Android Controller Triggers stay pressed on Android Jul 10, 2023
@Insane-Owl
Copy link
Author

Thanks. I updated the post.

@johnnyw
Copy link
Contributor

johnnyw commented Aug 31, 2023

I've observed this bug on Android using an Xbox One X Bluetooth controller. The game in question was built with Godot 3.5.

I'd be interested in tackling this but I'm not sure where to start. I was looking around here but I couldn't discern if the triggers are being treated differently from the other buttons in some way.

@johnnyw
Copy link
Contributor

johnnyw commented Sep 4, 2023

I wrote a minimal sample project to supplement the original one that displays the numerical joystick axis value for the R2 trigger. On PC it goes from 0 to 1 as expected. On Android, after the initial event trigger, it stays stuck at 0.5 with both a continuous read in _process and motion events.

Edit: The action event works as expected when the threshold value is changed, so if we up it to 0.65 for example, it will work as expected. It just seems like the numerical value is messed up on Android.

TriggerTest.zip

@johnnyw
Copy link
Contributor

johnnyw commented Sep 4, 2023

Found the culprit! The platform-agnostic input handler is indiscriminately adding 0.5 to the analog triggers: https://github.com/godotengine/godot/blob/75de1ca76871fdf7f5a9e081aa57ec0e33061107/core/input/input.cpp#L1120C7-L1120C7

Android's motion event for L2 and R2 already have a range from 0 to 1, so this conversion is not necessary on Android and ends up breaking the value.

https://developer.android.com/reference/android/view/MotionEvent#AXIS_RTRIGGER

For a joystick, reports the absolute position of the right trigger control. The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).

@johnnyw
Copy link
Contributor

johnnyw commented Sep 9, 2023

In the meantime, I was able to workaround this bug by changing the threshold value in the input map to something higher than 0.5 (I settled on 0.7 for my title).

@akien-mga akien-mga added this to the 4.2 milestone Oct 20, 2023
johnnyw added a commit to johnnyw/godot that referenced this issue Oct 20, 2023
`Input::joy_axis` converts trigger values to be between 0.0f to 1.0f by default. This is not needed for Android, as values are already within that range, as per Android documentation: https://developer.android.com/reference/android/view/MotionEvent#AXIS_RTRIGGER

This patch prevents this conversion on Android, which caused L2 and R2 triggers to get stuck pressed. godotengine#79263
ProbablyWorks pushed a commit to ProbablyWorks/godot that referenced this issue Oct 22, 2023
`Input::joy_axis` converts trigger values to be between 0.0f to 1.0f by default. This is not needed for Android, as values are already within that range, as per Android documentation: https://developer.android.com/reference/android/view/MotionEvent#AXIS_RTRIGGER

This patch prevents this conversion on Android, which caused L2 and R2 triggers to get stuck pressed. godotengine#79263
YuriSizov pushed a commit to YuriSizov/godot that referenced this issue Jan 23, 2024
`Input::joy_axis` converts trigger values to be between 0.0f to 1.0f by default. This is not needed for Android, as values are already within that range, as per Android documentation: https://developer.android.com/reference/android/view/MotionEvent#AXIS_RTRIGGER

This patch prevents this conversion on Android, which caused L2 and R2 triggers to get stuck pressed. godotengine#79263

(cherry picked from commit d413a02)
@KatieZeldaKat
Copy link

I'm using Godot 4.3 and this issue seems to still exist. The triggers rest at 0.5 and go to 1.0 when pressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants