From 0e5f8ac978e8da6f85ebb5c361f744b511923410 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Sat, 21 Dec 2024 04:21:44 +0100 Subject: [PATCH] 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. --- desktop_version/src/Input.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index c00f7362..1599dc4a 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -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