implement wiiuse_os_connect for mac
This commit is contained in:
@@ -34,7 +34,12 @@
|
||||
#ifdef __APPLE__
|
||||
|
||||
|
||||
#define BLUETOOTH_VERSION_USE_CURRENT
|
||||
|
||||
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||
#import <IOBluetooth/objc/IOBluetoothL2CAPChannel.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
|
||||
@@ -62,5 +67,34 @@
|
||||
[IOBluetoothDevice withDeviceRef: (ref)]
|
||||
#endif
|
||||
|
||||
// WIIUSE_IOBluetoothL2CAPChannel_to_IOBluetoothL2CAPChannelRef
|
||||
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
#define WIIUSE_IOBluetoothL2CAPChannel_to_IOBluetoothL2CAPChannelRef(channel) \
|
||||
((IOBluetoothL2CAPChannelRef) (channel))
|
||||
#else
|
||||
#define WIIUSE_IOBluetoothL2CAPChannel_to_IOBluetoothL2CAPChannelRef(channel) \
|
||||
[(channel) getL2CAPChannelRef]
|
||||
#endif
|
||||
|
||||
// WIIUSE_IOBluetoothL2CAPChannelRef_to_IOBluetoothL2CAPChannel
|
||||
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
|
||||
#define WIIUSE_IOBluetoothL2CAPChannelRef_to_IOBluetoothL2CAPChannel(ref) \
|
||||
((IOBluetoothL2CAPChannel*) (ref))
|
||||
#else
|
||||
#define WIIUSE_IOBluetoothL2CAPChannelRef_to_IOBluetoothL2CAPChannel(ref) \
|
||||
[IOBluetoothL2CAPChannel withChanneleRef: (ref)]
|
||||
#endif
|
||||
|
||||
|
||||
@interface WiiuseWiimote : NSObject<IOBluetoothL2CAPChannelDelegate> {
|
||||
wiimote* wm; // reference to the C wiimote struct
|
||||
IOBluetoothUserNotification* disconnectNotification;
|
||||
}
|
||||
|
||||
- (id) initWithPtr: (wiimote*) wm;
|
||||
- (IOReturn) connect;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
#import "../events.h"
|
||||
#import "../os.h"
|
||||
|
||||
|
||||
#define BLUETOOTH_VERSION_USE_CURRENT
|
||||
#import <IOBluetooth/IOBluetoothUtilities.h>
|
||||
#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
||||
#import <IOBluetooth/objc/IOBluetoothHostController.h>
|
||||
@@ -48,7 +46,7 @@
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark find
|
||||
#pragma mark WiiuseDeviceInquiry
|
||||
|
||||
@interface WiiuseDeviceInquiry : NSObject<IOBluetoothDeviceInquiryDelegate> {
|
||||
wiimote** wiimotes;
|
||||
@@ -122,6 +120,10 @@
|
||||
}
|
||||
|
||||
- (NSUInteger) collectResultsOf: (IOBluetoothDeviceInquiry*) inquiry {
|
||||
// stop the inquiry
|
||||
if(![inquiry stop])
|
||||
WIIUSE_ERROR("Unable to stop bluetooth device inquiry.");
|
||||
|
||||
// read found device information
|
||||
NSArray* devices = [inquiry foundDevices];
|
||||
for(NSUInteger i = 0; i < [devices count]; i++) {
|
||||
@@ -168,6 +170,8 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma mark IOBluetoothDeviceInquiryDelegate
|
||||
|
||||
- (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry *) inquiry device:(IOBluetoothDevice *) device {
|
||||
|
||||
WIIUSE_DEBUG("Found a wiimote");
|
||||
@@ -175,8 +179,6 @@
|
||||
_foundDevices++;
|
||||
if(_foundDevices >= maxDevices) {
|
||||
// reached maximum number of devices
|
||||
if(![inquiry stop])
|
||||
WIIUSE_ERROR("Unable to stop bluetooth device inquiry.");
|
||||
_inquiryComplete = YES;
|
||||
}
|
||||
}
|
||||
@@ -196,6 +198,9 @@
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark public interface
|
||||
|
||||
int wiiuse_os_find(struct wiimote_t** wm, int max_wiimotes, int timeout) {
|
||||
int result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user