diff options
| author | bunnei <bunneidev@gmail.com> | 2023-01-27 18:28:03 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-27 18:28:03 -0800 |
| commit | 5a53999a741d5b6a7af677f00f433beabdf9d80c (patch) | |
| tree | cdd5d8f93e9f79f5e8e38515f178520c07a27f3b /src/input_common/drivers/joycon.cpp | |
| parent | f81bd5bc15d7cf6ce2676d41f42b24e9e07ce3f1 (diff) | |
| parent | 8be6571a3896ae8fd838566022c40dce3e0ea5a8 (diff) | |
Merge pull request #9677 from Morph1984/sleep-one
polyfill_thread: Implement StoppableTimedWait
Diffstat (limited to 'src/input_common/drivers/joycon.cpp')
| -rw-r--r-- | src/input_common/drivers/joycon.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 40cda400d8..cedc94e639 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp @@ -5,6 +5,7 @@ #include "common/param_package.h" #include "common/polyfill_ranges.h" +#include "common/polyfill_thread.h" #include "common/settings.h" #include "common/thread.h" #include "input_common/drivers/joycon.h" @@ -67,7 +68,8 @@ void Joycons::Setup() { void Joycons::ScanThread(std::stop_token stop_token) { constexpr u16 nintendo_vendor_id = 0x057e; Common::SetCurrentThreadName("JoyconScanThread"); - while (!stop_token.stop_requested()) { + + do { SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); SDL_hid_device_info* cur_dev = devs; @@ -81,8 +83,7 @@ void Joycons::ScanThread(std::stop_token stop_token) { } SDL_hid_free_enumeration(devs); - std::this_thread::sleep_for(std::chrono::seconds(5)); - } + } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5})); } bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { |
