From 32df2ed7161d21242b9ebd10c3542f98f71210e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Mar 2022 19:12:29 +0100 Subject: [PATCH] Win32: Fix scancode and key for Alt+PrtSc events Alt+PrtSc emits a different scancode than just PrtSc. Since the GLFW API assumes each key corresponds to only one scancode, this cannot be added to the keycodes array. Instead we replace the scancode at the point of entry. Fixes #1993 (cherry picked from commit 03cfe957e739e41cdfd66b554c076b5b31f48c1e) --- CONTRIBUTORS.md | 1 + README.md | 3 ++- src/win32_window.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0bc0cd29..44f57a38 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -69,6 +69,7 @@ video tutorials. - Ryan C. Gordon - Stephen Gowen - Kovid Goyal + - Kevin Grandemange - Eloi Marín Gratacós - Stefan Gustavson - Andrew Gutekanst diff --git a/README.md b/README.md index 7c59dea9..0f200688 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,8 @@ information on what to include when reporting a bug. ## Changelog -There is nothing here yet. + - [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different + scancode than `PrtSc` (#1993) ## Contact diff --git a/src/win32_window.c b/src/win32_window.c index 507f3663..194d3ac9 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -748,6 +748,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); } + // HACK: Alt+PrtSc has a different scancode than just PrtSc + if (scancode == 0x54) + scancode = 0x137; + key = _glfw.win32.keycodes[scancode]; // The Ctrl keys require special handling