iw4x-client/src/Components/Modules/Lean.cpp

72 lines
1.3 KiB
C++
Raw Normal View History

2022-02-27 07:53:44 -05:00
#include <STDInclude.hpp>
2017-01-19 16:23:59 -05:00
namespace Components
{
Game::kbutton_t Lean::in_leanleft;
Game::kbutton_t Lean::in_leanright;
void Lean::IN_LeanLeft_Up()
{
Game::IN_KeyUp(&Lean::in_leanleft);
}
void Lean::IN_LeanLeft_Down()
{
Game::IN_KeyDown(&Lean::in_leanleft);
}
void Lean::IN_LeanRight_Up()
{
Game::IN_KeyUp(&Lean::in_leanright);
}
void Lean::IN_LeanRight_Down()
{
Game::IN_KeyDown(&Lean::in_leanright);
}
void Lean::SetLeanFlags(Game::usercmd_s* cmds)
{
if (Lean::in_leanleft.active || Lean::in_leanleft.wasPressed)
{
cmds->buttons |= BUTTON_FLAG_LEANLEFT;
}
if (Lean::in_leanright.active || Lean::in_leanright.wasPressed)
{
cmds->buttons |= BUTTON_FLAG_LEANRIGHT;
}
Lean::in_leanleft.wasPressed = false;
Lean::in_leanright.wasPressed = false;
2017-01-19 16:23:59 -05:00
}
void __declspec(naked) Lean::CL_CmdButtonsStub()
{
__asm
{
// CL_CmdButtons
mov ecx, 5A6510h
call ecx
2017-02-01 07:44:25 -05:00
pushad
2017-01-19 16:23:59 -05:00
push esi
call Lean::SetLeanFlags
pop esi
2017-02-01 07:44:25 -05:00
popad
2017-01-19 16:23:59 -05:00
retn
}
}
Lean::Lean()
{
Command::AddRaw("+leanleft", Lean::IN_LeanLeft_Down, true);
Command::AddRaw("-leanleft", Lean::IN_LeanLeft_Up, true);
Command::AddRaw("+leanright", Lean::IN_LeanRight_Down, true);
Command::AddRaw("-leanright", Lean::IN_LeanRight_Up, true);
Utils::Hook(0x5A6D84, Lean::CL_CmdButtonsStub, HOOK_CALL).install()->quick();
}
}