From 6eec70ec2ad54168442eca4f15030e7e6294cfb7 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sun, 21 Mar 2021 12:55:31 +0000 Subject: add events subsystem --- src/window/Events.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/window/Events.hpp (limited to 'src/window/Events.hpp') diff --git a/src/window/Events.hpp b/src/window/Events.hpp new file mode 100644 index 0000000..6914dca --- /dev/null +++ b/src/window/Events.hpp @@ -0,0 +1,33 @@ +#ifndef ENGINE_EVENTS_H +#define ENGINE_EVENTS_H + +#define MAX_KEYS GLFW_KEY_LAST + 1 + GLFW_MOUSE_BUTTON_LAST + 1 +#define MOUSE_BUTTONS GLFW_KEY_LAST + 1 /* when start mouse buttons */ + +class Events { + bool *keys; + unsigned int *frames; + unsigned int cur_frame; + bool update_frame; + float delta_x; + float delta_y; + float x; + float y; + bool cursor_locked; + +public: + Events(); + ~Events(); + + bool Pressed(int keycode); + bool Jpressed(int keycode); + bool Clicked(int button); + bool Jclicked(int button); + + void NextFrame(); + void KeyHandle(int key, int scancode, int action, int mode); + void CursorPosHandle(double xpos, double ypos); + void MouseButtonHandle(int button, int action, int mode); +}; + +#endif /* ENGINE_EVENTS_H */ -- cgit v1.2.3-18-g5258