mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 15:49:50 -06:00
BTReal: Don't falsely increase a controller's ACL packet number buffer size. WARN_LOG if the size is smaller than that of the original BT module.
This commit is contained in:
@ -228,18 +228,35 @@ auto BluetoothRealDevice::ProcessHCIEvent(BufferType buffer) -> BufferType
|
|||||||
std::memcpy(&ev, buffer.data() + sizeof(hci_event_hdr_t), sizeof(ev));
|
std::memcpy(&ev, buffer.data() + sizeof(hci_event_hdr_t), sizeof(ev));
|
||||||
|
|
||||||
if (ev.opcode == HCI_CMD_READ_BUFFER_SIZE)
|
if (ev.opcode == HCI_CMD_READ_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
hci_read_buffer_size_rp reply;
|
||||||
|
std::memcpy(&reply, buffer.data() + sizeof(hci_event_hdr_t) + sizeof(ev), sizeof(reply));
|
||||||
|
|
||||||
|
if (reply.status != 0x00)
|
||||||
|
{
|
||||||
|
ERROR_LOG_FMT(IOS_WIIMOTE, "HCI_CMD_READ_BUFFER_SIZE status: 0x{:02x}.", reply.status);
|
||||||
|
|
||||||
|
reply.status = 0x00;
|
||||||
|
reply.num_acl_pkts = ACL_PKT_NUM;
|
||||||
|
}
|
||||||
|
else if (reply.num_acl_pkts > ACL_PKT_NUM)
|
||||||
{
|
{
|
||||||
// Due to how the widcomm stack which Nintendo uses is coded, we must never
|
// Due to how the widcomm stack which Nintendo uses is coded, we must never
|
||||||
// let the stack think the controller is buffering more than 10 data packets
|
// let the stack think the controller is buffering more than 10 data packets
|
||||||
// - it will cause a u8 underflow and royally screw things up.
|
// - it will cause a u8 underflow and royally screw things up.
|
||||||
// Therefore, the reply to this command has to be faked to avoid random, weird issues
|
// Therefore, the reply to this command has to be faked to avoid random, weird issues
|
||||||
// (including Wiimote disconnects and "event mismatch" warning messages).
|
// (including Wiimote disconnects and "event mismatch" warning messages).
|
||||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Adjusting HCI_CMD_READ_BUFFER_SIZE results.");
|
|
||||||
|
|
||||||
hci_read_buffer_size_rp reply;
|
|
||||||
reply.status = 0x00;
|
|
||||||
reply.max_acl_size = ACL_PKT_SIZE;
|
|
||||||
reply.num_acl_pkts = ACL_PKT_NUM;
|
reply.num_acl_pkts = ACL_PKT_NUM;
|
||||||
|
}
|
||||||
|
else if (reply.num_acl_pkts < ACL_PKT_NUM)
|
||||||
|
{
|
||||||
|
// The controller buffers fewer ACL packets than the original BT module.
|
||||||
|
WARN_LOG_FMT(IOS_WIIMOTE, "HCI_CMD_READ_BUFFER_SIZE num_acl_pkts({}) < ACL_PKT_NUM({})",
|
||||||
|
reply.num_acl_pkts, ACL_PKT_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force the other the parameters to match that of the original BT module.
|
||||||
|
reply.max_acl_size = ACL_PKT_SIZE;
|
||||||
reply.max_sco_size = SCO_PKT_SIZE;
|
reply.max_sco_size = SCO_PKT_SIZE;
|
||||||
reply.num_sco_pkts = SCO_PKT_NUM;
|
reply.num_sco_pkts = SCO_PKT_NUM;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user