diff options
Diffstat (limited to 'src/input_common/helpers/joycon_driver.cpp')
| -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) { | |||
| 139 | input_thread_running = true; | 139 | input_thread_running = true; |
| 140 | 140 | ||
| 141 | // Max update rate is 5ms, ensure we are always able to read a bit faster | 141 | // Max update rate is 5ms, ensure we are always able to read a bit faster |
| 142 | constexpr int ThreadDelay = 2; | 142 | constexpr int ThreadDelay = 3; |
| 143 | std::vector<u8> buffer(MaxBufferSize); | 143 | std::vector<u8> buffer(MaxBufferSize); |
| 144 | 144 | ||
| 145 | while (!stop_token.stop_requested()) { | 145 | while (!stop_token.stop_requested()) { |
| @@ -163,6 +163,17 @@ void JoyconDriver::InputThread(std::stop_token stop_token) { | |||
| 163 | OnNewData(buffer); | 163 | OnNewData(buffer); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | if (!vibration_queue.Empty()) { | ||
| 167 | VibrationValue vibration_value; | ||
| 168 | vibration_queue.Pop(vibration_value); | ||
| 169 | last_vibration_result = rumble_protocol->SendVibration(vibration_value); | ||
| 170 | } | ||
| 171 | |||
| 172 | // We can't keep up with vibrations. Start skipping. | ||
| 173 | while (vibration_queue.Size() > 6) { | ||
| 174 | vibration_queue.Pop(); | ||
| 175 | } | ||
| 176 | |||
| 166 | std::this_thread::yield(); | 177 | std::this_thread::yield(); |
| 167 | } | 178 | } |
| 168 | 179 | ||
| @@ -402,7 +413,8 @@ Common::Input::DriverResult JoyconDriver::SetVibration(const VibrationValue& vib | |||
| 402 | if (disable_input_thread) { | 413 | if (disable_input_thread) { |
| 403 | return Common::Input::DriverResult::HandleInUse; | 414 | return Common::Input::DriverResult::HandleInUse; |
| 404 | } | 415 | } |
| 405 | return rumble_protocol->SendVibration(vibration); | 416 | vibration_queue.Push(vibration); |
| 417 | return last_vibration_result; | ||
| 406 | } | 418 | } |
| 407 | 419 | ||
| 408 | Common::Input::DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) { | 420 | Common::Input::DriverResult JoyconDriver::SetLedConfig(u8 led_pattern) { |