Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug GetBindingDisplayString gives different strings on different platforms

Discussion in 'Input System' started by Meorge, Sep 26, 2020.

  1. Meorge


    Feb 10, 2017
    Hi all,

    The past couple of days I've run into a rather frustrating bug with the new Input System's
    method. I'm using the following snippet of code:

    Code (CSharp):
    1. string dispString = action.GetBindingDisplayString(bindingIndex, options: InputBinding.DisplayStringOptions.DontOmitDevice | InputBinding.DisplayStringOptions.DontIncludeInteractions);
    2. Debug.Log($"dispString=<{dispString}>");
    I was expecting, at least for the Keyboard, that this would provide the same string across all platforms. On Linux, the Enter/Return key on the keyboard becomes the string "Return [Keyboard]", while on macOS, the string is simply the ASCII character 0x0D (carriage return) followed by " [Keyboard]". Similarly, Linux displays the Escape key as "Escape [Keyboard]" while Windows displays it as "ESC [Keyboard]" and, as I recall, macOS displays it as the ASCII character 0x1b (escape) followed by " [Keyboard]".

    For now, I have an idea on how to work around this for my control display string system, but it'd be very nice if we could get these strings to be the same across all platforms.
    pdinklag likes this.
  2. pdinklag


    Jan 24, 2017
    I'd like to bump this.

    On Linux, the display string for tabs is the literal tab character (code 0x9), for space it is a literal space character (code 0x20). These are not proper display strings at all.

    Almost even worse, the display strings for keyboard keys (including the tab and space mentioned above) have a character of code 0x1 appended for whatever reason (I have never seen that used ever, and string.Trim does not trim it away). TextMeshPro renders that as a space, so what should be "W" becomes "W ".

    On Windows, these things do not happen. This should work like that independent of the operating system.
    Last edited: Nov 23, 2023