2020-10-11 14:33:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-03-13 10:33:37 +00:00
|
|
|
#include "serializer.h"
|
2023-10-31 03:44:58 +00:00
|
|
|
#include "coreplayer.h"
|
2023-10-05 02:10:47 +00:00
|
|
|
#include "d_net.h"
|
2020-10-11 14:33:43 +00:00
|
|
|
|
2023-09-24 03:40:15 +00:00
|
|
|
enum : unsigned
|
|
|
|
{
|
|
|
|
CS_CANCROUCH = 1,
|
|
|
|
CS_DISABLETOGGLE = 2,
|
|
|
|
};
|
|
|
|
|
2023-09-25 09:51:53 +00:00
|
|
|
enum : unsigned
|
|
|
|
{
|
|
|
|
VEH_CANMOVE = 1,
|
|
|
|
VEH_CANTURN = 2,
|
|
|
|
VEH_SCALETURN = 4,
|
|
|
|
};
|
|
|
|
|
2023-04-03 08:46:36 +00:00
|
|
|
class GameInput
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BUILDTICRATE = 120,
|
|
|
|
TURBOTURNBASE = 590,
|
|
|
|
};
|
|
|
|
|
2023-04-21 10:09:19 +00:00
|
|
|
static constexpr double YAW_TURNSPEEDS[3] = { 234.375 * (360. / 2048.), 890.625 * (360. / 2048.), 1548.75 * (360. / 2048.) };
|
2023-10-03 21:56:08 +00:00
|
|
|
static constexpr DVector3 MAXVEL[3] = { { 0., 0., 1. }, { 1., 1., 1. }, { 2., 2., 1. } };
|
|
|
|
static constexpr DRotator MAXANG = { DAngle180 - minAngle, DAngle180 - minAngle, DAngle180 - minAngle };
|
2023-10-03 09:58:38 +00:00
|
|
|
static constexpr DAngle MOUSE_SCALE = DAngle::fromDeg(1. / 16.);
|
2023-04-03 08:46:36 +00:00
|
|
|
|
2023-04-03 08:40:34 +00:00
|
|
|
// Input received from the OS.
|
|
|
|
float joyAxes[NUM_JOYAXIS];
|
2023-10-04 08:20:57 +00:00
|
|
|
FVector2 mouseInput;
|
2023-04-03 08:40:34 +00:00
|
|
|
|
2023-04-03 08:46:36 +00:00
|
|
|
// Internal variables when generating a packet.
|
|
|
|
InputPacket inputBuffer;
|
2023-10-04 05:08:03 +00:00
|
|
|
ESyncBits ActionsToSend;
|
2023-04-03 08:46:36 +00:00
|
|
|
double turnheldtime;
|
2023-10-04 05:08:03 +00:00
|
|
|
double scaleAdjust;
|
2023-10-05 02:10:47 +00:00
|
|
|
bool syncinput;
|
2023-04-03 08:46:36 +00:00
|
|
|
int WeaponToSend;
|
|
|
|
int dpad_lock;
|
2023-10-04 05:08:03 +00:00
|
|
|
int keymove;
|
2023-04-03 08:46:36 +00:00
|
|
|
|
|
|
|
// Turn speed doubling after x amount of tics.
|
2023-10-04 05:08:03 +00:00
|
|
|
void updateTurnHeldAmt()
|
2023-04-03 08:46:36 +00:00
|
|
|
{
|
2023-10-31 03:44:58 +00:00
|
|
|
turnheldtime += getTicrateScale(BUILDTICRATE * scaleAdjust);
|
2023-04-03 08:46:36 +00:00
|
|
|
}
|
|
|
|
bool isTurboTurnTime()
|
|
|
|
{
|
|
|
|
return turnheldtime >= getTicrateScale(TURBOTURNBASE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prototypes for private member functions.
|
2023-04-03 08:40:34 +00:00
|
|
|
void processInputBits();
|
2023-04-03 08:46:36 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Bit sender updates.
|
|
|
|
void SendWeapon(const int weapon)
|
|
|
|
{
|
|
|
|
WeaponToSend = weapon;
|
|
|
|
}
|
|
|
|
void SendAction(const ESyncBits action)
|
|
|
|
{
|
|
|
|
ActionsToSend |= action;
|
|
|
|
}
|
|
|
|
|
2023-09-24 07:50:06 +00:00
|
|
|
// Clear all values within this object.
|
|
|
|
void Clear()
|
|
|
|
{
|
2023-09-28 22:31:03 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2023-09-24 07:50:06 +00:00
|
|
|
}
|
|
|
|
|
2023-04-03 08:40:34 +00:00
|
|
|
// Receives mouse input from OS for processing.
|
|
|
|
void MouseAddToPos(float x, float y)
|
|
|
|
{
|
|
|
|
mouseInput.X += x;
|
|
|
|
mouseInput.Y += y;
|
|
|
|
}
|
|
|
|
|
2023-10-04 05:08:03 +00:00
|
|
|
// Receives the current input scale from the engine's main loop.
|
|
|
|
void UpdateInputScale()
|
|
|
|
{
|
|
|
|
const double frac = I_GetInputFrac();
|
|
|
|
scaleAdjust = !SyncInput() ? frac : 1;
|
|
|
|
}
|
|
|
|
|
2023-10-05 02:10:47 +00:00
|
|
|
// Handling of whether to allow unsynchronised input.
|
|
|
|
bool SyncInput()
|
|
|
|
{
|
|
|
|
return syncinput || cl_syncinput || cl_capfps;
|
|
|
|
}
|
|
|
|
void ForceInputSync(const int pnum)
|
|
|
|
{
|
|
|
|
if (pnum == myconnectindex)
|
|
|
|
{
|
|
|
|
syncinput = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void ResetInputSync()
|
|
|
|
{
|
|
|
|
syncinput = false;
|
|
|
|
}
|
|
|
|
|
2023-04-03 08:46:36 +00:00
|
|
|
// Prototypes for large member functions.
|
2023-10-04 05:08:03 +00:00
|
|
|
void processMovement(const double turnscale = 1, const bool allowstrafe = true, const int drink_amt = 0);
|
|
|
|
void processVehicle(const double baseVel, const double velScale, const unsigned flags);
|
|
|
|
void getInput(InputPacket* packet = nullptr);
|
2023-09-24 07:50:06 +00:00
|
|
|
void resetCrouchToggle();
|
2023-04-03 08:46:36 +00:00
|
|
|
};
|
2023-04-02 08:26:22 +00:00
|
|
|
|
2023-04-03 08:46:36 +00:00
|
|
|
extern GameInput gameInput;
|