Skip to content

FIX: OnAnyButtonPress not recognizing touch anymore#2401

Open
ritamerkl wants to merge 5 commits intodevelopfrom
onanybuttonpress-fix-for-touch
Open

FIX: OnAnyButtonPress not recognizing touch anymore#2401
ritamerkl wants to merge 5 commits intodevelopfrom
onanybuttonpress-fix-for-touch

Conversation

@ritamerkl
Copy link
Copy Markdown
Collaborator

@ritamerkl ritamerkl commented Mar 27, 2026

Description

This fixes a regression where onAnyButtonPress would not work for touch. This is the ticket.

Note that this was a regression from one of my PRs: https://github.com/Unity-Technologies/InputSystem/pull/2249/changes.

Touches can happen to have no previous states to compare to when they just started, so the line of code will fail. I corrected that by excluding touches. Touch is the only control that is "created on the go" where this happens in my mind, but let me know when I am mistaken here.

Testing status & QA

Added automated test, please also test in simulator, player and device.

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: Low
  • Halo Effect: Mid

Comments to reviewers

Note that this was a regression from one of my PRs: https://github.com/Unity-Technologies/InputSystem/pull/2249/changes.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

Copy link
Copy Markdown
Contributor

@u-pr u-pr bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May require changes

The review identified several issues with the proposed changes to GetFirstButtonPressOrNull. Most critically, the touchscreen check causes repeated "press" events during movement, breaking the expected behavior of InputSystem.onAnyButtonPress. There are also concerns regarding architectural coupling and performance overhead in multi-touch scenarios.

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com bot commented Mar 27, 2026

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2401   +/-   ##
========================================
  Coverage    78.13%   78.13%           
========================================
  Files          483      483           
  Lines        98770    98787   +17     
========================================
+ Hits         77169    77191   +22     
+ Misses       21601    21596    -5     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.34% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2022.3_project 75.38% <100.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.27% <100.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.27% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.28% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.31% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.31% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_2022.3_project 75.28% <100.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.18% <100.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.17% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.18% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.22% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.22% <100.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3 5.34% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3_project 75.50% <100.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.40% <100.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.39% <100.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.40% <100.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.44% <100.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6_project 77.44% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Assets/Tests/InputSystem/CoreTests_Events.cs 98.50% <100.00%> (+0.01%) ⬆️
...tem/InputSystem/Controls/InputControlExtensions.cs 77.07% <100.00%> (+0.05%) ⬆️

... and 3 files with indirect coverage changes

ℹ️ Need help interpreting these results?

@ritamerkl ritamerkl changed the title Fix for onAnyButtonPress not recognizing touch anymore FIX: OnAnyButtonPress not recognizing touch anymore Mar 27, 2026
@Pauliusd01
Copy link
Copy Markdown
Collaborator

Will most likely take a look tomorrow

Copy link
Copy Markdown
Collaborator

@jfreire-unity jfreire-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this!
My main concern is the same as already pointed by U-PR:

Hardcoding a specific device type check (is Touchscreen) in a generic extension method creates tight coupling

If we find a way to avoid this, let's do it instead

Copy link
Copy Markdown
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just updating my status that I'm waiting for expected changes

@ritamerkl
Copy link
Copy Markdown
Collaborator Author

Hold on with reviews, I messed up.

@ritamerkl ritamerkl marked this pull request as draft April 9, 2026 15:22
@ritamerkl ritamerkl marked this pull request as ready for review April 13, 2026 17:09
@ritamerkl ritamerkl requested review from ekcoh and jfreire-unity and removed request for jfreire-unity April 13, 2026 17:38
@ritamerkl
Copy link
Copy Markdown
Collaborator Author

ritamerkl commented Apr 13, 2026

ready for review @jfreire-unity @Pauliusd01

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants