Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt-Graph Keys not recognized on Windows #1430

Closed
egrath opened this issue Apr 9, 2023 · 4 comments
Closed

Alt-Graph Keys not recognized on Windows #1430

egrath opened this issue Apr 9, 2023 · 4 comments

Comments

@egrath
Copy link

egrath commented Apr 9, 2023

Issue
On Windows, characters which are entered using Alt-Graph+Key combinations are not recognized, but instead only the regular Key.

To demonstrate the issue, i've adopted one of the official examples (attached). On both runs, Alt-Graph+Q was pressed to produce the at-Symbol (@):

Windows 11 (English) with german keyboard layout:

[KEY_DOWN]: keycode=[217], char=[], modifiers=[00000000](LCTRL)
[KEY_DOWN]: keycode=[220], char=[], modifiers=[00000000](ALTGR)
[KEY_DOWN]: keycode=[017], char=[], modifiers=[00000000](Q)
[KEY_CHAR]: keycode=[017], char=[q], modifiers=[00000242](Q)
[KEY_UP]: keycode=[017], char=[], modifiers=[00000000](Q)
[KEY_UP]: keycode=[217], char=[], modifiers=[00000000](LCTRL)
[KEY_UP]: keycode=[220], char=[], modifiers=[00000000](ALTGR)

Ubuntu 20.04 with german keyboard layout:

[KEY_DOWN]: keycode=[220], char=[], modifiers=[00000000](ISO_Level3_Shift)
[KEY_DOWN]: keycode=[017], char=[], modifiers=[00000000](q)
[KEY_CHAR]: keycode=[017], char=[@], modifiers=[00000220](q)
[KEY_UP]: keycode=[017], char=[], modifiers=[00000000](q)
[KEY_UP]: keycode=[220], char=[], modifiers=[00000000](ISO_Level3_Shift)

Only the later one correctly produces the @-symbol.

How to reproduce:
Build the attached application on Windows (MinGW, Allegro 5.2.8) and enter a Alt-Graph generated symbol like @ (Alt-Graph+Q).

Expected behavior:
Windows should recognized the keypress in the same way as Linux does.

If you need any further information which can help to get this bug fixed, please let me know.
keytest.zip

@torhus
Copy link

torhus commented Oct 22, 2023

I tried this in an Allegro 5.0.5 build of ex_keyboard_events I had laying around, AltGr works fine there with my Norwegian keyboard layout.

I don't have newer builds to test on, but this commit looks suspicious: 4ff2088

@vortigano
Copy link

Here I have tested MinGW, Allegro 5.2.6.0 and I have the same problem.
Alt-Graph + 2 was pressed to produce the at-Symbol (@)
Windows 8.1 (Spanish) with Spanish keyboard layout:

[KEY_DOWN]: keycode=[217], char=[], modifiers=[00000000](LCTRL)
[KEY_DOWN]: keycode=[220], char=[], modifiers=[00000000](ALTGR)
[KEY_DOWN]: keycode=[029], char=[], modifiers=[00000000](2)
[KEY_CHAR]: keycode=[029], char=[2], modifiers=[00000042](2)
[KEY_UP]: keycode=[029], char=[], modifiers=[00000000](2)
[KEY_UP]: keycode=[217], char=[], modifiers=[00000000](LCTRL)
[KEY_UP]: keycode=[220], char=[], modifiers=[00000000](ALTGR)

I had reported this on discord too.

@SiegeLord
Copy link
Member

So... reverting 4ff2088 does make this work, as far as I can tell. I sort of can imagine what that change was meant to do, but I think it is wrong. I need to cross-check what happens on Linux with this, but we'll probably just revert it.

@torhus
Copy link

torhus commented Nov 8, 2023

So... reverting 4ff2088 does make this work, as far as I can tell. I sort of can imagine what that change was meant to do, but I think it is wrong. I need to cross-check what happens on Linux with this, but we'll probably just revert it.

I'm not completely sure what that commit is supposed to fix, but in my testing key combinations involving AltGr work fine even if I hold Left Control down. I tried on Allegro 5.0.8. If the idea is to suppress the extra key down and key up events that are generated for Left Control when pressing and releasing AltGr, I think that would be more involved.

SiegeLord pushed a commit that referenced this issue Nov 25, 2023
This reverts commit 4ff2088 which was ostensibly meant
to make CHAR events return the same character as when control was not pressed.
This is incorrect, as Ctrl + A, for example, should indeed return a unichar of 1. Along the way,
this broke AltGr requiring keys on non-English keyboards.

Fixes #1430, #1504

(cherry picked from commit 310332a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants