mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- InputState: Make CONTROL_GetInput()
return an object instead of accepting a pointer and provide to games as a function parameter.
* Provide read-only/const results from `CONTROL_GetInput()` so games can't change received input. * Change non-descript `info` to `hidInput` (Human Interface Device). * Remove a few unused prototypes.
This commit is contained in:
parent
677efb20ba
commit
722537a1f0
16 changed files with 102 additions and 116 deletions
|
@ -88,7 +88,7 @@ struct GameInterface : ::GameInterface
|
|||
FString GetCoordString() override;
|
||||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||
void UpdateSounds() override;
|
||||
void GetInput(InputPacket* gInput) override;
|
||||
void GetInput(InputPacket* gInput, ControlInfo* const hidInput) override;
|
||||
void Ticker() override;
|
||||
void DrawBackground() override;
|
||||
void Startup() override;
|
||||
|
|
|
@ -51,10 +51,9 @@ float gViewAngleAdjust;
|
|||
float gViewLookAdjust;
|
||||
int gViewLookRecenter;
|
||||
|
||||
void GetInputInternal(InputPacket &inputParm)
|
||||
void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
|
||||
{
|
||||
int prevPauseState = paused;
|
||||
ControlInfo info;
|
||||
|
||||
static double lastInputTicks;
|
||||
auto const currentHiTicks = I_msTimeF();
|
||||
|
@ -66,9 +65,7 @@ void GetInputInternal(InputPacket &inputParm)
|
|||
|
||||
InputPacket input = {};
|
||||
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
ApplyGlobalInput(inputParm, &info);
|
||||
ApplyGlobalInput(inputParm, hidInput);
|
||||
|
||||
bool mouseaim = !(inputParm.actions & SB_AIMMODE);
|
||||
if (!mouseaim) inputParm.actions |= SB_CENTERVIEW;
|
||||
|
@ -146,26 +143,26 @@ void GetInputInternal(InputPacket &inputParm)
|
|||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
input.svel -= info.mousex * 32.f;
|
||||
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
||||
input.svel -= hidInput->mousex * 32.f;
|
||||
input.svel -= scaleAdjustmentToInterval(hidInput->dyaw * keyMove);
|
||||
}
|
||||
else
|
||||
{
|
||||
input.q16avel += FloatToFixed(info.mousex);
|
||||
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(info.dyaw));
|
||||
input.q16avel += FloatToFixed(hidInput->mousex);
|
||||
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(hidInput->dyaw));
|
||||
}
|
||||
|
||||
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove);
|
||||
input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove);
|
||||
input.svel -= scaleAdjustmentToInterval(hidInput->dx * keyMove);
|
||||
input.fvel -= scaleAdjustmentToInterval(hidInput->dz * keyMove);
|
||||
|
||||
if (mouseaim)
|
||||
input.q16horz += FloatToFixed(info.mousey / mlookScale);
|
||||
input.q16horz += FloatToFixed(hidInput->mousey / mlookScale);
|
||||
else
|
||||
input.fvel -= info.mousey * 64.f;
|
||||
input.fvel -= hidInput->mousey * 64.f;
|
||||
if (!in_mouseflip)
|
||||
input.q16horz = -input.q16horz;
|
||||
|
||||
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch / mlookScale));
|
||||
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch / mlookScale));
|
||||
|
||||
if (!automapFollow && automapMode != am_off)
|
||||
{
|
||||
|
@ -202,9 +199,9 @@ void GetInputInternal(InputPacket &inputParm)
|
|||
}
|
||||
}
|
||||
|
||||
void GameInterface::GetInput(InputPacket* packet)
|
||||
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||
{
|
||||
GetInputInternal(gInput);
|
||||
GetInputInternal(gInput, hidInput);
|
||||
if (packet)
|
||||
{
|
||||
*packet = gInput;
|
||||
|
|
|
@ -7,6 +7,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
|
|||
#include "engineerrors.h"
|
||||
#include "stats.h"
|
||||
#include "packet.h"
|
||||
#include "inputstate.h"
|
||||
|
||||
class FSerializer;
|
||||
|
||||
|
@ -93,7 +94,7 @@ struct GameInterface
|
|||
virtual void ExitFromMenu() { throw CExitEvent(0); }
|
||||
virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; }
|
||||
virtual void ResetFollowPos(bool) {}
|
||||
virtual void GetInput(InputPacket* packet) {}
|
||||
virtual void GetInput(InputPacket* packet, ControlInfo* const hidInput) {}
|
||||
virtual void UpdateSounds() {}
|
||||
virtual void ErrorCleanup() {}
|
||||
virtual void Startup() {}
|
||||
|
|
|
@ -53,24 +53,24 @@ bool sendPause;
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void InputState::GetMouseDelta(ControlInfo * info)
|
||||
void InputState::GetMouseDelta(ControlInfo * hidInput)
|
||||
{
|
||||
vec2f_t finput = g_mousePos;
|
||||
g_mousePos = {};
|
||||
|
||||
info->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f;
|
||||
info->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley;
|
||||
hidInput->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f;
|
||||
hidInput->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley;
|
||||
|
||||
// todo: Use these when the mouse is used for moving instead of turning.
|
||||
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
||||
//info->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward);
|
||||
//hidInput->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
|
||||
//hidInput->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward);
|
||||
|
||||
if (in_mousebias)
|
||||
{
|
||||
if (fabs(info->mousex) > fabs(info->mousey))
|
||||
info->mousey /= in_mousebias;
|
||||
if (fabs(hidInput->mousex) > fabs(hidInput->mousey))
|
||||
hidInput->mousey /= in_mousebias;
|
||||
else
|
||||
info->mousex /= in_mousebias;
|
||||
hidInput->mousex /= in_mousebias;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -175,11 +175,11 @@ int32_t handleevents(void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void CONTROL_GetInput(ControlInfo* info)
|
||||
ControlInfo CONTROL_GetInput()
|
||||
{
|
||||
memset(info, 0, sizeof(ControlInfo));
|
||||
ControlInfo hidInput {};
|
||||
|
||||
inputState.GetMouseDelta(info);
|
||||
inputState.GetMouseDelta(&hidInput);
|
||||
|
||||
if (use_joystick)
|
||||
{
|
||||
|
@ -188,11 +188,13 @@ void CONTROL_GetInput(ControlInfo* info)
|
|||
|
||||
I_GetAxes(joyaxes);
|
||||
|
||||
info->dyaw += -joyaxes[JOYAXIS_Yaw] * 45.f;
|
||||
info->dx += -joyaxes[JOYAXIS_Side] * 0.75f;
|
||||
info->dz += -joyaxes[JOYAXIS_Forward] * 0.75f;
|
||||
info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f;
|
||||
hidInput.dyaw += -joyaxes[JOYAXIS_Yaw] * 45.f;
|
||||
hidInput.dx += -joyaxes[JOYAXIS_Side] * 0.75f;
|
||||
hidInput.dz += -joyaxes[JOYAXIS_Forward] * 0.75f;
|
||||
hidInput.dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f;
|
||||
}
|
||||
|
||||
return hidInput;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -328,40 +330,40 @@ CCMD(pause)
|
|||
|
||||
|
||||
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo *info)
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput)
|
||||
{
|
||||
if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend);
|
||||
WeaponToSend = 0;
|
||||
if (info && buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
if (hidInput && buttonMap.ButtonDown(gamefunc_Dpad_Select))
|
||||
{
|
||||
// These buttons should not autorepeat. The game handlers are not really equipped for that.
|
||||
if (info->dz > 0 && !(dpad_lock & 1)) { dpad_lock |= 1; input.setNewWeapon(WeaponSel_Prev); }
|
||||
if (hidInput->dz > 0 && !(dpad_lock & 1)) { dpad_lock |= 1; input.setNewWeapon(WeaponSel_Prev); }
|
||||
else dpad_lock &= ~1;
|
||||
if (info->dz < 0 && !(dpad_lock & 2)) { dpad_lock |= 2; input.setNewWeapon(WeaponSel_Next); }
|
||||
if (hidInput->dz < 0 && !(dpad_lock & 2)) { dpad_lock |= 2; input.setNewWeapon(WeaponSel_Next); }
|
||||
else dpad_lock &= ~2;
|
||||
if ((info->dx < 0 || info->dyaw < 0) && !(dpad_lock & 4)) { dpad_lock |= 4; input.actions |= SB_INVPREV; }
|
||||
if ((hidInput->dx < 0 || hidInput->dyaw < 0) && !(dpad_lock & 4)) { dpad_lock |= 4; input.actions |= SB_INVPREV; }
|
||||
else dpad_lock &= ~4;
|
||||
if ((info->dx > 0 || info->dyaw > 0) && !(dpad_lock & 8)) { dpad_lock |= 8; input.actions |= SB_INVNEXT; }
|
||||
if ((hidInput->dx > 0 || hidInput->dyaw > 0) && !(dpad_lock & 8)) { dpad_lock |= 8; input.actions |= SB_INVNEXT; }
|
||||
else dpad_lock &= ~8;
|
||||
|
||||
// This eats the controller input for regular use
|
||||
info->dx = 0;
|
||||
info->dz = 0;
|
||||
info->dyaw = 0;
|
||||
hidInput->dx = 0;
|
||||
hidInput->dz = 0;
|
||||
hidInput->dyaw = 0;
|
||||
}
|
||||
else dpad_lock = 0;
|
||||
|
||||
input.actions |= ActionsToSend;
|
||||
ActionsToSend = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info->dz > 0))
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->dz > 0))
|
||||
input.actions |= SB_AIM_UP;
|
||||
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && info->dz < 0)))
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->dz < 0)))
|
||||
input.actions |= SB_AIM_DOWN;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
info->dz = 0;
|
||||
hidInput->dz = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Jump))
|
||||
input.actions |= SB_JUMP;
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
g_mousePos.y += y;
|
||||
}
|
||||
|
||||
void GetMouseDelta(ControlInfo* info);
|
||||
void GetMouseDelta(ControlInfo* hidInput);
|
||||
|
||||
void ClearAllInput();
|
||||
bool CheckAllInput()
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
extern InputState inputState;
|
||||
|
||||
void CONTROL_GetInput(ControlInfo* info);
|
||||
ControlInfo CONTROL_GetInput();
|
||||
int32_t handleevents(void);
|
||||
|
||||
enum GameFunction_t
|
||||
|
@ -96,5 +96,5 @@ enum GameFunction_t
|
|||
};
|
||||
|
||||
void SetupGameButtons();
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo *info);
|
||||
void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput);
|
||||
extern ESyncBits ActionsToSend;
|
|
@ -110,7 +110,7 @@ int gametic;
|
|||
void G_BuildTiccmd(ticcmd_t* cmd)
|
||||
{
|
||||
I_GetEvent();
|
||||
gi->GetInput(&cmd->ucmd);
|
||||
gi->GetInput(&cmd->ucmd, &CONTROL_GetInput());
|
||||
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS];
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ void TryRunTics (void)
|
|||
if (!cl_syncinput)
|
||||
{
|
||||
I_GetEvent();
|
||||
gi->GetInput(nullptr);
|
||||
gi->GetInput(nullptr, &CONTROL_GetInput());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ struct GameInterface : ::GameInterface
|
|||
void Ticker() override;
|
||||
void DrawBackground() override;
|
||||
void Render() override;
|
||||
void GetInput(InputPacket* packet) override;
|
||||
void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
|
||||
void Startup() override;
|
||||
const char* GenericCheat(int player, int cheat) override;
|
||||
void NewGame(MapRecord *map, int skill) override;
|
||||
|
|
|
@ -100,12 +100,8 @@ void CheckKeys2()
|
|||
}
|
||||
|
||||
|
||||
void PlayerInterruptKeys(bool after)
|
||||
static void PlayerInterruptKeys(bool after, ControlInfo* const hidInput)
|
||||
{
|
||||
ControlInfo info;
|
||||
memset(&info, 0, sizeof(ControlInfo)); // this is done within CONTROL_GetInput() anyway
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
static double lastInputTicks;
|
||||
auto const currentHiTicks = I_msTimeF();
|
||||
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
|
||||
|
@ -123,7 +119,7 @@ void PlayerInterruptKeys(bool after)
|
|||
if (!after)
|
||||
{
|
||||
localInput = {};
|
||||
ApplyGlobalInput(localInput, &info);
|
||||
ApplyGlobalInput(localInput, hidInput);
|
||||
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
|
||||
}
|
||||
|
||||
|
@ -142,26 +138,26 @@ void PlayerInterruptKeys(bool after)
|
|||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
tempinput.svel -= info.mousex * 4.f;
|
||||
tempinput.svel -= info.dyaw * keyMove;
|
||||
tempinput.svel -= hidInput->mousex * 4.f;
|
||||
tempinput.svel -= hidInput->dyaw * keyMove;
|
||||
}
|
||||
else
|
||||
{
|
||||
input_angle += FloatToFixed(info.mousex + scaleAdjustmentToInterval(info.dyaw));
|
||||
input_angle += FloatToFixed(hidInput->mousex + scaleAdjustmentToInterval(hidInput->dyaw));
|
||||
}
|
||||
|
||||
bool mouseaim = !(localInput.actions & SB_AIMMODE);
|
||||
|
||||
if (mouseaim)
|
||||
tempinput.q16horz += FloatToFixed(info.mousey);
|
||||
tempinput.q16horz += FloatToFixed(hidInput->mousey);
|
||||
else
|
||||
tempinput.fvel -= info.mousey * 8.f;
|
||||
tempinput.fvel -= hidInput->mousey * 8.f;
|
||||
|
||||
if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz;
|
||||
|
||||
tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch));
|
||||
tempinput.svel -= info.dx * keyMove;
|
||||
tempinput.fvel -= info.dz * keyMove;
|
||||
tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch));
|
||||
tempinput.svel -= hidInput->dx * keyMove;
|
||||
tempinput.fvel -= hidInput->dz * keyMove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
|
@ -297,9 +293,9 @@ void PlayerInterruptKeys(bool after)
|
|||
}
|
||||
|
||||
|
||||
void GameInterface::GetInput(InputPacket* packet)
|
||||
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||
{
|
||||
PlayerInterruptKeys(packet == nullptr);
|
||||
PlayerInterruptKeys(packet == nullptr, hidInput);
|
||||
if (packet) *packet = localInput;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_PS_NS
|
||||
|
||||
void PlayerInterruptKeys(bool after);
|
||||
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle);
|
||||
void SetSavePoint(int nPlayer, int x, int y, int z, short nSector, short nAngle);
|
||||
void InitPlayer();
|
||||
|
|
|
@ -51,7 +51,7 @@ struct GameInterface : public ::GameInterface
|
|||
ReservedSpace GetReservedScreenSpace(int viewsize) override;
|
||||
void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
|
||||
void ResetFollowPos(bool message) override;
|
||||
void GetInput(InputPacket* packet) override;
|
||||
void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
|
||||
void UpdateSounds() override;
|
||||
void Startup() override;
|
||||
void DrawBackground() override;
|
||||
|
|
|
@ -531,9 +531,9 @@ enum
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processInputBits(player_struct *p, ControlInfo &info)
|
||||
static void processInputBits(player_struct *p, ControlInfo* const hidInput)
|
||||
{
|
||||
ApplyGlobalInput(loc, &info);
|
||||
ApplyGlobalInput(loc, hidInput);
|
||||
if (isRR() && (loc.actions & SB_CROUCH)) loc.actions &= ~SB_JUMP;
|
||||
|
||||
if (p->OnMotorcycle || p->OnBoat)
|
||||
|
@ -598,7 +598,7 @@ int getticssincelastupdate()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processMovement(player_struct *p, InputPacket &input, ControlInfo &info, double scaleFactor)
|
||||
static void processMovement(player_struct *p, InputPacket &input, ControlInfo* const hidInput, double scaleFactor)
|
||||
{
|
||||
bool mouseaim = !(loc.actions & SB_AIMMODE);
|
||||
|
||||
|
@ -608,20 +608,20 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i
|
|||
int keymove = NORMALKEYMOVE << running;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
input.svel -= info.mousex * 4.f + scaleFactor * info.dyaw * keymove;
|
||||
input.svel -= hidInput->mousex * 4.f + scaleFactor * hidInput->dyaw * keymove;
|
||||
else
|
||||
input.q16avel += FloatToFixed(info.mousex + scaleFactor * info.dyaw);
|
||||
input.q16avel += FloatToFixed(hidInput->mousex + scaleFactor * hidInput->dyaw);
|
||||
|
||||
if (mouseaim)
|
||||
input.q16horz += FloatToFixed(info.mousey);
|
||||
input.q16horz += FloatToFixed(hidInput->mousey);
|
||||
else
|
||||
input.fvel -= info.mousey * 8.f;
|
||||
input.fvel -= hidInput->mousey * 8.f;
|
||||
|
||||
if (!in_mouseflip) input.q16horz = -input.q16horz;
|
||||
|
||||
input.q16horz -= FloatToFixed(scaleFactor * (info.dpitch));
|
||||
input.svel -= scaleFactor * (info.dx * keymove);
|
||||
input.fvel -= scaleFactor * (info.dz * keymove);
|
||||
input.q16horz -= FloatToFixed(scaleFactor * (hidInput->dpitch));
|
||||
input.svel -= scaleFactor * (hidInput->dx * keymove);
|
||||
input.fvel -= scaleFactor * (hidInput->dz * keymove);
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
{
|
||||
|
@ -876,9 +876,9 @@ static double boatApplyTurn(player_struct *p, int turnl, int turnr, int boat_tur
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void processVehicleInput(player_struct *p, ControlInfo& info, InputPacket& input, double scaleAdjust)
|
||||
static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, InputPacket& input, double scaleAdjust)
|
||||
{
|
||||
auto turnspeed = info.mousex + scaleAdjust * info.dyaw * (1. / 32); // originally this was 64, not 32. Why the change?
|
||||
auto turnspeed = hidInput->mousex + scaleAdjust * hidInput->dyaw * (1. / 32); // originally this was 64, not 32. Why the change?
|
||||
int turnl = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
|
||||
int turnr = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right);
|
||||
|
||||
|
@ -999,7 +999,7 @@ static void FinalizeInput(int playerNum, InputPacket& input, bool vehicle)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static void GetInputInternal(InputPacket &locInput)
|
||||
static void GetInputInternal(InputPacket &locInput, ControlInfo* const hidInput)
|
||||
{
|
||||
double elapsedInputTicks;
|
||||
auto const p = &ps[myconnectindex];
|
||||
|
@ -1023,15 +1023,13 @@ static void GetInputInternal(InputPacket &locInput)
|
|||
}
|
||||
|
||||
double scaleAdjust = !cl_syncinput ? elapsedInputTicks * REALGAMETICSPERSEC / 1000.0 : 1;
|
||||
ControlInfo info;
|
||||
CONTROL_GetInput(&info);
|
||||
InputPacket input{};
|
||||
|
||||
if (isRRRA() && (p->OnMotorcycle || p->OnBoat))
|
||||
{
|
||||
p->crouch_toggle = 0;
|
||||
processInputBits(p, info);
|
||||
processVehicleInput(p, info, input, scaleAdjust);
|
||||
processInputBits(p, hidInput);
|
||||
processVehicleInput(p, hidInput, input, scaleAdjust);
|
||||
FinalizeInput(myconnectindex, input, true);
|
||||
|
||||
if (!cl_syncinput && sprite[p->i].extra > 0)
|
||||
|
@ -1041,8 +1039,8 @@ static void GetInputInternal(InputPacket &locInput)
|
|||
}
|
||||
else
|
||||
{
|
||||
processInputBits(p, info);
|
||||
processMovement(p, input, info, scaleAdjust);
|
||||
processInputBits(p, hidInput);
|
||||
processMovement(p, input, hidInput, scaleAdjust);
|
||||
checkCrouchToggle(p);
|
||||
FinalizeInput(myconnectindex, input, false);
|
||||
}
|
||||
|
@ -1062,9 +1060,9 @@ static void GetInputInternal(InputPacket &locInput)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::GetInput(InputPacket* packet)
|
||||
void GameInterface::GetInput(InputPacket* packet, ControlInfo* const hidInput)
|
||||
{
|
||||
GetInputInternal(loc);
|
||||
GetInputInternal(loc, hidInput);
|
||||
if (packet)
|
||||
{
|
||||
auto const pPlayer = &ps[myconnectindex];
|
||||
|
|
|
@ -1604,7 +1604,6 @@ short ScreenSavePic = FALSE;
|
|||
|
||||
SWBOOL PicInView(short, SWBOOL);
|
||||
void DoPlayerDiveMeter(PLAYERp pp);
|
||||
void MoveScrollMode2D(PLAYERp pp);
|
||||
|
||||
void
|
||||
drawscreen(PLAYERp pp, double smoothratio)
|
||||
|
|
|
@ -2211,7 +2211,7 @@ struct GameInterface : ::GameInterface
|
|||
void ResetFollowPos(bool message) override;
|
||||
void UpdateSounds() override;
|
||||
void ErrorCleanup() override;
|
||||
void GetInput(InputPacket* input) override;
|
||||
void GetInput(InputPacket* input, ControlInfo* const hidInput) override;
|
||||
void DrawBackground(void) override;
|
||||
void Ticker(void) override;
|
||||
void Render() override;
|
||||
|
|
|
@ -67,7 +67,7 @@ void GameInterface::ResetFollowPos(bool)
|
|||
Follow_posy = pp->posy;
|
||||
}
|
||||
|
||||
static void getinput(InputPacket *loc)
|
||||
static void getinput(InputPacket *loc, ControlInfo* const hidInput)
|
||||
{
|
||||
int i;
|
||||
PLAYERp pp = Player + myconnectindex;
|
||||
|
@ -101,9 +101,6 @@ static void getinput(InputPacket *loc)
|
|||
|
||||
lastInputTicks = currentHiTicks;
|
||||
|
||||
ControlInfo info;
|
||||
CONTROL_GetInput(&info);
|
||||
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
|
@ -111,7 +108,7 @@ static void getinput(InputPacket *loc)
|
|||
// Tried calling this in domovethings, but key response it too poor, skips key presses
|
||||
// Note: this get called only during follow mode
|
||||
if (automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction)
|
||||
MoveScrollMode2D(Player + myconnectindex);
|
||||
MoveScrollMode2D(Player + myconnectindex, hidInput);
|
||||
|
||||
// !JIM! Added M_Active() so that you don't move at all while using menus
|
||||
if (M_Active() || (automapFollow && automapMode != am_off))
|
||||
|
@ -129,7 +126,7 @@ static void getinput(InputPacket *loc)
|
|||
// for dividing controller input to match speed input speed of other games.
|
||||
float const ticrateScale = 0.75f;
|
||||
|
||||
ApplyGlobalInput(*loc, &info);
|
||||
ApplyGlobalInput(*loc, hidInput);
|
||||
|
||||
bool mouseaim = !(loc->actions & SB_AIMMODE);
|
||||
|
||||
|
@ -179,25 +176,25 @@ static void getinput(InputPacket *loc)
|
|||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
||||
{
|
||||
svel -= (info.mousex * ticrateScale) * 4.f;
|
||||
svel -= info.dyaw * keymove;
|
||||
svel -= (hidInput->mousex * ticrateScale) * 4.f;
|
||||
svel -= hidInput->dyaw * keymove;
|
||||
}
|
||||
else
|
||||
{
|
||||
q16angvel += FloatToFixed((info.mousex / angvelScale) + scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale));
|
||||
q16angvel += FloatToFixed((hidInput->mousex / angvelScale) + scaleAdjustmentToInterval((hidInput->dyaw * ticrateScale) / angvelScale));
|
||||
}
|
||||
|
||||
if (mouseaim)
|
||||
q16horz -= FloatToFixed(info.mousey / aimvelScale);
|
||||
q16horz -= FloatToFixed(hidInput->mousey / aimvelScale);
|
||||
else
|
||||
vel -= (info.mousey * ticrateScale) * 8.f;
|
||||
vel -= (hidInput->mousey * ticrateScale) * 8.f;
|
||||
|
||||
if (in_mouseflip)
|
||||
q16horz = -q16horz;
|
||||
|
||||
q16horz -= FloatToFixed(scaleAdjustmentToInterval((info.dpitch * ticrateScale) / aimvelScale));
|
||||
svel -= info.dx * keymove;
|
||||
vel -= info.dz * keymove;
|
||||
q16horz -= FloatToFixed(scaleAdjustmentToInterval((hidInput->dpitch * ticrateScale) / aimvelScale));
|
||||
svel -= hidInput->dx * keymove;
|
||||
vel -= hidInput->dz * keymove;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
||||
{
|
||||
|
@ -359,9 +356,9 @@ static void getinput(InputPacket *loc)
|
|||
}
|
||||
}
|
||||
|
||||
void GameInterface::GetInput(InputPacket *packet)
|
||||
void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput)
|
||||
{
|
||||
getinput(&loc);
|
||||
getinput(&loc, hidInput);
|
||||
if (packet)
|
||||
{
|
||||
PLAYERp pp = &Player[myconnectindex];
|
||||
|
|
|
@ -2435,7 +2435,7 @@ void PlayerCheckValidMove(PLAYERp pp)
|
|||
}
|
||||
|
||||
void
|
||||
MoveScrollMode2D(PLAYERp pp)
|
||||
MoveScrollMode2D(PLAYERp pp, ControlInfo* const hidInput)
|
||||
{
|
||||
#define TURBOTURNTIME (120/8)
|
||||
#define NORMALTURN (12+6)
|
||||
|
@ -2446,22 +2446,19 @@ MoveScrollMode2D(PLAYERp pp)
|
|||
#define MAXSVEL ((NORMALKEYMOVE*2)+10)
|
||||
#define MAXANGVEL 100
|
||||
|
||||
ControlInfo scrl_input;
|
||||
int32_t keymove;
|
||||
int32_t momx, momy;
|
||||
static int mfvel=0, mfsvel=0;
|
||||
|
||||
CONTROL_GetInput(&scrl_input);
|
||||
|
||||
mfsvel = mfvel = 0;
|
||||
|
||||
if (M_Active())
|
||||
return;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
||||
mfsvel -= scrl_input.dyaw / 4;
|
||||
mfsvel -= scrl_input.dx / 4;
|
||||
mfvel = -scrl_input.dz /4;
|
||||
mfsvel -= hidInput->dyaw / 4;
|
||||
mfsvel -= hidInput->dx / 4;
|
||||
mfvel = -hidInput->dz /4;
|
||||
|
||||
keymove = NORMALKEYMOVE;
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void DoPlayer(void);
|
|||
void domovethings(void);
|
||||
void InitAllPlayers(void);
|
||||
void InitMultiPlayerInfo(void);
|
||||
void MoveScrollMode2D(PLAYERp pp);
|
||||
void MoveScrollMode2D(PLAYERp pp, ControlInfo* const hidInput);
|
||||
void DoPlayerDivePalette(PLAYERp pp);
|
||||
void DoPlayerNightVisionPalette(PLAYERp pp);
|
||||
void DoPlayerStopDiveNoWarp(PLAYERp pp);
|
||||
|
|
Loading…
Reference in a new issue