move most of the wiiuse mac implementation into WiiuseWiimote* object

This commit is contained in:
Lysann Schlegel
2012-11-10 20:57:20 +01:00
parent b295af0777
commit a39cfd4374
4 changed files with 56 additions and 112 deletions

View File

@@ -42,57 +42,29 @@
#import "../wiiuse_internal.h"
#if 0
#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
// WIIUSE_IOBluetoothDevice_to_IOBluetoothDeviceRef
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
#define WIIUSE_IOBluetoothDevice_to_IOBluetoothDeviceRef(device) \
((IOBluetoothDeviceRef) (device))
#else
#define WIIUSE_IOBluetoothDevice_to_IOBluetoothDeviceRef(device) \
[(device) getDeviceRef]
#endif
// WIIUSE_IOBluetoothDeviceRef_to_IOBluetoothDevice
#if WIIUSE_MAC_OS_X_VERSION_10_7_OR_ABOVE
#define WIIUSE_IOBluetoothDeviceRef_to_IOBluetoothDevice(ref) \
((IOBluetoothDevice*) (ref))
#else
#define WIIUSE_IOBluetoothDeviceRef_to_IOBluetoothDevice(ref) \
[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
IOBluetoothDevice* device;
IOBluetoothL2CAPChannel* controlChannel;
IOBluetoothL2CAPChannel* interruptChannel;
IOBluetoothUserNotification* disconnectNotification;
}
- (id) initWithPtr: (wiimote*) wm;
- (id) initWithPtr: (wiimote*) wm device: (IOBluetoothDevice*) device;
- (IOReturn) connect;
- (void) disconnect;
@end

View File

@@ -130,7 +130,7 @@
IOBluetoothDevice* device = [devices objectAtIndex:i];
// save the device in the wiimote structure
wiimotes[i]->device = WIIUSE_IOBluetoothDevice_to_IOBluetoothDeviceRef(device);
wiimotes[i]->objc_wm = (void*) [[WiiuseWiimote alloc] initWithPtr:wiimotes[i] device: device];
[device retain]; // must retain it for later access through its ref
// mark as found