mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Add fault-tolerance to kpad driver
== DETAILS So, the KPadRead function will sometimes return 0, but this doesn't mean the wiimote is actually disconnected. It's usually something transient, like the BT chip has nothing to send or whatever. I don't know. So, I added a buffer so that it won't disconnect the pad without 5 consecutive 0-reads. This is a temporary hack; a proper solution will use the Wii U's callback mechanisms to do wiimote detection. But that's a separate project. This at least prevents OSD spam. == TESTING Tested locally. Verified that connecting/disconnecting nunchuk during play still works properly.
This commit is contained in:
parent
f33fa3d566
commit
07864aebb4
@ -206,6 +206,8 @@ static void kpad_deregister(unsigned channel)
|
||||
}
|
||||
}
|
||||
|
||||
static int poll_failures[WIIU_WIIMOTE_CHANNELS] = { 0, 0, 0, 0 };
|
||||
|
||||
static void kpad_poll(void)
|
||||
{
|
||||
unsigned channel;
|
||||
@ -217,10 +219,16 @@ static void kpad_poll(void)
|
||||
memset(&kpad, 0, sizeof(kpad));
|
||||
|
||||
result = KPADRead(channel, &kpad, 1);
|
||||
/* this is a hack to prevent spurious disconnects */
|
||||
/* TODO: use KPADSetConnectCallback and use callbacks to detect */
|
||||
/* pad disconnects properly. */
|
||||
if (result == 0) {
|
||||
kpad_deregister(channel);
|
||||
poll_failures[channel]++;
|
||||
if(poll_failures[channel] > 5)
|
||||
kpad_deregister(channel);
|
||||
continue;
|
||||
}
|
||||
poll_failures[channel] = 0;
|
||||
|
||||
kpad_poll_one_channel(channel, &kpad);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user