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
|
#ifndef MGLPP_EVENT_HPP
#define MGLPP_EVENT_HPP
#include "Keyboard.hpp"
#include "Mouse.hpp"
#include <stdint.h>
/* These have to match the same structures in mgl event */
namespace mgl {
class Event {
public:
struct SizeEvent {
int width;
int height;
};
struct TextEvent {
uint32_t codepoint;
int size;
char str[5]; /* utf8, null terminated */
};
struct KeyEvent {
Keyboard::Key code;
bool alt;
bool control;
bool shift;
bool system;
};
struct MouseButtonEvent {
Mouse::Button button;
int x; /* mouse position relative to left of the window */
int y; /* mouse position relative to top of the window */
};
struct MouseWheelScrollEvent {
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 */
};
struct MouseMoveEvent {
int x; /* relative to left of the window */
int y; /* relative to the top of the window */
};
enum Type : int {
Unknown,
Closed, /* Window closed */
Resized, /* Window resized */
LostFocus,
GainedFocus,
TextEntered,
KeyPressed,
KeyReleased,
MouseButtonPressed,
MouseButtonReleased,
MouseWheelScrolled,
MouseMoved
};
Type type;
union {
SizeEvent size;
TextEvent text;
KeyEvent key;
MouseButtonEvent mouse_button;
MouseWheelScrollEvent mouse_wheel_scroll;
MouseMoveEvent mouse_move;
};
};
}
#endif /* MGLPP_EVENT_HPP */
|