diff --git a/gamecube.c b/gamecube.c index e978572..baf73cc 100644 --- a/gamecube.c +++ b/gamecube.c @@ -156,6 +156,11 @@ static char gamecubeUpdate() return 0; } +static void gamecubeHotplug(void) +{ + // Make sure next read becomes the refence center values + origins_set = 0; +} static char gamecubeProbe(void) { @@ -191,6 +196,7 @@ Gamepad GamecubeGamepad = { .getReport = gamecubeGetReport, .probe = gamecubeProbe, .setVibration = gamecubeVibration, + .hotplug = gamecubeHotplug, }; Gamepad *gamecubeGetGamepad(void) diff --git a/gamepads.h b/gamepads.h index 33c47a2..7a60726 100644 --- a/gamepads.h +++ b/gamepads.h @@ -75,6 +75,7 @@ typedef struct { void (*init)(void); char (*update)(void); char (*changed)(void); + void (*hotplug)(void); void (*getReport)(gamepad_data *dst); void (*setVibration)(char enable); char (*probe)(void); /* return true if found */ diff --git a/main.c b/main.c index 03c0d81..7e7096f 100644 --- a/main.c +++ b/main.c @@ -305,6 +305,12 @@ int main(void) /* Try to auto-detect controller if none*/ if (!pad) { 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->update()) {