From f7cdc0f5b4b4a7728e5dd2db71d4bf3149eefce3 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 20 Jan 2018 15:46:37 +0100 Subject: [PATCH] ALT+TAB now gets special treatment when the mouse is not captured, prevents stuck TAB key. --- src/win/win_keyboard.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/win/win_keyboard.c b/src/win/win_keyboard.c index 483ada3c6..287fa2c08 100644 --- a/src/win/win_keyboard.c +++ b/src/win/win_keyboard.c @@ -8,11 +8,11 @@ * * Windows raw keyboard input handler. * - * Version: @(#)win_keyboard.c 1.0.5 2018/01/09 + * Version: @(#)win_keyboard.c 1.0.6 2018/01/20 * * Author: Miran Grca, * - * Copyright 2016,2018 Miran Grca. + * Copyright 2016-2018 Miran Grca. */ #define UNICODE #define _WIN32_WINNT 0x0501 @@ -150,8 +150,29 @@ keyboard_handle(LPARAM lParam, int infocus) We use scan code 0xFFFF to mean a mapping that has a prefix other than E0 and that is not E1 1D, which is, for our purposes, invalid. */ - if (scancode != 0xFFFF) - keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode); + if ((scancode == 0x00F) && + !(rawKB.Flags & RI_KEY_BREAK) && + (keyboard_recv(0x038) || keyboard_recv(0x138)) && + !mouse_capture) { + /* We received a TAB while ALT was pressed, while the mouse + is not captured, suppress the TAB and send an ALT key up. */ + if (keyboard_recv(0x038)) + keyboard_input(0, 0x038); + if (keyboard_recv(0x138)) + keyboard_input(0, 0x138); + } else if (((scancode == 0x038) || (scancode == 0x138)) && + !(rawKB.Flags & RI_KEY_BREAK) && + keyboard_recv(0x00F) && + !mouse_capture) { + /* We received an ALT while TAB was pressed, while the mouse + is not captured, suppress the ALT and send a TAB key up. */ + keyboard_input(0, 0x00F); + } else { + /* Normal scan code pass through, pass it through as is if + it's not an invalid scan code. */ + if (scancode != 0xFFFF) + keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode); + } } else { if (rawKB.MakeCode == 0x1D) { scancode = scancode_map[0x100]; /* Translate E1 1D to 0x100 (which would