diff options
| author | Vincent Duvert <vincent@duvert.net> | 2018-07-25 21:44:57 +0200 |
|---|---|---|
| committer | Vincent Duvert <vincent@duvert.net> | 2019-05-29 18:28:24 +0200 |
| commit | 9e7d4d2abbe62e2d4d6578e883effff18fed44c4 (patch) | |
| tree | f658ecf355b8d967d3248c26d28fb3434e284d88 /Source/Core/InputCommon/GCAdapter.cpp | |
| parent | 2ac1ca133fac669e876e80d4b31202bcc2826d71 (diff) | |
GCAdapter: Handle dynamic status updates for non-hotplug libusb
Detect when the setup function found no adapter, or found one but could
not connect to it, and report the new status in that case.
Diffstat (limited to 'Source/Core/InputCommon/GCAdapter.cpp')
| -rw-r--r-- | Source/Core/InputCommon/GCAdapter.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index a4a4cee5cf..2d990a213c 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -177,8 +177,6 @@ static void ScanThreadFunc() { std::lock_guard<std::mutex> lk(s_init_mutex); Setup(); - if (s_status == ADAPTER_DETECTED && s_detect_callback != nullptr) - s_detect_callback(); } Common::SleepCurrentThread(500); } @@ -229,6 +227,12 @@ void StopScanThread() static void Setup() { + int prev_status = s_status; + + // Reset the error status in case the adapter gets unplugged + if (s_status < 0) + s_status = NO_ADAPTER_DETECTED; + for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; i++) { s_controller_type[i] = ControllerTypes::CONTROLLER_NONE; @@ -244,6 +248,9 @@ static void Setup() } return true; }); + + if (s_status != ADAPTER_DETECTED && prev_status != s_status && s_detect_callback != nullptr) + s_detect_callback(); } static bool CheckDeviceAccess(libusb_device* device) |
