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.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index e232511..21d17c7 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -9,6 +9,7 @@
#include <functional>
#include <memory>
#include <string>
+#include <array>
#include "api/Camera.h"
#include "api/Color.h"
@@ -79,19 +80,37 @@ public:
KEYUP,
KEYDOWN,
SHUTDOWN,
-
+ WINDOW_MINIMIZE,
+ WINDOW_MAXIMIZE,
+ WINDOW_FOCUS_GAIN,
+ WINDOW_FOCUS_LOST,
+ WINDOW_MOVE,
+ WINDOW_RESIZE,
+ WINDOW_EXPOSE,
};
- //! EventData struct for passing event data from facade
- struct EventData {
- SDLContext::EventType event_type = SDLContext::EventType::NONE;
+ struct KeyData{
Keycode key = Keycode::NONE;
bool key_repeat = false;
+ };
+ struct MouseData{
MouseButton mouse_button = MouseButton::NONE;
ivec2 mouse_position = {-1, -1};
int scroll_direction = -1;
float scroll_delta = INFINITY;
ivec2 rel_mouse_move = {-1, -1};
};
+ struct WindowData{
+ ivec2 move_delta;
+ ivec2 resize_dimension;
+ };
+ //! 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;
+ };
+
/**
* \brief Gets the singleton instance of SDLContext.
* \return Reference to the SDLContext instance.
@@ -116,7 +135,14 @@ private:
* \return Events that occurred since last call to `get_events()`
*/
std::vector<SDLContext::EventData> get_events();
-
+ /**
+ * \brief Fills event_list with triggered window events
+ *
+ * This method checks if any window events are triggered and adds them to the event_list.
+ *
+ */
+ void handle_window_event(const SDL_WindowEvent& window_event,
+ std::vector<SDLContext::EventData>& event_list);
/**
* \brief Converts an SDL key code to the custom Keycode type.
*
@@ -127,7 +153,19 @@ private:
* \return The corresponding `Keycode` value or `Keycode::NONE` if the key is unrecognized.
*/
Keycode sdl_to_keycode(SDL_Keycode sdl_key);
-
+ /**
+ * \brief Retrieves the current state of the keyboard.
+ *
+ * This method returns the state of all keys on the keyboard, represented as a
+ * `std::array` of boolean values. Each element of the array corresponds to a
+ * specific key defined in the `Keycode` enum, and the value indicates whether
+ * the key is currently pressed (true) or not pressed (false).
+ *
+ * \return A `std::array<bool, Keycode::NUM_KEYCODES>` representing the state of
+ * each key on the keyboard, where `true` means the key is pressed, and
+ * `false` means it is not pressed.
+ */
+ std::array<bool, Keycode::NUM_KEYCODES> get_keyboard_state();
/**
* \brief Converts an SDL mouse button code to the custom MouseButton type.
*