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):
Running the game in the Unity Editor:
Running a build of the game:
This doesn’t make sense since @Rene-Damm said here :
So, the second line of the second picture I posted above should end with a “Q” and not a “A” !
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 did not find anything related to that on the internet…