Skip to content

Conversation

@Rene-Damm
Copy link
Contributor

@Rene-Damm Rene-Damm commented Aug 23, 2019

This PR attempts to solve two issues in one change.

  1. The first is that the "Path" property on bindings in the UI displays differently than the paths selected in the control picker, which has been confusing for people. The picker was switched over to using display names at some point but doing the same for the path display was left as a TODO.
  2. The second is that users want to themselves display paths to the player in their rebinding UIs. With the current APIs that left them with either using InputControlPath.ToHumanReadableString which was NOT using display names and thus produced ugly strings or implementing their own conversion routines which required a good deal of understanding of how paths and the layout system works.

What this PR changes is that InputControlPath.ToHumanReadableString now actually goes to the InputControlLayout database to translate, where possible, path components from internal names to external display names. So, where <XInputController>/buttonSouth used to come out as buttonSouth [XInputController], it now comes out as A [Xbox Controller].

Also, I've added an option to omit the device so you can translate <XInputController>/buttonSouth to just "A", for example.

As part of this, I've changed the system to no longer just use local InputControlLayout caches. Constructing layouts is expensive and should not be done over and over. Instead, there is now one global cache which is always initialized in the editor (if input system UIs are used) and initialized for certain code regions in the player and then released.

Note that ToHumanReadableString is now much more costly than before. Initially, this made the control picker come up noticeably slower than before (my timings showed something like 50-60ms on average before and 90-100ms on average after my change) as it was called for every possible control in the system. However, since in the picker ToHumanReadableString is only used for searchable names, I mitigated this by making searchable names be constructed lazily. Which now actually makes the picker come up faster than before the change and the initial hit when starting the search has proven to not be too bad (basically we're moving around 30-40ms of work to when you start the first search).

image

image

@Rene-Damm Rene-Damm merged commit d4dcb3a into develop Aug 23, 2019
@Rene-Damm Rene-Damm deleted the fix-control-path-display branch August 23, 2019 19:20
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