WiimoteReal: actually stop continuous scanning

This commit is contained in:
Tillmann Karras 2020-09-01 02:15:14 +01:00
parent e0b64e0ef8
commit f1ae85282c
1 changed files with 7 additions and 7 deletions

View File

@ -669,15 +669,19 @@ void WiimoteScanner::ThreadFunc()
{ {
m_scan_mode_changed_event.WaitFor(std::chrono::milliseconds(500)); m_scan_mode_changed_event.WaitFor(std::chrono::milliseconds(500));
if (m_scan_mode.load() == WiimoteScanMode::DO_NOT_SCAN)
continue;
// Stop scanning if not in continous mode.
auto scan_mode = WiimoteScanMode::SCAN_ONCE;
m_scan_mode.compare_exchange_strong(scan_mode, WiimoteScanMode::DO_NOT_SCAN);
// Does stuff needed to detect disconnects on Windows // Does stuff needed to detect disconnects on Windows
for (const auto& backend : m_backends) for (const auto& backend : m_backends)
backend->Update(); backend->Update();
CheckForDisconnectedWiimotes(); CheckForDisconnectedWiimotes();
if (m_scan_mode.load() == WiimoteScanMode::DO_NOT_SCAN)
continue;
// If we don't want Wiimotes in ControllerInterface, we may not need them at all. // If we don't want Wiimotes in ControllerInterface, we may not need them at all.
if (!SConfig::GetInstance().connect_wiimotes_for_ciface) if (!SConfig::GetInstance().connect_wiimotes_for_ciface)
{ {
@ -722,10 +726,6 @@ void WiimoteScanner::ThreadFunc()
} }
} }
} }
// Stop scanning if not in continous mode.
auto scan_mode = WiimoteScanMode::SCAN_ONCE;
m_scan_mode.compare_exchange_strong(scan_mode, WiimoteScanMode::DO_NOT_SCAN);
} }
{ {