diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/joycon.cpp | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index ecb3e9dc2..d09ff178b 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/param_package.h" | 8 | #include "common/param_package.h" |
| 9 | #include "common/polyfill_thread.h" | ||
| 9 | #include "common/settings_input.h" | 10 | #include "common/settings_input.h" |
| 10 | #include "common/thread.h" | 11 | #include "common/thread.h" |
| 11 | #include "input_common/drivers/gc_adapter.h" | 12 | #include "input_common/drivers/gc_adapter.h" |
| @@ -217,8 +218,7 @@ void GCAdapter::AdapterScanThread(std::stop_token stop_token) { | |||
| 217 | Common::SetCurrentThreadName("ScanGCAdapter"); | 218 | Common::SetCurrentThreadName("ScanGCAdapter"); |
| 218 | usb_adapter_handle = nullptr; | 219 | usb_adapter_handle = nullptr; |
| 219 | pads = {}; | 220 | pads = {}; |
| 220 | while (!stop_token.stop_requested() && !Setup()) { | 221 | while (!Setup() && Common::StoppableTimedWait(stop_token, std::chrono::seconds{2})) { |
| 221 | std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
| 222 | } | 222 | } |
| 223 | } | 223 | } |
| 224 | 224 | ||
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 40cda400d..cedc94e63 100644 --- a/src/input_common/drivers/joycon.cpp +++ b/src/input_common/drivers/joycon.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/param_package.h" | 6 | #include "common/param_package.h" |
| 7 | #include "common/polyfill_ranges.h" | 7 | #include "common/polyfill_ranges.h" |
| 8 | #include "common/polyfill_thread.h" | ||
| 8 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| 9 | #include "common/thread.h" | 10 | #include "common/thread.h" |
| 10 | #include "input_common/drivers/joycon.h" | 11 | #include "input_common/drivers/joycon.h" |
| @@ -67,7 +68,8 @@ void Joycons::Setup() { | |||
| 67 | void Joycons::ScanThread(std::stop_token stop_token) { | 68 | void Joycons::ScanThread(std::stop_token stop_token) { |
| 68 | constexpr u16 nintendo_vendor_id = 0x057e; | 69 | constexpr u16 nintendo_vendor_id = 0x057e; |
| 69 | Common::SetCurrentThreadName("JoyconScanThread"); | 70 | Common::SetCurrentThreadName("JoyconScanThread"); |
| 70 | while (!stop_token.stop_requested()) { | 71 | |
| 72 | do { | ||
| 71 | SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); | 73 | SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); |
| 72 | SDL_hid_device_info* cur_dev = devs; | 74 | SDL_hid_device_info* cur_dev = devs; |
| 73 | 75 | ||
| @@ -81,8 +83,7 @@ void Joycons::ScanThread(std::stop_token stop_token) { | |||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | SDL_hid_free_enumeration(devs); | 85 | SDL_hid_free_enumeration(devs); |
| 84 | std::this_thread::sleep_for(std::chrono::seconds(5)); | 86 | } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5})); |
| 85 | } | ||
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { | 89 | bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { |