2019-10-28 00:24:09 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-28 06:47:49 +01:00
|
|
|
#include <stdint.h>
|
2020-07-14 14:00:27 +02:00
|
|
|
#include "printf.h"
|
|
|
|
#include "c_dispatch.h"
|
2019-10-28 06:47:49 +01:00
|
|
|
#include "tarray.h"
|
2019-10-28 01:12:31 +01:00
|
|
|
#include "scancodes.h"
|
2019-11-03 20:24:50 +01:00
|
|
|
#include "c_bind.h"
|
2019-11-04 23:01:50 +01:00
|
|
|
#include "c_buttons.h"
|
2019-11-04 00:53:55 +01:00
|
|
|
#include "d_event.h"
|
2019-12-14 20:15:15 +01:00
|
|
|
#include "m_joy.h"
|
|
|
|
#include "gamecvars.h"
|
2020-08-27 00:53:35 +02:00
|
|
|
#include "packet.h"
|
2021-12-14 11:57:24 +01:00
|
|
|
#include "vectors.h"
|
2019-11-04 17:58:18 +01:00
|
|
|
|
2020-07-14 14:00:27 +02:00
|
|
|
|
2019-11-10 15:15:14 +01:00
|
|
|
struct ControlInfo
|
|
|
|
{
|
2020-06-24 23:11:42 +10:00
|
|
|
float dx;
|
|
|
|
float dy;
|
|
|
|
float dz;
|
|
|
|
float dyaw;
|
|
|
|
float dpitch;
|
|
|
|
float droll;
|
2020-09-28 22:36:43 +02:00
|
|
|
float mouseturnx;
|
|
|
|
float mouseturny;
|
|
|
|
float mousemovex;
|
|
|
|
float mousemovey;
|
2019-11-10 15:15:14 +01:00
|
|
|
};
|
|
|
|
|
2019-11-04 01:01:54 +01:00
|
|
|
|
2019-10-28 00:24:09 +01:00
|
|
|
class InputState
|
|
|
|
{
|
2019-12-23 20:03:03 +01:00
|
|
|
uint8_t KeyStatus[NUM_KEYS];
|
2020-08-24 20:34:18 +02:00
|
|
|
bool AnyKeyStatus;
|
2021-12-14 10:07:06 +01:00
|
|
|
FVector2 g_mousePos;
|
2019-11-10 15:15:14 +01:00
|
|
|
|
2019-10-28 00:24:09 +01:00
|
|
|
public:
|
|
|
|
|
2019-10-28 01:12:31 +01:00
|
|
|
bool ShiftPressed()
|
|
|
|
{
|
|
|
|
return KeyStatus[sc_LeftShift] || KeyStatus[sc_RightShift];
|
|
|
|
}
|
2019-11-04 00:53:55 +01:00
|
|
|
|
2019-11-10 15:15:14 +01:00
|
|
|
void AddEvent(const event_t* ev);
|
2019-11-04 00:53:55 +01:00
|
|
|
|
2020-07-05 12:02:33 +10:00
|
|
|
void MouseAddToPos(float x, float y)
|
2019-11-10 15:15:14 +01:00
|
|
|
{
|
2021-12-14 10:07:06 +01:00
|
|
|
g_mousePos.X += x;
|
|
|
|
g_mousePos.Y += y;
|
2019-11-10 15:15:14 +01:00
|
|
|
}
|
2019-12-14 20:15:15 +01:00
|
|
|
|
2020-09-06 20:17:54 +10:00
|
|
|
void GetMouseDelta(ControlInfo* hidInput);
|
2019-11-10 15:15:14 +01:00
|
|
|
|
2020-07-17 20:56:10 +02:00
|
|
|
void ClearAllInput();
|
2019-12-24 12:59:26 +01:00
|
|
|
bool CheckAllInput()
|
2019-12-14 20:15:15 +01:00
|
|
|
{
|
2020-08-24 20:34:18 +02:00
|
|
|
bool res = AnyKeyStatus;
|
|
|
|
AnyKeyStatus = false;
|
2019-12-24 12:59:26 +01:00
|
|
|
return res;
|
2019-11-28 19:35:35 +01:00
|
|
|
}
|
2019-10-28 00:24:09 +01:00
|
|
|
};
|
2019-12-14 20:15:15 +01:00
|
|
|
|
|
|
|
extern InputState inputState;
|
2019-11-06 19:22:14 +01:00
|
|
|
|
2020-09-06 20:17:54 +10:00
|
|
|
ControlInfo CONTROL_GetInput();
|
2019-12-24 13:54:50 +01:00
|
|
|
int32_t handleevents(void);
|
2020-08-27 00:25:59 +02:00
|
|
|
|
|
|
|
enum GameFunction_t
|
|
|
|
{
|
2020-08-28 00:03:35 +02:00
|
|
|
gamefunc_Move_Forward, //
|
|
|
|
gamefunc_Move_Backward, //
|
|
|
|
gamefunc_Turn_Left, //
|
|
|
|
gamefunc_Turn_Right, //
|
|
|
|
gamefunc_Strafe, //
|
2020-08-27 00:25:59 +02:00
|
|
|
gamefunc_Fire,
|
|
|
|
gamefunc_Open,
|
|
|
|
gamefunc_Run,
|
|
|
|
gamefunc_Alt_Fire,
|
|
|
|
gamefunc_Jump,
|
|
|
|
gamefunc_Crouch,
|
|
|
|
gamefunc_Look_Up,
|
|
|
|
gamefunc_Look_Down,
|
|
|
|
gamefunc_Look_Left,
|
|
|
|
gamefunc_Look_Right,
|
2020-08-28 00:03:35 +02:00
|
|
|
gamefunc_Strafe_Left, //
|
|
|
|
gamefunc_Strafe_Right, //
|
2020-08-27 00:25:59 +02:00
|
|
|
gamefunc_Aim_Up,
|
|
|
|
gamefunc_Aim_Down,
|
|
|
|
gamefunc_Shrink_Screen, // Automap only
|
|
|
|
gamefunc_Enlarge_Screen, // Automap only
|
|
|
|
gamefunc_Mouse_Aiming,
|
|
|
|
gamefunc_Dpad_Select,
|
|
|
|
gamefunc_Dpad_Aiming,
|
|
|
|
gamefunc_Toggle_Crouch,
|
|
|
|
gamefunc_Quick_Kick,
|
2020-09-06 20:49:43 +02:00
|
|
|
gamefunc_AM_PanLeft,
|
|
|
|
gamefunc_AM_PanRight,
|
|
|
|
gamefunc_AM_PanUp,
|
|
|
|
gamefunc_AM_PanDown,
|
2020-08-27 00:25:59 +02:00
|
|
|
NUM_ACTIONS
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetupGameButtons();
|
2020-11-07 18:16:16 +11:00
|
|
|
void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput, bool const crouchable = true, bool const disableToggle = false);
|
2020-09-04 17:53:36 +10:00
|
|
|
extern ESyncBits ActionsToSend;
|
2020-11-30 23:45:21 +01:00
|
|
|
extern bool gamesetinput;
|
2020-11-30 23:40:16 +01:00
|
|
|
|
|
|
|
inline bool SyncInput()
|
|
|
|
{
|
2022-06-06 18:24:35 +10:00
|
|
|
return gamesetinput || cl_syncinput || cl_capfps;
|
2020-11-30 23:45:21 +01:00
|
|
|
}
|
|
|
|
|
2021-12-06 17:21:41 +11:00
|
|
|
inline float backendinputscale()
|
|
|
|
{
|
|
|
|
return (1.f / 16.f);
|
|
|
|
}
|
|
|
|
|
2020-11-30 23:45:21 +01:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Inline functions to help with edge cases where synchronised input is needed.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
inline void setForcedSyncInput()
|
|
|
|
{
|
|
|
|
gamesetinput = true;
|
|
|
|
}
|
|
|
|
inline void resetForcedSyncInput()
|
|
|
|
{
|
|
|
|
gamesetinput = false;
|
|
|
|
}
|