HW: Fix libusb support for older libusb APIs

This commit is contained in:
Jeffrey Pfau 2016-01-03 00:53:31 -08:00
parent f0e5811d9a
commit d4e2c9fa98
2 changed files with 9 additions and 1 deletions

View File

@ -23,7 +23,7 @@ elseif (NOT LIBUSB_FOUND)
/usr/local/include
)
find_library(LIBUSB_LIBRARIES NAMES usb-1.0
find_library(LIBUSB_LIBRARIES NAMES usb-1.0 usb
PATHS
${LIBUSB_PKG_LIBRARY_DIRS}
/usr/lib

View File

@ -50,7 +50,9 @@ static std::function<void(void)> s_detect_callback;
static bool s_libusb_driver_not_supported = false;
static libusb_context* s_libusb_context = nullptr;
static bool s_libusb_hotplug_enabled = false;
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
static libusb_hotplug_callback_handle s_hotplug_handle;
#endif
static u8 s_endpoint_in = 0;
static u8 s_endpoint_out = 0;
@ -72,6 +74,7 @@ static void Read()
}
}
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
static int HotplugCallback(libusb_context* ctx, libusb_device* dev, libusb_hotplug_event event, void* user_data)
{
if (event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED)
@ -86,12 +89,14 @@ static int HotplugCallback(libusb_context* ctx, libusb_device* dev, libusb_hotpl
}
return 0;
}
#endif
static void ScanThreadFunc()
{
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
NOTICE_LOG(SERIALINTERFACE, "GC Adapter scanning thread started");
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
s_libusb_hotplug_enabled = libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG) != 0;
if (s_libusb_hotplug_enabled)
{
@ -100,6 +105,7 @@ static void ScanThreadFunc()
if (s_libusb_hotplug_enabled)
NOTICE_LOG(SERIALINTERFACE, "Using libUSB hotplug detection");
}
#endif
while (s_adapter_detect_thread_running.IsSet())
{
@ -302,8 +308,10 @@ static void AddGCAdapter(libusb_device* device)
void Shutdown()
{
StopScanThread();
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
if (s_libusb_hotplug_enabled)
libusb_hotplug_deregister_callback(s_libusb_context, s_hotplug_handle);
#endif
Reset();
if (s_libusb_context)