diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-03-13 18:45:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-13 18:45:40 +0100 |
commit | 8870fae674b891b4cfeef71386ba17dd7c6ebad5 (patch) | |
tree | b8c8d557439e0b397dc7a888ee67b65b8c5d9e56 /src | |
parent | Merge pull request #9941 from german77/settings (diff) | |
parent | input_common: sdl: Only send last vibration command (diff) | |
download | yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar.gz yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar.bz2 yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar.lz yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar.xz yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.tar.zst yuzu-8870fae674b891b4cfeef71386ba17dd7c6ebad5.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index f7f0c7eaa..7f9e8dbb9 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -652,12 +652,27 @@ bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) { } 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)); - joystick->RumblePlay(request.vibration); + 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); } } |