From 8d8b9758ced52b6303af95ad7e28ae9c5636cdf8 Mon Sep 17 00:00:00 2001 From: Anton Sharonov Date: Fri, 7 Oct 2022 16:28:48 +0100 Subject: [PATCH] patch 9.0.0686: the right ALT key does not work on some MS-Windows keyboards Problem: The right ALT key does not work on some MS-Windows keyboards. Solution: Adjust the modifiers based on GetKeyState(). (Anoton Sharonov, closes #11300) --- src/gui_w32.c | 7 +++++++ src/version.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/gui_w32.c b/src/gui_w32.c index 5e8fbe2a80..2dc54bf5f8 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -852,6 +852,13 @@ get_active_modifiers(void) modifiers |= MOD_MASK_ALT; if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000)) modifiers &= ~MOD_MASK_CTRL; + // Add RightALT only if it is hold alone (without Ctrl), because if AltGr + // is pressed, Windows claims that Ctrl is hold as well. That way we can + // recognize Right-ALT alone and be sure that not AltGr is hold. + if (!(GetKeyState(VK_CONTROL) & 0x8000) + && (GetKeyState(VK_RMENU) & 0x8000) + && !(GetKeyState(VK_LMENU) & 0x8000)) // seems AltGr has both set + modifiers |= MOD_MASK_ALT; return modifiers; } diff --git a/src/version.c b/src/version.c index 391ae4defb..c6c01976c7 100644 --- a/src/version.c +++ b/src/version.c @@ -699,6 +699,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 686, /**/ 685, /**/