- 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:
Mitchell Richters 2020-09-06 20:17:54 +10:00
parent 677efb20ba
commit 722537a1f0
16 changed files with 102 additions and 116 deletions

View file

@ -88,7 +88,7 @@ struct GameInterface : ::GameInterface
FString GetCoordString() override; FString GetCoordString() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override; void UpdateSounds() override;
void GetInput(InputPacket* gInput) override; void GetInput(InputPacket* gInput, ControlInfo* const hidInput) override;
void Ticker() override; void Ticker() override;
void DrawBackground() override; void DrawBackground() override;
void Startup() override; void Startup() override;

View file

@ -51,10 +51,9 @@ float gViewAngleAdjust;
float gViewLookAdjust; float gViewLookAdjust;
int gViewLookRecenter; int gViewLookRecenter;
void GetInputInternal(InputPacket &inputParm) void GetInputInternal(InputPacket &inputParm, ControlInfo* const hidInput)
{ {
int prevPauseState = paused; int prevPauseState = paused;
ControlInfo info;
static double lastInputTicks; static double lastInputTicks;
auto const currentHiTicks = I_msTimeF(); auto const currentHiTicks = I_msTimeF();
@ -66,9 +65,7 @@ void GetInputInternal(InputPacket &inputParm)
InputPacket input = {}; InputPacket input = {};
CONTROL_GetInput(&info); ApplyGlobalInput(inputParm, hidInput);
ApplyGlobalInput(inputParm, &info);
bool mouseaim = !(inputParm.actions & SB_AIMMODE); bool mouseaim = !(inputParm.actions & SB_AIMMODE);
if (!mouseaim) inputParm.actions |= SB_CENTERVIEW; if (!mouseaim) inputParm.actions |= SB_CENTERVIEW;
@ -146,26 +143,26 @@ void GetInputInternal(InputPacket &inputParm)
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
input.svel -= info.mousex * 32.f; input.svel -= hidInput->mousex * 32.f;
input.svel -= scaleAdjustmentToInterval(info.dyaw * keyMove); input.svel -= scaleAdjustmentToInterval(hidInput->dyaw * keyMove);
} }
else else
{ {
input.q16avel += FloatToFixed(info.mousex); input.q16avel += FloatToFixed(hidInput->mousex);
input.q16avel += FloatToFixed(scaleAdjustmentToInterval(info.dyaw)); input.q16avel += FloatToFixed(scaleAdjustmentToInterval(hidInput->dyaw));
} }
input.svel -= scaleAdjustmentToInterval(info.dx * keyMove); input.svel -= scaleAdjustmentToInterval(hidInput->dx * keyMove);
input.fvel -= scaleAdjustmentToInterval(info.dz * keyMove); input.fvel -= scaleAdjustmentToInterval(hidInput->dz * keyMove);
if (mouseaim) if (mouseaim)
input.q16horz += FloatToFixed(info.mousey / mlookScale); input.q16horz += FloatToFixed(hidInput->mousey / mlookScale);
else else
input.fvel -= info.mousey * 64.f; input.fvel -= hidInput->mousey * 64.f;
if (!in_mouseflip) if (!in_mouseflip)
input.q16horz = -input.q16horz; input.q16horz = -input.q16horz;
input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch / mlookScale)); input.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch / mlookScale));
if (!automapFollow && automapMode != am_off) 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) if (packet)
{ {
*packet = gInput; *packet = gInput;

View file

@ -7,6 +7,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
#include "engineerrors.h" #include "engineerrors.h"
#include "stats.h" #include "stats.h"
#include "packet.h" #include "packet.h"
#include "inputstate.h"
class FSerializer; class FSerializer;
@ -93,7 +94,7 @@ struct GameInterface
virtual void ExitFromMenu() { throw CExitEvent(0); } virtual void ExitFromMenu() { throw CExitEvent(0); }
virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; } virtual ReservedSpace GetReservedScreenSpace(int viewsize) { return { 0, 0 }; }
virtual void ResetFollowPos(bool) {} virtual void ResetFollowPos(bool) {}
virtual void GetInput(InputPacket* packet) {} virtual void GetInput(InputPacket* packet, ControlInfo* const hidInput) {}
virtual void UpdateSounds() {} virtual void UpdateSounds() {}
virtual void ErrorCleanup() {} virtual void ErrorCleanup() {}
virtual void Startup() {} virtual void Startup() {}

View file

@ -53,24 +53,24 @@ bool sendPause;
// //
//========================================================================== //==========================================================================
void InputState::GetMouseDelta(ControlInfo * info) void InputState::GetMouseDelta(ControlInfo * hidInput)
{ {
vec2f_t finput = g_mousePos; vec2f_t finput = g_mousePos;
g_mousePos = {}; g_mousePos = {};
info->mousex = finput.x * (16.f / 32.f) * in_mousesensitivity * in_mousescalex / 3.f; hidInput->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->mousey = finput.y * (16.f / 64.f) * in_mousesensitivity * in_mousescaley;
// todo: Use these when the mouse is used for moving instead of turning. // todo: Use these when the mouse is used for moving instead of turning.
//info->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside); //hidInput->mousex = int(finput.x * (4.f) * in_mousesensitivity * in_mouseside);
//info->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward); //hidInput->mousey = int(finput.y * (4.f) * in_mousesensitivity * in_mouseforward);
if (in_mousebias) if (in_mousebias)
{ {
if (fabs(info->mousex) > fabs(info->mousey)) if (fabs(hidInput->mousex) > fabs(hidInput->mousey))
info->mousey /= in_mousebias; hidInput->mousey /= in_mousebias;
else 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) if (use_joystick)
{ {
@ -188,11 +188,13 @@ void CONTROL_GetInput(ControlInfo* info)
I_GetAxes(joyaxes); I_GetAxes(joyaxes);
info->dyaw += -joyaxes[JOYAXIS_Yaw] * 45.f; hidInput.dyaw += -joyaxes[JOYAXIS_Yaw] * 45.f;
info->dx += -joyaxes[JOYAXIS_Side] * 0.75f; hidInput.dx += -joyaxes[JOYAXIS_Side] * 0.75f;
info->dz += -joyaxes[JOYAXIS_Forward] * 0.75f; hidInput.dz += -joyaxes[JOYAXIS_Forward] * 0.75f;
info->dpitch += -joyaxes[JOYAXIS_Pitch] * 22.5f; 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); if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend);
WeaponToSend = 0; 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. // 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; 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; 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; 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; else dpad_lock &= ~8;
// This eats the controller input for regular use // This eats the controller input for regular use
info->dx = 0; hidInput->dx = 0;
info->dz = 0; hidInput->dz = 0;
info->dyaw = 0; hidInput->dyaw = 0;
} }
else dpad_lock = 0; else dpad_lock = 0;
input.actions |= ActionsToSend; input.actions |= ActionsToSend;
ActionsToSend = 0; 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; 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; input.actions |= SB_AIM_DOWN;
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming)) if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
info->dz = 0; hidInput->dz = 0;
if (buttonMap.ButtonDown(gamefunc_Jump)) if (buttonMap.ButtonDown(gamefunc_Jump))
input.actions |= SB_JUMP; input.actions |= SB_JUMP;

