From d72d07ae66f6f9ec556a7948945eab217dfd1449 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Tue, 17 Sep 2024 08:14:54 -0500 Subject: [PATCH] display the profile label on the display when a label is set e.g. the top line splash says "SNES FG" instead of "Profile #2" --- headers/gamepad.h | 1 + headers/storagemanager.h | 1 + src/display/ui/screens/ButtonLayoutScreen.cpp | 14 ++++++++++---- src/storagemanager.cpp | 10 ++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/headers/gamepad.h b/headers/gamepad.h index 5552f7ba7..69e521fd5 100644 --- a/headers/gamepad.h +++ b/headers/gamepad.h @@ -4,6 +4,7 @@ #include "BoardConfig.h" #include "types.h" #include +#include #include "enums.pb.h" #include "gamepad/GamepadState.h" diff --git a/headers/storagemanager.h b/headers/storagemanager.h index d332d1196..952e4715d 100644 --- a/headers/storagemanager.h +++ b/headers/storagemanager.h @@ -71,6 +71,7 @@ class Storage { void setProfile(const uint32_t); // profile support for multiple mappings void nextProfile(); void setFunctionalPinMappings(); + char* currentProfileLabel(); void ResetSettings(); // EEPROM Reset Feature diff --git a/src/display/ui/screens/ButtonLayoutScreen.cpp b/src/display/ui/screens/ButtonLayoutScreen.cpp index 3e716cf3e..d7c179ed0 100644 --- a/src/display/ui/screens/ButtonLayoutScreen.cpp +++ b/src/display/ui/screens/ButtonLayoutScreen.cpp @@ -114,13 +114,19 @@ int8_t ButtonLayoutScreen::update() { void ButtonLayoutScreen::generateHeader() { // Limit to 21 chars with 6x8 font for now statusBar.clear(); + Storage& storage = Storage::getInstance(); // Display Profile # banner if ( profileModeDisplay ) { if (((getMillis() - profileDelayStart) / 1000) < profileDelay) { - statusBar = " Profile #"; - statusBar += std::to_string(getGamepad()->getOptions().profileNumber); - return; + statusBar.assign(storage.currentProfileLabel(), strlen(storage.currentProfileLabel())); + if (statusBar.empty()) { + statusBar = " Profile #"; + statusBar += std::to_string(getGamepad()->getOptions().profileNumber); + } else { + statusBar.insert(statusBar.begin(), (21-statusBar.length())/2, ' '); + } + return; } else { profileModeDisplay = false; } @@ -165,7 +171,7 @@ void ButtonLayoutScreen::generateHeader() { case INPUT_MODE_CONFIG: statusBar += "CONFIG"; break; } - const TurboOptions& turboOptions = Storage::getInstance().getAddonOptions().turboOptions; + const TurboOptions& turboOptions = storage.getAddonOptions().turboOptions; if ( turboOptions.enabled ) { statusBar += " T"; if ( turboOptions.shotCount < 10 ) // padding diff --git a/src/storagemanager.cpp b/src/storagemanager.cpp index 845e94e37..9d1a565a0 100644 --- a/src/storagemanager.cpp +++ b/src/storagemanager.cpp @@ -124,6 +124,16 @@ void Storage::nextProfile() this->config.gamepadOptions.profileNumber = (this->config.gamepadOptions.profileNumber % 4) + 1; } +/** + * @brief Return the current profile label. + */ +char* Storage::currentProfileLabel() { + if (this->config.gamepadOptions.profileNumber == 1) + return this->config.gpioMappings.profileLabel; + else + return this->config.profileOptions.gpioMappingsSets[config.gamepadOptions.profileNumber-2].profileLabel; +} + void Storage::setFunctionalPinMappings() { GpioMappingInfo* alts = nullptr;