summaryrefslogtreecommitdiff
path: root/src/player-input.hpp
blob: a5e64be75e5c1256719e3e02af00a88b703b67ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef PKE_PLAYER_INPUT_HPP
#define PKE_PLAYER_INPUT_HPP

#include "dynamic-array.hpp"
#include "game-type-defs.hpp"
#include "macros.hpp"

TypeSafeInt_H(InputEventHash, int16_t, 0x0FFF);
TypeSafeInt_H(InputEventType, int16_t, 0x0FFF);
TypeSafeInt_H(InputCursorEntered, int16_t, 0x0FFF);
TypeSafeInt_H(InputKeyboardKeyAction, int16_t, 0x0FFF);
TypeSafeInt_H(InputMouseButtonAction, int16_t, 0x0FFF);
TypeSafeInt_H(InputWindowFocused, int16_t, 0x0FFF);

const InputEventType PKE_INPUT_EVENT_TYPE_CURSOR_ENTER = InputEventType{0};
const InputEventType PKE_INPUT_EVENT_TYPE_CURSOR_POS = InputEventType{1};
const InputEventType PKE_INPUT_EVENT_TYPE_KEY = InputEventType{2};
const InputEventType PKE_INPUT_EVENT_TYPE_MOUSE_BUTTON = InputEventType{3};
const InputEventType PKE_INPUT_EVENT_TYPE_SCROLL = InputEventType{4};
const InputEventType PKE_INPUT_EVENT_TYPE_WINDOW_FOCUS = InputEventType{5};

const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_UNSET = InputCursorEntered{-1};
const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_FALSE = InputCursorEntered{0};
const InputCursorEntered PKE_INPUT_CURSOR_ENTERED_TRUE = InputCursorEntered{1};

const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_UNSET = InputKeyboardKeyAction{-1};
const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_RELEASE = InputKeyboardKeyAction{0};
const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_PRESS = InputKeyboardKeyAction{1};
const InputKeyboardKeyAction PKE_INPUT_KEYBOARD_KEY_ACTION_REPEAT = InputKeyboardKeyAction{2};

const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_UNSET = InputMouseButtonAction{-1};
const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_RELEASE = InputMouseButtonAction{0};
const InputMouseButtonAction PKE_INPUT_MOUSE_BUTTON_ACTION_PRESS = InputMouseButtonAction{1};

const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_UNSET = InputWindowFocused{-1};
const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_FALSE = InputWindowFocused{0};
const InputWindowFocused PKE_INPUT_WINDOW_FOCUSED_TRUE = InputWindowFocused{1};

struct PkeInputEvent {
	InputEventType type;
	GameTimePoint timePoint;
	InputCursorEntered cursorEntered;
	InputKeyboardKeyAction keyboardKeyAction;
	InputMouseButtonAction mouseButtonAction;
	InputWindowFocused windowFocused;
	double x;
	double y;
	int32_t button;
	int32_t scanCode;
	int32_t mods;
	uint64_t tickCount;
};

void PkeInput_Tick(double delta);
bool PkeInput_Query(const PkeInputEvent &mask);
void PkeInput_Init();
void PkeInput_Teardown();

#endif /* PKE_PLAYER_INPUT_HPP */