forked from devpack/mayhem
-
Notifications
You must be signed in to change notification settings - Fork 2
/
xc.h
67 lines (61 loc) · 1.56 KB
/
xc.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
58
59
60
61
62
63
64
65
66
67
#ifndef XC_H
#define XC_H
#include <allegro5/allegro.h>
#define XC_EVENT_AXIS ALLEGRO_EVENT_JOYSTICK_AXIS
#define XC_EVENT_BUTTON_DOWN ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
#define XC_EVENT_BUTTON_UP ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
#define XC_CONFIGURATION ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
typedef struct {
bool analog_output;
bool trigger;
float* position;
bool* negative;
bool* positive;
} XC_STICK_AXIS_MAP;
typedef struct {
int num_buttons;
bool* button_map[15];
int num_sticks;
XC_STICK_AXIS_MAP stick_map[4][2];
} XC_MAP;
typedef struct {
// axis values
float left_stick_x;
float left_stick_y;
float left_trigger;
float right_stick_x;
float right_stick_y;
float right_trigger;
bool dpad_up;
bool dpad_down;
bool dpad_left;
bool dpad_right;
// buttons pressed
bool button_a;
bool button_b;
bool button_x;
bool button_y;
bool button_left_stick;
bool button_right_stick;
bool button_left_shoulder;
bool button_right_shoulder;
bool button_start;
bool button_back;
bool button_xbox;
// reference to the underlying joystick object
ALLEGRO_JOYSTICK *joy;
XC_MAP controls_map;
int num_buttons;
bool* button_map[15];
} XC_STATE;
bool xc_install();
bool xc_reconfigure();
void xc_clear_state(XC_STATE *state);
void xc_free_state(XC_STATE *state);
void xc_update(ALLEGRO_EVENT event);
XC_STATE *xc_get_state(int num);
ALLEGRO_EVENT_SOURCE *xc_get_event_source();
void setup_controller_map(XC_STATE *state);
void setup_default_controller_map(XC_STATE *state);
void setup_xinput_controller_map(XC_STATE *state);
#endif