diff options
| author | 2023-03-11 12:20:55 -0600 | |
|---|---|---|
| committer | 2023-03-12 21:30:02 -0600 | |
| commit | 96b8a3ecac209b5b66e099c7f7301fc2fb956f20 (patch) | |
| tree | 2864f36c879dca6b3cb1fdae8f2f01a03a9d7e32 /src/input_common | |
| parent | Merge pull request #9942 from liamwhite/speling (diff) | |
| download | yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.gz yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.xz yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.zip | |
input_common: sdl: Only send last vibration command
Diffstat (limited to 'src/input_common')
| -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) { | |||
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | void SDLDriver::SendVibrations() { | 654 | void SDLDriver::SendVibrations() { |
| 655 | std::vector<VibrationRequest> filtered_vibrations{}; | ||
| 655 | while (!vibration_queue.Empty()) { | 656 | while (!vibration_queue.Empty()) { |
| 656 | VibrationRequest request; | 657 | VibrationRequest request; |
| 657 | vibration_queue.Pop(request); | 658 | vibration_queue.Pop(request); |
| 658 | const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(), | 659 | const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(), |
| 659 | static_cast<int>(request.identifier.port)); | 660 | static_cast<int>(request.identifier.port)); |
| 660 | joystick->RumblePlay(request.vibration); | 661 | const auto it = std::find_if(filtered_vibrations.begin(), filtered_vibrations.end(), |
| 662 | [request](VibrationRequest vibration) { | ||
| 663 | return vibration.identifier == request.identifier; | ||
| 664 | }); | ||
| 665 | if (it == filtered_vibrations.end()) { | ||
| 666 | filtered_vibrations.push_back(std::move(request)); | ||
| 667 | continue; | ||
| 668 | } | ||
| 669 | *it = request; | ||
| 670 | } | ||
| 671 | |||
| 672 | for (const auto& vibration : filtered_vibrations) { | ||
| 673 | const auto joystick = GetSDLJoystickByGUID(vibration.identifier.guid.RawString(), | ||
| 674 | static_cast<int>(vibration.identifier.port)); | ||
| 675 | joystick->RumblePlay(vibration.vibration); | ||
| 661 | } | 676 | } |
| 662 | } | 677 | } |
| 663 | 678 | ||