diff --git a/src/Components/Modules/XInput.cpp b/src/Components/Modules/XInput.cpp index cda6af1d..4feb3520 100644 --- a/src/Components/Modules/XInput.cpp +++ b/src/Components/Modules/XInput.cpp @@ -2,7 +2,43 @@ namespace Components { + XINPUT_STATE XInput::xiStates[XUSER_MAX_COUNT]; + + void XInput::PollXInputDevices() + { + for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) + { + XInputGetState(i, &xiStates[i]); + } + } + + __declspec(naked) void XInput::CL_FrameStub() + { + __asm + { + // poll the xinput devices on every client frame + pusha + pushad + + call XInput::PollXInputDevices + + popad + popa + + // execute the code we patched over + sub esp, 0Ch + push ebx + push ebp + push esi + + // return back to original code + push 0x486976 + retn + } + } + XInput::XInput() { + Utils::Hook(0x486970, XInput::CL_FrameStub, HOOK_JUMP).install()->quick(); } } diff --git a/src/Components/Modules/XInput.hpp b/src/Components/Modules/XInput.hpp index 5263d6b2..21670867 100644 --- a/src/Components/Modules/XInput.hpp +++ b/src/Components/Modules/XInput.hpp @@ -8,6 +8,12 @@ namespace Components XInput(); private: - + static XINPUT_STATE xiStates[XUSER_MAX_COUNT]; + + static void CL_FrameStub(); + static void PollXInputDevices(); + + static void CL_CreateCmdStub(); + static void CL_GamepadMove(int, Game::usercmd_s*); }; } diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 872e40c3..d6574ed3 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -48,6 +48,9 @@ #include #pragma comment(lib, "D3dx9.lib") +#include +#pragma comment (lib, "xinput.lib") + // Usefull for debugging template class Sizer { }; #define BindNum(x, y) Sizer y;