better wiimote code for osx with sonic fix, wiimote works better in wiiuse, but not in dolphin becau i think the read function in the wiimote plugin is in a separate thread and osx dont like this

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3924 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
tmator 2009-08-01 19:35:45 +00:00
parent 10443c3f3a
commit 7b19632b4a
2 changed files with 29 additions and 30 deletions

View File

@ -84,31 +84,8 @@ static int state_changed(struct wiimote_t* wm);
int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
int evnt = 0;
#if defined(__APPLE__)
int i;
if (!wm)
return 0;
for (i = 0; i < wiimotes; ++i) {
wm[i]->event = WIIUSE_NONE;
if (wiiuse_io_read(wm[i])) {
/* propagate the event */
propagate_event(wm[i], wm[i]->event_buf[1], wm[i]->event_buf+2);
evnt += (wm[i]->event != WIIUSE_NONE);
/* clear out the event buffer */
memset(wm[i]->event_buf, 0, sizeof(wm[i]->event_buf));
} else {
idle_cycle(wm[i]);
}
}
#else
/*
* Windows, Unix
* Windows, Unix and Apple
*/
int i;
@ -128,7 +105,6 @@ int wiiuse_poll(struct wiimote_t** wm, int wiimotes) {
idle_cycle(wm[i]);
}
}
#endif
return evnt;
}

View File

@ -113,6 +113,12 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address);
- (void) l2capChannelClosed:(IOBluetoothL2CAPChannel*) l2capChannel
{
//channel closed
printf("Bt channel closed\n");
if (l2capChannel == _cchan)
_cchan = nil;
if (l2capChannel == _ichan)
_ichan = nil;
}
#pragma mark -
@ -348,21 +354,38 @@ void wiiuse_disconnect(struct wiimote_t* wm) {
}
int wiiuse_io_read(struct wiimote_t* wm) {
if (!WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
return 0;
/* if this wiimote is not connected, skip it */
if (!WIIMOTE_IS_CONNECTED(wm))
return 0;
//run the main loop to get bt data
CFRunLoopRun();
for (int len=0; len<MAX_PAYLOAD; len++)
{
wm->event_buf[len] = DataFromWiimote[len];
}
memcpy(wm->event_buf,DataFromWiimote,sizeof(wm->event_buf));
memcpy(wm->event_buf, &wm->event_buf[1], sizeof(wm->event_buf) - 1);
return 1;
return 1;
}
int wiiuse_io_write(struct wiimote_t* wm, byte* buf, int len) {
if(buf[0] != (WM_SET_REPORT | WM_BT_OUTPUT))
{
// Linux and OSX need this, Windows strips it out
// Only packets from Dolphin don't have the start
// Wiiuse uses ifdefs to add the first byte without you ever knowing it
// Should find out a nice way of doing this, getting windows to stop stripping the packets would be nice
memcpy(buf + 1, buf, len - 1);
buf[0] = (WM_SET_REPORT | WM_BT_OUTPUT);
}
[cbt writeToWiimote:buf length:len];
return 1;
}