1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 01:29:43 +01:00

Fix squeak and save spam in gamepad menu

If you push a button to set a controller binding, you may either hear
one Viridian squeak, two Viridian squeaks (a louder one), or Viridian
doesn't stop squeaking until you let go of the button. While you hear
the continuous squeaking, your save file is also repeatedly saved.

There are two small bugs at play here:
- the squeak is actually played in two different places at the same
  time (both in titleinput() whenever a button is pressed, and in
  updatebuttonmappings() when a mapping is succesfully changed)
- titleinput() doesn't register that a button is held down and applies
  the button (and saves to file) every frame for as long as the button
  is held

This commit fixes both these issues. Now a single button press always
causes one squeak, and only if the bindings actually changed. Your save
file is also no longer saved repeatedly from holding down the button.
This commit is contained in:
Dav999 2024-12-21 04:21:44 +01:00
parent f9f9f076b4
commit 0e5f8ac978

View file

@ -2377,17 +2377,26 @@ void titleinput(void)
game.jumpheld = true;
}
static bool controller_held = false;
if ( game.currentmenuname == Menu::controller &&
game.currentmenuoption > 0 &&
game.currentmenuoption < 6 &&
(game.separate_interact || game.currentmenuoption < 5) &&
key.controllerButtonDown() )
{
updatebuttonmappings(game.currentmenuoption);
music.playef(Sound_VIRIDIAN);
game.savestatsandsettings_menu();
if (!controller_held)
{
controller_held = true;
updatebuttonmappings(game.currentmenuoption);
game.savestatsandsettings_menu();
}
return;
}
else
{
controller_held = false;
}
if (game.menustart
&& game.menucountdown <= 0