Localization of keyboard controls

Hey,

I’m using the new Input System v. 1.7.0 and my controls are freely configurable in the settings of the game.
All works as it should, but the keyboard keys are not localized.

My Code:

        InputBinding inputBinding = inputActionReference.action.bindings[bindingIndex];
        string controlName = inputBinding.ToDisplayString();

        textBindingDisplayText.text = inputBinding.ToDisplayString();

ToDisplayString() is always returning the US keyboard key.

After some searching, I found the following (source: New Input System - Which keyboard layouts are supported? )

Keyboard.current.aKey.displayName;

This delivers the correct local key. I tested with German, Español and Russian. It takes the keyboard layout which is used in Windows (not yet tested on Mac or Linux).

My question now is, how do I get from the InputBinding => KeyControl? Any idea?

Maybe something like this could help x.com

Hi Karl,

thanks for your reply, but that is UI localization, which I have already that in place. Means, localize UI text to different languages with placeholders.

What I’m looking for is, “mapping” of keyboard layouts from the base “US” to any country the system is currently running on.

Unity already offers the function to get the “localized keyboard layout” / “mapped keyboard key”, which I would like to use that. But I don’t know how I can convert the InputBinding to KeyControl.
inputBinding.ToDisplayString(); is always retuning some display string based on US keyboard.

Is it comming from the OS? Maybe I can use native C# functions?

Hey,

I found the solution.

string controlName = inputActionReference.action.GetBindingDisplayString(bindingIndex);
2 Likes

for newcomers to skip X
https://github.com/noio/games.noio.input-hints

1 Like