[XInput] Added sending movement components
This commit is contained in:
parent
a737dd16e4
commit
d123ade36f
@ -35,14 +35,14 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
void XInput::CL_GamepadMove(int localClientNum, Game::usercmd_s* cmd)
|
||||
void XInput::CL_GamepadMove(int, Game::usercmd_s* cmd)
|
||||
{
|
||||
if (XInput::xiPlayerNum != -1)
|
||||
{
|
||||
XINPUT_STATE* xiState = &xiStates[xiPlayerNum];
|
||||
|
||||
cmd->rightmove = xiState->Gamepad.sThumbLX / 256;
|
||||
cmd->forwardmove = xiState->Gamepad.sThumbLY / 256;
|
||||
cmd->rightmove = static_cast<BYTE>(xiState->Gamepad.sThumbLX / 256);
|
||||
cmd->forwardmove = static_cast<BYTE>(xiState->Gamepad.sThumbLY / 256);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,10 +67,48 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void XInput::MSG_WriteDeltaUsercmdKeyStub()
|
||||
{
|
||||
__asm
|
||||
{
|
||||
// fix stack pointer
|
||||
add esp, 0Ch
|
||||
|
||||
// put both forward move and rightmove values in the movement button
|
||||
mov dl, byte ptr [edi+1Ah] // to_forwardMove
|
||||
mov dh, byte ptr [edi+1Bh] // to_rightMove
|
||||
|
||||
mov [esp+30h], dx // to_buttons
|
||||
|
||||
mov dl, byte ptr [ebp+1Ah] // from_forwardMove
|
||||
mov dh, byte ptr [ebp+1Bh] // from_rightMove
|
||||
|
||||
mov [esp+2Ch], dx // from_buttons
|
||||
|
||||
// return back
|
||||
push 0x60E40E
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(naked) void XInput::MSG_ReadDeltaUsercmdKeyStub()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XInput::XInput()
|
||||
{
|
||||
Utils::Hook(0x486970, XInput::CL_FrameStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
Utils::Hook(0x5A6DB9, XInput::CL_CreateCmdStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// package the forward and right move components in the move buttons
|
||||
Utils::Hook(0x60E38D, XInput::MSG_WriteDeltaUsercmdKeyStub, HOOK_JUMP).install()->quick();
|
||||
|
||||
// send two bytes instead of one for sending movement data
|
||||
Utils::Hook::Set<BYTE>(0x60E501, 8);
|
||||
Utils::Hook::Set<BYTE>(0x60E5CD, 8);
|
||||
|
||||
//Utils::Hook(0x5A6DB9, XInput::MSG_ReadDeltaUsercmdKeyStub, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +16,9 @@ namespace Components
|
||||
|
||||
static void CL_CreateCmdStub();
|
||||
static void CL_GamepadMove(int, Game::usercmd_s*);
|
||||
};
|
||||
|
||||
static void MSG_WriteDeltaUsercmdKeyStub();
|
||||
|
||||
static void MSG_ReadDeltaUsercmdKeyStub();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user