Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » [Linux] Does Allegro 5 respect xkb/xmodmap remapping?

This thread is locked; no one can reply to it. rss feed Print
[Linux] Does Allegro 5 respect xkb/xmodmap remapping?
Chris Katko
Member #1,881
January 2002
avatar

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.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

SiegeLord
Member #7,827
October 2006
avatar

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.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

torhu
Member #2,727
September 2002
avatar

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
Member #3,925
October 2003

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
Member #1,881
January 2002
avatar

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

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

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

Go to: