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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#ifndef ENGINE_EVENTS_H
#define ENGINE_EVENTS_H
enum keys_name {
KEY_UNKNOWN = -1,
KEY_SPACE,
KEY_APOSTROPHE,
KEY_COMMA,
KEY_MINUS,
KEY_PERIOD,
KEY_SLASH,
KEY_0,
KEY_1,
KEY_2,
KEY_3,
KEY_4,
KEY_5,
KEY_6,
KEY_7,
KEY_8,
KEY_9,
KEY_KEY_SEMICOLON,
KEY_EQUAL,
KEY_A,
KEY_B,
KEY_C,
KEY_D,
KEY_E,
KEY_F,
KEY_G,
KEY_H,
KEY_I,
KEY_J,
KEY_K,
KEY_L,
KEY_M,
KEY_N,
KEY_O,
KEY_P,
KEY_Q,
KEY_R,
KEY_S,
KEY_T,
KEY_U,
KEY_V,
KEY_W,
KEY_X,
KEY_Y,
KEY_Z,
KEY_LEFT_BRACKET,
KEY_BACKSLASH,
KEY_RIGHT_BRACKET,
KEY_GRAVE_ACCENT,
KEY_WORLD_1,
KEY_WORLD_2,
KEY_ESCAPE,
KEY_ENTER,
KEY_TAB,
KEY_BACKSPACE,
KEY_INSERT,
KEY_DELETE,
KEY_RIGHT,
KEY_LEFT,
KEY_DOWN,
KEY_UP,
KEY_PAGE_UP,
KEY_PAGE_DOWN,
KEY_HOME,
KEY_END,
KEY_CAPS_LOCK,
KEY_SCROLL_LOCK,
KEY_NUM_LOCK,
KEY_PRINT_SCREEN,
KEY_PAUSE,
KEY_F1,
KEY_F2,
KEY_F3,
KEY_F4,
KEY_F5,
KEY_F6,
KEY_F7,
KEY_F8,
KEY_F9,
KEY_F10,
KEY_F11,
KEY_F12,
KEY_F13,
KEY_F14,
KEY_F15,
KEY_F16,
KEY_F17,
KEY_F18,
KEY_F19,
KEY_F20,
KEY_F21,
KEY_F22,
KEY_F23,
KEY_F24,
KEY_F25,
KEY_KP_0,
KEY_KP_1,
KEY_KP_2,
KEY_KP_3,
KEY_KP_4,
KEY_KP_5,
KEY_KP_6,
KEY_KP_7,
KEY_KP_8,
KEY_KP_9,
KEY_KP_DECIMAL,
KEY_KP_DIVIDE,
KEY_KP_MULTIPLY,
KEY_KP_SUBTRACT,
KEY_KP_ADD,
KEY_KP_ENTER,
KEY_KP_EQUAL,
KEY_LEFT_SHIFT,
KEY_LEFT_CONTROL,
KEY_LEFT_ALT,
KEY_LEFT_SUPER,
KEY_RIGHT_SHIFT,
KEY_RIGHT_CONTROL,
KEY_RIGHT_ALT,
KEY_RIGHT_SUPER,
KEY_MENU,
KEY_LAST = KEY_MENU
};
#define MAX_KEYS KEY_LAST + 1 + GLFW_MOUSE_BUTTON_LAST + 1
#define MOUSE_BUTTONS KEY_LAST + 1 /* when start mouse buttons */
class Window;
class Events {
Window *master;
bool *keys;
unsigned int *frames;
unsigned int cur_frame;
bool update_frame;
double delta_x;
double delta_y;
double x;
double y;
double scroll_dx;
double scroll_dy;
bool cursor_locked;
public:
Events(Window *w);
~Events();
Window *GetWindow() { return master; }
double GetDX() { return delta_x; }
double GetDY() { return delta_y; }
double GetScrollDX() { return scroll_dx; }
double GetScrollDY() { return scroll_dy; }
bool Pressed(int keycode);
bool Jpressed(int keycode);
bool Clicked(int button);
bool Jclicked(int button);
void NextFrame();
void KeyHandle(int key, int scancode, int action, int mode);
void CursorPosHandle(double xpos, double ypos);
void MouseButtonHandle(int button, int action, int mode);
void WindowResizeHandle(int width, int height);
void MouseScrollHandle(double xoffset, double yoffset);
};
#endif /* ENGINE_EVENTS_H */
|