2019-10-27 23:24:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-28 05:47:49 +00:00
|
|
|
#include <stdint.h>
|
2020-07-14 12:00:27 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "printf.h"
|
|
|
|
#include "c_dispatch.h"
|
2019-10-28 05:47:49 +00:00
|
|
|
#include "tarray.h"
|
2019-10-28 00:12:31 +00:00
|
|
|
#include "scancodes.h"
|
2019-11-03 19:24:50 +00:00
|
|
|
#include "c_bind.h"
|
2019-11-04 22:01:50 +00:00
|
|
|
#include "c_buttons.h"
|
2019-11-03 23:53:55 +00:00
|
|
|
#include "d_event.h"
|
2019-12-14 19:15:15 +00:00
|
|
|
#include "m_joy.h"
|
|
|
|
#include "gamecvars.h"
|
2020-08-26 22:53:35 +00:00
|
|
|
#include "packet.h"
|
2019-11-04 16:58:18 +00:00
|
|
|
|
2020-07-14 12:00:27 +00:00
|
|
|
|
2019-11-10 14:15:14 +00:00
|
|
|
struct ControlInfo
|
|
|
|
{
|
2020-06-24 13:11:42 +00:00
|
|
|
float dx;
|
|
|
|
float dy;
|
|
|
|
float dz;
|
|
|
|
float dyaw;
|
|
|
|
float dpitch;
|
|
|
|
float droll;
|
2020-07-05 02:02:33 +00:00
|
|
|
float mousex;
|
|
|
|
float mousey;
|
2019-11-10 14:15:14 +00:00
|
|
|
};
|
|
|
|
|
2019-11-04 00:01:54 +00:00
|
|
|
|
2019-10-27 23:24:09 +00:00
|
|
|
class InputState
|
|
|
|
{
|
2019-12-23 19:03:03 +00:00
|
|
|
uint8_t KeyStatus[NUM_KEYS];
|
2020-08-24 18:34:18 +00:00
|
|
|
bool AnyKeyStatus;
|
2020-07-05 02:02:33 +00:00
|
|
|
vec2f_t g_mousePos;
|
2019-11-10 14:15:14 +00:00
|
|
|
|
2019-10-27 23:24:09 +00:00
|
|
|
public:
|
|
|
|
|
2019-10-28 00:12:31 +00:00
|
|
|
bool ShiftPressed()
|
|
|
|
{
|
|
|
|
return KeyStatus[sc_LeftShift] || KeyStatus[sc_RightShift];
|
|
|
|
}
|
2019-11-03 23:53:55 +00:00
|
|
|
|
2019-11-10 14:15:14 +00:00
|
|
|
void AddEvent(const event_t* ev);
|
2019-11-03 23:53:55 +00:00
|
|
|
|
2020-07-05 02:02:33 +00:00
|
|
|
void MouseAddToPos(float x, float y)
|
2019-11-10 14:15:14 +00:00
|
|
|
{
|
|
|
|
g_mousePos.x += x;
|
|
|
|
g_mousePos.y += y;
|
|
|
|
}
|
2019-12-14 19:15:15 +00:00
|
|
|
|
2020-09-06 10:17:54 +00:00
|
|
|
void GetMouseDelta(ControlInfo* hidInput);
|
2019-11-10 14:15:14 +00:00
|
|
|
|
2020-07-17 18:56:10 +00:00
|
|
|
void ClearAllInput();
|
2019-12-24 11:59:26 +00:00
|
|
|
bool CheckAllInput()
|
2019-12-14 19:15:15 +00:00
|
|
|
{
|
2020-08-24 18:34:18 +00:00
|
|
|
bool res = AnyKeyStatus;
|
|
|
|
AnyKeyStatus = false;
|
2019-12-24 11:59:26 +00:00
|
|
|
return res;
|
2019-11-28 18:35:35 +00:00
|
|
|
}
|
2019-10-27 23:24:09 +00:00
|
|
|
};
|
2019-12-14 19:15:15 +00:00
|
|
|
|
|
|
|
extern InputState inputState;
|
2019-11-06 18:22:14 +00:00
|
|
|
|
2020-09-06 10:17:54 +00:00
|
|
|
ControlInfo CONTROL_GetInput();
|
2019-12-24 12:54:50 +00:00
|
|
|
int32_t handleevents(void);
|
2020-08-26 22:25:59 +00:00
|
|
|
|
|
|
|
enum GameFunction_t
|
|
|
|
{
|
2020-08-27 22:03:35 +00:00
|
|
|
gamefunc_Move_Forward, //
|
|
|
|
gamefunc_Move_Backward, //
|
|
|
|
gamefunc_Turn_Left, //
|
|
|
|
gamefunc_Turn_Right, //
|
|
|
|
gamefunc_Strafe, //
|
2020-08-26 22:25:59 +00: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-27 22:03:35 +00:00
|
|
|
gamefunc_Strafe_Left, //
|
|
|
|
gamefunc_Strafe_Right, //
|
2020-08-26 22:25:59 +00: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 18:49:43 +00:00
|
|
|
gamefunc_AM_PanLeft,
|
|
|
|
gamefunc_AM_PanRight,
|
|
|
|
gamefunc_AM_PanUp,
|
|
|
|
gamefunc_AM_PanDown,
|
2020-08-26 22:25:59 +00:00
|
|
|
NUM_ACTIONS
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetupGameButtons();
|
2020-09-06 10:17:54 +00:00
|
|
|
void ApplyGlobalInput(InputPacket& input, ControlInfo* const hidInput);
|
2020-09-04 07:53:36 +00:00
|
|
|
extern ESyncBits ActionsToSend;
|
|
|
|
double InputScale();
|