diff options
Diffstat (limited to '')
-rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 4 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.cpp | 11 | ||||
-rw-r--r-- | src/input_common/drivers/joycon.h | 2 |
3 files changed, 8 insertions, 9 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 @@ #include "common/logging/log.h" #include "common/param_package.h" +#include "common/polyfill_thread.h" #include "common/settings_input.h" #include "common/thread.h" #include "input_common/drivers/gc_adapter.h" @@ -217,8 +218,7 @@ void GCAdapter::AdapterScanThread(std::stop_token stop_token) { Common::SetCurrentThreadName("ScanGCAdapter"); usb_adapter_handle = nullptr; pads = {}; - while (!stop_token.stop_requested() && !Setup()) { - std::this_thread::sleep_for(std::chrono::seconds(2)); + while (!Setup() && Common::StoppableTimedWait(stop_token, std::chrono::seconds{2})) { } } diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp index 40cda400d..4fcfb4510 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 { @@ -667,12 +668,10 @@ std::string Joycons::JoyconName(Joycon::ControllerType type) const { return "Right Joycon"; case Joycon::ControllerType::Pro: return "Pro Controller"; - case Joycon::ControllerType::Grip: - return "Grip Controller"; case Joycon::ControllerType::Dual: return "Dual Joycon"; default: - return "Unknown Joycon"; + return "Unknown Switch Controller"; } } } // namespace InputCommon diff --git a/src/input_common/drivers/joycon.h b/src/input_common/drivers/joycon.h index 316d383d8..2149ab7fd 100644 --- a/src/input_common/drivers/joycon.h +++ b/src/input_common/drivers/joycon.h @@ -15,7 +15,7 @@ using SerialNumber = std::array<u8, 15>; struct Battery; struct Color; struct MotionData; -enum class ControllerType; +enum class ControllerType : u8; enum class DriverResult; enum class IrsResolution; class JoyconDriver; |