Skip to content

Commit

Permalink
added support for F12-24, browser_back, browser_forward keys
Browse files Browse the repository at this point in the history
fixed print screen key issue.
  • Loading branch information
zaafar committed Nov 20, 2023
1 parent e204817 commit eecdb59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion ClickableTransparentOverlay/ImGuiInputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down

0 comments on commit eecdb59

Please sign in to comment.