-
Notifications
You must be signed in to change notification settings - Fork 2
/
gamepad.h
57 lines (50 loc) · 1.49 KB
/
gamepad.h
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
/*
* author : Shuichi TAKANO
* since : Fri Jul 30 2021 04:42:27
*/
#ifndef _510036F3_0134_6411_4376_A918ACA8AC4C
#define _510036F3_0134_6411_4376_A918ACA8AC4C
#include <stdint.h>
namespace io
{
struct GamePadState
{
bool connected{false};
struct Button
{
inline static constexpr int A = 1 << 0;
inline static constexpr int B = 1 << 1;
inline static constexpr int X = 1 << 2;
inline static constexpr int Y = 1 << 3;
inline static constexpr int SELECT = 1 << 6;
inline static constexpr int START = 1 << 7;
inline static constexpr int LEFT = 1 << 31;
inline static constexpr int RIGHT = 1 << 30;
inline static constexpr int UP = 1 << 29;
inline static constexpr int DOWN = 1 << 28;
};
enum class Hat
{
N,
NE,
E,
SE,
S,
SW,
W,
NW,
RELEASED,
};
uint8_t axis[3]{0x80, 0x80, 0x80};
Hat hat{Hat::RELEASED};
uint32_t buttons{0};
char GamePadName[20]{};
public:
void convertButtonsFromAxis(int axisX, int axisY);
void convertButtonsFromHat();
void flagConnected(bool connected) { this->connected = connected; }
bool isConnected() const { return connected; }
};
GamePadState &getCurrentGamePadState(int i);
}
#endif /* _510036F3_0134_6411_4376_A918ACA8AC4C */