From 8ea04000bfa98798a0283bcf80ea136ea8b4dd42 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 16 Nov 2021 04:18:39 +0100 Subject: Window: add function to get the current mouse button state --- include/mgl/window/event.h | 10 +--------- include/mgl/window/mouse_button.h | 16 ++++++++++++++++ include/mgl/window/window.h | 2 ++ 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 include/mgl/window/mouse_button.h (limited to 'include') 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 #include @@ -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 /* 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); -- cgit v1.2.3