mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
Make cancellable between name reads, disable cancel button during inquiry.
This commit is contained in:
parent
d53e4fe35a
commit
a6bab48842
@ -244,15 +244,23 @@ void PairingDialog::WorkerThread()
|
|||||||
|
|
||||||
// Search for device
|
// Search for device
|
||||||
inquiry_info* infos = nullptr;
|
inquiry_info* infos = nullptr;
|
||||||
|
m_cancelButton->Disable();
|
||||||
const auto respCount = hci_inquiry(hostId, 5, 4, liacLap, &infos, IREQ_CACHE_FLUSH);
|
const auto respCount = hci_inquiry(hostId, 5, 4, liacLap, &infos, IREQ_CACHE_FLUSH);
|
||||||
|
m_cancelButton->Enable();
|
||||||
if (respCount <= 0)
|
if (respCount <= 0)
|
||||||
{
|
{
|
||||||
UpdateCallback(PairingState::SearchFailed);
|
UpdateCallback(PairingState::SearchFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
stdx::scope_exit infoFree([&]() { bt_free(infos);});
|
||||||
|
|
||||||
|
if (m_threadShouldQuit)
|
||||||
|
return;
|
||||||
|
|
||||||
// Open dev to read name
|
// Open dev to read name
|
||||||
const auto hostDevDesc = hci_open_dev(hostId);
|
const auto hostDev = hci_open_dev(hostId);
|
||||||
|
stdx::scope_exit devClose([&]() { hci_close_dev(hostDev);});
|
||||||
|
|
||||||
char nameBuffer[HCI_MAX_NAME_LENGTH] = {};
|
char nameBuffer[HCI_MAX_NAME_LENGTH] = {};
|
||||||
|
|
||||||
bool foundADevice = false;
|
bool foundADevice = false;
|
||||||
@ -260,11 +268,13 @@ void PairingDialog::WorkerThread()
|
|||||||
for (const auto& devInfo : std::span(infos, respCount))
|
for (const auto& devInfo : std::span(infos, respCount))
|
||||||
{
|
{
|
||||||
const auto& addr = devInfo.bdaddr;
|
const auto& addr = devInfo.bdaddr;
|
||||||
if (hci_read_remote_name(hostDevDesc, &addr, HCI_MAX_NAME_LENGTH, nameBuffer,
|
const auto err = hci_read_remote_name(hostDev, &addr, HCI_MAX_NAME_LENGTH, nameBuffer,
|
||||||
2000) != 0 || !isWiimoteName(nameBuffer))
|
2000);
|
||||||
{
|
if (m_threadShouldQuit)
|
||||||
|
return;
|
||||||
|
if (err || !isWiimoteName(nameBuffer))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
L2CapWiimote::AddCandidateAddress(addr);
|
L2CapWiimote::AddCandidateAddress(addr);
|
||||||
foundADevice = true;
|
foundADevice = true;
|
||||||
const auto& b = addr.b;
|
const auto& b = addr.b;
|
||||||
@ -275,9 +285,6 @@ void PairingDialog::WorkerThread()
|
|||||||
UpdateCallback(PairingState::Finished);
|
UpdateCallback(PairingState::Finished);
|
||||||
else
|
else
|
||||||
UpdateCallback(PairingState::SearchFailed);
|
UpdateCallback(PairingState::SearchFailed);
|
||||||
|
|
||||||
bt_free(infos);
|
|
||||||
hci_close_dev(hostDevDesc);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void PairingDialog::WorkerThread()
|
void PairingDialog::WorkerThread()
|
||||||
|
Loading…
Reference in New Issue
Block a user