summaryrefslogtreecommitdiffstats
path: root/src/game/client/io/gamepad.hh
blob: 5f76277b783176eb0a060309a9a03423c19cc9c1 (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
#pragma once

constexpr static int INVALID_GAMEPAD_AXIS = INT_MAX;
constexpr static int INVALID_GAMEPAD_BUTTON = INT_MAX;

namespace config
{
class Boolean;
class Float;
} // namespace config

struct GLFWgamepadstate;

namespace gamepad
{
extern bool available;
extern config::Float deadzone;
extern config::Boolean active;
extern GLFWgamepadstate state;
extern GLFWgamepadstate last_state;
} // namespace gamepad

namespace gamepad
{
void init(void);
void update_late(void);
} // namespace gamepad

// This simulates buttons using axes. When an axis
// value exceeds 1.5 times the deadzone, the event is
// queued with a GLFW_PRESS action, when it falls back
// below the threshold, the event is queued with GLFW_RELEASE action
struct GamepadAxisEvent final {
    int action;
    int axis;
};

// This smears GLFW event sugar over gamepad polling
// system. Whenever it detects a state change, the event
// is queued with an appropriate action
struct GamepadButtonEvent final {
    int action;
    int button;
};