From d4e2c9fa98edf82380033b4192e511c634e5fc0c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 3 Jan 2016 00:53:31 -0800 Subject: [PATCH] HW: Fix libusb support for older libusb APIs --- CMakeTests/FindLibUSB.cmake | 2 +- Source/Core/Core/HW/SI_GCAdapter.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeTests/FindLibUSB.cmake b/CMakeTests/FindLibUSB.cmake index b829eef66b..dec0b98b07 100644 --- a/CMakeTests/FindLibUSB.cmake +++ b/CMakeTests/FindLibUSB.cmake @@ -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 diff --git a/Source/Core/Core/HW/SI_GCAdapter.cpp b/Source/Core/Core/HW/SI_GCAdapter.cpp index 655b9965e0..b6b12bcfdb 100644 --- a/Source/Core/Core/HW/SI_GCAdapter.cpp +++ b/Source/Core/Core/HW/SI_GCAdapter.cpp @@ -50,7 +50,9 @@ static std::function 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)