From e5f6c6ee020d3469f94ae66f45fef4f63aef1135 Mon Sep 17 00:00:00 2001 From: Raphael Assenat Date: Wed, 17 Feb 2021 22:41:13 +0900 Subject: [PATCH] Add a workaround for the Brawler 64 wireless gamepad This controller (or its receiver) needs a pause between the "get caps" and "get status" commands. Introduce a pause of a duration based on the poll interval. Unfortunately poll interval that works with this controller is 2ms. --- n64.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/n64.c b/n64.c index 2be6730..557f2df 100644 --- a/n64.c +++ b/n64.c @@ -1,5 +1,5 @@ /* gc_n64_usb : Gamecube or N64 controller to USB firmware - Copyright (C) 2007-2016 Raphael Assenat + Copyright (C) 2007-2021 Raphael Assenat This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include "gamepads.h" #include "n64.h" #include "gcn64_protocol.h" +#include "eeprom.h" #undef BUTTON_A_RUMBLE_TEST @@ -110,6 +111,18 @@ static char n64Update(unsigned char chn) return -1; } + /* The brawler 64 wireless gamepad does not like when the get caps command is followed + * too closely by the get status command. Without a long pause between the two commands, + * it just returns an all zeros. */ + if (g_eeprom_data.cfg.poll_interval[0] >= 4) { + _delay_ms(2.5); + } else if (g_eeprom_data.cfg.poll_interval[0] >= 3) { + _delay_ms(1.5); + } else if (g_eeprom_data.cfg.poll_interval[0] >= 2) { + _delay_ms(1.25); // does not work at 1ms + } + + /* Detect when a pack becomes present and schedule initialisation when it happens. */ if ((caps[2] & 0x01) && (n64_rumble_state[chn] == RSTATE_UNAVAILABLE)) { n64_rumble_state[chn] = RSTATE_INIT;