mirror of
https://github.com/raphnet/gc_n64_usb-v3
synced 2024-12-22 07:18:52 -05:00
Gamecube hotplugging infrastructure
This commit is contained in:
parent
db8d973b82
commit
4a6ccfb448
@ -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)
|
||||||
|
@ -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
6
main.c
@ -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()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user