WiimoteScannerBackend: Allow StopThreads to request that any Wiimote searching stops
Used by WiimoteScannerDarwin to know when to exit its runloop.
This commit is contained in:
parent
0de30fa0bb
commit
b494d109d4
|
@ -48,6 +48,7 @@ public:
|
||||||
bool IsReady() const override { return true; }
|
bool IsReady() const override { return true; }
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||||
void Update() override {}
|
void Update() override {}
|
||||||
|
void RequestStopSearching() override {}
|
||||||
};
|
};
|
||||||
} // namespace WiimoteReal
|
} // namespace WiimoteReal
|
||||||
|
|
||||||
|
|
|
@ -16,5 +16,6 @@ public:
|
||||||
bool IsReady() const override { return false; }
|
bool IsReady() const override { return false; }
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override {}
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override {}
|
||||||
void Update() override {}
|
void Update() override {}
|
||||||
|
void RequestStopSearching() override {}
|
||||||
};
|
};
|
||||||
} // namespace WiimoteReal
|
} // namespace WiimoteReal
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||||
void Update() override {} // not needed on Linux
|
void Update() override {} // not needed on Linux
|
||||||
|
void RequestStopSearching() override {} // not needed on Linux
|
||||||
private:
|
private:
|
||||||
int m_device_id;
|
int m_device_id;
|
||||||
int m_device_sock;
|
int m_device_sock;
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
void RequestStopSearching() override {}
|
||||||
};
|
};
|
||||||
} // namespace WiimoteReal
|
} // namespace WiimoteReal
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||||
void Update() override {} // not needed
|
void Update() override {} // not needed
|
||||||
|
void RequestStopSearching() override { m_stop_scanning = true; }
|
||||||
private:
|
private:
|
||||||
IOBluetoothHostController* m_host_controller;
|
IOBluetoothHostController* m_host_controller;
|
||||||
bool m_stop_scanning = false;
|
bool m_stop_scanning = false;
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
bool IsReady() const override;
|
bool IsReady() const override;
|
||||||
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) override;
|
||||||
void Update() override {} // not needed for hidapi
|
void Update() override {} // not needed for hidapi
|
||||||
|
void RequestStopSearching() override {} // not needed for hidapi
|
||||||
};
|
};
|
||||||
} // namespace WiimoteReal
|
} // namespace WiimoteReal
|
||||||
|
|
||||||
|
|
|
@ -545,6 +545,12 @@ void WiimoteScanner::StopThread()
|
||||||
if (m_scan_thread_running.TestAndClear())
|
if (m_scan_thread_running.TestAndClear())
|
||||||
{
|
{
|
||||||
SetScanMode(WiimoteScanMode::DO_NOT_SCAN);
|
SetScanMode(WiimoteScanMode::DO_NOT_SCAN);
|
||||||
|
|
||||||
|
for (const auto& backend : m_backends)
|
||||||
|
{
|
||||||
|
backend->RequestStopSearching();
|
||||||
|
}
|
||||||
|
|
||||||
m_scan_thread.join();
|
m_scan_thread.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2008 Dolphin Emulator Project
|
// Copyright 2008 Dolphin Emulator Project
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
@ -155,6 +155,8 @@ public:
|
||||||
virtual void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) = 0;
|
virtual void FindWiimotes(std::vector<Wiimote*>&, Wiimote*&) = 0;
|
||||||
// function called when not looking for more Wiimotes
|
// function called when not looking for more Wiimotes
|
||||||
virtual void Update() = 0;
|
virtual void Update() = 0;
|
||||||
|
// requests the backend to stop scanning if FindWiimotes is blocking
|
||||||
|
virtual void RequestStopSearching() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class WiimoteScanMode
|
enum class WiimoteScanMode
|
||||||
|
|
Loading…
Reference in New Issue