Skip to content

Commit

Permalink
Fix modifiers + keys on Windows.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Nov 20, 2023
1 parent 8595185 commit 310332a
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/win/wkeyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ void _al_win_kbd_handle_key_press(int scode, int vcode, bool extended,
int char_count;
int event_count;
int i;
bool ks_state;
BYTE ks[256];
WCHAR buf[8] = { 0 };

Expand Down Expand Up @@ -380,11 +379,7 @@ void _al_win_kbd_handle_key_press(int scode, int vcode, bool extended,

/* Send char events, but not for modifier keys or dead keys. */
if (my_code < ALLEGRO_KEY_MODIFIERS) {
ks_state = GetKeyboardState(ks);
if(ks_state && ks[VK_CONTROL] && (modifiers & ALLEGRO_KEYMOD_CTRL)) {
ks[VK_CONTROL] = 0;
}
char_count = ToUnicode(vcode, scode, ks_state ? ks : NULL, buf, 8, 0);
char_count = ToUnicode(vcode, scode, GetKeyboardState(ks) ? ks : NULL, buf, 8, 0);
/* Send ASCII code 127 for both Del keys. */
if (char_count == 0 && vcode == VK_DELETE) {
char_count = 1;
Expand Down

0 comments on commit 310332a

Please sign in to comment.