summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 5c20b3426..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);
}
}
@@ -748,7 +763,7 @@ ButtonMapping SDLDriver::GetButtonMappingForDevice(const Common::ParamPackage& p
// This list is missing ZL/ZR since those are not considered buttons in SDL GameController.
// We will add those afterwards
- // This list also excludes Screenshot since theres not really a mapping for that
+ // This list also excludes Screenshot since there's not really a mapping for that
ButtonBindings switch_to_sdl_button;
if (SDL_GameControllerGetType(controller) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) {
@@ -1007,7 +1022,7 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p
Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const {
if (params.Has("button")) {
- // TODO(German77): Find how to substitue the values for real button names
+ // TODO(German77): Find how to substitute the values for real button names
return Common::Input::ButtonNames::Value;
}
if (params.Has("hat")) {