Use gcn64_detectController to detect N64 vs Gamecube controllers

This commit is contained in:
Raphael Assenat 2015-08-21 23:31:50 -04:00
parent 829ba2b560
commit 290588dbd5
1 changed files with 16 additions and 14 deletions

30
main.c
View File

@ -467,24 +467,27 @@ uint8_t hid_set_report_data(const struct usb_request *rq, const uint8_t *dat, ui
#define NUM_PAD_TYPES 2 #define NUM_PAD_TYPES 2
static Gamepad *pads[NUM_PAD_TYPES];
void initPads(void)
{
gcn64protocol_hwinit();
pads[0] = n64GetGamepad();
pads[1] = gamecubeGetGamepad();
}
Gamepad *detectPad(void) Gamepad *detectPad(void)
{ {
int i; int i;
int type;
for (i=0; i<NUM_PAD_TYPES; i++) { type = gcn64_detectController();
if (pads[i]->probe()) {
return pads[i]; switch (type)
} {
case CONTROLLER_IS_ABSENT:
case CONTROLLER_IS_UNKNOWN:
return NULL;
case CONTROLLER_IS_N64:
return n64GetGamepad();
break;
case CONTROLLER_IS_GC:
return gamecubeGetGamepad();
} }
return NULL; return NULL;
} }
@ -496,7 +499,6 @@ int main(void)
hwinit(); hwinit();
usart1_init(); usart1_init();
initPads();
/* Init the buffer with idle data */ /* Init the buffer with idle data */
usbpad_buildReport(NULL, gamepad_report0); usbpad_buildReport(NULL, gamepad_report0);