diff options
| author | 2022-05-23 11:33:34 -0500 | |
|---|---|---|
| committer | 2022-05-23 12:25:02 -0500 | |
| 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.gz yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.xz yuzu-bf948b57903a55b562287347129ec718154b5f82.zip | |
input_common: Make vibration request async
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -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 | |||
| 434 | using namespace std::chrono_literals; | 434 | using namespace std::chrono_literals; |
| 435 | while (initialized) { | 435 | while (initialized) { |
| 436 | SDL_PumpEvents(); | 436 | SDL_PumpEvents(); |
| 437 | SendVibrations(); | ||
| 437 | std::this_thread::sleep_for(1ms); | 438 | std::this_thread::sleep_for(1ms); |
| 438 | } | 439 | } |
| 439 | }); | 440 | }); |
| @@ -531,13 +532,31 @@ Common::Input::VibrationError SDLDriver::SetRumble( | |||
| 531 | .type = Common::Input::VibrationAmplificationType::Exponential, | 532 | .type = Common::Input::VibrationAmplificationType::Exponential, |
| 532 | }; | 533 | }; |
| 533 | 534 | ||
| 534 | if (!joystick->RumblePlay(new_vibration)) { | 535 | if (vibration.type == Common::Input::VibrationAmplificationType::Test) { |
| 535 | return Common::Input::VibrationError::Unknown; | 536 | if (!joystick->RumblePlay(new_vibration)) { |
| 537 | return Common::Input::VibrationError::Unknown; | ||
| 538 | } | ||
| 539 | return Common::Input::VibrationError::None; | ||
| 536 | } | 540 | } |
| 537 | 541 | ||
| 542 | vibration_queue.Push(VibrationRequest{ | ||
| 543 | .identifier = identifier, | ||
| 544 | .vibration = new_vibration, | ||
| 545 | }); | ||
| 546 | |||
| 538 | return Common::Input::VibrationError::None; | 547 | return Common::Input::VibrationError::None; |
| 539 | } | 548 | } |
| 540 | 549 | ||
| 550 | void SDLDriver::SendVibrations() { | ||
| 551 | while (!vibration_queue.Empty()) { | ||
| 552 | VibrationRequest request; | ||
| 553 | vibration_queue.Pop(request); | ||
| 554 | const auto joystick = GetSDLJoystickByGUID(request.identifier.guid.RawString(), | ||
| 555 | static_cast<int>(request.identifier.port)); | ||
| 556 | joystick->RumblePlay(request.vibration); | ||
| 557 | } | ||
| 558 | } | ||
| 559 | |||
| 541 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 560 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |
| 542 | s32 axis, float value) const { | 561 | s32 axis, float value) const { |
| 543 | Common::ParamPackage params{}; | 562 | Common::ParamPackage params{}; |