diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-05-23 18:33:34 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2022-05-23 19:25:02 +0200 |
commit | bf948b57903a55b562287347129ec718154b5f82 (patch) | |
tree | 452677f5ec79e8dcef0a9c6f12c8fb928b5bfa0c /src/input_common/drivers/sdl_driver.cpp | |
parent | Merge pull request #8342 from lat9nq/clang-latest-stdc++ (diff) | |
download | yuzu-bf948b57903a55b562287347129ec718154b5f82.tar yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.gz yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.bz2 yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.lz yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.xz yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.zst yuzu-bf948b57903a55b562287347129ec718154b5f82.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index a5c63e74a..1a14ef10b 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -434,6 +434,7 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en using namespace std::chrono_literals; while (initialized) { SDL_PumpEvents(); + SendVibrations(); std::this_thread::sleep_for(1ms); } }); @@ -531,13 +532,31 @@ Common::Input::VibrationError SDLDriver::SetRumble( .type = Common::Input::VibrationAmplificationType::Exponential, }; - if (!joystick->RumblePlay(new_vibration)) { - return Common::Input::VibrationError::Unknown; + if (vibration.type == Common::Input::VibrationAmplificationType::Test) { + if (!joystick->RumblePlay(new_vibration)) { + return Common::Input::VibrationError::Unknown; + } + return Common::Input::VibrationError::None; } + vibration_queue.Push(VibrationRequest{ + .identifier = identifier, + .vibration = new_vibration, + }); + return Common::Input::VibrationError::None; } +void SDLDriver::SendVibrations() { + 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); + } +} + Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, s32 axis, float value) const { Common::ParamPackage params{}; |