Skip to content

Conversation

Rene-Damm
Copy link
Contributor

@Rene-Damm Rene-Damm commented Mar 4, 2020

This PR is a larger scale rewrite of InputSystemUIInputModule.

Why?

I found so many issues that after I initially just fixed individual issues as I went, I ultimately decided to take a knife to the current code and cut away a great deal of what I perceived as unnecessary complexity and systematically build out tests (which were greatly lacking) and functionality.

Many of the issues were deviations from StandaloneInputModule behavior which were regressions but some of the issues also arose from peculiarities of how InputSystemUIInputModule sources input and thus needs different handling than StandaloneInputModule. For example, StandaloneInputModule simply used Input.mousePosition which by nature is an aggregate whereas InputSystemUIInputModule sources position values from individual devices and may thus receive multiple conflicting pointer inputs whereas the old input had one already unified input.

These changes come in very late for 1.0 but IMO the current InputSytemUIInputModule is simply too broken to be 1.0 and UI is too critical to not fix this.

Changes

  • Added lots of tests. Our UI tests were greatly lacking. Situation is still not stallar but probably already a great deal more extensive than the stuff we ever had for StandaloneInputModule :)
  • Renamed MouseModel (internal) to PointerModel and simplified the code.
  • Collapsed TrackedDeviceModel (internal) into PointerModel as tracked devices are ultimately just a special type of pointers (like touch).
  • In the same vein, removed trackedDeviceSelect. Tracked input is pointer input so this is simply equivalent to leftClick (same as for touch). As part of this change, it is now also possible to right and middle click from tracked devices by simply binding rightClick and/or middleClick for them.
  • Renamed JoystickModel (internal) to NavigationModel and simplified it.
  • Added a public ExtendedPointerEventData which surfaces input system-specific information in UI events. Also replaces the internal TrackedPointerEventData class. Tracked device input and pointer input now sit on the same single codepath.
  • Exposed max raycast distance for TrackedDevice input as a maxDistance setting on TrackedDeviceRaycaster.
  • Added TrackedDeviceRaycaster to the component menu (like GraphicRaycaster) and added instructions for how to set it up to the docs.
  • Added documentation about how input is sourced from actions by InputSystemUIInputModule.
  • Fixed pointer states in InputSystemUIInputModule growing infinitely with Touchscreen if touch IDs were not reused.
  • Fixed lastPress value on PointerEventData getting lost.
  • Fixed button press&release happening in same frame resulting in no UI input.
  • Fixed trigger clicks with non-pointer devices leading to pointer events with (0,0) positions. Now triggers clicks on the last pointer and thus uses its position.
  • Fixed huge screen deltas on pointer events from tracked devices.
  • Fixed TrackedDeviceRaycaster not setting screenPosition in RaycastResult.
  • Fixed GC heap garbage from mouse UI input.
  • Fixed touch input not sending pointer exit events.
  • Fixed InputSystem.onActionChange getting invoked too many times when actions got enabled/disabled/changed.
  • Renamed repeatDelay and repeatRate in InputSystemUIInputModule to moveRepeatDelay and moveRepeatRate.
  • Added InputSystemUIInputModule.pointerBehavior to give control over how the input module resolves concurrent input from multiple pointers. Default behavior is to unify all pointer input that isn't from touch or tracked devices. This preserves multi-point ability for touch and tracked devices while collapsing input from other pointers such as mice and pens into a single unified pointer.

Pretty sure I missed a couple issues I found and fixed.

Known Issues

  • UI input module does not react to pointer positions until pointers are moved.

Copy link

@keiramoon keiramoon left a comment

Choose a reason for hiding this comment

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

Added some style suggestions.

@keiramoon keiramoon self-requested a review March 5, 2020 21:12
@Rene-Damm Rene-Damm merged commit 2879d8b into develop Mar 6, 2020
@Rene-Damm Rene-Damm deleted the ui-input-overhaul branch March 6, 2020 16:41
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.

4 participants