Merge pull request #13784 from jordan-woyak/btreal-restore-keys-on-hci-reset

BTReal: Always restore link keys on HCI reset.
This commit is contained in:
JMC47
2025-07-21 21:00:20 -04:00
committed by GitHub

View File

@ -121,6 +121,17 @@ std::optional<IPCReply> BluetoothRealDevice::IOCtlV(const IOCtlVRequest& request
const auto payload = memory.GetSpanForAddress(cmd->data_address).first(cmd->length);
m_lib_usb_bt_adapter->ScheduleControlTransfer(cmd->request_type, cmd->request, cmd->value,
cmd->index, payload, GetTargetTime());
if (opcode == HCI_CMD_RESET)
{
// After the console issues HCI reset is a good place to restore our link keys.
// We need to do this because:
// Some adapters apparently incorrectly delete keys on HCI reset.
// The adapter was potentially being controlled by the host OS bluetooth stack
// or a Dolphin instance with different link keys.
SendHCIDeleteLinkKeyCommand();
SendHCIStoreLinkKeyCommand();
}
}
return IPCReply{cmd->length};
}
@ -262,11 +273,6 @@ auto BluetoothRealDevice::ProcessHCIEvent(BufferType buffer) -> BufferType
std::memcpy(buffer.data() + sizeof(hci_event_hdr_t) + sizeof(ev), &reply, sizeof(reply));
}
else if (ev.opcode == HCI_CMD_RESET)
{
SendHCIDeleteLinkKeyCommand();
SendHCIStoreLinkKeyCommand();
}
}
else if (event == HCI_EVENT_CON_COMPL)
{