From 9958033d052db8145be8aa1d9dc197d863599db4 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Thu, 31 Oct 2024 21:40:15 +0100 Subject: [PATCH] General code cleanup --- src/sdl_window.cpp | 29 ++--------------------------- src/sdl_window.h | 1 - 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 084ea74ce..1c682e82a 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -32,7 +32,6 @@ Uint32 getMouseWheelEvent(const SDL_Event* event) { if (event->type != SDL_EVENT_MOUSE_WHEEL) return 0; - // std::cout << "We got a wheel event! "; if (event->wheel.y > 0) { return SDL_MOUSE_WHEEL_UP; } else if (event->wheel.y < 0) { @@ -145,7 +144,6 @@ std::vector delayedActions; KeyBinding::KeyBinding(const SDL_Event* event) { modifier = getCustomModState(); key = 0; - // std::cout << "Someone called the new binding ctor!\n"; if (event->type == SDL_EVENT_KEY_DOWN || event->type == SDL_EVENT_KEY_UP) { key = event->key.key; } else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN || @@ -367,29 +365,9 @@ typename std::map::const_iterator FindKeyAllowingOnlyNoModifiers( return map.end(); // Return end if no match is found } -Uint32 WindowSDL::keyRepeatCallback(void* param, Uint32 id, Uint32 interval) { - auto* data = (std::pair*)param; - KeyBinding binding(data->second); - if (data->second->type == SDL_EVENT_MOUSE_WHEEL) { - // send an off signal a frame later - auto button_it = button_map.find(binding); - auto axis_it = axis_map.find(binding); - if (button_it != button_map.end()) { - data->first->updateButton(binding, button_it->second, false); - } else if (axis_it != axis_map.end()) { - data->first->controller->Axis(0, axis_it->second.axis, Input::GetAxis(-0x80, 0x80, 0)); - } - return 0; - } - data->first->updateModKeyedInputsManually(binding); - delete data->second; - delete data; - return 0; // Return 0 to stop the timer after firing once -} - void WindowSDL::handleDelayedActions() { // Uncomment at your own terminal's risk - // std::cout << "I fear the amount of spam this line will generate\n"; + // std::cout << "I fear the amount of spam this line will generate\n"; std::this_thread::sleep_for(std::chrono::milliseconds(1)); Uint32 currentTime = SDL_GetTicks(); for (auto it = delayedActions.begin(); it != delayedActions.end();) { @@ -420,7 +398,7 @@ void WindowSDL::handleDelayedActions() { Uint32 WindowSDL::mousePolling(void* param, Uint32 id, Uint32 interval) { auto* data = (WindowSDL*)param; data->updateMouse(); - return 33; // Return 0 to stop the timer after firing once + return 33; } void WindowSDL::updateMouse() { @@ -447,7 +425,6 @@ void WindowSDL::updateMouse() { float output_speed = SDL_clamp((sqrt(d_x * d_x + d_y * d_y) + mouse_speed_offset * 128) * mouse_speed, mouse_deadzone_offset * 128, 128.0); - // std::cout << "speed: " << mouse_speed << "\n"; float angle = atan2(d_y, d_x); float a_x = cos(angle) * output_speed, a_y = sin(angle) * output_speed; @@ -599,8 +576,6 @@ void WindowSDL::updateButton(KeyBinding& binding, u32 button, bool is_pressed) { case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2: axis = (button == OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_R2) ? Input::Axis::TriggerRight : Input::Axis::TriggerLeft; - // int axis_value = is_pressed ? 255 : 0; - // int ax = Input::GetAxis(0, 0x80, is_pressed ? 255 : 0); controller->Axis(0, axis, Input::GetAxis(0, 0x80, is_pressed ? 255 : 0)); break; case OrbisPadButtonDataOffset::ORBIS_PAD_BUTTON_TOUCH_PAD: diff --git a/src/sdl_window.h b/src/sdl_window.h index 60c748c35..4f4e9b8eb 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -274,7 +274,6 @@ private: void updateModKeyedInputsManually(KBMConfig::KeyBinding& binding); void updateButton(KBMConfig::KeyBinding& binding, u32 button, bool isPressed); - static Uint32 keyRepeatCallback(void* param, Uint32 id, Uint32 interval); static Uint32 mousePolling(void* param, Uint32 id, Uint32 interval); void handleDelayedActions();