Skip to content

FIX: Composite touchscreen controls not firing action after enabling (ISXB-98)#1540

Merged
jamesmcgill merged 9 commits intodevelopfrom
fix-isxb-98
May 13, 2022
Merged

FIX: Composite touchscreen controls not firing action after enabling (ISXB-98)#1540
jamesmcgill merged 9 commits intodevelopfrom
fix-isxb-98

Conversation

@jamesmcgill
Copy link
Copy Markdown
Collaborator

Description

After the first enabling of an action map that is bound to composite touchscreen controls, the action would not fire if the touchscreen was not in the default state at this point. Which would happen if the screen was ever touched prior to enabling the action. (This is because Touchscreens are never in the default state if they were ever used. E.g. the position never returns to default and is essentially always actuated forever).

The issue was due to sorting behaviour introduced in #1405
This sorting would reverse the order of the Touchscreen controls which just happened to work before because the Press Control was first in the list (after sorting everything was reversed; device order was Touch 4, Touch3, Touch 2 etc, and controls within are reversed, with Pressed now last).
This fragile behaviour of the Touchscreen controls always being actuated and the order mattering is not addressed in this PR. What this PR does, is restore the previous ordering but still doing the sorting. As sorting by composite complexity is required for the composite PR #1405 to work.

Changes made

  • Change sorting to be only based on complexity but otherwise be stable sorting (e.g. no reversing of controls)
  • Revert unit test changes that were done in PR NEW: Actions now consume their inputs. #1405 which were only due to the ordering change.

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.

@unity-cla-assistant
Copy link
Copy Markdown

unity-cla-assistant commented May 9, 2022

CLA assistant check
All committers have signed the CLA.

@jamesmcgill jamesmcgill requested review from andrew-oc and ekcoh May 9, 2022 13:25
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs
Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/InputManagerStateMonitors.cs Outdated
Copy link
Copy Markdown
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.

@jamesmcgill Great description of the issue and fix in this PR and walking the reader through what was causing the problem. Impressed you were able to decipher this issue. Is there something regarding this behavior we should add or are missing in docs in your opinion?

@jamesmcgill
Copy link
Copy Markdown
Collaborator Author

Thanks for the review @ekcoh !
I've made some changes (cleanup the test, put the bit unpacking in a function, CHANGELOG etc.)

I found one place that the sorting was mentioned in the docs and I edited that part. But generally I think the sorting is an internal detail so I don't think we will need to add anything (especially as this PR just partially restores the previous behaviour rather than add something new).

Comment thread Assets/Tests/InputSystem/CoreTests_Actions.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
Comment thread Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs Outdated
Comment on lines +267 to +271
// i.e. don't reverse the order of controls which have the same complexity
var firstComplexity = InputActionState.GetComplexityFromMonitorIndex(listeners[j - 1].monitorIndex);
var secondComplexity = InputActionState.GetComplexityFromMonitorIndex(listeners[j].monitorIndex);
if (firstComplexity >= secondComplexity)
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we remove sorting by monitorIndex, which includes the binding index in the lowest bits, we'll end up processing bindings in potentially a different order than they are specified in the input asset. I can't decide if that's ok or not. Wasn't there some discussion recently in devs-input about a team using the explicit order of bindings to fall through to less specific bindings if more specific ones weren't available? Can this break that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The sorting was merged on the 24th March and it effectively was reversing the order they would have been in before. So bindings with the sorting enabled were now in descending order e.g. 4,3,2,1. This PR change would keep them in whatever order they were before 24th March (which I think would be ascending).

I'm not sure about the order in the asset or about the binding fall through discussion, but I'm thinking unless these things were post 24th March, then they might have also been broken by adding the sort, and this PR should probably help restore those too?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

XR team is using it for this use-case and might have a project to test with, contact @chris-massie may provide insight

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep, good point.

@jamesmcgill jamesmcgill requested review from andrew-oc and removed request for ekcoh May 11, 2022 13:14
@jamesmcgill jamesmcgill merged commit e109744 into develop May 13, 2022
@jamesmcgill jamesmcgill deleted the fix-isxb-98 branch May 13, 2022 08:53
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.

5 participants