diff --git a/README.md b/README.md index c409a1e5f..c3bd5c299 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Cxbx-Reloaded is an emulator for running Microsoft Xbox (and eventually, Chihiro * [32-bit (x86) Visual C++ 2022 Redistributable](https://aka.ms/vs/17/release/vc_redist.x86.exe) * [Npcap *(used for network emulation)*](https://nmap.org/npcap/#download) * Make sure to enable winpcap compatibility mode. - * WinUSB compliant driver + * [WinUSB compliant driver](https://github.com/libusb/libusb/wiki/Windows#Driver_Installation) * *Optional, only needed for USB pass-through of original Xbox and Steel Battalion controllers.* ### Wine diff --git a/src/common/input/LibusbDevice.cpp b/src/common/input/LibusbDevice.cpp index c21b32f6c..c51961f1e 100644 --- a/src/common/input/LibusbDevice.cpp +++ b/src/common/input/LibusbDevice.cpp @@ -170,7 +170,7 @@ namespace Libusb } else { for (size_t i = 0; i < ARRAY_SIZE(SupportedDevices_VidPid); ++i) { - if ((Desc->idVendor = SupportedDevices_VidPid[i][0]) && (Desc->idProduct == SupportedDevices_VidPid[i][1])) { + if ((Desc->idVendor == SupportedDevices_VidPid[i][0]) && (Desc->idProduct == SupportedDevices_VidPid[i][1])) { m_Type = XBOX_INPUT_DEVICE::HW_XBOX_CONTROLLER; m_UcType = XINPUT_DEVTYPE_GAMEPAD; m_UcSubType = XINPUT_DEVSUBTYPE_GC_GAMEPAD; @@ -185,9 +185,18 @@ namespace Libusb if (m_Type == XBOX_INPUT_DEVICE::DEVICE_INVALID) { return; } - // Duke, S and SBC have 1 configuration, 1 interface and 2 endpoints (input and output) and use the default alternate setting zero. - // The code below assumes that third-party controllers follow suit. - if (libusb_open(Dev, &m_hDev) == 0) { + // check if we are able to open device through libusb + if (int err = libusb_open(Dev, &m_hDev)) { + // Couldn't open device, create an error log report then don't use it. + EmuLog(LOG_LEVEL::ERROR2, "Unable to open original xbox device \"%s\" (%hX:%hX), libusb's error was: %s", + m_Name.c_str(), Desc->idVendor, Desc->idProduct, libusb_strerror(err)); + m_Type = XBOX_INPUT_DEVICE::DEVICE_INVALID; + return; + } + // If we are able to open device, continue with query process. + else { + // Duke, S and SBC have 1 configuration, 1 interface and 2 endpoints (input and output) and use the default alternate setting zero. + // The code below assumes that third-party controllers follow suit. libusb_config_descriptor *ConfDesc; if (libusb_get_active_config_descriptor(Dev, &ConfDesc) == 0) { if (ConfDesc->bNumInterfaces == 1) { @@ -211,7 +220,7 @@ namespace Libusb } } EmuLog(LOG_LEVEL::INFO, "Out endpoint %s", m_HasEndpointOut ? "present" : "not present"); - if (int err = libusb_claim_interface(m_hDev, m_IfaceNum) != 0) { + if (int err = libusb_claim_interface(m_hDev, m_IfaceNum)) { EmuLog(LOG_LEVEL::INFO, "Rejected device %s because libusb could not claim its interface. The error was: %s", m_Name.c_str(), libusb_strerror(err)); m_Type = XBOX_INPUT_DEVICE::DEVICE_INVALID;