Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Display Name Empty For Some Keyboard Inputs On MacOS

Discussion in 'Input System' started by hodge47, Feb 16, 2022.

  1. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    Hello,

    I am just getting started with the new input system after using the InControl package for years. Setup was a breeze and I got the input system working in my game just fine.

    However, when I got to rebinding, I found the binding display name for certain keys is empty. Currently, I am using a modified RebindActionUI (just converted the Text to TMP Text), but it does the same with the original script.

    I checked the input debugger, and the same thing is happening: no display name. I haven't tested it on my Windows PC as I use a MacBook on the go. Would this be related to how macOS reports the keys to the system (possibly the character in the details field)? Is there a quick fix that I can possibly try to implement? I guess for now I can try to format the name if the binding has no display name.

    Here are some screenshots of my UI/RebindActionUI as well as what is being reported in the input debugger window...




    Edit: I opened the project on Windows and the display name is not empty. This is the same commit as the one on my macOS machine.


    Edit #2: I came up with a hacky solution that runs a method when the UpdateBindingUIEvent event is called that checks for control characters in the display string using Char.IsControl(). If there are control characters, I pass the key control name to a static method that has a dictionary of all key controls that are reported in Unity and updates the display string with the value.

    Even though it is working now, a more elegant solution would be much appreciated.
     
    Last edited: Feb 17, 2022
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Yup. Would consider this a bug. The code should check whether we get an empty string back from the platform and just go with the default display name in that case.

    Looking at the code, it seems we are actually doing that. Makes me suspect that instead of an empty, we are actually getting a string that does have one or more characters but they're all whitespace. Or something like that.

    Either way, the code should handle that automatically.
     
  3. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    Thanks for your response.

    Unfortunately, all the empty and whitespace checks I did failed, but the display strings were showing empty everywhere in the editor so it was throwing me for a loop. This was because, at least in my situation, the control characters in the string were non-printing characters (Wiki link for anyone wondering what I'm talking about). This check is able to identify those potential control characters.