Skip to content

Commit

Permalink
Fix squeak and save spam in gamepad menu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Daaaav committed Dec 21, 2024
1 parent f9f9f07 commit 0e5f8ac
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions desktop_version/src/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e5f8ac

Please sign in to comment.