summaryrefslogtreecommitdiffhomepage
path: root/floormat
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-31 21:41:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2022-10-31 21:41:46 +0100
commit4accaa62047f27bcf1ea28e1e68db33e50c335df (patch)
treea591529bce4fcb7b31164363a435fdca6dadb443 /floormat
parent089f188a5b68c87f2be32b465624841fd3c2b44f (diff)
a
Diffstat (limited to 'floormat')
-rw-r--r--floormat/app.hpp2
-rw-r--r--floormat/events.hpp28
2 files changed, 14 insertions, 16 deletions
diff --git a/floormat/app.hpp b/floormat/app.hpp
index 60ecc52c..c7c40d78 100644
--- a/floormat/app.hpp
+++ b/floormat/app.hpp
@@ -10,7 +10,7 @@ struct mouse_scroll_event;
struct key_event;
struct text_input_event;
struct text_editing_event;
-struct any_event;
+union any_event;
struct chunk_coords;
struct chunk;
diff --git a/floormat/events.hpp b/floormat/events.hpp
index 97c5f171..6ab1b3ae 100644
--- a/floormat/events.hpp
+++ b/floormat/events.hpp
@@ -1,23 +1,20 @@
#pragma once
#include <Magnum/Math/Vector2.h>
-#include <SDL_keycode.h>
-#include <SDL_mouse.h>
-#include <SDL_events.h>
namespace floormat {
enum mouse_button : std::uint8_t {
mouse_button_none = 0,
- mouse_button_left = SDL_BUTTON_LMASK,
- mouse_button_middle = SDL_BUTTON_MMASK,
- mouse_button_right = SDL_BUTTON_RMASK,
- mouse_button_x1 = SDL_BUTTON_X1MASK,
- mouse_button_x2 = SDL_BUTTON_X2MASK,
+ mouse_button_left = 1 << 0,
+ mouse_button_middle = 1 << 1,
+ mouse_button_right = 1 << 3,
+ mouse_button_x1 = 1 << 4,
+ mouse_button_x2 = 1 << 5,
};
struct mouse_button_event final {
Vector2i position;
- SDL_Keymod mods = KMOD_NONE;
+ int mods = 0;
mouse_button button = mouse_button_none;
std::uint8_t click_count = 0;
};
@@ -25,13 +22,13 @@ struct mouse_button_event final {
struct mouse_move_event final {
Vector2i position, relative_position;
mouse_button buttons = mouse_button_none;
- SDL_Keymod mods = KMOD_NONE;
+ int mods = 0;
};
struct mouse_scroll_event final {
Magnum::Vector2 offset;
Vector2i position;
- SDL_Keymod mods = KMOD_NONE;
+ int mods = 0;
};
struct text_input_event final {
@@ -44,13 +41,14 @@ struct text_editing_event final {
};
struct key_event final {
- SDL_Keycode key = SDLK_UNKNOWN;
- SDL_Keymod mods = KMOD_NONE;
+ int key = 0;
+ int mods = 0;
std::uint8_t is_repeated = false;
};
-struct any_event final {
- SDL_Event event = {};
+union alignas(alignof(void*)) any_event {
+ std::size_t size[0] = {};
+ char buf[64];
};
} // namespace floormat