diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-10-29 16:25:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-29 16:25:02 +0100 |
commit | 40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d (patch) | |
tree | a75821894c25e0de0f466e1ca3f78400e8a8a78a /src/input_common/helpers/joycon_driver.cpp | |
parent | Merge pull request #11843 from liamwhite/sync-process (diff) | |
parent | input_common: joycon: Move vibrations to a queue (diff) | |
download | yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar.gz yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar.bz2 yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar.lz yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar.xz yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.tar.zst yuzu-40c97c0549fa5f680f47a7f9d10c536d1cb1fd0d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/input_common/helpers/joycon_driver.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp index cf51f3481..c9f903213 100644 --- a/src/input_common/helpers/joycon_driver.cpp +++ b/src/input_common/helpers/joycon_driver.cpp @@ -139,7 +139,7 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { input_thread_running = true; // Max update rate is 5ms, ensure we are always able to read a bit faster - constexpr int ThreadDelay = 2; + constexpr int ThreadDelay = 3; std::vector<u8> buffer(MaxBufferSize); while (!stop_token.stop_requested()) { @@ -163,6 +163,17 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { OnNewData(buffer); } + if (!vibration_queue.Empty()) { + VibrationValue vibration_value; + vibration_queue.Pop(vibration_value); + last_vibration_result = rumble_protocol->SendVibration(vibration_value); + } + + // We can't keep up with vibrations. Start skipping. + while (vibration_queue.Size() > 6) { + vibration_queue.Pop(); + } + std::this_thread::yield(); } @@ -402,7 +413,8 @@ Common::Input::DriverResult JoyconDriver::SetVibration(const VibrationValue& vib if (disable_input_thread) { return Common::Input::DriverResult::HandleInUse; } - return rumble_protocol->SendVibration(vibration); + vibration_queue.Push(vibration); + return last_vibration_result; } Common::Input::DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) { |