OSX 10.6 compatibility
This commit is contained in:
@@ -58,18 +58,20 @@ if(WIN32)
|
||||
elseif(LINUX)
|
||||
target_link_libraries(wiiuse m ${BLUEZ_LIBRARIES})
|
||||
elseif(APPLE)
|
||||
# link libraries
|
||||
find_library(IOBLUETOOTH_FRAMEWORK
|
||||
NAMES
|
||||
IOBluetooth)
|
||||
|
||||
find_library(COREFOUNDATION_FRAMEWORK
|
||||
NAMES
|
||||
CoreFoundation)
|
||||
|
||||
find_library(FOUNDATION_FRAMEWORK
|
||||
NAMES
|
||||
Foundation)
|
||||
target_link_libraries(wiiuse ${IOBLUETOOTH_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK} ${FOUNDATION_FRAMEWORK})
|
||||
|
||||
# do not link Objective-C runtime with clang
|
||||
set_target_properties(wiiuse PROPERTIES XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME "NO")
|
||||
endif()
|
||||
|
||||
set_property(TARGET
|
||||
|
||||
@@ -42,6 +42,13 @@
|
||||
#import "../wiiuse_internal.h"
|
||||
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
|
||||
#define WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE 1
|
||||
#else
|
||||
#define WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE 0
|
||||
#endif
|
||||
|
||||
|
||||
@interface WiiuseWiimote : NSObject<IOBluetoothL2CAPChannelDelegate> {
|
||||
wiimote* wm; // reference to the C wiimote struct
|
||||
|
||||
|
||||
@@ -243,7 +243,12 @@
|
||||
byte* data = (byte*) data_;
|
||||
|
||||
// This is done in case the control channel woke up this handler
|
||||
if(!data || ([channel PSM] == kBluetoothL2CAPPSMHIDControl)) {
|
||||
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
BluetoothL2CAPPSM psm = channel.PSM;
|
||||
#else
|
||||
BluetoothL2CAPPSM psm = [channel getPSM];
|
||||
#endif
|
||||
if(!data || (psm == kBluetoothL2CAPPSMHIDControl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -255,6 +260,25 @@
|
||||
[newData release];
|
||||
}
|
||||
|
||||
#if !WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
// the following delegate methods were required on 10.6. They are here to get rid of 10.6 compiler warnings.
|
||||
- (void)l2capChannelOpenComplete:(IOBluetoothL2CAPChannel*)l2capChannel status:(IOReturn)error {
|
||||
/* no-op */
|
||||
}
|
||||
- (void)l2capChannelClosed:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||
/* no-op */
|
||||
}
|
||||
- (void)l2capChannelReconfigured:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||
/* no-op */
|
||||
}
|
||||
- (void)l2capChannelWriteComplete:(IOBluetoothL2CAPChannel*)l2capChannel refcon:(void*)refcon status:(IOReturn)error {
|
||||
/* no-op */
|
||||
}
|
||||
- (void)l2capChannelQueueSpaceAvailable:(IOBluetoothL2CAPChannel*)l2capChannel {
|
||||
/* no-op */
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@@ -43,12 +43,19 @@
|
||||
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
||||
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
|
||||
#if !WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
#import <IOBluetooth/IOBluetoothUserLib.h> // IOBluetoothLocalDeviceGetPowerState
|
||||
#endif
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WiiuseDeviceInquiry
|
||||
|
||||
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
@interface WiiuseDeviceInquiry : NSObject<IOBluetoothDeviceInquiryDelegate> {
|
||||
#else
|
||||
@interface WiiuseDeviceInquiry : NSObject {
|
||||
#endif
|
||||
wiimote** wiimotes;
|
||||
NSUInteger maxDevices;
|
||||
int timeout;
|
||||
@@ -68,8 +75,17 @@
|
||||
- (id) initWithMemory:(wiimote**)wiimotes_ maxDevices:(int)maxDevices_ timeout:(int)timeout_ {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
|
||||
BluetoothHCIPowerState powerState = kBluetoothHCIPowerStateUnintialized;
|
||||
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
if([IOBluetoothHostController defaultController])
|
||||
powerState = [IOBluetoothHostController defaultController].powerState;
|
||||
#else
|
||||
// yes it is deprecated. no, there is no alternative (on 10.6).
|
||||
IOBluetoothLocalDeviceGetPowerState(&powerState);
|
||||
#endif
|
||||
if (![IOBluetoothHostController defaultController] ||
|
||||
[IOBluetoothHostController defaultController].powerState == kBluetoothHCIPowerStateOFF)
|
||||
powerState != kBluetoothHCIPowerStateON)
|
||||
{
|
||||
WIIUSE_DEBUG("Bluetooth hardware not available.");
|
||||
[self release];
|
||||
|
||||
Reference in New Issue
Block a user