mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
HW: Fix libusb support for older libusb APIs
This commit is contained in:
parent
f0e5811d9a
commit
d4e2c9fa98
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user