use the interrupt (data) channel as output channel on mac

This commit is contained in:
Lysann Schlegel
2012-11-12 01:45:32 +01:00
parent 4bf58ca73a
commit 7b13623d12
3 changed files with 22 additions and 17 deletions

View File

@@ -100,10 +100,10 @@
} }
// open channels // open channels
if(![self connectChannel:&controlChannel PSM:WM_OUTPUT_CHANNEL]) { if(![self connectChannel:&controlChannel PSM:kBluetoothL2CAPPSMHIDControl]) {
[self disconnect]; [self disconnect];
return kIOReturnNotOpen; return kIOReturnNotOpen;
} else if(![self connectChannel:&interruptChannel PSM:WM_INPUT_CHANNEL]) { } else if(![self connectChannel:&interruptChannel PSM:kBluetoothL2CAPPSMHIDInterrupt]) {
[self disconnect]; [self disconnect];
return kIOReturnNotOpen; return kIOReturnNotOpen;
} }
@@ -210,26 +210,26 @@
} }
- (int) writeBuffer: (byte*) buffer length: (NSUInteger) length { - (int) writeBuffer: (byte*) buffer length: (NSUInteger) length {
if(controlChannel == nil) { if(interruptChannel == nil) {
WIIUSE_ERROR("Attempted to write to nil control channel [id %i].", wm->unid); WIIUSE_ERROR("Attempted to write to nil interrupt channel [id %i].", wm->unid);
return 0; return 0;
} }
IOReturn error = [controlChannel writeSync:buffer length:length]; IOReturn error = [interruptChannel writeSync:buffer length:length];
if (error != kIOReturnSuccess) { if (error != kIOReturnSuccess) {
WIIUSE_ERROR("Error writing to control channel [id %i].", wm->unid); WIIUSE_ERROR("Error writing to interrupt channel [id %i].", wm->unid);
WIIUSE_DEBUG("Attempting to reopen the control channel [id %i].", wm->unid); WIIUSE_DEBUG("Attempting to reopen the interrupt channel [id %i].", wm->unid);
[self disconnectChannel:&controlChannel]; [self disconnectChannel:&interruptChannel];
[self connectChannel:&controlChannel PSM:WM_OUTPUT_CHANNEL]; [self connectChannel:&interruptChannel PSM:kBluetoothL2CAPPSMHIDInterrupt];
if(!controlChannel) { if(!interruptChannel) {
WIIUSE_ERROR("Error reopening the control channel [id %i].", wm->unid); WIIUSE_ERROR("Error reopening the interrupt channel [id %i].", wm->unid);
[self disconnect]; [self disconnect];
} else { } else {
WIIUSE_DEBUG("Attempting to write again to the control channel [id %i].", wm->unid); WIIUSE_DEBUG("Attempting to write again to the interrupt channel [id %i].", wm->unid);
error = [controlChannel writeSync:buffer length:length]; error = [interruptChannel writeSync:buffer length:length];
if (error != kIOReturnSuccess) if (error != kIOReturnSuccess)
WIIUSE_ERROR("Unable to write again to the control channel [id %i].", wm->unid); WIIUSE_ERROR("Unable to write again to the interrupt channel [id %i].", wm->unid);
} }
} }
@@ -242,8 +242,8 @@
byte* data = (byte*) data_; byte* data = (byte*) data_;
// This is done in case the output channel woke up this handler // This is done in case the control channel woke up this handler
if(!data || ([channel PSM] == WM_OUTPUT_CHANNEL)) { if(!data || ([channel PSM] == kBluetoothL2CAPPSMHIDControl)) {
return; return;
} }

View File

@@ -663,7 +663,11 @@ int wiiuse_send(struct wiimote_t* wm, byte report_type, byte* msg, int len) {
#ifdef WIIUSE_WIN32 #ifdef WIIUSE_WIN32
buf[0] = report_type; buf[0] = report_type;
#else #else
#ifdef WIIUSE_MAC
buf[0] = WM_SET_DATA | WM_BT_OUTPUT;
#else // *NIX
buf[0] = WM_SET_REPORT | WM_BT_OUTPUT; buf[0] = WM_SET_REPORT | WM_BT_OUTPUT;
#endif
buf[1] = report_type; buf[1] = report_type;
#endif #endif

View File

@@ -104,6 +104,7 @@
#define WM_INPUT_CHANNEL 0x13 #define WM_INPUT_CHANNEL 0x13
#define WM_SET_REPORT 0x50 #define WM_SET_REPORT 0x50
#define WM_SET_DATA 0xA0
/* commands */ /* commands */
#define WM_CMD_LED 0x11 #define WM_CMD_LED 0x11