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"
|
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
|
|
|
|
2019-11-10 14:15:14 +00:00
|
|
|
void GetMouseDelta(ControlInfo* info);
|
|
|
|
|
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
|
|
|
|
2019-12-24 12:54:50 +00:00
|
|
|
void CONTROL_GetInput(ControlInfo* info);
|
|
|
|
int32_t handleevents(void);
|