From ce04dca0f15fecb7f055aa89b3e0f63993763dd5 Mon Sep 17 00:00:00 2001 From: blattersturm <24576130+blattersturm@users.noreply.github.com> Date: Mon, 8 Jan 2024 00:34:50 +0200 Subject: [PATCH] tweak(input/five): release cursor capture for the game's cursor Custom bits of UI (NUI focus, as well as the F8 console/dear ImGui) do this already, which makes the game's mouse cursor (such as in the pause menu) behave differently. This commit solves this by hooking up the QueryMayLockCursor event to a flag specifying if the cursor is visible. --- code/components/rage-input-five/src/InputHook.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/components/rage-input-five/src/InputHook.cpp b/code/components/rage-input-five/src/InputHook.cpp index c4e39e630a..feb55b73ca 100644 --- a/code/components/rage-input-five/src/InputHook.cpp +++ b/code/components/rage-input-five/src/InputHook.cpp @@ -793,6 +793,17 @@ static HookFunction hookFunction([]() // cancel out ioLogitechLedDevice hook::jump(hook::get_pattern("85 C0 0F 85 ? ? 00 00 48 8B CB FF 15", -0x77), Return0); + + // hook up cursor lock to CMousePointer::_bIsVisible + static auto isPointerVisible = hook::get_address(hook::get_pattern("80 3D ? ? ? ? 00 0F 45 C6 88 05 ? ? ? ? 48 8B 5C", 10), 2, 6) + 2; + + InputHook::QueryMayLockCursor.Connect([](int& may) + { + if (*isPointerVisible) + { + may = FALSE; + } + }); }); fwEvent InputHook::DeprecatedOnWndProc;