OSX 10.6 compatibility

This commit is contained in:
Lysann Schlegel
2012-12-08 13:11:36 +01:00
parent 43e8a27fcc
commit 8a3354d11b
4 changed files with 53 additions and 4 deletions

View File

@@ -58,18 +58,20 @@ if(WIN32)
elseif(LINUX) elseif(LINUX)
target_link_libraries(wiiuse m ${BLUEZ_LIBRARIES}) target_link_libraries(wiiuse m ${BLUEZ_LIBRARIES})
elseif(APPLE) elseif(APPLE)
# link libraries
find_library(IOBLUETOOTH_FRAMEWORK find_library(IOBLUETOOTH_FRAMEWORK
NAMES NAMES
IOBluetooth) IOBluetooth)
find_library(COREFOUNDATION_FRAMEWORK find_library(COREFOUNDATION_FRAMEWORK
NAMES NAMES
CoreFoundation) CoreFoundation)
find_library(FOUNDATION_FRAMEWORK find_library(FOUNDATION_FRAMEWORK
NAMES NAMES
Foundation) Foundation)
target_link_libraries(wiiuse ${IOBLUETOOTH_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK} ${FOUNDATION_FRAMEWORK}) 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() endif()
set_property(TARGET set_property(TARGET

View File

@@ -42,6 +42,13 @@
#import "../wiiuse_internal.h" #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> { @interface WiiuseWiimote : NSObject<IOBluetoothL2CAPChannelDelegate> {
wiimote* wm; // reference to the C wiimote struct wiimote* wm; // reference to the C wiimote struct

View File

@@ -243,7 +243,12 @@
byte* data = (byte*) data_; byte* data = (byte*) data_;
// This is done in case the control channel woke up this handler // 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; return;
} }
@@ -255,6 +260,25 @@
[newData release]; [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 @end
#pragma mark - #pragma mark -

View File

@@ -43,12 +43,19 @@
#import <IOBluetooth/objc/IOBluetoothDevice.h> #import <IOBluetooth/objc/IOBluetoothDevice.h>
#import <IOBluetooth/objc/IOBluetoothHostController.h> #import <IOBluetooth/objc/IOBluetoothHostController.h>
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.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 -
#pragma mark WiiuseDeviceInquiry #pragma mark WiiuseDeviceInquiry
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
@interface WiiuseDeviceInquiry : NSObject<IOBluetoothDeviceInquiryDelegate> { @interface WiiuseDeviceInquiry : NSObject<IOBluetoothDeviceInquiryDelegate> {
#else
@interface WiiuseDeviceInquiry : NSObject {
#endif
wiimote** wiimotes; wiimote** wiimotes;
NSUInteger maxDevices; NSUInteger maxDevices;
int timeout; int timeout;
@@ -68,8 +75,17 @@
- (id) initWithMemory:(wiimote**)wiimotes_ maxDevices:(int)maxDevices_ timeout:(int)timeout_ { - (id) initWithMemory:(wiimote**)wiimotes_ maxDevices:(int)maxDevices_ timeout:(int)timeout_ {
self = [super init]; self = [super init];
if(self) { 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] || if (![IOBluetoothHostController defaultController] ||
[IOBluetoothHostController defaultController].powerState == kBluetoothHCIPowerStateOFF) powerState != kBluetoothHCIPowerStateON)
{ {
WIIUSE_DEBUG("Bluetooth hardware not available."); WIIUSE_DEBUG("Bluetooth hardware not available.");
[self release]; [self release];