Disable Bluetooth descriptor check if adapter is forced

Some adapters don't have the correct interface class, so they are not
recognised as Bluetooth adapters. It seems that apart from hardcoding
VIDs/PIDs (which is how it's done in the Linux kernel, and which I'm
not very fond of), there is no other way to detect if a device is a
Bluetooth adapter or not.

This change makes Dolphin skip the descriptor check when trying to find
a usable adapter for Bluetooth Passthrough if the use of a specific
adapter was forced; it is assumed that the user knows what they are
doing if they hand-edited their config file.

This allows such adapters to be used.
This commit is contained in:
Léo Lam 2016-10-24 22:15:41 +02:00
parent 476cf3803d
commit e89ca79059
2 changed files with 14 additions and 7 deletions

View File

@ -36,7 +36,7 @@ static void EnqueueReply(const u32 command_address)
WII_IPC_HLE_Interface::EnqueueReply(command_address, 0, CoreTiming::FromThread::ANY);
}
static bool IsWantedDevice(libusb_device_descriptor& descriptor)
static bool IsWantedDevice(const libusb_device_descriptor& descriptor)
{
const int vid = SConfig::GetInstance().m_bt_passthrough_vid;
const int pid = SConfig::GetInstance().m_bt_passthrough_pid;
@ -45,6 +45,18 @@ static bool IsWantedDevice(libusb_device_descriptor& descriptor)
return descriptor.idVendor == vid && descriptor.idProduct == pid;
}
static bool IsBluetoothDevice(const libusb_interface_descriptor& descriptor)
{
constexpr u8 SUBCLASS = 0x01;
constexpr u8 PROTOCOL_BLUETOOTH = 0x01;
if (SConfig::GetInstance().m_bt_passthrough_vid != -1 &&
SConfig::GetInstance().m_bt_passthrough_pid != -1)
return true;
return descriptor.bInterfaceClass == LIBUSB_CLASS_WIRELESS &&
descriptor.bInterfaceSubClass == SUBCLASS &&
descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH;
}
CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CWII_IPC_HLE_Device_usb_oh1_57e_305_real(
u32 device_id, const std::string& device_name)
: CWII_IPC_HLE_Device_usb_oh1_57e_305_base(device_id, device_name)
@ -94,10 +106,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(u32 command_addr
const libusb_interface& interface = config_descriptor->interface[INTERFACE];
const libusb_interface_descriptor& descriptor = interface.altsetting[0];
if (descriptor.bInterfaceClass == LIBUSB_CLASS_WIRELESS &&
descriptor.bInterfaceSubClass == SUBCLASS &&
descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH && IsWantedDevice(device_descriptor) &&
OpenDevice(device))
if (IsBluetoothDevice(descriptor) && IsWantedDevice(device_descriptor) && OpenDevice(device))
{
unsigned char manufacturer[50] = {}, product[50] = {}, serial_number[50] = {};
libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iManufacturer, manufacturer,

View File

@ -50,8 +50,6 @@ public:
private:
static constexpr u8 INTERFACE = 0x00;
static constexpr u8 SUBCLASS = 0x01;
static constexpr u8 PROTOCOL_BLUETOOTH = 0x01;
// Arbitrarily chosen value that allows emulated software to send commands often enough
// so that the sync button event is triggered at least every 200ms.
// Ideally this should be equal to 0, so we don't trigger unnecessary libusb transfers.