aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/InputSystem.h
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-18 21:14:17 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-18 21:14:17 +0100
commit6d333439fa955d2da69dac72ec2470e1bfc2e63d (patch)
treea58ae1644abc5e931fad1899d25a87e9e6a6bd3e /src/crepe/system/InputSystem.h
parent3855044ad97a41ca71b0d3ea2240f4eee93cc86f (diff)
parent4dd30ea92296892c9a9bd94787531d6a1319d8ac (diff)
Merge branch 'jaro/collision-system-handeling' of github.com:lonkaars/crepe into jaro/collision-system-handeling
Diffstat (limited to 'src/crepe/system/InputSystem.h')
-rw-r--r--src/crepe/system/InputSystem.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/crepe/system/InputSystem.h b/src/crepe/system/InputSystem.h
index 87e86f8..eefd9fe 100644
--- a/src/crepe/system/InputSystem.h
+++ b/src/crepe/system/InputSystem.h
@@ -1,6 +1,8 @@
#pragma once
-#include "../facade/SDLContext.h"
+#include "../api/Config.h"
+#include "../facade/EventData.h"
+
#include "../types.h"
#include "../util/OptionalRef.h"
@@ -11,7 +13,6 @@ namespace crepe {
class Camera;
class Button;
class Transform;
-
/**
* \brief Handles the processing of input events created by SDLContext
*
@@ -31,15 +32,30 @@ public:
private:
//! Stores the last position of the mouse when the button was pressed.
- ivec2 last_mouse_down_position;
+ vec2 last_mouse_down_position;
// TODO: specify world/hud space and make regular `vec2`
//! Stores the last mouse button pressed.
MouseButton last_mouse_button = MouseButton::NONE;
-
- //! The maximum allowable distance between mouse down and mouse up to register as a click.
- const int click_tolerance = 5;
-
+ /**
+ * \brief Handles mouse-related events.
+ * \param event The event data for the mouse event.
+ * \param camera_origin The origin position of the camera in world space.
+ * \param current_cam The currently active camera.
+ *
+ * This method processes mouse events, adjusts the mouse position to world coordinates,
+ * and triggers the appropriate mouse-specific event handling logic.
+ */
+ void handle_mouse_event(const EventData & event, const vec2 & camera_origin,
+ const Camera & current_cam);
+ /**
+ * \brief Handles non-mouse-related events.
+ * \param event The event data for the non-mouse event.
+ *
+ * This method processes events that do not involve the mouse, such as keyboard events,
+ * window events, and shutdown events, and triggers the corresponding event actions.
+ */
+ void handle_non_mouse_event(const EventData & event);
/**
* \brief Handles the mouse click event.
* \param mouse_button The mouse button involved in the click.
@@ -48,8 +64,7 @@ private:
*
* This method processes the mouse click event and triggers the corresponding button action.
*/
- void handle_click(const MouseButton & mouse_button, const int world_mouse_x,
- const int world_mouse_y);
+ void handle_click(const MouseButton & mouse_button, const vec2 & mouse_pos);
/**
* \brief Handles the mouse movement event.
@@ -59,8 +74,7 @@ private:
*
* This method processes the mouse movement event and updates the button hover state.
*/
- void handle_move(const SDLContext::EventData & event_data, const int world_mouse_x,
- const int world_mouse_y);
+ void handle_move(const EventData & event_data, const vec2 & mouse_pos);
/**
* \brief Checks if the mouse position is inside the bounds of the button.
@@ -70,8 +84,8 @@ private:
* \param transform The transform component of the button.
* \return True if the mouse is inside the button, false otherwise.
*/
- bool is_mouse_inside_button(const int world_mouse_x, const int world_mouse_y,
- const Button & button, const Transform & transform);
+ bool is_mouse_inside_button(const vec2 & mouse_pos, const Button & button,
+ const Transform & transform);
/**
* \brief Handles the button press event, calling the on_click callback if necessary.