0

I have made a rebind system with the new input system, and it is working well. My only issue is that the name of the rebinded control is displayed as if I was using a qwerty keyboard even when I am actually using a azerty one.

I am using this to display the name of the rebinded key: displayString = action.GetBindingDisplayString(bindingIndex, out deviceLayoutName, out controlPath, displayStringOptions);

The very very VERY strange thing is that it works correctly when I am running the game in the unity Editor, but it doesn't work in builds...

I have made some debug texts to show the issue, here is the code of it:

using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;

public class Debugger : MonoBehaviour
{
    [SerializeField]
    private Text textKeyborad,textInput,textLang;

    void Update()
    {
        if(Keyboard.current.anyKey.IsPressed()){
            foreach (KeyControl k in Keyboard.current.allKeys)
            {
                if (k.wasPressedThisFrame)
                {
                    textKeyborad.text = "Keyboard.current.layout = " + Keyboard.current.keyboardLayout.ToString();
                    Debug.Log("Keyboard.current.layout = " + Keyboard.current.layout);

                    textLang.text = "This system is in " + Application.systemLanguage + ", Keyboard.current.aKey.displayName = " + Keyboard.current.aKey.displayName;
                    Debug.Log("This system is in " + Application.systemLanguage + ", Keyboard.current.aKey.displayName = " + Keyboard.current.aKey.displayName);

                    textInput.text = "Testing by pressing a key: output = a key keycode id = " + (int)k.keyCode + "  path = " + k.path + "  keycode = " + k.keyCode.ToString() + "  displayName = " + k.displayName;
                    Debug.Log("keycode id = " + (int)k.keyCode + "   path = " + k.path + "   keycode = " + k.keyCode.ToString() + "   displayName = " + k.displayName);
                    break;
                }
            }
        }
    }
}

So here is what I get when I press the "A" key on my azerty keyboard ("which corresponds to a "Q" on a qwerty keyboard):

In the Unity Editor: enter image description here In a build: enter image description here

This doesn't make sense since Rene-Damm said here: enter image description here

Do you have ideas or explanation about what is going on ? I believe it is a unity bug, but I am not sure since I haven't been able to find anything related to that on the internet...

  • Ive seen same between US and UK layouts. Where " and @ are differently located. Some games you bind @ and well it says not. But it is. – BugFinder Mar 19 '23 at 00:07

0 Answers0