From 137b36ded2d67e0ff636fe4e936e16d5a7a3e90f Mon Sep 17 00:00:00 2001 From: WBoerenkamps Date: Wed, 27 Nov 2024 14:51:55 +0100 Subject: small {} changes --- src/crepe/facade/SDLContext.cpp | 6 ++---- src/crepe/system/InputSystem.cpp | 20 +++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src/crepe') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 512e858..735ed70 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -336,15 +336,13 @@ std::vector SDLContext::get_events() { .key = sdl_to_keycode(event.key.keysym.scancode), }); break; - case SDL_MOUSEBUTTONDOWN: { - int x, y; - SDL_GetMouseState(&x, &y); + case SDL_MOUSEBUTTONDOWN: event_list.push_back(EventData{ .event_type = SDLContext::EventType::MOUSEDOWN, .mouse_button = sdl_to_mousebutton(event.button.button), .mouse_position = {event.button.x, event.button.y}, }); - } break; + break; case SDL_MOUSEBUTTONUP: { int x, y; SDL_GetMouseState(&x, &y); diff --git a/src/crepe/system/InputSystem.cpp b/src/crepe/system/InputSystem.cpp index dc5efff..bb67e5f 100644 --- a/src/crepe/system/InputSystem.cpp +++ b/src/crepe/system/InputSystem.cpp @@ -12,20 +12,18 @@ void InputSystem::update() { for (const SDLContext::EventData & event : event_list) { switch (event.event_type) { - case SDLContext::EventType::KEYDOWN: { + case SDLContext::EventType::KEYDOWN: event_mgr.queue_event(KeyPressEvent{ .repeat = event.key_repeat, .key = event.key, }); break; - } - case SDLContext::EventType::KEYUP: { + case SDLContext::EventType::KEYUP: event_mgr.queue_event(KeyReleaseEvent{ .key = event.key, }); break; - } - case SDLContext::EventType::MOUSEDOWN: { + case SDLContext::EventType::MOUSEDOWN: event_mgr.queue_event(MousePressEvent{ .mouse_x = event.mouse_position.first, .mouse_y = event.mouse_position.second, @@ -34,7 +32,6 @@ void InputSystem::update() { last_mouse_down_position = event.mouse_position; last_mouse_button = event.mouse_button; break; - } case SDLContext::EventType::MOUSEUP: { event_mgr.queue_event(MouseReleaseEvent{ .mouse_x = event.mouse_position.first, @@ -56,9 +53,9 @@ void InputSystem::update() { handle_click(event); } - break; } - case SDLContext::EventType::MOUSEMOVE: { + break; + case SDLContext::EventType::MOUSEMOVE: event_mgr.queue_event(MouseMoveEvent{ .mouse_x = event.mouse_position.first, .mouse_y = event.mouse_position.second, @@ -67,19 +64,16 @@ void InputSystem::update() { }); handle_move(event); break; - } - case SDLContext::EventType::MOUSEWHEEL: { + case SDLContext::EventType::MOUSEWHEEL: event_mgr.queue_event(MouseScrollEvent{ .scroll_x = event.wheel_delta, .scroll_y = 0, .direction = event.wheel_delta, }); break; - } - case SDLContext::EventType::SHUTDOWN: { + case SDLContext::EventType::SHUTDOWN: event_mgr.queue_event(ShutDownEvent{}); break; - } default: break; } -- cgit v1.2.3