Merge pull request #6234 from amolloy/high_sierra

Fix Wiimote support on macOS 10.13 High Sierra
This commit is contained in:
Anthony 2017-12-07 12:04:37 -08:00 committed by GitHub
commit 3b887388cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -13,10 +13,12 @@ class WiimoteScannerDarwin final : public WiimoteScannerBackend
{ {
public: public:
WiimoteScannerDarwin() = default; WiimoteScannerDarwin() = default;
~WiimoteScannerDarwin() override = default; ~WiimoteScannerDarwin() override;
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
private:
bool stopScanning = false;
}; };
} }

View File

@ -21,6 +21,11 @@
namespace WiimoteReal namespace WiimoteReal
{ {
WiimoteScannerDarwin::~WiimoteScannerDarwin()
{
stopScanning = true;
}
void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
Wiimote*& found_board) Wiimote*& found_board)
{ {
@ -54,8 +59,8 @@ void WiimoteScannerDarwin::FindWiimotes(std::vector<Wiimote*>& found_wiimotes,
do do
{ {
CFRunLoopRun(); CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
} while (!sbt->done); } while (!sbt->done && !stopScanning);
int found_devices = [[bti foundDevices] count]; int found_devices = [[bti foundDevices] count];
@ -255,7 +260,6 @@ void WiimoteDarwin::DisablePowerAssertionInternal()
aborted:(BOOL)aborted aborted:(BOOL)aborted
{ {
done = true; done = true;
CFRunLoopStop(CFRunLoopGetCurrent());
} }
- (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender device:(IOBluetoothDevice*)device - (void)deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender device:(IOBluetoothDevice*)device