Skip to content

Commit

Permalink
Merge DirectInput mouseDev unacquire (pr-3072)
Browse files Browse the repository at this point in the history
9518c13 - fix(input/five): DirectInput mouseDev unacquire
  • Loading branch information
prikolium-cfx committed Feb 5, 2025
2 parents 7b6e04d + 9518c13 commit 7a6ab03
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions code/components/rage-input-five/src/InputHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@

#include <ICoreGameInit.h>
#include <GlobalInput.h>
#include <dinput.h>

#include "ffx_antilag2_dx11.h"

static WNDPROC origWndProc;

typedef IDirectInputDeviceW* LPDIRECTINPUTDEVICEW;
static LPDIRECTINPUTDEVICEW* g_diMouseDevice = nullptr;

static bool g_isFocused = true;
static bool g_enableSetCursorPos = false;
static bool g_isFocusStolen = false;
Expand Down Expand Up @@ -66,6 +70,16 @@ static void EnableFocus()
}
}

static void (*recaptureLostDevices)();

static void RecaptureLostDevices()
{
if (!g_isFocusStolen)
{
recaptureLostDevices();
}
}

static bool g_useHostCursor;

void EnableHostCursor()
Expand Down Expand Up @@ -151,6 +165,10 @@ void InputHook::SetGameMouseFocus(bool focus)

if (g_isFocusStolen)
{
if (*g_diMouseDevice)
{
(*g_diMouseDevice)->Unacquire();
}
memset(g_gameKeyArray, 0, 256);
}

Expand Down Expand Up @@ -736,6 +754,12 @@ static HookFunction hookFunction([]()
hook::set_call(&enableFocus, patternMatch);
hook::call(patternMatch, EnableFocus);

patternMatch = hook::pattern("48 83 EC ? 8B 0D ? ? ? ? 85 C9 74 ? FF C9 74 ? FF C9 75").count(1).get(0).get<void>(53);
hook::set_call(&recaptureLostDevices, patternMatch);
hook::call(patternMatch, RecaptureLostDevices);

g_diMouseDevice = hook::get_address<LPDIRECTINPUTDEVICEW*>(hook::get_pattern("48 8B 0D ? ? ? ? 48 8B 01 FF 50 ? 83 F8 ? 7F ? 48 83 C4", 3));

// game key array
location = hook::pattern("BF 00 01 00 00 48 8D 1D ? ? ? ? 48 3B 05").count(1).get(0).get<char>(8);

Expand Down

0 comments on commit 7a6ab03

Please sign in to comment.