summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2023-03-11 19:20:55 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-03-13 04:30:02 +0100
commit96b8a3ecac209b5b66e099c7f7301fc2fb956f20 (patch)
tree2864f36c879dca6b3cb1fdae8f2f01a03a9d7e32 /src/input_common
parentMerge pull request #9942 from liamwhite/speling (diff)
downloadyuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.gz
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.bz2
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.lz
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.xz
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.tar.zst
yuzu-96b8a3ecac209b5b66e099c7f7301fc2fb956f20.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp17
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);
}
}