|
12 | 12 |
|
13 | 13 | #include <ICoreGameInit.h>
|
14 | 14 | #include <GlobalInput.h>
|
| 15 | +#include <dinput.h> |
15 | 16 |
|
16 | 17 | #include "ffx_antilag2_dx11.h"
|
17 | 18 |
|
18 | 19 | static WNDPROC origWndProc;
|
19 | 20 |
|
| 21 | +typedef IDirectInputDeviceW* LPDIRECTINPUTDEVICEW; |
| 22 | +static LPDIRECTINPUTDEVICEW* g_diMouseDevice = nullptr; |
| 23 | + |
20 | 24 | static bool g_isFocused = true;
|
21 | 25 | static bool g_enableSetCursorPos = false;
|
22 | 26 | static bool g_isFocusStolen = false;
|
@@ -66,6 +70,16 @@ static void EnableFocus()
|
66 | 70 | }
|
67 | 71 | }
|
68 | 72 |
|
| 73 | +static void (*recaptureLostDevices)(); |
| 74 | + |
| 75 | +static void RecaptureLostDevices() |
| 76 | +{ |
| 77 | + if (!g_isFocusStolen) |
| 78 | + { |
| 79 | + recaptureLostDevices(); |
| 80 | + } |
| 81 | +} |
| 82 | + |
69 | 83 | static bool g_useHostCursor;
|
70 | 84 |
|
71 | 85 | void EnableHostCursor()
|
@@ -151,6 +165,10 @@ void InputHook::SetGameMouseFocus(bool focus)
|
151 | 165 |
|
152 | 166 | if (g_isFocusStolen)
|
153 | 167 | {
|
| 168 | + if (*g_diMouseDevice) |
| 169 | + { |
| 170 | + (*g_diMouseDevice)->Unacquire(); |
| 171 | + } |
154 | 172 | memset(g_gameKeyArray, 0, 256);
|
155 | 173 | }
|
156 | 174 |
|
@@ -736,6 +754,12 @@ static HookFunction hookFunction([]()
|
736 | 754 | hook::set_call(&enableFocus, patternMatch);
|
737 | 755 | hook::call(patternMatch, EnableFocus);
|
738 | 756 |
|
| 757 | + patternMatch = hook::pattern("48 83 EC ? 8B 0D ? ? ? ? 85 C9 74 ? FF C9 74 ? FF C9 75").count(1).get(0).get<void>(53); |
| 758 | + hook::set_call(&recaptureLostDevices, patternMatch); |
| 759 | + hook::call(patternMatch, RecaptureLostDevices); |
| 760 | + |
| 761 | + g_diMouseDevice = hook::get_address<LPDIRECTINPUTDEVICEW*>(hook::get_pattern("48 8B 0D ? ? ? ? 48 8B 01 FF 50 ? 83 F8 ? 7F ? 48 83 C4", 3)); |
| 762 | + |
739 | 763 | // game key array
|
740 | 764 | location = hook::pattern("BF 00 01 00 00 48 8D 1D ? ? ? ? 48 3B 05").count(1).get(0).get<char>(8);
|
741 | 765 |
|
|
0 commit comments