aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-16 04:18:39 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-16 04:19:54 +0100
commit8ea04000bfa98798a0283bcf80ea136ea8b4dd42 (patch)
tree34637967d90c1fa975d2acacdcdfb654778667f4 /include
parent61c7efc6dd2a036b5d14aa223d06a18cb7d1388e (diff)
Window: add function to get the current mouse button state
Diffstat (limited to 'include')
-rw-r--r--include/mgl/window/event.h10
-rw-r--r--include/mgl/window/mouse_button.h16
-rw-r--r--include/mgl/window/window.h2
3 files changed, 19 insertions, 9 deletions
diff --git a/include/mgl/window/event.h b/include/mgl/window/event.h
index a0d3982..1e7cebf 100644
--- a/include/mgl/window/event.h
+++ b/include/mgl/window/event.h
@@ -2,6 +2,7 @@
#define MGL_EVENT_H
#include "key.h"
+#include "mouse_button.h"
#include <stdbool.h>
#include <stdint.h>
@@ -26,15 +27,6 @@ typedef struct {
bool system;
} mgl_key_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; /* mouse position relative to left of the window */
diff --git a/include/mgl/window/mouse_button.h b/include/mgl/window/mouse_button.h
new file mode 100644
index 0000000..fccf0a7
--- /dev/null
+++ b/include/mgl/window/mouse_button.h
@@ -0,0 +1,16 @@
+#ifndef _MGL_MOUSE_BUTTON_H_
+#define _MGL_MOUSE_BUTTON_H_
+
+typedef enum {
+ MGL_BUTTON_UNKNOWN,
+ MGL_BUTTON_LEFT,
+ MGL_BUTTON_RIGHT,
+ MGL_BUTTON_MIDDLE,
+ MGL_BUTTON_XBUTTON1,
+ MGL_BUTTON_XBUTTON2,
+
+ /* This should always be the last mouse button */
+ __MGL_NUM_MOUSE_BUTTONS__
+} mgl_mouse_button;
+
+#endif /* _MGL_MOUSE_BUTTON_H_ */
diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h
index 4bbb46d..a63bc03 100644
--- a/include/mgl/window/window.h
+++ b/include/mgl/window/window.h
@@ -5,6 +5,7 @@
#include "../system/vec.h"
#include "../system/clock.h"
#include "key.h"
+#include "mouse_button.h"
#include <stdbool.h>
/* Vsync is automatically set for created windows, if supported by the system */
@@ -55,6 +56,7 @@ void mgl_window_get_view(mgl_window *self, mgl_view *view);
bool mgl_window_is_open(const mgl_window *self);
bool mgl_window_has_focus(const mgl_window *self);
bool mgl_window_is_key_pressed(const mgl_window *self, mgl_key key);
+bool mgl_window_is_mouse_button_pressed(const mgl_window *self, mgl_mouse_button button);
void mgl_window_close(mgl_window *self);
void mgl_window_set_title(mgl_window *self, const char *title);