Check Bluetooth power state
Taken from http://cocoadev.com/wiki/FindingBluetoothAvailability
This commit is contained in:
6
src/io_mac.m
Executable file → Normal file
6
src/io_mac.m
Executable file → Normal file
@@ -45,13 +45,17 @@
|
|||||||
foundWiimotes = 0;
|
foundWiimotes = 0;
|
||||||
isDiscovering = NO;
|
isDiscovering = NO;
|
||||||
if (self != nil) {
|
if (self != nil) {
|
||||||
|
BluetoothHCIPowerState powerState;
|
||||||
|
IOBluetoothLocalDeviceGetPowerState(&powerState);
|
||||||
/*
|
/*
|
||||||
* Calling IOBluetoothLocalDeviceAvailable has two advantages:
|
* Calling IOBluetoothLocalDeviceAvailable has two advantages:
|
||||||
* 1. it sets up a event source in the run loop (bug for C version of the bluetooth api)
|
* 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
|
* 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 release];
|
||||||
self = nil;
|
self = nil;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user