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 "compat.h"
|
|
|
|
#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"
|
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-07-05 12:02:33 +10:00
|
|
|
float mousex;
|
|
|
|
float mousey;
|
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;
|
2020-07-05 12:02:33 +10:00
|
|
|
vec2f_t 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
|
|
|
{
|
|
|
|
g_mousePos.x += x;
|
|
|
|
g_mousePos.y += y;
|
|
|
|
}
|
2019-12-14 20:15:15 +01:00
|
|
|
|
2019-11-10 15:15:14 +01:00
|
|
|
void GetMouseDelta(ControlInfo* info);
|
|
|
|
|
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
|
|
|
|
2019-12-24 13:54:50 +01:00
|
|
|
void CONTROL_GetInput(ControlInfo* info);
|
|
|
|
int32_t handleevents(void);
|