Skip to content
Permalink
Browse files

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.
  • Loading branch information...
VinDuv committed Jul 25, 2018
1 parent 2ac1ca1 commit 9e7d4d2abbe62e2d4d6578e883effff18fed44c4
Showing with 9 additions and 2 deletions.
  1. +9 −2 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)

0 comments on commit 9e7d4d2

Please sign in to comment.
You can’t perform that action at this time.