CHANGE: Make ToHumanReadableString() respect display names. #804
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to solve two issues in one change.
TODO.InputControlPath.ToHumanReadableStringwhich 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.ToHumanReadableStringnow actually goes to the InputControlLayout database to translate, where possible, path components from internal names to external display names. So, where<XInputController>/buttonSouthused to come out asbuttonSouth [XInputController], it now comes out asA [Xbox Controller].Also, I've added an option to omit the device so you can translate
<XInputController>/buttonSouthto 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
ToHumanReadableStringis 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 pickerToHumanReadableStringis 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).