From 4af77130df2bf18d12eda1392f4589ca8233339d Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 4 May 2022 20:15:17 +0200 Subject: [PATCH 1/2] Fix RawMouse patch making gamepad mouse move hook not getting called --- src/Components/Modules/Gamepad.cpp | 7 ++++++- src/Components/Modules/Gamepad.hpp | 2 ++ src/Components/Modules/RawMouse.cpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index a511feea..250a5d85 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1833,13 +1833,18 @@ namespace Components return gamePads[0].inUse; } - int Gamepad::CL_MouseEvent_Hk(const int x, const int y, const int dx, const int dy) + void Gamepad::OnMouseMove(const int x, const int y, const int dx, const int dy) { if (dx != 0 || dy != 0) { gamePads[0].inUse = false; gpad_in_use.setRaw(false); } + } + + int Gamepad::CL_MouseEvent_Hk(const int x, const int y, const int dx, const int dy) + { + OnMouseMove(x, y, dx, dy); // Call original function return Utils::Hook::Call(0x4D7C50)(x, y, dx, dy); diff --git a/src/Components/Modules/Gamepad.hpp b/src/Components/Modules/Gamepad.hpp index 024d0c6a..a09a4ec6 100644 --- a/src/Components/Modules/Gamepad.hpp +++ b/src/Components/Modules/Gamepad.hpp @@ -41,6 +41,8 @@ namespace Components public: Gamepad(); + static void OnMouseMove(int x, int y, int dx, int dy); + private: static Game::ButtonToCodeMap_t buttonList[]; static Game::StickToCodeMap_t analogStickList[4]; diff --git a/src/Components/Modules/RawMouse.cpp b/src/Components/Modules/RawMouse.cpp index 3f95a874..51cba280 100644 --- a/src/Components/Modules/RawMouse.cpp +++ b/src/Components/Modules/RawMouse.cpp @@ -97,6 +97,7 @@ namespace Components Game::s_wmv->oldPos = curPos; ScreenToClient(Window::GetWindow(), &curPos); + Gamepad::OnMouseMove(curPos.x, curPos.y, dx, dy); auto recenterMouse = Game::CL_MouseEvent(curPos.x, curPos.y, dx, dy); if (recenterMouse) From 20d17a3dec95cce2c8ac48a5a22122eb721ad56f Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 4 May 2022 20:29:02 +0200 Subject: [PATCH 2/2] Mark Gamepad OnMouseMove parameters as maybe unused --- src/Components/Modules/Gamepad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Modules/Gamepad.cpp b/src/Components/Modules/Gamepad.cpp index 250a5d85..364021c8 100644 --- a/src/Components/Modules/Gamepad.cpp +++ b/src/Components/Modules/Gamepad.cpp @@ -1833,7 +1833,7 @@ namespace Components return gamePads[0].inUse; } - void Gamepad::OnMouseMove(const int x, const int y, const int dx, const int dy) + void Gamepad::OnMouseMove([[maybe_unused]] const int x, [[maybe_unused]] const int y, const int dx, const int dy) { if (dx != 0 || dy != 0) {