swfans / swars

Syndicate Wars port, alternative binary for the classic Bullfrog game
Other
103 stars 15 forks source link

Keyboard layout #128

Open geist22 opened 10 months ago

geist22 commented 10 months ago

Syndicate Wars uses the american keyboard layout, which can be annoying as the Y and Z keys are switched, along with pretty much every special key.

Would it be possible to use the layout of the host instead?

mefistotelis commented 10 months ago

The bullfrog library has lbInkeyToAscii and lbInkeyToAsciiShift to translate keys into characters.

To switch to a different keyboard layout, we'd have to modify those arrays.

There is also SDL1.2 way of doing scancode-to-char translation, by using SDL_EnableUNICODE()

In SDL2 there is SDL_GetKeyFromScancode() which would allow to detect the layout, and even fill the translation table from OS data.

The SDL 1.2 way is not really compatible with with what bullfrog library does, so I guess the layout would have to be selected manually? Not sure is there's a way to ask SDL for that info.