-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_event.h
69 lines (60 loc) · 1.43 KB
/
input_event.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
68
69
#ifndef INPUT_EVENT_H
#define INPUT_EVENT_H
#include <SDL2/SDL.h>
#include <stdbool.h>
extern const Uint8 *key_state;
extern SDL_Event input_mouse_wheel_sum;
enum {
LEFTX,
LEFTY,
RIGHTX,
RIGHTY,
TRIGGERLEFT,
TRIGGERRIGHT,
NUM_HANDLED_AXES
};
enum nes30_button {
INPUT_BUTTON_A = 0,
INPUT_BUTTON_B = 1,
INPUT_BUTTON_X = 3,
INPUT_BUTTON_Y = 4,
INPUT_BUTTON_L1 = 6,
INPUT_BUTTON_R1 = 7,
INPUT_BUTTON_L2 = 8,
INPUT_BUTTON_R2 = 9,
INPUT_BUTTON_SELECT = 10,
INPUT_BUTTON_START = 11,
INPUT_BUTTON_LSTICK = 13,
INPUT_BUTTON_RSTICK = 14,
NUM_HANDLED_BUTTONS = 16
};
extern Sint16 axes[NUM_HANDLED_AXES];
extern bool nes30_buttons[NUM_HANDLED_BUTTONS];
struct controller_axis_input {
float leftx;
float lefty;
float rightx;
float righty;
float ltrigger;
float rtrigger;
};
struct mouse_input {
Uint32 buttons;
int x, y;
};
void input_event_init();
void input_event_deinit();
void input_event_save_prev_key_state();
void input_event_save_prev_mouse_state();
void input_event_device_arrival(int which);
void caxisevent(SDL_Event e);
void jaxisevent(SDL_Event e);
void jbuttonevent(SDL_Event e);
void mousewheelevent(SDL_Event e);
void mousewheelreset();
bool key_pressed(SDL_Scancode s);
bool key_down(SDL_Scancode s);
Uint8 mouse_button_pressed(int *x, int *y);
void keyevent(SDL_Keysym keysym, SDL_EventType type);
struct controller_axis_input controller_input_apply_threshold(struct controller_axis_input input, float threshold);
#endif