Hello,
Is there a way to unify input for different keyboard layouts?
For example, with czech keyboard (and many different as well), keys 0-9 work as +ěščřžýáíé, so whenever player starts the game for the first time, the 0-9 bindings don’t work because player has to rebind them. On top of that, because they have rebound the keys, hotbar no longer shows 0-9, but +ěščřžýáíé, which is confusing.
So, is there a way, that player with different keyboard will be able to use +ěščřžýáíé as normal 0-9 without rebinding?
The solution can be from BP or C++, doesn’t matter.
Or at least is there a way to detect keyboard layout? So I can manually rebind them for supported languages?
Yes and no, I needed it quickly, so I did it dirty and used hacky solution, got it to work, but there are definitely better solutions like remapping the keymap at runtime or something else, but for my needs, I have modified the engine for 0-9 keys to be treated always the same regardless of keyboard layout (based on their physical location, so 1 will always call a binding for 1).
I have manually added 0-9 to KeyMap, so they are not added with char code from the localized layout (e.g. +), but rather with physical char code (e.g. 1). I have did it only for cooked versions of the game, so in editor, the keys would behave the same as they did.
On windows it would be FWindowsPlatformInput::GetKeyMap in WindowsPlatformInput.cpp
I don’t remember the exact code I used, it was something like:
Ve verzi 4.26 (30.05 2021 nejnovější) to už funguje. Musíš zmáčknout tlačítko na vlastní input. I když se tam ukáže chyba která říká že toto tlačítko nejde přiřadit, funguje mi to normálně.
Yeah, you can assign it, the problem I had wasn’t with assigning it, but rather that if I have assigned “1” to the bind by default, new players with different keyboard layout had to assign their “1” (e.g. “+” in Czech) and then I they had “+” in their hotbar instead of “1”. What I wanted was keyboard unification for 0-9, so the input is based on the physical layout of the keyboard and not virtual layout (e.g. you have to press shift to write 1 in Czech)
This is starting to be a problem, it is still not fixed in UE not even In 5 and more and more games launch with this out of the box. I would love a solution to be available to all.
With the “new” input system, what is the preferred method for making sure that, as previously mentioned, visual keyboard layout trumps actual keys defined for english/developer keyboard ones? just create a bunch of different default keymaps, and switch them depending on player locale? I cant believe nobody whos already launched a game in multiple regions hasnt used the new input system yet, or is there a way to provide a table of keys per locale in code?