Skip to content

Commit

Permalink
Merge pull request dolphin-emu#7216 from leoetlino/test
Browse files Browse the repository at this point in the history
Fix BT passthrough by sending larger packets
  • Loading branch information
Tilka authored Oct 14, 2018
2 parents 34f50d3 + 5a289de commit 64515d0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,17 @@ void BluetoothReal::WaitForHCICommandComplete(const u16 opcode)
{
int actual_length;
SHCIEventCommand packet;
std::vector<u8> buffer(1024);
// Only try 100 transfers at most, to avoid being stuck in an infinite loop
for (int tries = 0; tries < 100; ++tries)
{
const int ret = libusb_interrupt_transfer(m_handle, HCI_EVENT, reinterpret_cast<u8*>(&packet),
sizeof(packet), &actual_length, 20);
if (ret == 0 && actual_length == sizeof(packet) &&
packet.EventType == HCI_EVENT_COMMAND_COMPL && packet.Opcode == opcode)
{
const int ret = libusb_interrupt_transfer(m_handle, HCI_EVENT, buffer.data(),
static_cast<int>(buffer.size()), &actual_length, 20);
if (ret != 0 || actual_length < sizeof(packet))
continue;
std::memcpy(&packet, buffer.data(), sizeof(packet));
if (packet.EventType == HCI_EVENT_COMMAND_COMPL && packet.Opcode == opcode)
break;
}
}
}

Expand Down

0 comments on commit 64515d0

Please sign in to comment.