From 106f81eaf95a3ce44b12461f7a5ae8f07a9336c4 Mon Sep 17 00:00:00 2001 From: Brodie Blackburn Date: Sat, 6 Oct 2012 10:22:45 +1000 Subject: [PATCH] Check Bluetooth power state Taken from http://cocoadev.com/wiki/FindingBluetoothAvailability --- src/io_mac.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/io_mac.m diff --git a/src/io_mac.m b/src/io_mac.m old mode 100755 new mode 100644 index 80ab33d..2cec19b --- a/src/io_mac.m +++ b/src/io_mac.m @@ -45,13 +45,17 @@ foundWiimotes = 0; isDiscovering = NO; if (self != nil) { + BluetoothHCIPowerState powerState; + IOBluetoothLocalDeviceGetPowerState(&powerState); /* * Calling IOBluetoothLocalDeviceAvailable has two advantages: * 1. it sets up a event source in the run loop (bug for C version of the bluetooth api) * 2. it checks for the availability of the BT hardware */ - if (![IOBluetoothHostController defaultController]) + if (![IOBluetoothHostController defaultController] || + powerState == kBluetoothHCIPowerStateOFF) { + WIIUSE_DEBUG("Bluetooth hardware not available."); [self release]; self = nil; }