Skip to content

Commit

Permalink
display the profile label on the display when a label is set
Browse files Browse the repository at this point in the history
e.g. the top line splash says "SNES FG" instead of "Profile #2"
  • Loading branch information
bsstephan committed Sep 17, 2024
1 parent 3d5caaa commit d72d07a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions headers/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "BoardConfig.h"
#include "types.h"
#include <string.h>
#include <string>

#include "enums.pb.h"
#include "gamepad/GamepadState.h"
Expand Down
1 change: 1 addition & 0 deletions headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions src/display/ui/screens/ButtonLayoutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d72d07a

Please sign in to comment.