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

FIX: Timers on interactions sometimes triggering erroneously (case 1251231). #1474

Merged
merged 1 commit into from Nov 24, 2021

Conversation

Rene-Damm
Copy link
Contributor

@Rene-Damm Rene-Damm commented Nov 23, 2021

Fixes 1251231 (FogBugz).

Description

Say you have a "Hold" on a "Shift+B" binding like so:

        var action = new InputAction(interactions: "hold(duration=2)");
        action.AddCompositeBinding("OneModifier")
            .With("Modifier", "<Keyboard>/shift")
            .With("Button", "<Keyboard>/b");

Then depending on the order that shift and B were pressed in, you'd sometimes see the action spuriously getting triggered when no input was received.

The problem is that the current InputActionState.StartTimeout and InputActionState.StopTimeout code assume that the bindingIndex and controlIndex passed to StopTimeout is the same as that passed to StartTimeout. If that is not the case, an existing timeout will not be removed.

Changes made

Removed the explicit bindingIndex and controlIndex parameters. We already have the assumption that any given interactionIndex can have only one associated timer running. So instead, we now retain the monitorIndex and store it in the InteractionState. Thus, StopTimeout works regardless of what the currently active control is.

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.
    • FogBugz ticket attached, example ([case %number%](https://issuetracker.unity3d.com/issues/...)).
    • FogBugz is marked as "Resolved" with next release version correctly set.
  • 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
Contributor

@andrew-oc andrew-oc left a comment

Choose a reason for hiding this comment

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

Very nice

@Rene-Damm Rene-Damm merged commit cca1e3b into develop Nov 24, 2021
@Rene-Damm Rene-Damm deleted the fix-hold-on-multiple-controls branch November 24, 2021 20:24
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.

None yet

2 participants