aboutsummaryrefslogtreecommitdiff
path: root/include/mgl/window/event.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mgl/window/event.h')
-rw-r--r--include/mgl/window/event.h54
1 files changed, 53 insertions, 1 deletions
diff --git a/include/mgl/window/event.h b/include/mgl/window/event.h
index 2aea478..020d5c9 100644
--- a/include/mgl/window/event.h
+++ b/include/mgl/window/event.h
@@ -1,10 +1,62 @@
#ifndef MGL_EVENT_H
#define MGL_EVENT_H
+#include "key.h"
+#include <stdbool.h>
+
typedef struct mgl_event mgl_event;
+typedef struct {
+ int width;
+ int height;
+} mgl_size_event;
+
+typedef struct {
+ int code; /* mgl_key */
+ bool alt;
+ bool control;
+ bool shift;
+ bool system;
+} mgl_key_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 enum {
+ MGL_BUTTON_UNKNOWN,
+ MGL_BUTTON_LEFT,
+ MGL_BUTTON_RIGHT,
+ MGL_BUTTON_MIDDLE,
+ MGL_BUTTON_XBUTTON1,
+ MGL_BUTTON_XBUTTON2
+} mgl_mouse_button;
+
+typedef struct {
+ int button; /* mgl_mouse_button */
+ int x; /* relative to left of the window */
+ int y; /* relative to top of the window */
+} mgl_mouse_button_event;
+
+typedef enum {
+ MGL_EVENT_UNKNOWN,
+ MGL_EVENT_RESIZED,
+ MGL_EVENT_KEY_PRESSED,
+ MGL_EVENT_KEY_RELEASED,
+ MGL_EVENT_MOUSE_BUTTON_PRESSED,
+ MGL_EVENT_MOUSE_BUTTON_RELEASED,
+ MGL_EVENT_MOUSE_MOVED
+} mgl_event_type;
+
struct mgl_event {
- int type;
+ int type; /* mgl_event_type */
+ union {
+ mgl_size_event size;
+ mgl_key_event key;
+ mgl_mouse_button_event mouse_button;
+ mgl_mouse_move_event mouse_move;
+ };
};
#endif /* MGL_EVENT_H */