Overhaul of OS X real Wiimote support.

Fixes a number of problems, including unreliable connection setup, 
frequent disconnections, busy-waiting and shutdown deadlocks.

Motion Plus and nunchuk hot swapping now work and Wiiuse does a small
amount of queueing to prevent occasional dropped packets. The OS X 
bluetooth stack has no internal input buffering and while a worker  
thread can easily keep up with data coming from the Wiimote, the rest
of Dolphin can easily get behind if it is blocked by disk I/O or 
similar. Mostly the Wiimote protocol recovers from dropped packets,   
but sometimes the Wiimote would get out of sync and send a disconnect.
I wonder if the other platforms might benefit from a bit of queueing
at this layer as well.
 
Still doesn't support multiple devices, as I kept changing my mind 
about how best to do it. I only have one Wiimote anyway..
 
One improvement to the Wiimote plugin that would be really nice would
be for the scan for new devices to operate continuously or periodically
like on a real Wii rather than just for 5 seconds at startup..   


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5640 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2010-06-09 19:36:08 +00:00
parent 9d792d4673
commit e648c6d68b
9 changed files with 287 additions and 348 deletions

View File

@ -49,7 +49,7 @@ void handle_ctrl_status(struct wiimote_t* wm)
{
DEBUG_LOG(WIIMOTE, "--- CONTROLLER STATUS [wiimote id %i] ---", wm->unid);
DEBUG_LOG(WIIMOTE, "attachment: %i", wm->exp.type);
DEBUG_LOG(WIIMOTE, "attachment: %i", wm->expansion.type);
DEBUG_LOG(WIIMOTE, "speaker: %i", WIIUSE_USING_SPEAKER(wm));
DEBUG_LOG(WIIMOTE, "ir: %i", WIIUSE_USING_IR(wm));
DEBUG_LOG(WIIMOTE, "leds: %i %i %i %i", WIIUSE_IS_LED_SET(wm, 1), WIIUSE_IS_LED_SET(wm, 2), WIIUSE_IS_LED_SET(wm, 3), WIIUSE_IS_LED_SET(wm, 4));
@ -89,9 +89,9 @@ void handle_event(struct wiimote_t* wm)
struct nunchuk_t* nc = NULL;
if (wm->exp.type == EXP_NUNCHUK) {
if (wm->expansion.type == EXP_NUNCHUK) {
nc = (nunchuk_t*)&wm->exp.nunchuk;
nc = (nunchuk_t*)&wm->expansion.nunchuk;
if (IS_PRESSED(nc, NUNCHUK_BUTTON_C))
DEBUG_LOG(WIIMOTE, "C pressed");
if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z))
@ -160,7 +160,7 @@ void handle_event(struct wiimote_t* wm)
Tmp += StringFromFormat("IR cursor: (%u, %u)\n", wm->ir.x, wm->ir.y);
Tmp += StringFromFormat("IR z distance: %f\n", wm->ir.z);
if(wm->exp.type == EXP_NUNCHUK)
if(wm->expansion.type == EXP_NUNCHUK)
{
Tmp += "\n";
Tmp += StringFromFormat("Nunchuck accel x, y, z: %03i %03i %03i\n", nc->accel.x, nc->accel.y, nc->accel.z);
@ -202,7 +202,7 @@ void handle_event(struct wiimote_t* wm)
int GNCx, GNCy, GNCz;
if(wm->exp.type == EXP_NUNCHUK) // Updating Nunchuck Gauges
if(wm->expansion.type == EXP_NUNCHUK) // Updating Nunchuck Gauges
{
m_RecordingConfigFrame->m_GaugeGForceNunchuk[0]->SetValue((int)floor((nc->gforce.x * 300) + 100.5));
m_RecordingConfigFrame->m_GaugeGForceNunchuk[1]->SetValue((int)floor((nc->gforce.y * 300) + 100.5));
@ -231,7 +231,7 @@ void handle_event(struct wiimote_t* wm)
// wxT("Current: %03u %03u %03u"), Gx, Gy, Gz));
if(m_RecordingConfigFrame->m_bRecording) {
if(wm->exp.type != EXP_NUNCHUK) {
if(wm->expansion.type != EXP_NUNCHUK) {
DEBUG_LOG(WIIMOTE, "Wiiuse Recorded accel x, y, z: %03i %03i %03i", Gx, Gy, Gz);
}
else {