From eecdb5950c2bfa2d8db8fbebeeb4ea0af9f206b8 Mon Sep 17 00:00:00 2001 From: Zaafar <5079646+zaafar@users.noreply.github.com> Date: Sun, 19 Nov 2023 20:18:04 -0500 Subject: [PATCH] added support for F12-24, browser_back, browser_forward keys fixed print screen key issue. --- ClickableTransparentOverlay/ImGuiInputHandler.cs | 9 ++++++++- README.md | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ClickableTransparentOverlay/ImGuiInputHandler.cs b/ClickableTransparentOverlay/ImGuiInputHandler.cs index 0be1da0..1cb4ba3 100644 --- a/ClickableTransparentOverlay/ImGuiInputHandler.cs +++ b/ClickableTransparentOverlay/ImGuiInputHandler.cs @@ -88,6 +88,11 @@ public bool ProcessMessage(WindowMessage msg, UIntPtr wParam, IntPtr lParam) bool is_key_down = msg == WindowMessage.SysKeyDown || msg == WindowMessage.KeyDown; if ((ulong)wParam < 256 && TryMapKey((VK)wParam, out ImGuiKey imguikey)) { + if (imguikey == ImGuiKey.PrintScreen && !is_key_down) + { + io.AddKeyEvent(imguikey, true); + } + io.AddKeyEvent(imguikey, is_key_down); } @@ -161,7 +166,7 @@ static ImGuiKey KeyToImGuiKeyShortcut(VK keyToConvert, VK startKey1, ImGuiKey st result = key switch { - >= VK.F1 and <= VK.F12 => KeyToImGuiKeyShortcut(key, VK.F1, ImGuiKey.F1), + >= VK.F1 and <= VK.F24 => KeyToImGuiKeyShortcut(key, VK.F1, ImGuiKey.F1), >= VK.NUMPAD0 and <= VK.NUMPAD9 => KeyToImGuiKeyShortcut(key, VK.NUMPAD0, ImGuiKey.Keypad0), >= VK.KEY_A and <= VK.KEY_Z => KeyToImGuiKeyShortcut(key, VK.KEY_A, ImGuiKey.A), >= VK.KEY_0 and <= VK.KEY_9 => KeyToImGuiKeyShortcut(key, VK.KEY_0, ImGuiKey._0), @@ -213,6 +218,8 @@ static ImGuiKey KeyToImGuiKeyShortcut(VK keyToConvert, VK startKey1, ImGuiKey st VK.RMENU => ImGuiKey.RightAlt, VK.RWIN => ImGuiKey.RightSuper, VK.APPS => ImGuiKey.Menu, + VK.BROWSER_BACK => ImGuiKey.AppBack, + VK.BROWSER_FORWARD => ImGuiKey.AppForward, _ => ImGuiKey.None }; diff --git a/README.md b/README.md index 54f92d5..71689f7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ https://www.nuget.org/packages/ClickableTransparentOverlay Lots of classes in this library (e.g. ImGuiRenderer, ImGuiInputHandler and etc) closely follow (if not identical to) the official example in c++ ImGui library ([here](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp "Last changelog looked was 2022-10-11") -and [here](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp "Last changelog looked was 2023-04-04")). +and [here](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp "Last changelog looked was 2023-10-05")). This allows us to easily update this library if something changes over there.