[Linux] Does Allegro 5 respect xkb/xmodmap remapping?
Chris Katko

I was trying to help another user with keyboard issues (trying being a keyword ;) ) and I noticed an oddity.

From the other thread, I was running the al_keyboard_event example. On my machine, I use xmodmap:

xmodmap -e "keycode 22 = BackSpace Delete"

...so that my keyboard (which has no delete key) binds SHIFT+Backspace to be delete.

It works in Chrome and all other applications I normally use.

However, it does not work with al_keyboard_event. It simply shows backspace. (The actual key pressed, as opposed to the mapping.)

Now, I'm not 100% sure where the distinction between xmodmap ("depreciated" in newest Ubuntu but still works) and xkb are. Perhaps a xkb remapping works fine with Allegro. I used xmodmap because it's simple (and downright better), while hacking xkb scripts is a super easy way to brick your machine. (Any syntax error end up with no keyboard support at all.)

I'm not sure what the best, "correct" default behavior should be for Allegro, and whether there should be a configuration option. But it seems like Allegro should be respecting remapped keys for disabled people / international people.

Running Ubuntu 16.04 LTS with Allegro 5.1.11.


The intention of ALLEGRO_KEY_CODE is to be just an opaque identifier of the key that is pressed. As it is implemented right now, on OSX and Windows key down/up events do not respect the keyboard layout, while on Linux they sometimes respect it and sometimes don't. I'm working on code to opt into Linux never respecting the key layouts so you can rely on them being the same physical key cross-platform.

What does respect they key layout are the ALLEGRO_KEY_CHAR events and al_keycode_to_name. The former allows you to handle text input, and the latter lets you convert the keycodes to something you can draw on the screen (which will respect the layout). I do note that al_keycode_to_name doesn't seem to do what I'm describing on Windows and it only sort of works on Linux like that... not sure about OSX.


It think it does respect the keyboard layout on Windows though. Might have to revert to using scan codes directly to avoid that...

Gideon Weems

Allegro, Virtualbox, and SDL: These three have never respected xmodmap for me.

Virtualbox did respect xmodmap at one point, but one of the maintainers decided he did not like that. I hope to one day map my keycodes in hardware.

Chris Katko

but one of the maintainers decided he did not like that.

Man, people really love to crap on the disabled. >:(

Thread #616770. Printed from Allegro.cc