mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-31 13:10:39 +00:00
- Adjust signatures of input functions slightly for consistency.
This commit is contained in:
parent
b8ba78cf89
commit
bd3e9b305e
8 changed files with 39 additions and 39 deletions
|
@ -110,7 +110,7 @@ void resetTurnHeldAmt()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, HIDInput* const hidInput, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale)
|
||||
{
|
||||
// set up variables.
|
||||
const int keymove = 1 << int(!!(inputBuffer->actions & SB_RUN));
|
||||
|
|
|
@ -83,4 +83,4 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P
|
|||
void updateTurnHeldAmt(const double scaleAdjust);
|
||||
bool isTurboTurnTime();
|
||||
void resetTurnHeldAmt();
|
||||
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, HIDInput* const hidInput, const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1);
|
||||
void processMovement(HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1);
|
||||
|
|
|
@ -370,46 +370,46 @@ CCMD(show_weapon)
|
|||
gi->ToggleShowWeapon();
|
||||
}
|
||||
|
||||
void ApplyGlobalInput(InputPacket& input, HIDInput* const hidInput)
|
||||
void ApplyGlobalInput(HIDInput* const hidInput, InputPacket* const inputBuffer)
|
||||
{
|
||||
if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend);
|
||||
if (WeaponToSend != 0) inputBuffer->setNewWeapon(WeaponToSend);
|
||||
WeaponToSend = 0;
|
||||
if (hidInput && buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
{
|
||||
// These buttons should not autorepeat. The game handlers are not really equipped for that.
|
||||
if (hidInput->joyaxes[JOYAXIS_Forward] > 0 && !(dpad_lock & 1)) { dpad_lock |= 1; input.setNewWeapon(WeaponSel_Prev); }
|
||||
if (hidInput->joyaxes[JOYAXIS_Forward] > 0 && !(dpad_lock & 1)) { dpad_lock |= 1; inputBuffer->setNewWeapon(WeaponSel_Prev); }
|
||||
else dpad_lock &= ~1;
|
||||
if (hidInput->joyaxes[JOYAXIS_Forward] < 0 && !(dpad_lock & 2)) { dpad_lock |= 2; input.setNewWeapon(WeaponSel_Next); }
|
||||
if (hidInput->joyaxes[JOYAXIS_Forward] < 0 && !(dpad_lock & 2)) { dpad_lock |= 2; inputBuffer->setNewWeapon(WeaponSel_Next); }
|
||||
else dpad_lock &= ~2;
|
||||
if ((hidInput->joyaxes[JOYAXIS_Side] < 0 || hidInput->joyaxes[JOYAXIS_Yaw] > 0) && !(dpad_lock & 4)) { dpad_lock |= 4; input.actions |= SB_INVPREV; }
|
||||
if ((hidInput->joyaxes[JOYAXIS_Side] < 0 || hidInput->joyaxes[JOYAXIS_Yaw] > 0) && !(dpad_lock & 4)) { dpad_lock |= 4; inputBuffer->actions |= SB_INVPREV; }
|
||||
else dpad_lock &= ~4;
|
||||
if ((hidInput->joyaxes[JOYAXIS_Side] > 0 || hidInput->joyaxes[JOYAXIS_Yaw] < 0) && !(dpad_lock & 8)) { dpad_lock |= 8; input.actions |= SB_INVNEXT; }
|
||||
if ((hidInput->joyaxes[JOYAXIS_Side] > 0 || hidInput->joyaxes[JOYAXIS_Yaw] < 0) && !(dpad_lock & 8)) { dpad_lock |= 8; inputBuffer->actions |= SB_INVNEXT; }
|
||||
else dpad_lock &= ~8;
|
||||
|
||||
// This eats the controller input for regular use
|
||||
// This eats the controller inputBuffer-> for regular use
|
||||
hidInput->joyaxes[JOYAXIS_Side] = 0;
|
||||
hidInput->joyaxes[JOYAXIS_Forward] = 0;
|
||||
hidInput->joyaxes[JOYAXIS_Yaw] = 0;
|
||||
}
|
||||
else dpad_lock = 0;
|
||||
|
||||
input.actions |= ActionsToSend;
|
||||
inputBuffer->actions |= ActionsToSend;
|
||||
ActionsToSend = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->joyaxes[JOYAXIS_Forward] > 0))
|
||||
input.actions |= SB_AIM_UP;
|
||||
inputBuffer->actions |= SB_AIM_UP;
|
||||
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->joyaxes[JOYAXIS_Forward] < 0)))
|
||||
input.actions |= SB_AIM_DOWN;
|
||||
inputBuffer->actions |= SB_AIM_DOWN;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
hidInput->joyaxes[JOYAXIS_Forward] = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Jump))
|
||||
input.actions |= SB_JUMP;
|
||||
inputBuffer->actions |= SB_JUMP;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Crouch) || buttonMap.ButtonDown(gamefunc_Toggle_Crouch) || crouch_toggle)
|
||||
input.actions |= SB_CROUCH;
|
||||
inputBuffer->actions |= SB_CROUCH;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Toggle_Crouch))
|
||||
{
|
||||
|
@ -421,36 +421,36 @@ void ApplyGlobalInput(InputPacket& input, HIDInput* const hidInput)
|
|||
crouch_toggle = false;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Fire))
|
||||
input.actions |= SB_FIRE;
|
||||
inputBuffer->actions |= SB_FIRE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Alt_Fire))
|
||||
input.actions |= SB_ALTFIRE;
|
||||
inputBuffer->actions |= SB_ALTFIRE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Open))
|
||||
{
|
||||
if (isBlood()) buttonMap.ClearButton(gamefunc_Open);
|
||||
input.actions |= SB_OPEN;
|
||||
inputBuffer->actions |= SB_OPEN;
|
||||
}
|
||||
if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run)))
|
||||
input.actions |= SB_RUN;
|
||||
inputBuffer->actions |= SB_RUN;
|
||||
|
||||
if (!in_mousemode && !buttonMap.ButtonDown(gamefunc_Mouse_Aiming))
|
||||
input.actions |= SB_AIMMODE;
|
||||
inputBuffer->actions |= SB_AIMMODE;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Up))
|
||||
input.actions |= SB_LOOK_UP;
|
||||
inputBuffer->actions |= SB_LOOK_UP;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Down))
|
||||
input.actions |= SB_LOOK_DOWN;
|
||||
inputBuffer->actions |= SB_LOOK_DOWN;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Left))
|
||||
input.actions |= SB_LOOK_LEFT;
|
||||
inputBuffer->actions |= SB_LOOK_LEFT;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Look_Right))
|
||||
input.actions |= SB_LOOK_RIGHT;
|
||||
inputBuffer->actions |= SB_LOOK_RIGHT;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Quick_Kick))
|
||||
input.actions |= SB_QUICK_KICK;
|
||||
inputBuffer->actions |= SB_QUICK_KICK;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ enum GameFunction_t
|
|||
};
|
||||
|
||||
void SetupGameButtons();
|
||||
void ApplyGlobalInput(InputPacket& input, HIDInput* const hidInput);
|
||||
void ApplyGlobalInput(HIDInput* const hidInput, InputPacket* const inputBuffer);
|
||||
extern ESyncBits ActionsToSend;
|
||||
extern bool gamesetinput;
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet)
|
|||
PLAYER* pPlayer = &gPlayer[myconnectindex];
|
||||
InputPacket input{};
|
||||
|
||||
ApplyGlobalInput(gInput, &hidInput);
|
||||
processMovement(&input, &gInput, &hidInput, scaleAdjust);
|
||||
ApplyGlobalInput(&hidInput, &gInput);
|
||||
processMovement(&hidInput, &gInput, &input, scaleAdjust);
|
||||
|
||||
// Perform unsynchronised angle/horizon if not dead.
|
||||
if (!SyncInput() && gamestate == GS_LEVEL && pPlayer->actor->xspr.health != 0)
|
||||
|
|
|
@ -709,7 +709,7 @@ static float boatApplyTurn(player_struct *p, HIDInput* const hidInput, bool cons
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processVehicleInput(player_struct *p, HIDInput* const hidInput, InputPacket& input, double const scaleAdjust)
|
||||
static void processVehicleInput(player_struct *p, HIDInput* const hidInput, InputPacket* const inputBuffer, InputPacket* const currInput, const double scaleAdjust)
|
||||
{
|
||||
bool const kbdLeft = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
|
||||
bool const kbdRight = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right);
|
||||
|
@ -729,16 +729,16 @@ static void processVehicleInput(player_struct *p, HIDInput* const hidInput, Inpu
|
|||
|
||||
if (p->OnMotorcycle)
|
||||
{
|
||||
input.avel = motoApplyTurn(p, hidInput, kbdLeft, kbdRight, (float)scaleAdjust);
|
||||
currInput->avel = motoApplyTurn(p, hidInput, kbdLeft, kbdRight, (float)scaleAdjust);
|
||||
if (p->moto_underwater) p->MotoSpeed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
input.avel = boatApplyTurn(p, hidInput, kbdLeft, kbdRight, (float)scaleAdjust);
|
||||
currInput->avel = boatApplyTurn(p, hidInput, kbdLeft, kbdRight, (float)scaleAdjust);
|
||||
}
|
||||
|
||||
loc.fvel = clamp<float>((float)p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f);
|
||||
loc.avel += input.avel;
|
||||
inputBuffer->fvel = clamp<float>((float)p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f);
|
||||
inputBuffer->avel += currInput->avel;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -797,15 +797,15 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet)
|
|||
auto const p = &ps[myconnectindex];
|
||||
InputPacket input{};
|
||||
|
||||
ApplyGlobalInput(loc, &hidInput);
|
||||
ApplyGlobalInput(&hidInput, &loc);
|
||||
|
||||
if (isRRRA() && (p->OnMotorcycle || p->OnBoat))
|
||||
{
|
||||
processVehicleInput(p, &hidInput, input, scaleAdjust);
|
||||
processVehicleInput(p, &hidInput, &loc, &input, scaleAdjust);
|
||||
}
|
||||
else
|
||||
{
|
||||
processMovement(&input, &loc, &hidInput, scaleAdjust, p->drink_amt);
|
||||
processMovement(&hidInput, &loc, &input, scaleAdjust, p->drink_amt);
|
||||
}
|
||||
|
||||
FinalizeInput(p, input);
|
||||
|
|
|
@ -57,12 +57,12 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet)
|
|||
HIDInput hidInput;
|
||||
getHidInput(&hidInput);
|
||||
|
||||
ApplyGlobalInput(localInput, &hidInput);
|
||||
ApplyGlobalInput(&hidInput, &localInput);
|
||||
|
||||
Player* pPlayer = &PlayerList[nLocalPlayer];
|
||||
InputPacket input {};
|
||||
|
||||
processMovement(&input, &localInput, &hidInput, scaleAdjust);
|
||||
processMovement(&hidInput, &localInput, &input, scaleAdjust);
|
||||
|
||||
if (!SyncInput() && gamestate == GS_LEVEL)
|
||||
{
|
||||
|
|
|
@ -172,8 +172,8 @@ void GameInterface::GetInput(const double scaleAdjust, InputPacket *packet)
|
|||
|
||||
InputPacket input {};
|
||||
|
||||
ApplyGlobalInput(loc, &hidInput);
|
||||
processMovement(&input, &loc, &hidInput, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.);
|
||||
ApplyGlobalInput(&hidInput, &loc);
|
||||
processMovement(&hidInput, &loc, &input, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.);
|
||||
|
||||
if (!SyncInput())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue