aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r--src/crepe/facade/SDLContext.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index 0a2456d..d7af226 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -105,10 +105,21 @@ public:
};
//! EventData struct for passing event data from facade
struct EventData {
- SDLContext::EventType event_type = SDLContext::EventType::NONE;
- KeyData key_data;
- MouseData mouse_data;
- WindowData window_data;
+ SDLContext::EventType event_type = SDLContext::EventType::NONE;
+
+ union EventDataUnion {
+ KeyData key_data;
+ MouseData mouse_data;
+ WindowData window_data;
+
+ EventDataUnion() {}
+ ~EventDataUnion() {}
+ } data;
+
+ // Helper functions
+ // bool isKeyEvent() const { return event_type == SDLContext::EventType::KEYDOWN || event_type == SDLContext::EventType::KEYUP; }
+ // bool isMouseEvent() const { return event_type == SDLContext::EventType::MOUSEDOWN || event_type == SDLContext::EventType::MOUSEUP || event_type == SDLContext::EventType::MOUSEMOVE; }
+ // bool isWindowEvent() const { return event_type == SDLContext::EventType::WINDOW_MINIMIZE || event_type == SDLContext::EventType::WINDOW_RESIZE; }
};
/**
* \brief Retrieves the current state of the keyboard.