Browse Source

[input_common/mouse, sdl_driver] increase latency of mouse and SDL_vibration threads to 4 "evals" per sec (#2982)

No need to have those nano-sleeps for these threads...

Signed-off-by: lizzie lizzie@eden-emu.dev

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2982
Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
vk-fix-oom-force-maller-buffers
lizzie 3 weeks ago
committed by crueter
parent
commit
0eed5100f9
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 10
      src/input_common/drivers/mouse.cpp
  2. 5
      src/input_common/drivers/mouse.h
  3. 2
      src/input_common/drivers/sdl_driver.cpp

10
src/input_common/drivers/mouse.cpp

@ -14,7 +14,7 @@
#include "input_common/drivers/mouse.h" #include "input_common/drivers/mouse.h"
namespace InputCommon { namespace InputCommon {
constexpr int update_time = 10;
constexpr int update_time = 250; // 4 TPS
constexpr float default_panning_sensitivity = 0.0010f; constexpr float default_panning_sensitivity = 0.0010f;
constexpr float default_stick_sensitivity = 0.0006f; constexpr float default_stick_sensitivity = 0.0006f;
constexpr float default_deadzone_counterweight = 0.01f; 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_mouse_change = {};
last_motion_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) {
update_thread = std::jthread([this](std::stop_token stop_token) {
Common::SetCurrentThreadName("Mouse"); Common::SetCurrentThreadName("Mouse");
while (!stop_token.stop_requested()) { while (!stop_token.stop_requested()) {
UpdateStickInput(); UpdateStickInput();
UpdateMotionInput(); UpdateMotionInput();
std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); std::this_thread::sleep_for(std::chrono::milliseconds(update_time));
} }
});
} }
void Mouse::UpdateStickInput() { void Mouse::UpdateStickInput() {

5
src/input_common/drivers/mouse.h

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
@ -95,10 +98,8 @@ public:
Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override; Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override;
private: private:
void UpdateThread(std::stop_token stop_token);
void UpdateStickInput(); void UpdateStickInput();
void UpdateMotionInput(); void UpdateMotionInput();
bool IsMousePanningEnabled(); bool IsMousePanningEnabled();
Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const;

2
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; using namespace std::chrono_literals;
while (initialized) { while (initialized) {
SendVibrations(); SendVibrations();
std::this_thread::sleep_for(10ms);
std::this_thread::sleep_for(250ms); // 4 TPS
} }
}); });
} }

Loading…
Cancel
Save