@@ -478,9 +478,6 @@ void OnDXPresent(IDXGISwapChain* pSwapChain) {
478478 }
479479 g_ShowKeyWasPressed = keyCurrentlyPressed;
480480
481- if (!g_Visible)
482- return ;
483-
484481 g_needsNewImGuiFrame = true ;
485482 g_totalPresentCalls++;
486483
@@ -682,11 +679,39 @@ void OnDXPresent(IDXGISwapChain* pSwapChain) {
682679
683680 // UI Logic
684681 if (g_needsNewImGuiFrame) {
682+ ImGuiIO& io = ImGui::GetIO ();
683+
685684 ImGui_ImplDX12_NewFrame ();
686685 ImGui_ImplWin32_NewFrame ();
686+ io.DisplaySize = ImVec2 ((float )width, (float )height);
687+
688+ if (g_Visible && g_currentHWND) {
689+ POINT cursorPos;
690+ if (GetCursorPos (&cursorPos)) {
691+ ScreenToClient (g_currentHWND, &cursorPos);
692+ io.AddMousePosEvent ((float )cursorPos.x , (float )cursorPos.y );
693+ }
694+ // Poll button state and feed it through the event queue
695+ io.AddMouseButtonEvent (0 , (GetAsyncKeyState (VK_LBUTTON) & 0x8000 ) != 0 );
696+ io.AddMouseButtonEvent (1 , (GetAsyncKeyState (VK_RBUTTON) & 0x8000 ) != 0 );
697+ io.AddMouseButtonEvent (2 , (GetAsyncKeyState (VK_MBUTTON) & 0x8000 ) != 0 );
698+ // Draw ImGui's own cursor on top – mirrors Community Shaders behaviour.
699+ // The game cursor can be hidden in certain states (in-game, menus with
700+ // hardware cursor hidden), so ImGui's software cursor is more reliable.
701+ io.MouseDrawCursor = true ;
702+ } else {
703+ io.MouseDrawCursor = false ;
704+ }
705+
706+ if (!g_Visible) {
707+ io.ClearInputKeys ();
708+ }
709+
687710 ImGui::NewFrame ();
688711
689- ImGuiOverlayShared::DrawUI (width, height);
712+ if (g_Visible) {
713+ ImGuiOverlayShared::DrawUI (width, height);
714+ }
690715 ImGui::Render ();
691716 g_needsNewImGuiFrame = false ;
692717 }
0 commit comments