Skip to content

FIX: Tap Interaction is performed after it times out (ISXB-627) #2172

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

jfreire-unity
Copy link
Collaborator

@jfreire-unity jfreire-unity commented Apr 23, 2025

Description

Fixes an issue surfaced by https://jira.unity3d.com/browse/ISXB-627

Tap interaction for analog controls such as Gamepad sticks and triggers would keep getting restarted and canceled once above the press point. And could potentially get performed after it's first timeout.

Now, once the Tap Interactions timer expires, it can only be "restarted" once if goes below the release point.

Testing status & QA

I added a automated test to confirm the behavior and validated it with the ISX-627 project (adapted) as well.

Overall Product Risks

  • Complexity: 0
  • Halo Effect: 0

Comments to reviewers

⚠️ The ISXB-627 bug repro doesn't work properly from 1.14 forward since it uses PlayerInput, and there are some issues with the project setup. I recommend editing that project.
Or alternatively, creating a project with an InputActionAsset that has 2 different actions for a Gamepad trigger: one with a Hold interaction and one with a Tap interaction and see that the problem doesn't reproduce.

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.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@jfreire-unity jfreire-unity force-pushed the isxb-627-fix-tap-interaction-analog-controls branch from 489bd15 to 874397e Compare April 23, 2025 15:15
@jfreire-unity jfreire-unity requested a review from Copilot April 23, 2025 15:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the Tap Interaction for analog controls (e.g. Gamepad sticks/triggers) would erroneously restart immediately after timing out.

  • Added a flag (canceledFromTimerExpired) to prevent immediate reactivation after the timeout.
  • Updated the Process method to incorporate this flag and reset it when appropriate.
  • Updated the CHANGELOG to document the fix.

Reviewed Changes

Copilot reviewed 19 out of 23 changed files in this pull request and generated no comments.

File Description
Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs Added a timeout flag and logic to prevent restarting after tap timeout.
Packages/com.unity.inputsystem/CHANGELOG.md Updated the changelog with a description of the tap interaction fix.
Files not reviewed (4)
  • Assets/Samples/SimpleDemo/SimpleDemo_UsingPlayerInputSettings.lighting: Language not supported
  • ProjectSettings/MemorySettings.asset: Language not supported
  • ProjectSettings/MultiplayerManager.asset: Language not supported
  • ProjectSettings/SceneTemplateSettings.json: Language not supported
Comments suppressed due to low confidence (1)

Packages/com.unity.inputsystem/InputSystem/Actions/Interactions/TapInteraction.cs:91

  • Consider resetting the 'canceledFromTimerExpired' flag in the Reset() method to ensure that no stale state persists between interactions.
public void Reset()

Also adds a test to make sure the tap interaction doesn't restart.
@jfreire-unity jfreire-unity force-pushed the isxb-627-fix-tap-interaction-analog-controls branch from 874397e to c7c82e3 Compare April 24, 2025 08:45
Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

Great fix, test case and changes looks good to me.

@jfreire-unity
Copy link
Collaborator Author

Great fix, test case and changes looks good to me.

thanks for proactively approving before I requested the review! :)

@jfreire-unity
Copy link
Collaborator Author

jfreire-unity commented Apr 24, 2025

@Pauliusd01 ping me on Slack if you have any issues trying to reproduce the bug. Essentially, avoid the PlayerInput component usage since it's broken even without a fix (I'm not sure if we have a bug for it)

Copy link
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.

LGTM, previoulsy I'd get tap interactions on start and end of holding the trigger now I only get it at the start

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