View file

@ -48,7 +48,7 @@ public:
g_mousePos.y += y; g_mousePos.y += y;
} }
void GetMouseDelta(ControlInfo* info); void GetMouseDelta(ControlInfo* hidInput);
void ClearAllInput(); void ClearAllInput();
bool CheckAllInput() bool CheckAllInput()
@ -61,7 +61,7 @@ public:
extern InputState inputState; extern InputState inputState;
void CONTROL_GetInput(ControlInfo* info); ControlInfo CONTROL_GetInput();
int32_t handleevents(void); int32_t handleevents(void);
enum GameFunction_t enum GameFunction_t
@ -96,5 +96,5 @@ enum GameFunction_t
}; };
void SetupGameButtons(); void SetupGameButtons();
void ApplyGlobalInput(InputPacket& input, ControlInfo *info); void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput);
extern ESyncBits ActionsToSend; extern ESyncBits ActionsToSend;

View file

@ -110,7 +110,7 @@ int gametic;
void G_BuildTiccmd(ticcmd_t* cmd) void G_BuildTiccmd(ticcmd_t* cmd)
{ {
I_GetEvent(); I_GetEvent();
gi->GetInput(&cmd->ucmd); gi->GetInput(&cmd->ucmd, &CONTROL_GetInput());
cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS]; cmd->consistancy = consistancy[myconnectindex][(maketic / ticdup) % BACKUPTICS];
} }
@ -491,7 +491,7 @@ void TryRunTics (void)
if (!cl_syncinput) if (!cl_syncinput)
{ {
I_GetEvent(); I_GetEvent();
gi->GetInput(nullptr); gi->GetInput(nullptr, &CONTROL_GetInput());
} }
return; return;
} }

View file

