sergiou87 / open-supaplex

Reverse engineering Supaplex
245 stars 39 forks source link

Keyboard layout #11

Closed DarthGandalf closed 2 years ago

DarthGandalf commented 4 years ago

Typing player name doesn't honor current layout. I configured my keyboard to use Colemak but the game treats it like Qwerty.

It's not a too big deal, since there's not much typing involved in this game, but still...

Platform is linux, as you could guess :)

sergiou87 commented 4 years ago

That'sā€¦ weird. The game uses the SDL scan codes to match key -> ASCII. I'm curious about the reason behind this bug šŸ˜†

NY00123 commented 3 years ago

I know it's been a while, but going to write a bit about this.

The SDL2 port seems to use SDL_Scancode exclusively, so the reported issue is expected. SDL scancodes aim to identify keys by their locations on the keyboard, regardless of the actual layout in use. SDL_Keycode should be layout-dependent, according to this page: https://wiki.libsdl.org/CategoryKeyboard

There may still be exceptions. For instance, if you're using a layout on Windows for which AltGr is mapped to Ctrl+LAlt, then you might get two separate key press events after pressing on AltGr.

There's also SDL2's separate text input API: https://wiki.libsdl.org/Tutorials/TextInput

sergiou87 commented 3 years ago

Hah! That's very interesting, and another thing I didn't know about. Thank you!! I think this shouldn't be hard to fix šŸ¤”

dascandy commented 2 years ago

@DarthGandalf Can you check that my PR fixes your issue?

DarthGandalf commented 2 years ago

Yes, it follows the layout now with your patch. I don't remember, only arrows and space is used in other parts of the game, never letter keys?

dascandy commented 2 years ago

@DarthGandalf In the name creation that should matter.

DarthGandalf commented 2 years ago

Of course. I meant, whether it doesn't break anything else, like WASD keys which are not used here

dascandy commented 2 years ago

Ah - pretty sure everything else uses the scancode still, which will work as it has before (positional on keyboard). Maybe a nice idea in the future to support remapping them...