Skip to content

Commit

Permalink
Add a hotkey to cycle between profiles. (#1031)
Browse files Browse the repository at this point in the history
* Fixed selecting B3 in the hotkey settings

* Added support for cycling profiles

* Reverted values to expected numbers

* Removed Next Profile localization to separate into another pull request

* Adjust spacing for consistency
  • Loading branch information
MechLizard authored Jun 3, 2024
1 parent 121cfda commit a88eef8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Storage {
uint8_t * GetFeatureData();

void setProfile(const uint32_t); // profile support for multiple mappings
void nextProfile();
void setFunctionalPinMappings();

void ResetSettings(); // EEPROM Reset Feature
Expand Down
1 change: 1 addition & 0 deletions proto/enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ enum GamepadHotkey
HOTKEY_S2_BUTTON = 32;
HOTKEY_A1_BUTTON = 33;
HOTKEY_A2_BUTTON = 34;
HOTKEY_NEXT_PROFILE = 35;
}

// This has to be kept in sync with LEDFormat in NeoPico.hpp
Expand Down
8 changes: 7 additions & 1 deletion src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void Gamepad::setup()
}
}

lastAction = HOTKEY_NONE;
}

/**
Expand Down Expand Up @@ -438,6 +437,13 @@ void Gamepad::processHotkeyAction(GamepadHotkey action) {
reqSave = true;
}
break;
case HOTKEY_NEXT_PROFILE:
if (action != lastAction) {
Storage::getInstance().nextProfile();
userRequestedReinit = true;
reqSave = true;
}
break;
default: // Unknown action
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ void Storage::setProfile(const uint32_t profileNum)
this->config.gamepadOptions.profileNumber = (profileNum < 1 || profileNum > 4) ? 1 : profileNum;
}

void Storage::nextProfile()
{
this->config.gamepadOptions.profileNumber = (this->config.gamepadOptions.profileNumber % 4) + 1;
}

void Storage::setFunctionalPinMappings()
{
GpioMappingInfo* alts = nullptr;
Expand Down
1 change: 1 addition & 0 deletions www/src/Pages/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ const HOTKEY_ACTIONS = [
{ labelKey: 'hotkey-actions.load-profile-2', value: 16 },
{ labelKey: 'hotkey-actions.load-profile-3', value: 17 },
{ labelKey: 'hotkey-actions.load-profile-4', value: 18 },
{ labelKey: 'hotkey-actions.next-profile', value: 35 },
{ labelKey: 'hotkey-actions.l3-button', value: 19 },
{ labelKey: 'hotkey-actions.r3-button', value: 20 },
{ labelKey: 'hotkey-actions.touchpad-button', value: 21 },
Expand Down

0 comments on commit a88eef8

Please sign in to comment.