-
Notifications
You must be signed in to change notification settings - Fork 332
FIX: OnAnyButtonPress not recognizing touch anymore #2401
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1114,7 +1114,7 @@ public static InputControl GetFirstButtonPressOrNull(this InputEventPtr eventPtr | |
|
|
||
| foreach (var control in eventPtr.EnumerateControls(Enumerate.IgnoreControlsInDefaultState, magnitudeThreshold: magnitude)) | ||
| { | ||
| if (!control.HasValueChangeInEvent(eventPtr)) | ||
| if (!control.HasValueChangeInEvent(eventPtr) && !(control.device is Touchscreen)) // touches can happen to not have a previous state to compare to after the touch started | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Have you considered moving this logic into 🤖 Helpful? 👍/👎
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Additionally, bypassing the 🤖 Helpful? 👍/👎
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| continue; | ||
| if (buttonControlsOnly && !control.isButton) | ||
| continue; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
!(control.device is Touchscreen)bypasses the value change check for all touchscreen controls. This causesGetFirstButtonPressOrNullto return a control even if its state hasn't changed in the current event (e.g., during a touch move event where the finger is already down).Since
InputSystem.onAnyButtonPresstriggers based on the return value of this method, it will now fire repeatedly for every touch move event as long as the finger is held down, rather than only on the initial press. This breaks the expected behavior of a "press" event and differs from how other devices (like Gamepads or Keyboards) behave.If the goal is to handle the case where
HasValueChangeInEventfails due to missing previous state, consider checking if the control is specifically transitioning to a pressed state or if the event represents aTouchPhase.Beganequivalent.🤖 Helpful? 👍/👎