Skip to content

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

Open
Abdelakil wants to merge 1 commit 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 1 commit into
YimMenu:enhancedfrom
Abdelakil:pr/mouse-fix

Conversation

@Abdelakil

Copy link
Copy Markdown

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.

{
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.

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