From 27772e01d9e263e172daf7adb379621b0499fcf9 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 8 Jun 2022 15:27:55 -0700 Subject: [PATCH] GCAdapter: Compare with LIBUSB_SUCCESS instead of 0 --- Source/Core/InputCommon/GCAdapter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/GCAdapter.cpp b/Source/Core/InputCommon/GCAdapter.cpp index 993e032bf3..345559c7ac 100644 --- a/Source/Core/InputCommon/GCAdapter.cpp +++ b/Source/Core/InputCommon/GCAdapter.cpp @@ -71,7 +71,7 @@ enum ADAPTER_DETECTED = 1, }; -// Current adapter status: detected/not detected/in error (holds the error code) +// Current adapter status: detected/not detected/in error (libusb error codes are negative) static std::atomic s_status = NO_ADAPTER_DETECTED; static libusb_device_handle* s_handle = nullptr; #elif GCADAPTER_USE_ANDROID_IMPLEMENTATION @@ -539,7 +539,8 @@ static bool CheckDeviceAccess(libusb_device* device) // We assume user is using GCAdapterDriver and therefor don't want to detach anything #if !defined(__APPLE__) ret = libusb_detach_kernel_driver(s_handle, 0); - detach_failed = ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND && ret != LIBUSB_ERROR_NOT_SUPPORTED; + detach_failed = + ret < LIBUSB_SUCCESS && ret != LIBUSB_ERROR_NOT_FOUND && ret != LIBUSB_ERROR_NOT_SUPPORTED; #endif if (detach_failed) { @@ -557,7 +558,7 @@ static bool CheckDeviceAccess(libusb_device* device) // This call makes Nyko-brand (and perhaps other) adapters work. // However it returns LIBUSB_ERROR_PIPE with Mayflash adapters. const int transfer = libusb_control_transfer(s_handle, 0x21, 11, 0x0001, 0, nullptr, 0, 1000); - if (transfer < 0) + if (transfer < LIBUSB_SUCCESS) { WARN_LOG_FMT(CONTROLLERINTERFACE, "libusb_control_transfer failed: {}", LibusbUtils::ErrorWrap(transfer));