From ef76acd8b40a98b2270d6074a2fb985f5f277867 Mon Sep 17 00:00:00 2001 From: INeedBots Date: Sat, 2 Jan 2021 17:37:46 -0600 Subject: [PATCH] [XInput] Stubbed user movement apply, make sure reading 8 bits for movement data --- src/Components/Modules/XInput.cpp | 27 ++++++++++++++++++++++++++- src/Components/Modules/XInput.hpp | 3 ++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/XInput.cpp b/src/Components/Modules/XInput.cpp index c2f8f261..c4dc50b8 100644 --- a/src/Components/Modules/XInput.cpp +++ b/src/Components/Modules/XInput.cpp @@ -93,13 +93,32 @@ namespace Components __declspec(naked) void XInput::MSG_ReadDeltaUsercmdKeyStub() { + __asm + { + // return back + push 0x4921BF + ret + } + } + __declspec(naked) void XInput::MSG_ReadDeltaUsercmdKeyStub2() + { + __asm + { + // return back + push 3 + push esi + push 0x492085 + ret + } } XInput::XInput() { + // poll xinput devices every client frame Utils::Hook(0x486970, XInput::CL_FrameStub, HOOK_JUMP).install()->quick(); + // use the xinput state when creating a usercmd Utils::Hook(0x5A6DB9, XInput::CL_CreateCmdStub, HOOK_JUMP).install()->quick(); // package the forward and right move components in the move buttons @@ -109,6 +128,12 @@ namespace Components Utils::Hook::Set(0x60E501, 8); Utils::Hook::Set(0x60E5CD, 8); - //Utils::Hook(0x5A6DB9, XInput::MSG_ReadDeltaUsercmdKeyStub, HOOK_JUMP).install()->quick(); + // make sure to parse the movement data properally and apply it + Utils::Hook(0x492191, XInput::MSG_ReadDeltaUsercmdKeyStub, HOOK_JUMP).install()->quick(); + Utils::Hook(0x492061, XInput::MSG_ReadDeltaUsercmdKeyStub2, HOOK_JUMP).install()->quick(); + + // read two bytes instead of one for receiveing movement data + Utils::Hook::Set(0x492049, 8); + Utils::Hook::Set(0x492177, 8); } } diff --git a/src/Components/Modules/XInput.hpp b/src/Components/Modules/XInput.hpp index 0a808b77..7a1b328a 100644 --- a/src/Components/Modules/XInput.hpp +++ b/src/Components/Modules/XInput.hpp @@ -20,5 +20,6 @@ namespace Components static void MSG_WriteDeltaUsercmdKeyStub(); static void MSG_ReadDeltaUsercmdKeyStub(); - } + static void MSG_ReadDeltaUsercmdKeyStub2(); + }; }