Skip to content

Commit 6894648

Browse files
SiegeLordExSiegeLord
authored andcommitted
Try fixing some oddities with Shift + Alt on Windows.
There were two issues. 1. Holding Shift + tapping Alt would send spurious Control(!?) key up messages. I can reliably identify them by checking whether the repeat(aka previous) flag is set. MSDN says it always should be 1, but it's 0 for these weird events. 2. Holding Alt + tapping Shift would set weird KEY_CHAR events. This evidently can be fixed by sending the scan code to our event decoder from WM_SYSKEYDOWN messages. I'm not sure why we didn't before. Fixes #1348
1 parent d96f635 commit 6894648

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/win/wwindow.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,10 @@ static LRESULT CALLBACK window_callback(HWND hWnd, UINT message,
711711
}
712712
case WM_SYSKEYDOWN: {
713713
int vcode = wParam;
714+
int scode = (lParam >> 16) & 0xff;
714715
bool extended = (lParam >> 24) & 0x1;
715716
bool repeated = (lParam >> 30) & 0x1;
716-
_al_win_kbd_handle_key_press(0, vcode, extended, repeated, win_display);
717+
_al_win_kbd_handle_key_press(scode, vcode, extended, repeated, win_display);
717718
break;
718719
}
719720
case WM_KEYDOWN: {
@@ -731,7 +732,13 @@ static LRESULT CALLBACK window_callback(HWND hWnd, UINT message,
731732
int vcode = wParam;
732733
int scode = (lParam >> 16) & 0xff;
733734
bool extended = (lParam >> 24) & 0x1;
734-
_al_win_kbd_handle_key_release(scode, vcode, extended, win_display);
735+
bool previous = (lParam >> 30) & 0x1;
736+
737+
/* The docs say that previous should always be 1, but it's not in practice.
738+
* The events with previous = 0 seem malformed? I can get them reliably by
739+
* pressing + holding Shift and then tapping Alt. */
740+
if (previous)
741+
_al_win_kbd_handle_key_release(scode, vcode, extended, win_display);
735742
break;
736743
}
737744
case WM_SYSCOMMAND: {

0 commit comments

Comments
 (0)