Bluetooth: show vid:pid in error message

This commit is contained in:
Tillmann Karras 2024-10-01 23:15:05 +01:00
parent 122bce08de
commit e455833ea4
2 changed files with 9 additions and 5 deletions

View File

@ -103,7 +103,8 @@ std::optional<IPCReply> BluetoothRealDevice::Open(const OpenRequest& request)
const libusb_interface& interface = config_descriptor->interface[INTERFACE]; const libusb_interface& interface = config_descriptor->interface[INTERFACE];
const libusb_interface_descriptor& descriptor = interface.altsetting[0]; const libusb_interface_descriptor& descriptor = interface.altsetting[0];
if (IsBluetoothDevice(descriptor) && IsWantedDevice(device_descriptor) && OpenDevice(device)) if (IsBluetoothDevice(descriptor) && IsWantedDevice(device_descriptor) &&
OpenDevice(device_descriptor, device))
{ {
unsigned char manufacturer[50] = {}, product[50] = {}, serial_number[50] = {}; unsigned char manufacturer[50] = {}, product[50] = {}, serial_number[50] = {};
const int manufacturer_ret = libusb_get_string_descriptor_ascii( const int manufacturer_ret = libusb_get_string_descriptor_ascii(
@ -637,14 +638,16 @@ void BluetoothRealDevice::SaveLinkKeys()
Config::SetBase(Config::MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS, config_string); Config::SetBase(Config::MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS, config_string);
} }
bool BluetoothRealDevice::OpenDevice(libusb_device* device) bool BluetoothRealDevice::OpenDevice(const libusb_device_descriptor& device_descriptor,
libusb_device* device)
{ {
m_device = libusb_ref_device(device); m_device = libusb_ref_device(device);
const int ret = libusb_open(m_device, &m_handle); const int ret = libusb_open(m_device, &m_handle);
if (ret != LIBUSB_SUCCESS) if (ret != LIBUSB_SUCCESS)
{ {
m_last_open_error = m_last_open_error = Common::FmtFormatT("Failed to open Bluetooth device {:04x}:{:04x}: {}",
Common::FmtFormatT("Failed to open Bluetooth device: {0}", LibusbUtils::ErrorWrap(ret)); device_descriptor.idVendor, device_descriptor.idProduct,
LibusbUtils::ErrorWrap(ret));
return false; return false;
} }

View File

@ -23,6 +23,7 @@
class PointerWrap; class PointerWrap;
struct libusb_device; struct libusb_device;
struct libusb_device_handle; struct libusb_device_handle;
struct libusb_device_descriptor;
struct libusb_transfer; struct libusb_transfer;
namespace IOS::HLE namespace IOS::HLE
@ -116,7 +117,7 @@ private:
void LoadLinkKeys(); void LoadLinkKeys();
void SaveLinkKeys(); void SaveLinkKeys();
bool OpenDevice(libusb_device* device); bool OpenDevice(const libusb_device_descriptor& device_descriptor, libusb_device* device);
}; };
} // namespace IOS::HLE } // namespace IOS::HLE