From 6454975779acb39d7d546e11855a07a952e68e5b Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 4 Dec 2024 20:12:34 +0100 Subject: loeks feedback changes --- src/crepe/system/InputSystem.cpp | 70 +++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'src/crepe/system/InputSystem.cpp') diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index 11749e1..bbf2547 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -37,7 +37,7 @@ void InputSystem::update() { || world_mouse_x > camera_origin_x + current_cam.viewport_size.x || world_mouse_y < camera_origin_y || world_mouse_y > camera_origin_y + current_cam.viewport_size.y); - + switch (event.event_type) { case SDLContext::EventType::KEYDOWN: event_mgr.queue_event(KeyPressEvent{ @@ -59,8 +59,8 @@ void InputSystem::update() { .mouse_y = world_mouse_y, .button = event.mouse_button, }); - last_mouse_down_position = {world_mouse_x, world_mouse_y}; - last_mouse_button = event.mouse_button; + this->last_mouse_down_position = {world_mouse_x, world_mouse_y}; + this->last_mouse_button = event.mouse_button; break; case SDLContext::EventType::MOUSEUP: { if (!mouse_in_viewport) { @@ -72,10 +72,10 @@ void InputSystem::update() { .button = event.mouse_button, }); //check if its a click by checking the last button down - int delta_x = world_mouse_x - last_mouse_down_position.first; - int delta_y = world_mouse_y - last_mouse_down_position.second; + int delta_x = world_mouse_x - this->last_mouse_down_position.x; + int delta_y = world_mouse_y - this->last_mouse_down_position.y; - if (last_mouse_button == event.mouse_button + if (this->last_mouse_button == event.mouse_button && std::abs(delta_x) <= click_tolerance && std::abs(delta_y) <= click_tolerance) { event_mgr.queue_event(MouseClickEvent{ @@ -84,7 +84,7 @@ void InputSystem::update() { .button = event.mouse_button, }); - handle_click(event.mouse_button, world_mouse_x, world_mouse_y); + this->handle_click(event.mouse_button, world_mouse_x, world_mouse_y); } } break; case SDLContext::EventType::MOUSEMOVE: @@ -94,16 +94,17 @@ void InputSystem::update() { event_mgr.queue_event(MouseMoveEvent{ .mouse_x = world_mouse_x, .mouse_y = world_mouse_y, - .rel_x = event.rel_mouse_move.first, - .rel_y = event.rel_mouse_move.second, + .delta_x = event.rel_mouse_move.first, + .delta_y = event.rel_mouse_move.second, }); handle_move(event, world_mouse_x, world_mouse_y); break; case SDLContext::EventType::MOUSEWHEEL: event_mgr.queue_event(MouseScrollEvent{ - .scroll_x = event.wheel_delta, - .scroll_y = 0, - .direction = event.wheel_delta, + .mouse_x = world_mouse_x, + .mouse_y = world_mouse_y, + .scroll_direction = event.scroll_direction, + .scroll_delta = event.scroll_delta, }); break; case SDLContext::EventType::SHUTDOWN: @@ -115,7 +116,7 @@ void InputSystem::update() { } } void InputSystem::handle_move(const SDLContext::EventData & event_data, - const int & world_mouse_x, const int & world_mouse_y) { + const int world_mouse_x, const int world_mouse_y) { ComponentManager & mgr = this->component_manager; RefVector