@ -252,7 +252,7 @@ struct GameInterface : ::GameInterface
void Ticker() override; void Ticker() override;
void DrawBackground() override; void DrawBackground() override;
void Render() override; void Render() override;
void GetInput(InputPacket* packet) override; void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
void Startup() override; void Startup() override;
const char* GenericCheat(int player, int cheat) override; const char* GenericCheat(int player, int cheat) override;
void NewGame(MapRecord *map, int skill) override; void NewGame(MapRecord *map, int skill) override;

View file

@ -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; static double lastInputTicks;
auto const currentHiTicks = I_msTimeF(); auto const currentHiTicks = I_msTimeF();
double const elapsedInputTicks = currentHiTicks - lastInputTicks; double const elapsedInputTicks = currentHiTicks - lastInputTicks;
@ -123,7 +119,7 @@ void PlayerInterruptKeys(bool after)
if (!after) if (!after)
{ {
localInput = {}; localInput = {};
ApplyGlobalInput(localInput, &info); ApplyGlobalInput(localInput, hidInput);
if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN; if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN;
} }
@ -142,26 +138,26 @@ void PlayerInterruptKeys(bool after)
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
tempinput.svel -= info.mousex * 4.f; tempinput.svel -= hidInput->mousex * 4.f;
tempinput.svel -= info.dyaw * keyMove; tempinput.svel -= hidInput->dyaw * keyMove;
} }
else else
{ {
input_angle += FloatToFixed(info.mousex + scaleAdjustmentToInterval(info.dyaw)); input_angle += FloatToFixed(hidInput->mousex + scaleAdjustmentToInterval(hidInput->dyaw));
} }
bool mouseaim = !(localInput.actions & SB_AIMMODE); bool mouseaim = !(localInput.actions & SB_AIMMODE);
if (mouseaim) if (mouseaim)
tempinput.q16horz += FloatToFixed(info.mousey); tempinput.q16horz += FloatToFixed(hidInput->mousey);
else else
tempinput.fvel -= info.mousey * 8.f; tempinput.fvel -= hidInput->mousey * 8.f;
if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz; if (!in_mouseflip) tempinput.q16horz = -tempinput.q16horz;
tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(info.dpitch)); tempinput.q16horz -= FloatToFixed(scaleAdjustmentToInterval(hidInput->dpitch));
tempinput.svel -= info.dx * keyMove; tempinput.svel -= hidInput->dx * keyMove;
tempinput.fvel -= info.dz * keyMove; tempinput.fvel -= hidInput->dz * keyMove;
if (buttonMap.ButtonDown(gamefunc_Strafe)) 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; if (packet) *packet = localInput;
} }

View file

@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS BEGIN_PS_NS
void PlayerInterruptKeys(bool after);
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle); 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 SetSavePoint(int nPlayer, int x, int y, int z, short nSector, short nAngle);
void InitPlayer(); void InitPlayer();

View file

@ -51,7 +51,7 @@ struct GameInterface : public ::GameInterface
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;
void DrawPlayerSprite(const DVector2& origin, bool onteam) override; void DrawPlayerSprite(const DVector2& origin, bool onteam) override;
void ResetFollowPos(bool message) override; void ResetFollowPos(bool message) override;
void GetInput(InputPacket* packet) override; void GetInput(InputPacket* packet, ControlInfo* const hidInput) override;
void UpdateSounds() override; void UpdateSounds() override;
void Startup() override; void Startup() override;
void DrawBackground() override; void DrawBackground() override;

View file

@ -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 (isRR() && (loc.actions & SB_CROUCH)) loc.actions &= ~SB_JUMP;
if (p->OnMotorcycle || p->OnBoat) 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); bool mouseaim = !(loc.actions & SB_AIMMODE);
@ -608,20 +608,20 @@ static void processMovement(player_struct *p, InputPacket &input, ControlInfo &i
int keymove = NORMALKEYMOVE << running; int keymove = NORMALKEYMOVE << running;
if (buttonMap.ButtonDown(gamefunc_Strafe)) 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 else
input.q16avel += FloatToFixed(info.mousex + scaleFactor * info.dyaw); input.q16avel += FloatToFixed(hidInput->mousex + scaleFactor * hidInput->dyaw);
if (mouseaim) if (mouseaim)
input.q16horz += FloatToFixed(info.mousey); input.q16horz += FloatToFixed(hidInput->mousey);
else else
input.fvel -= info.mousey * 8.f; input.fvel -= hidInput->mousey * 8.f;
if (!in_mouseflip) input.q16horz = -input.q16horz; if (!in_mouseflip) input.q16horz = -input.q16horz;
input.q16horz -= FloatToFixed(scaleFactor * (info.dpitch)); input.q16horz -= FloatToFixed(scaleFactor * (hidInput->dpitch));
input.svel -= scaleFactor * (info.dx * keymove); input.svel -= scaleFactor * (hidInput->dx * keymove);
input.fvel -= scaleFactor * (info.dz * keymove); input.fvel -= scaleFactor * (hidInput->dz * keymove);
if (buttonMap.ButtonDown(gamefunc_Strafe)) 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 turnl = buttonMap.ButtonDown(gamefunc_Turn_Left) || buttonMap.ButtonDown(gamefunc_Strafe_Left);
int turnr = buttonMap.ButtonDown(gamefunc_Turn_Right) || buttonMap.ButtonDown(gamefunc_Strafe_Right); 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; double elapsedInputTicks;
auto const p = &ps[myconnectindex]; auto const p = &ps[myconnectindex];
@ -1023,15 +1023,13 @@ static void GetInputInternal(InputPacket &locInput)
} }
double scaleAdjust = !cl_syncinput ? elapsedInputTicks * REALGAMETICSPERSEC / 1000.0 : 1; double scaleAdjust = !cl_syncinput ? elapsedInputTicks * REALGAMETICSPERSEC / 1000.0 : 1;
ControlInfo info;
CONTROL_GetInput(&info);
InputPacket input{}; InputPacket input{};
if (isRRRA() && (p->OnMotorcycle || p->OnBoat)) if (isRRRA() && (p->OnMotorcycle || p->OnBoat))
{ {
p->crouch_toggle = 0; p->crouch_toggle = 0;
processInputBits(p, info); processInputBits(p, hidInput);
processVehicleInput(p, info, input, scaleAdjust); processVehicleInput(p, hidInput, input, scaleAdjust);
FinalizeInput(myconnectindex, input, true); FinalizeInput(myconnectindex, input, true);
if (!cl_syncinput && sprite[p->i].extra > 0) if (!cl_syncinput && sprite[p->i].extra > 0)
@ -1041,8 +1039,8 @@ static void GetInputInternal(InputPacket &locInput)
} }
else else
{ {
processInputBits(p, info); processInputBits(p, hidInput);
processMovement(p, input, info, scaleAdjust); processMovement(p, input, hidInput, scaleAdjust);
checkCrouchToggle(p); checkCrouchToggle(p);
FinalizeInput(myconnectindex, input, false); 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) if (packet)
{ {
auto const pPlayer = &ps[myconnectindex]; auto const pPlayer = &ps[myconnectindex];

View file

@ -1604,7 +1604,6 @@ short ScreenSavePic = FALSE;
SWBOOL PicInView(short, SWBOOL); SWBOOL PicInView(short, SWBOOL);
void DoPlayerDiveMeter(PLAYERp pp); void DoPlayerDiveMeter(PLAYERp pp);
void MoveScrollMode2D(PLAYERp pp);
void void
drawscreen(PLAYERp pp, double smoothratio) drawscreen(PLAYERp pp, double smoothratio)

View file

@ -2211,7 +2211,7 @@ struct GameInterface : ::GameInterface
void ResetFollowPos(bool message) override; void ResetFollowPos(bool message) override;
void UpdateSounds() override; void UpdateSounds() override;
void ErrorCleanup() override; void ErrorCleanup() override;
void GetInput(InputPacket* input) override; void GetInput(InputPacket* input, ControlInfo* const hidInput) override;
void DrawBackground(void) override; void DrawBackground(void) override;
void Ticker(void) override; void Ticker(void) override;
void Render() override; void Render() override;

View file

@ -67,7 +67,7 @@ void GameInterface::ResetFollowPos(bool)
Follow_posy = pp->posy; Follow_posy = pp->posy;
} }
static void getinput(InputPacket *loc) static void getinput(InputPacket *loc, ControlInfo* const hidInput)
{ {
int i; int i;
PLAYERp pp = Player + myconnectindex; PLAYERp pp = Player + myconnectindex;
@ -101,9 +101,6 @@ static void getinput(InputPacket *loc)
lastInputTicks = currentHiTicks; lastInputTicks = currentHiTicks;
ControlInfo info;
CONTROL_GetInput(&info);
if (paused) if (paused)
return; return;
@ -111,7 +108,7 @@ static void getinput(InputPacket *loc)
// Tried calling this in domovethings, but key response it too poor, skips key presses // Tried calling this in domovethings, but key response it too poor, skips key presses
// Note: this get called only during follow mode // Note: this get called only during follow mode
if (automapFollow && automapMode != am_off && pp == Player + myconnectindex && !Prediction) 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 // !JIM! Added M_Active() so that you don't move at all while using menus
if (M_Active() || (automapFollow && automapMode != am_off)) 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. // for dividing controller input to match speed input speed of other games.
float const ticrateScale = 0.75f; float const ticrateScale = 0.75f;
ApplyGlobalInput(*loc, &info); ApplyGlobalInput(*loc, hidInput);
bool mouseaim = !(loc->actions & SB_AIMMODE); bool mouseaim = !(loc->actions & SB_AIMMODE);
@ -179,25 +176,25 @@ static void getinput(InputPacket *loc)
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
{ {
svel -= (info.mousex * ticrateScale) * 4.f; svel -= (hidInput->mousex * ticrateScale) * 4.f;
svel -= info.dyaw * keymove; svel -= hidInput->dyaw * keymove;
} }
else else
{ {
q16angvel += FloatToFixed((info.mousex / angvelScale) + scaleAdjustmentToInterval((info.dyaw * ticrateScale) / angvelScale)); q16angvel += FloatToFixed((hidInput->mousex / angvelScale) + scaleAdjustmentToInterval((hidInput->dyaw * ticrateScale) / angvelScale));
} }
if (mouseaim) if (mouseaim)
q16horz -= FloatToFixed(info.mousey / aimvelScale); q16horz -= FloatToFixed(hidInput->mousey / aimvelScale);
else else
vel -= (info.mousey * ticrateScale) * 8.f; vel -= (hidInput->mousey * ticrateScale) * 8.f;
if (in_mouseflip) if (in_mouseflip)
q16horz = -q16horz; q16horz = -q16horz;
q16horz -= FloatToFixed(scaleAdjustmentToInterval((info.dpitch * ticrateScale) / aimvelScale)); q16horz -= FloatToFixed(scaleAdjustmentToInterval((hidInput->dpitch * ticrateScale) / aimvelScale));
svel -= info.dx * keymove; svel -= hidInput->dx * keymove;
vel -= info.dz * keymove; vel -= hidInput->dz * keymove;
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop) 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) if (packet)
{ {
PLAYERp pp = &Player[myconnectindex]; PLAYERp pp = &Player[myconnectindex];

View file

@ -2435,7 +2435,7 @@ void PlayerCheckValidMove(PLAYERp pp)
} }
void void
MoveScrollMode2D(PLAYERp pp) MoveScrollMode2D(PLAYERp pp, ControlInfo* const hidInput)
{ {
#define TURBOTURNTIME (120/8) #define TURBOTURNTIME (120/8)
#define NORMALTURN (12+6) #define NORMALTURN (12+6)
@ -2446,22 +2446,19 @@ MoveScrollMode2D(PLAYERp pp)
#define MAXSVEL ((NORMALKEYMOVE*2)+10) #define MAXSVEL ((NORMALKEYMOVE*2)+10)
#define MAXANGVEL 100 #define MAXANGVEL 100
ControlInfo scrl_input;
int32_t keymove; int32_t keymove;
int32_t momx, momy; int32_t momx, momy;
static int mfvel=0, mfsvel=0; static int mfvel=0, mfsvel=0;
CONTROL_GetInput(&scrl_input);
mfsvel = mfvel = 0; mfsvel = mfvel = 0;
if (M_Active()) if (M_Active())
return; return;
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
mfsvel -= scrl_input.dyaw / 4; mfsvel -= hidInput->dyaw / 4;
mfsvel -= scrl_input.dx / 4; mfsvel -= hidInput->dx / 4;
mfvel = -scrl_input.dz /4; mfvel = -hidInput->dz /4;
keymove = NORMALKEYMOVE; keymove = NORMALKEYMOVE;

View file

@ -130,7 +130,7 @@ void DoPlayer(void);
void domovethings(void); void domovethings(void);
void InitAllPlayers(void); void InitAllPlayers(void);
void InitMultiPlayerInfo(void); void InitMultiPlayerInfo(void);
void MoveScrollMode2D(PLAYERp pp); void MoveScrollMode2D(PLAYERp pp, ControlInfo* const hidInput);
void DoPlayerDivePalette(PLAYERp pp); void DoPlayerDivePalette(PLAYERp pp);
void DoPlayerNightVisionPalette(PLAYERp pp); void DoPlayerNightVisionPalette(PLAYERp pp);
void DoPlayerStopDiveNoWarp(PLAYERp pp); void DoPlayerStopDiveNoWarp(PLAYERp pp);