diff options
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 21 |
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) { | |||
| 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 | ||
| @@ -748,7 +763,7 @@ ButtonMapping SDLDriver::GetButtonMappingForDevice(const Common::ParamPackage& p | |||
| 748 | 763 | ||
| 749 | // This list is missing ZL/ZR since those are not considered buttons in SDL GameController. | 764 | // This list is missing ZL/ZR since those are not considered buttons in SDL GameController. |
| 750 | // We will add those afterwards | 765 | // We will add those afterwards |
| 751 | // This list also excludes Screenshot since theres not really a mapping for that | 766 | // This list also excludes Screenshot since there's not really a mapping for that |
| 752 | ButtonBindings switch_to_sdl_button; | 767 | ButtonBindings switch_to_sdl_button; |
| 753 | 768 | ||
| 754 | if (SDL_GameControllerGetType(controller) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) { | 769 | if (SDL_GameControllerGetType(controller) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) { |
| @@ -1007,7 +1022,7 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p | |||
| 1007 | 1022 | ||
| 1008 | Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const { | 1023 | Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const { |
| 1009 | if (params.Has("button")) { | 1024 | if (params.Has("button")) { |
| 1010 | // TODO(German77): Find how to substitue the values for real button names | 1025 | // TODO(German77): Find how to substitute the values for real button names |
| 1011 | return Common::Input::ButtonNames::Value; | 1026 | return Common::Input::ButtonNames::Value; |
| 1012 | } | 1027 | } |
| 1013 | if (params.Has("hat")) { | 1028 | if (params.Has("hat")) { |