Skip to content

fix: hook GetRawInputData to block mouse clicks from reaching game through menu#959

Open
Abdelakil wants to merge 5 commits into
YimMenu:enhancedfrom
Abdelakil:pr/mouse-fix
Open

fix: hook GetRawInputData to block mouse clicks from reaching game through menu#959
Abdelakil wants to merge 5 commits into
YimMenu:enhancedfrom
Abdelakil:pr/mouse-fix

Conversation

@Abdelakil

Copy link
Copy Markdown
Contributor

When YimMenuV2 is open and the user clicks on a menu option, the click also passes through to the game window because GTA V Enhanced reads mouse input via Raw Input (GetRawInputData), not WM_LBUTTONDOWN/WM_RBUTTONDOWN.

This hooks GetRawInputData and zeroes out mouse button flags when the menu is open, preventing the game from seeing clicks that ImGui has already consumed.

  • Adds src/game/hooks/GUI/RawInput.cpp — GetRawInputData hook
  • Registers the hook in Hooking.cpp
  • Declares the hook in Hooks.hpp

No behavioral changes when the menu is closed.

Comment thread src/game/hooks/GUI/RawInput.cpp Outdated
{
auto result = BaseHook::Get<RawInput::GetRawInputData, DetourHook<decltype(&RawInput::GetRawInputData)>>()->Original()(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader);

if (result > 0 && pData && uiCommand == RID_INPUT && GUI::IsOpen())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better if this only blocks the clicks that are on the menu.

Abdelakil and others added 3 commits July 20, 2026 02:54
Blocks clicks using ImGui::GetIO().WantCaptureMouse instead of
blanket-blocking all clicks when menu is open. Lets clicks pass
through to the game for areas outside the menu.
@Abdelakil

Copy link
Copy Markdown
Contributor Author

Addressed review feedback: now only blocks raw mouse clicks when the click lands on the ImGui menu (via ImGui::GetIO().WantCaptureMouse), instead of blocking all clicks while the menu is open. Clicks outside the menu pass through to the game.

@Abdelakil
Abdelakil requested a review from tuyilmaz July 21, 2026 15:11
@Abdelakil

Copy link
Copy Markdown
Contributor Author

@tuyilmaz @ShinyWasabi updated per feedback — now only blocks raw mouse clicks when cursor is over the menu (WantCaptureMouse). Ready for re-review.

Comment thread src/game/hooks/GUI/RawInput.cpp Outdated
auto result = BaseHook::Get<RawInput::GetRawInputData, DetourHook<decltype(&RawInput::GetRawInputData)>>()->Original()(hRawInput, uiCommand, pData, pcbSize, cbSizeHeader);

if (result > 0 && pData && uiCommand == RID_INPUT && GUI::IsOpen())
if (result > 0 && pData && uiCommand == RID_INPUT && GUI::IsOpen() && ImGui::GetIO().WantCaptureMouse)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io.WantCaptureMouse already checks if the UI is visible. We don't need GUI::IsOpen()

WantCaptureMouse already implies menu is visible.
@Abdelakil

Copy link
Copy Markdown
Contributor Author

Addressed — removed GUI::IsOpen(). WantCaptureMouse alone covers it.

@Abdelakil
Abdelakil requested a review from tuyilmaz July 21, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants