diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 9cd87b092..7913857db 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -110,7 +110,7 @@ void resetTurnHeldAmt() // //--------------------------------------------------------------------------- -void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, const double scaleAdjust, const int drink_amt, const bool allowstrafe, const double turnscale) +void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, HIDInput* const hidInput, 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)); diff --git a/source/core/gameinput.h b/source/core/gameinput.h index e58c553f7..378ca98ae 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -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, ControlInfo* const hidInput, const double scaleAdjust, const int drink_amt = 0, const bool allowstrafe = true, const double turnscale = 1); +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); diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index af0ee818d..9f1e3cb9c 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -88,7 +88,7 @@ struct GameInterface virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {} virtual void SetAmbience(bool on) {} virtual void ExitFromMenu() { throw CExitEvent(0); } - virtual void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) {} + virtual void GetInput(const double scaleAdjust, InputPacket* packet = nullptr) {} virtual void UpdateSounds() {} virtual void ErrorCleanup() {} virtual void Startup() {} diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index b548311fe..b4c59fb12 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -65,7 +65,7 @@ CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertic // //========================================================================== -void InputState::GetMouseDelta(ControlInfo * hidInput) +void InputState::GetMouseDelta(HIDInput * hidInput) { g_mousePos *= backendinputscale(); @@ -201,11 +201,9 @@ int32_t handleevents(void) // //========================================================================== -ControlInfo CONTROL_GetInput() +void getHidInput(HIDInput* const hidInput) { - ControlInfo hidInput {}; - - inputState.GetMouseDelta(&hidInput); + inputState.GetMouseDelta(hidInput); if (use_joystick) { @@ -214,13 +212,11 @@ ControlInfo CONTROL_GetInput() I_GetAxes(joyaxes); - hidInput.dyaw += -joyaxes[JOYAXIS_Yaw]; - hidInput.dpitch += -joyaxes[JOYAXIS_Pitch]; - hidInput.dforward += joyaxes[JOYAXIS_Forward] * .5f; - hidInput.dside += joyaxes[JOYAXIS_Side] * .5f; + hidInput->dyaw += -joyaxes[JOYAXIS_Yaw]; + hidInput->dpitch += -joyaxes[JOYAXIS_Pitch]; + hidInput->dforward += joyaxes[JOYAXIS_Forward] * .5f; + hidInput->dside += joyaxes[JOYAXIS_Side] * .5f; } - - return hidInput; } //--------------------------------------------------------------------------- @@ -398,7 +394,7 @@ CCMD(show_weapon) gi->ToggleShowWeapon(); } -void ApplyGlobalInput(InputPacket& input, ControlInfo* hidInput, bool const crouchable, bool const disableToggle) +void ApplyGlobalInput(InputPacket& input, HIDInput* hidInput, bool const crouchable, bool const disableToggle) { if (WeaponToSend != 0) input.setNewWeapon(WeaponToSend); WeaponToSend = 0; diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 568acdf6c..52a0740a3 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -14,7 +14,7 @@ #include "vectors.h" -struct ControlInfo +struct HIDInput { float dside; float dup; @@ -50,7 +50,7 @@ public: g_mousePos.Y += y; } - void GetMouseDelta(ControlInfo* hidInput); + void GetMouseDelta(HIDInput* hidInput); void ClearAllInput(); bool CheckAllInput() @@ -63,7 +63,7 @@ public: extern InputState inputState; -ControlInfo CONTROL_GetInput(); +void getHidInput(HIDInput* const hidInput); int32_t handleevents(void); enum GameFunction_t @@ -102,7 +102,7 @@ enum GameFunction_t }; void SetupGameButtons(); -void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput, bool const crouchable = true, bool const disableToggle = false); +void ApplyGlobalInput(InputPacket& input, HIDInput* const hidInput, bool const crouchable = true, bool const disableToggle = false); extern ESyncBits ActionsToSend; extern bool gamesetinput; diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 75d96fbce..196ea891e 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -136,8 +136,7 @@ void G_BuildTiccmd(ticcmd_t* cmd) } cmd->ucmd = {}; I_GetEvent(); - auto input = CONTROL_GetInput(); - gi->GetInput(&input, inputScale, &cmd->ucmd); + gi->GetInput(inputScale, &cmd->ucmd); cmd->consistency = consistency[myconnectindex][(maketic / ticdup) % BACKUPTICS]; } @@ -615,8 +614,7 @@ void TryRunTics (void) if (!SyncInput()) { I_GetEvent(); - auto input = CONTROL_GetInput(); - gi->GetInput(&input, inputScale); + gi->GetInput(inputScale); } return; } diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index 070d6ee1b..4994f2682 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -120,7 +120,7 @@ struct GameInterface : public ::GameInterface void MenuClosed() override; bool CanSave() override; void UpdateSounds() override; - void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override; + void GetInput(const double scaleAdjust, InputPacket* packet = nullptr) override; void Ticker() override; void DrawBackground() override; void Startup() override; diff --git a/source/games/blood/src/controls.cpp b/source/games/blood/src/controls.cpp index 5829e7eb3..36d2d1f79 100644 --- a/source/games/blood/src/controls.cpp +++ b/source/games/blood/src/controls.cpp @@ -40,7 +40,7 @@ static InputPacket gInput; // //--------------------------------------------------------------------------- -void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet) +void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet) { if (paused || M_Active()) { @@ -48,11 +48,14 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju return; } + HIDInput hidInput; + getHidInput(&hidInput); + PLAYER* pPlayer = &gPlayer[myconnectindex]; InputPacket input{}; - ApplyGlobalInput(gInput, hidInput); - processMovement(&input, &gInput, hidInput, scaleAdjust); + ApplyGlobalInput(gInput, &hidInput); + processMovement(&input, &gInput, &hidInput, scaleAdjust); // Perform unsynchronised angle/horizon if not dead. if (!SyncInput() && gamestate == GS_LEVEL && pPlayer->actor->xspr.health != 0) diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 7e0b60c5d..430abe230 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -38,7 +38,7 @@ struct GameInterface : public ::GameInterface void SerializeGameState(FSerializer& arc) override; void ExitFromMenu() override; void DrawPlayerSprite(const DVector2& origin, bool onteam) override; - void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override; + void GetInput(const double scaleAdjust, InputPacket* packet = nullptr) override; void UpdateSounds() override; void Startup() override; void DrawBackground() override; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 758bbd27a..892c2eb81 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -523,7 +523,7 @@ static constexpr float VEHICLETURN = (20.f * 360.f / 2048.f); // //--------------------------------------------------------------------------- -static void processInputBits(player_struct *p, ControlInfo* const hidInput) +static void processInputBits(player_struct *p, HIDInput* const hidInput) { // Set-up crouch bools. int const sectorLotag = p->insector() ? p->cursector->lotag : 0; @@ -555,7 +555,7 @@ static void processInputBits(player_struct *p, ControlInfo* const hidInput) // //--------------------------------------------------------------------------- -static float motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, const float factor) +static float motoApplyTurn(player_struct* p, HIDInput* const hidInput, bool const kbdLeft, bool const kbdRight, const float factor) { float turnvel = 0; p->oTiltStatus = p->TiltStatus; @@ -645,7 +645,7 @@ static float motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool c // //--------------------------------------------------------------------------- -static float boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, const float factor) +static float boatApplyTurn(player_struct *p, HIDInput* const hidInput, bool const kbdLeft, bool const kbdRight, const float factor) { float turnvel = 0; p->oTiltStatus = p->TiltStatus; @@ -731,7 +731,7 @@ static float boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool c // //--------------------------------------------------------------------------- -static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, InputPacket& input, double const scaleAdjust) +static void processVehicleInput(player_struct *p, HIDInput* const hidInput, InputPacket& input, double const 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); @@ -805,7 +805,7 @@ static void FinalizeInput(player_struct *p, InputPacket& input) // //--------------------------------------------------------------------------- -void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet) +void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet) { if (paused || gamestate != GS_LEVEL) { @@ -813,18 +813,21 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju return; } + HIDInput hidInput; + getHidInput(&hidInput); + auto const p = &ps[myconnectindex]; InputPacket input{}; - processInputBits(p, hidInput); + processInputBits(p, &hidInput); if (isRRRA() && (p->OnMotorcycle || p->OnBoat)) { - processVehicleInput(p, hidInput, input, scaleAdjust); + processVehicleInput(p, &hidInput, input, scaleAdjust); } else { - processMovement(&input, &loc, hidInput, scaleAdjust, p->drink_amt); + processMovement(&input, &loc, &hidInput, scaleAdjust, p->drink_amt); } FinalizeInput(p, input); diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 06960c93c..c89973a50 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -225,7 +225,7 @@ struct GameInterface : public ::GameInterface void DrawBackground() override; void Render() override; //void DrawWeapons() override; - void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet = nullptr) override; + void GetInput(const double scaleAdjust, InputPacket* packet = nullptr) override; void Startup() override; const char* GenericCheat(int player, int cheat) override; void NewGame(MapRecord *map, int skill, bool) override; diff --git a/source/games/exhumed/src/input.cpp b/source/games/exhumed/src/input.cpp index 461c08d59..275be4165 100644 --- a/source/games/exhumed/src/input.cpp +++ b/source/games/exhumed/src/input.cpp @@ -46,7 +46,7 @@ void ClearSpaceBar(int nPlayer) // //--------------------------------------------------------------------------- -void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* packet) +void GameInterface::GetInput(const double scaleAdjust, InputPacket* packet) { if (paused || M_Active()) { @@ -54,10 +54,13 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju return; } + HIDInput hidInput; + getHidInput(&hidInput); + if (packet != nullptr) { localInput = {}; - ApplyGlobalInput(localInput, hidInput); + ApplyGlobalInput(localInput, &hidInput); if (PlayerList[nLocalPlayer].nHealth == 0) localInput.actions &= SB_OPEN; } @@ -66,7 +69,7 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju if (PlayerList[nLocalPlayer].nHealth != 0) { - processMovement(&input, &localInput, hidInput, scaleAdjust); + processMovement(&input, &localInput, &hidInput, scaleAdjust); } else { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 3e37d9fe8..801578132 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1681,7 +1681,7 @@ struct GameInterface : public ::GameInterface void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); } void UpdateSounds() override; void ErrorCleanup() override; - void GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket* input = nullptr) override; + void GetInput(const double scaleAdjust, InputPacket* input = nullptr) override; void DrawBackground(void) override; void Ticker(void) override; void Render() override; diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index 0b7e69ccc..d81bb0137 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -160,7 +160,7 @@ static void processWeapon(PLAYER* const pp) } } -void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdjust, InputPacket *packet) +void GameInterface::GetInput(const double scaleAdjust, InputPacket *packet) { PLAYER* pp = &Player[myconnectindex]; @@ -170,10 +170,13 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju return; } + HIDInput hidInput; + getHidInput(&hidInput); + InputPacket input {}; - ApplyGlobalInput(loc, hidInput); - processMovement(&input, &loc, hidInput, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.); + ApplyGlobalInput(loc, &hidInput); + processMovement(&input, &loc, &hidInput, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.); processWeapon(pp); if (!SyncInput()) diff --git a/source/games/sw/src/player.h b/source/games/sw/src/player.h index 60a9747ad..bb00b973d 100644 --- a/source/games/sw/src/player.h +++ b/source/games/sw/src/player.h @@ -125,7 +125,7 @@ void DoPlayer(void); void domovethings(void); void InitAllPlayers(void); void InitMultiPlayerInfo(const DVector3& spawnpos, const DAngle startang); -void MoveScrollMode2D(PLAYER* pp, ControlInfo* const hidInput); +void MoveScrollMode2D(PLAYER* pp, HIDInput* const hidInput); void DoPlayerDivePalette(PLAYER* pp); void DoPlayerNightVisionPalette(PLAYER* pp); void DoPlayerStopDiveNoWarp(PLAYER* pp);