Skip to content

Commit 3b750b9

Browse files
committed
fix ui interaction
1 parent 38f332d commit 3b750b9

6 files changed

Lines changed: 129 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010

11+
## [1.0.1] - 2026-05-28
12+
13+
### Fixed
14+
- Fix UI not interactable on some games.
15+
16+
1117
## [1.0.0] - 2026-05-26
1218

1319
### Added

src/d3d10/overlay.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ void OnDXPresent(IDXGISwapChain* pSwapChain) {
173173
}
174174
g_ShowKeyWasPressed = keyCurrentlyPressed;
175175

176-
if (!g_Visible)
177-
return;
178-
179176
g_needsNewImGuiFrame = true;
180177
g_totalPresentCalls++;
181178

@@ -277,11 +274,39 @@ void OnDXPresent(IDXGISwapChain* pSwapChain) {
277274
if (shouldLog)
278275
Logger::info("DX10 Frame " + std::to_string(frameCount10));
279276

277+
ImGuiIO& io = ImGui::GetIO();
278+
280279
ImGui_ImplDX10_NewFrame();
281280
ImGui_ImplWin32_NewFrame();
281+
io.DisplaySize = ImVec2((float)desc.BufferDesc.Width, (float)desc.BufferDesc.Height);
282+
283+
if (g_Visible && g_currentHWND) {
284+
POINT cursorPos;
285+
if (GetCursorPos(&cursorPos)) {
286+
ScreenToClient(g_currentHWND, &cursorPos);
287+
io.AddMousePosEvent((float)cursorPos.x, (float)cursorPos.y);
288+
}
289+
// Poll button state and feed it through the event queue
290+
io.AddMouseButtonEvent(0, (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0);
291+
io.AddMouseButtonEvent(1, (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0);
292+
io.AddMouseButtonEvent(2, (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0);
293+
// Draw ImGui's own cursor on top – mirrors Community Shaders behaviour.
294+
// The game cursor can be hidden in certain states (in-game, menus with
295+
// hardware cursor hidden), so ImGui's software cursor is more reliable.
296+
io.MouseDrawCursor = true;
297+
} else {
298+
io.MouseDrawCursor = false;
299+
}
300+
301+
if (!g_Visible) {
302+
io.ClearInputKeys();
303+
}
304+
282305
ImGui::NewFrame();
283306

284-
ImGuiOverlayShared::DrawUI(desc.BufferDesc.Width, desc.BufferDesc.Height);
307+
if (g_Visible) {
308+
ImGuiOverlayShared::DrawUI(desc.BufferDesc.Width, desc.BufferDesc.Height);
309+
}
285310

286311
ImGui::Render();
287312

src/d3d11/overlay.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,31 @@ void OnDXPresent(IDXGISwapChain* pSwapChain) {
282282
bool shouldLog = (frameCount11 < 5);
283283
if (shouldLog)
284284
Logger::info("DX11 Frame " + std::to_string(frameCount11));
285-
285+
286286
ImGuiIO& io = ImGui::GetIO();
287287

288288
ImGui_ImplDX11_NewFrame();
289289
ImGui_ImplWin32_NewFrame();
290290
io.DisplaySize = ImVec2((float)desc.BufferDesc.Width, (float)desc.BufferDesc.Height);
291291

292+
if (g_Visible && g_currentHWND) {
293+
POINT cursorPos;
294+
if (GetCursorPos(&cursorPos)) {
295+
ScreenToClient(g_currentHWND, &cursorPos);
296+
io.AddMousePosEvent((float)cursorPos.x, (float)cursorPos.y);
297+
}
298+
// Poll button state and feed it through the event queue
299+
io.AddMouseButtonEvent(0, (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0);
300+
io.AddMouseButtonEvent(1, (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0);
301+
io.AddMouseButtonEvent(2, (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0);
302+
// Draw ImGui's own cursor on top – mirrors Community Shaders behaviour.
303+
// The game cursor can be hidden in certain states (in-game, menus with
304+
// hardware cursor hidden), so ImGui's software cursor is more reliable.
305+
io.MouseDrawCursor = true;
306+
} else {
307+
io.MouseDrawCursor = false;
308+
}
309+
292310
// io.MouseDrawCursor = g_Visible;
293311
if (!g_Visible) {
294312
io.ClearInputKeys();

src/d3d12/overlay.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/d3d9/dx_overlay.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,29 @@ void OverlayRenderer::NewFrame() {
119119

120120
ImGui_ImplDX9_NewFrame();
121121
ImGui_ImplWin32_NewFrame();
122+
123+
if (m_visible && m_hWnd) {
124+
POINT cursorPos;
125+
if (GetCursorPos(&cursorPos)) {
126+
ScreenToClient(m_hWnd, &cursorPos);
127+
io.AddMousePosEvent((float)cursorPos.x, (float)cursorPos.y);
128+
}
129+
// Poll button state and feed it through the event queue
130+
io.AddMouseButtonEvent(0, (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0);
131+
io.AddMouseButtonEvent(1, (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0);
132+
io.AddMouseButtonEvent(2, (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0);
133+
// Draw ImGui's own cursor on top – mirrors Community Shaders behaviour.
134+
// The game cursor can be hidden in certain states (in-game, menus with
135+
// hardware cursor hidden), so ImGui's software cursor is more reliable.
136+
io.MouseDrawCursor = true;
137+
} else {
138+
io.MouseDrawCursor = false;
139+
}
140+
141+
if (!m_visible) {
142+
io.ClearInputKeys();
143+
}
144+
122145
ImGui::NewFrame();
123146
}
124147

src/vk/overlay.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ void OverlayRenderer::NewFrame() {
328328
}
329329
m_showKeyWasPressed = keyCurrentlyPressed;
330330

331-
if (!m_visible)
332-
return;
333-
334331
auto currentTime = std::chrono::steady_clock::now();
335332
float deltaTime = std::chrono::duration<float, std::ratio<1, 1>>(currentTime - m_lastTime).count();
336333
m_lastTime = currentTime;
@@ -341,6 +338,29 @@ void OverlayRenderer::NewFrame() {
341338

342339
ImGui_ImplVulkan_NewFrame();
343340
ImGui_ImplWin32_NewFrame();
341+
342+
if (m_visible && m_hWnd) {
343+
POINT cursorPos;
344+
if (GetCursorPos(&cursorPos)) {
345+
ScreenToClient(m_hWnd, &cursorPos);
346+
io.AddMousePosEvent((float)cursorPos.x, (float)cursorPos.y);
347+
}
348+
// Poll button state and feed it through the event queue
349+
io.AddMouseButtonEvent(0, (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0);
350+
io.AddMouseButtonEvent(1, (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0);
351+
io.AddMouseButtonEvent(2, (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0);
352+
// Draw ImGui's own cursor on top – mirrors Community Shaders behaviour.
353+
// The game cursor can be hidden in certain states (in-game, menus with
354+
// hardware cursor hidden), so ImGui's software cursor is more reliable.
355+
io.MouseDrawCursor = true;
356+
} else {
357+
io.MouseDrawCursor = false;
358+
}
359+
360+
if (!m_visible) {
361+
io.ClearInputKeys();
362+
}
363+
344364
ImGui::NewFrame();
345365
}
346366

0 commit comments

Comments
 (0)