From 09b6a143948eeb6f994285a2d65c044464280460 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 8 Nov 2025 07:28:30 +0000 Subject: [PATCH] [input_common/mouse, sdl_driver] increase latency of mouse and SDL_vibration threads to 4 "evals" per sec --- src/input_common/drivers/mouse.cpp | 22 +++++++++------------- src/input_common/drivers/mouse.h | 2 -- src/input_common/drivers/sdl_driver.cpp | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 0949e1e2ad..424e716850 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp @@ -14,7 +14,7 @@ #include "input_common/drivers/mouse.h" namespace InputCommon { -constexpr int update_time = 10; +constexpr int update_time = 250; // 4 TPS constexpr float default_panning_sensitivity = 0.0010f; constexpr float default_stick_sensitivity = 0.0006f; constexpr float default_deadzone_counterweight = 0.01f; @@ -73,18 +73,14 @@ Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) last_mouse_change = {}; last_motion_change = {}; - update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); -} - -void Mouse::UpdateThread(std::stop_token stop_token) { - Common::SetCurrentThreadName("Mouse"); - - while (!stop_token.stop_requested()) { - UpdateStickInput(); - UpdateMotionInput(); - - std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); - } + update_thread = std::jthread([this](std::stop_token stop_token) { + Common::SetCurrentThreadName("Mouse"); + while (!stop_token.stop_requested()) { + UpdateStickInput(); + UpdateMotionInput(); + std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); + } + }); } void Mouse::UpdateStickInput() { diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 124b6f3bd5..ab6d1dcb38 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h @@ -95,10 +95,8 @@ public: Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override; private: - void UpdateThread(std::stop_token stop_token); void UpdateStickInput(); void UpdateMotionInput(); - bool IsMousePanningEnabled(); Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 972abec9fe..b527668052 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -548,7 +548,7 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en using namespace std::chrono_literals; while (initialized) { SendVibrations(); - std::this_thread::sleep_for(10ms); + std::this_thread::sleep_for(250ms); // 4 TPS } }); }