Merge pull request #4385 from leoetlino/disable-bt-check

Disable descriptor check for BT passthrough in some cases
This commit is contained in:
Markus Wick 2016-11-04 14:38:19 +01:00 committed by GitHub
commit 234691abf7
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.