mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-06 23:11:18 +12:00
Search for up to 4 devices at a time
This commit is contained in:
parent
9046dca558
commit
5184e632e2
1 changed files with 23 additions and 16 deletions
|
@ -243,34 +243,41 @@ void PairingDialog::WorkerThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for device
|
// Search for device
|
||||||
inquiry_info* info = nullptr;
|
inquiry_info* infos = nullptr;
|
||||||
const auto respCount = hci_inquiry(hostId, 5, 1, liacLap, &info, IREQ_CACHE_FLUSH);
|
const auto respCount = hci_inquiry(hostId, 5, 4, liacLap, &infos, IREQ_CACHE_FLUSH);
|
||||||
if (respCount <= 0)
|
if (respCount <= 0)
|
||||||
{
|
{
|
||||||
UpdateCallback(PairingState::SearchFailed);
|
UpdateCallback(PairingState::SearchFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stdx::scope_exit freeInfo([info]() { bt_free(info);});
|
|
||||||
|
|
||||||
//! Open dev to read name
|
// Open dev to read name
|
||||||
const auto hostDesc = hci_open_dev(hostId);
|
const auto hostDevDesc = hci_open_dev(hostId);
|
||||||
stdx::scope_exit freeDev([hostDesc]() { hci_close_dev(hostDesc);});
|
|
||||||
char nameBuffer[HCI_MAX_NAME_LENGTH] = {};
|
char nameBuffer[HCI_MAX_NAME_LENGTH] = {};
|
||||||
|
|
||||||
|
bool foundADevice = false;
|
||||||
// Get device name and compare. Would use product and vendor id from SDP, but many third-party Wiimotes don't store them
|
// Get device name and compare. Would use product and vendor id from SDP, but many third-party Wiimotes don't store them
|
||||||
const auto& addr = info->bdaddr;
|
for (const auto& devInfo : std::span(infos, respCount))
|
||||||
if (hci_read_remote_name(hostDesc, &addr, HCI_MAX_NAME_LENGTH, nameBuffer,
|
|
||||||
2000) != 0 || !isWiimoteName(nameBuffer))
|
|
||||||
{
|
{
|
||||||
UpdateCallback(PairingState::SearchFailed);
|
const auto& addr = devInfo.bdaddr;
|
||||||
return;
|
if (hci_read_remote_name(hostDevDesc, &addr, HCI_MAX_NAME_LENGTH, nameBuffer,
|
||||||
|
2000) != 0 || !isWiimoteName(nameBuffer))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
L2CapWiimote::AddCandidateAddress(addr);
|
||||||
|
foundADevice = true;
|
||||||
|
const auto& b = addr.b;
|
||||||
|
cemuLog_log(LogType::Force, "Pairing Dialog: Found '{}' with address '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'",
|
||||||
|
nameBuffer, b[5], b[4], b[3], b[2], b[1], b[0]);
|
||||||
}
|
}
|
||||||
const auto& b = addr.b;
|
if (foundADevice)
|
||||||
cemuLog_log(LogType::Force, "Pairing Dialog: Found '{}' with address '{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}'",
|
UpdateCallback(PairingState::Finished);
|
||||||
nameBuffer, b[5], b[4], b[3], b[2], b[1], b[0]);
|
else
|
||||||
|
UpdateCallback(PairingState::SearchFailed);
|
||||||
|
|
||||||
UpdateCallback(PairingState::Finished);
|
bt_free(infos);
|
||||||
L2CapWiimote::AddCandidateAddress(addr);
|
hci_close_dev(hostDevDesc);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void PairingDialog::WorkerThread()
|
void PairingDialog::WorkerThread()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue