1
0
mirror of https://github.com/raphnet/gc_n64_usb-v3 synced 2024-12-21 23:08:53 -05:00

Gamecube hotplugging infrastructure

This commit is contained in:
Raphael Assenat 2015-12-06 16:36:33 -05:00
parent db8d973b82
commit 4a6ccfb448
3 changed files with 13 additions and 0 deletions

View File

@ -156,6 +156,11 @@ static char gamecubeUpdate()
return 0; return 0;
} }
static void gamecubeHotplug(void)
{
// Make sure next read becomes the refence center values
origins_set = 0;
}
static char gamecubeProbe(void) static char gamecubeProbe(void)
{ {
@ -191,6 +196,7 @@ Gamepad GamecubeGamepad = {
.getReport = gamecubeGetReport, .getReport = gamecubeGetReport,
.probe = gamecubeProbe, .probe = gamecubeProbe,
.setVibration = gamecubeVibration, .setVibration = gamecubeVibration,
.hotplug = gamecubeHotplug,
}; };
Gamepad *gamecubeGetGamepad(void) Gamepad *gamecubeGetGamepad(void)

View File

@ -75,6 +75,7 @@ typedef struct {
void (*init)(void); void (*init)(void);
char (*update)(void); char (*update)(void);
char (*changed)(void); char (*changed)(void);
void (*hotplug)(void);
void (*getReport)(gamepad_data *dst); void (*getReport)(gamepad_data *dst);
void (*setVibration)(char enable); void (*setVibration)(char enable);
char (*probe)(void); /* return true if found */ char (*probe)(void); /* return true if found */

6
main.c
View File

@ -305,6 +305,12 @@ int main(void)
/* Try to auto-detect controller if none*/ /* Try to auto-detect controller if none*/
if (!pad) { if (!pad) {
pad = detectPad(); pad = detectPad();
if (pad->hotplug) {
// For gamecube, this make sure the next
// analog values we read become the center
// reference.
pad->hotplug();
}
} }
if (pad) { if (pad) {
if (pad->update()) { if (pad->update()) {