Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Different ALLEGRO_KEYCODE_* with Alt-Graph on Windows/Linux

This thread is locked; no one can reply to it. rss feed Print
Different ALLEGRO_KEYCODE_* with Alt-Graph on Windows/Linux
egrath
Member #23,748
April 2023

Hi,

i'm absolutely new to the world of Allegro development and stumbled across my first issue. My application uses keyboard events and the generated keycodes differ on Windows and Linux.

My keyboard layout uses Alt-Graph to access some keys like the at-Symbol (@) - i'm using a german keyboard. On Linux, whenever i press Alt-Graph+Q to generate the at-Symbol, it's picked up correctly by Allegro:

KEY_DOWN  code=220, char=' ' (   0), modifiers=00000000, [ISO_Level3_Shift]
KEY_DOWN  code=017, char=' ' (   0), modifiers=00000000, [q]
KEY_CHAR  code=017, char='@' (  64), modifiers=00000220, [q]
KEY_UP    code=017, char=' ' (   0), modifiers=00000000, [q]
KEY_UP    code=220, char=' ' (   0), modifiers=00000000, [ISO_Level3_Shift]

however, the same code compiled on Windows (with MinGW), yields a completely different result:

KEY_DOWN  code=220, char=' ' (   0), modifiers=00000000, [ALTGR]
KEY_DOWN  code=017, char=' ' (   0), modifiers=00000000, [Q]
KEY_CHAR  code=017, char='q' ( 113), modifiers=00000242, [Q]
KEY_UP    code=017, char=' ' (   0), modifiers=00000000, [Q]
KEY_UP    code=217, char=' ' (   0), modifiers=00000000, [LCTRL]

The application used to generate the output above is the keyboard event example from the official repository (https://github.com/liballeg/allegro5/blob/master/examples/ex_keyboard_events.c)

Any ideas what i have done wrong? Or is this simply a bug in the library?

Best regards,
Egon

/edit: I've attached the test program i used. Would be great if someone could verify the results i got to make sure that it's not a configuration issue on my side. I'm running Windows 11 22H2 (English) with German (QWERTZ) keyboard layout

torhu
Member #2,727
September 2002
avatar

Just to confirm, are you sure you are using a German keyboard layout on Windows, does it work correctly in other applications?

egrath
Member #23,748
April 2023

Yes definitely - i'm a german native speaker and use german keyboard layouts almost on every device :-)

Inserting Alt-Graph symbols like @, {, }, ... works in every other application i use.

torhu
Member #2,727
September 2002
avatar

Hm, that's odd. I have a Norwegian keyboard, we also use AltGr. I tested with an old version of Allegro that I had installed, no problem.

egrath
Member #23,748
April 2023

Which version of Allegro have you used? I want to cross-check with that version to determine if it's a regression introduced lately.

torhu
Member #2,727
September 2002
avatar

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: