diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-12 08:58:08 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-12-12 08:58:08 +0100 |
commit | 44cab6ad59d257d949112dcd4a9e0bdc9302e92b (patch) | |
tree | 8b00630668082554ab8b9ca600cc40856e133184 /src/crepe/facade/SDLContext.h | |
parent | 0f68177a0384d41a7feff36cc0e1869b6d2ac9aa (diff) |
save
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r-- | src/crepe/facade/SDLContext.h | 19 |
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. |