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
|
#ifndef MGL_EVENT_H
#define MGL_EVENT_H
#include <stdbool.h>
#include <stdint.h>
typedef struct mgl_event mgl_event;
typedef struct {
int width;
int height;
} mgl_size_event;
typedef struct {
uint32_t codepoint;
int size;
char str[5]; /* utf8, null terminated */
} mgl_text_event;
typedef struct {
int code; /* mgl_key */
bool alt;
bool control;
bool shift;
bool system;
} mgl_key_event;
typedef struct {
int button; /* mgl_mouse_button */
int x; /* mouse position relative to left of the window */
int y; /* mouse position relative to top of the window */
} mgl_mouse_button_event;
typedef struct {
int delta; /* positive = up, negative = down */
int x; /* mouse position relative to left of the window */
int y; /* mouse position relative to left of the window */
} mgl_mouse_wheel_scroll_event;
typedef struct {
int x; /* relative to left of the window */
int y; /* relative to the top of the window */
} mgl_mouse_move_event;
typedef struct {
const char *name; /* This name may only be valid until the next time |mgl_window_poll_event| is called */
int id;
int x;
int y;
int width;
int height;
int refresh_rate; /* 0 if unknown */
} mgl_monitor_generic_event;
typedef mgl_monitor_generic_event mgl_monitor_connected_event;
typedef mgl_monitor_generic_event mgl_monitor_property_changed_event;
typedef struct {
int id;
} mgl_monitor_disconnected_event;
typedef enum {
MGL_EVENT_UNKNOWN,
MGL_EVENT_CLOSED, /* Window closed */
MGL_EVENT_RESIZED, /* Window resized */
MGL_EVENT_LOST_FOCUS,
MGL_EVENT_GAINED_FOCUS,
MGL_EVENT_TEXT_ENTERED,
MGL_EVENT_KEY_PRESSED,
MGL_EVENT_KEY_RELEASED,
MGL_EVENT_MOUSE_BUTTON_PRESSED,
MGL_EVENT_MOUSE_BUTTON_RELEASED,
MGL_EVENT_MOUSE_WHEEL_SCROLLED,
MGL_EVENT_MOUSE_MOVED,
MGL_EVENT_MONITOR_CONNECTED,
MGL_EVENT_MONITOR_DISCONNECTED,
MGL_EVENT_MONITOR_PROPERTY_CHANGED,
} mgl_event_type;
struct mgl_event {
int type; /* mgl_event_type */
union {
mgl_size_event size;
mgl_text_event text;
mgl_key_event key;
mgl_mouse_button_event mouse_button;
mgl_mouse_wheel_scroll_event mouse_wheel_scroll;
mgl_mouse_move_event mouse_move;
mgl_monitor_connected_event monitor_connected;
mgl_monitor_disconnected_event monitor_disconnected;
mgl_monitor_property_changed_event monitor_property_changed;
};
};
#endif /* MGL_EVENT_H */
|