aboutsummaryrefslogtreecommitdiff
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2026-10-14 21:24:35 +0200
committercrueter <crueter@eden-emu.dev>2026-10-14 21:24:35 +0200
commitfb51a1253447a2655382d3cf952c4c470a1d96c6 (patch)
treee2abe08e4e40ada75df0b2322612b9732b6f9153 /src/input_common/drivers/sdl_driver.cpp
parenta594c8d60ef79280adc046760561912207e16e17 (diff)
[input/sdl] nuke SDL_Vibration thread (#4299)
Signed-off-by: lizzie <lizzie@eden-emu.dev> - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- isn't it net faster to just...send things, serially? especially since vibration occurs so non-often... i dont think it would cause any issues TEST: if this causes ANY sort of perf regression on games when the thing vibrates WITH AN SDL CONFIGURED GAMEPAD OR WHATEVER Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4299 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp41
1 files changed, 1 insertions, 40 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 91589063b5..c3e9a066b3 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -697,16 +697,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
SDL_AddEventWatch(&SDLEventWatcher, this);
initialized = true;
- if (start_thread) {
- vibration_thread = std::thread([this] {
- Common::SetCurrentThreadName("SDL_Vibration");
- using namespace std::chrono_literals;
- while (initialized) {
- SendVibrations();
- std::this_thread::sleep_for(250ms); // 4 TPS
- }
- });
- }
// Because the events for joystick connection happens before we have our event watcher added, we
// can just open all the joysticks right here
int joystick_count = 0;
@@ -725,7 +715,6 @@ SDLDriver::~SDLDriver() {
initialized = false;
if (start_thread) {
- vibration_thread.join();
SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD);
}
}
@@ -805,10 +794,7 @@ Common::Input::DriverResult SDLDriver::SetVibration(
.type = Common::Input::VibrationAmplificationType::Exponential,
};
- vibration_queue.Push(VibrationRequest{
- .identifier = identifier,
- .vibration = new_vibration,
- });
+ joystick->RumblePlay(new_vibration);
return Common::Input::DriverResult::Success;
}
@@ -852,31 +838,6 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {
return true;
}
-void SDLDriver::SendVibrations() {
- std::vector<VibrationRequest> filtered_vibrations{};
- while (!vibration_queue.Empty()) {
- VibrationRequest request;
- vibration_queue.Pop(request);
- const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(),
- static_cast<int>(request.identifier.port));
- const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(),
- [request](VibrationRequest vibration) {
- return vibration.identifier == request.identifier;
- });
- if (it == filtered_vibrations.end()) {
- filtered_vibrations.push_back(std::move(request));
- continue;
- }
- *it = request;
- }
-
- for (const auto& vibration : filtered_vibrations) {
- const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(),
- static_cast<int>(vibration.identifier.port));
- joystick->RumblePlay(vibration.vibration);
- }
-}
-
Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, const Common::UUID& guid,
s32 axis, float value) const {
Common::ParamPackage params{};