GCAdapter: Compare with LIBUSB_SUCCESS instead of 0

This commit is contained in:
Pokechu22 2022-06-08 15:27:55 -07:00
parent 83afaba785
commit 27772e01d9
1 changed files with 4 additions and 3 deletions

View File

@ -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<int> 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));