Change keyboard bindings (for games that don't support it) on Linux

So I wanted to play EDGE. In this game all you do is move in 4 diagonal directions. The original mobile game got it right: you move with the buttons 1, 4, 3, 6. For some reason, the controls for the PC remake are completely idiotic: W A S D... and there is no way to change it.

I couldn't cope with this, so I've searched for solutions. Unfortunately, all the things I found for Linux are to remap what letters or actions each key generates, but not the actual keys. As EDGE is an SDL game, it deals with the scancodes directly so nothing worked.

By accident I found setkeycodes. With it, the solution is simple:

wzxhzdk:0

This piece of code will make Q mean W, ] mean D and ' mean S (A stays the same). So the controls become Q A ] '. Look at the keyboard and see how intuitive that is.


Now, there are a few problems with setkeycodes. First of all, it requires root (sudo). Second, it remaps the keys globally and the only thing that will reset it is a reboot. So you gotta reset it manually.

The following Bash command will set the keys as before, then wait until you press Enter in that terminal and then set them to their original values:

wzxhzdk:1

Yes, this could be separated into 3 lines, but the effect wouldn't be the same, because you would have to enter the password for the 2nd time, and that may not be possible with the mangled keys...


Sometimes a very nice alternative is to use a controller, with AntiMicro, but I don't like how EDGE plays on a controller...

Created
Comments powered by Disqus