Merge pull request #15 from jscasallas/master

Solved the "if unable to write, then relaunch" issue on Mac.
Mac is now "fully supported"
This commit is contained in:
Juan Sebastian Casallas
2012-01-16 21:12:42 -08:00
3 changed files with 36 additions and 7 deletions

View File

@@ -29,6 +29,8 @@ Added:
on it with fwiine and WiiC code as well as additional code. Try it out
in the example by pressing 1 to start and 2 to stop.
- Full Mac support using Apple's native Bluetooth stack, based on [wiic](http://wiic.sourceforge.net/).
Fixed:
- Properly disable rumbling when told to. Thanks to Jeff Baker from

View File

@@ -194,11 +194,6 @@ If that happens open the Bluetooth Preferences, select the Nintendo device on th
list and remove it (by clicking on the minus sign). Close the Preference Pane and
try again.
If you get the following error on runtime when connecting to your wiimote:
`Unable to write over the output channel`,
you probably won't be able to read IR or accelerometer data, or make the wiimote vibrate.
Relaunching your application and connecting again should solve this issue.
Acknowledgements by Michael Laforest
------------------------------------
<http://wiibrew.org/>

View File

@@ -755,8 +755,40 @@ int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len)
IOBluetoothL2CAPChannel* channel = [IOBluetoothL2CAPChannel withL2CAPChannelRef:wm->outputCh];
IOReturn error = [channel writeSync:buf length:length];
if (error != kIOReturnSuccess)
WIIUSE_ERROR("Unable to write over the output channel (id %i).", wm->unid);
if (error != kIOReturnSuccess)
{
WIIUSE_ERROR("Unable to write over the output channel (id %i).", wm->unid);
WIIUSE_INFO("Attempting to reopen the output channel (id %i).", wm->unid);
IOReturn error = [channel closeChannel];
if (error != kIOReturnSuccess)
WIIUSE_ERROR("Unable to close the output channel (id %i).", wm->unid);
[channel setDelegate:nil];
usleep(10000);
[channel release];
wm->outputCh = 0;
WiiConnect* connect = (WiiConnect*)(wm->connectionHandler);
IOBluetoothDevice* device = [IOBluetoothDevice withDeviceRef:wm->device];
channel = [connect openL2CAPChannelWithPSM:WM_OUTPUT_CHANNEL device:device delegate:connect];
if (!channel) {
WIIUSE_ERROR("Unable to open L2CAP output channel (id %i).", wm->unid);
[device closeConnection];
return kIOReturnNotOpen;
}
wm->outputCh = [[channel retain] getL2CAPChannelRef];
usleep(20000);
WIIUSE_INFO("Attempting to write again through the output channel (id %i).", wm->unid);
error = [channel writeSync:buf length:length];
if (error != kIOReturnSuccess)
{
WIIUSE_ERROR("Unable to write again over the output channel (id %i).", wm->unid);
}
}
usleep(10000);
[pool drain];