Skip to content

Commit

Permalink
Add hotkey for decrementing profile number (OpenStickCommunity#1130)
Browse files Browse the repository at this point in the history
* Add hotkey for decrementing profile number

* Code style change
  • Loading branch information
Pelsin authored Sep 17, 2024
1 parent 37f31ac commit 6c97bc0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Storage {

void setProfile(const uint32_t); // profile support for multiple mappings
void nextProfile();
void previousProfile();
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 @@ -299,6 +299,7 @@ enum GamepadHotkey
HOTKEY_DPAD_DOWN = 39;
HOTKEY_DPAD_LEFT = 40;
HOTKEY_DPAD_RIGHT = 41;
HOTKEY_PREVIOUS_PROFILE = 42;
}

// This has to be kept in sync with LEDFormat in NeoPico.hpp
Expand Down
7 changes: 7 additions & 0 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,13 @@ void Gamepad::processHotkeyAction(GamepadHotkey action) {
reqSave = true;
}
break;
case HOTKEY_PREVIOUS_PROFILE:
if (action != lastAction) {
Storage::getInstance().previousProfile();
userRequestedReinit = true;
reqSave = true;
}
break;
default: // Unknown action
return;
}
Expand Down
7 changes: 7 additions & 0 deletions src/storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ void Storage::nextProfile()
{
this->config.gamepadOptions.profileNumber = (this->config.gamepadOptions.profileNumber % 4) + 1;
}
void Storage::previousProfile()
{
if (this->config.gamepadOptions.profileNumber == 1)
this->config.gamepadOptions.profileNumber = 4;
else
this->config.gamepadOptions.profileNumber -= 1;
}

void Storage::setFunctionalPinMappings()
{
Expand Down
1 change: 1 addition & 0 deletions www/src/Locales/en/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default {
'load-profile-4': 'Load Profile #4',
'reboot-default': 'Reboot GP2040-CE',
'next-profile': 'Next Profile',
'previous-profile': 'Previous Profile',
},
'forced-setup-mode-label': 'Forced Setup Mode',
'forced-setup-mode-options': {
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 @@ -253,6 +253,7 @@ const HOTKEY_ACTIONS = [
{ 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.previous-profile', value: 42 },
{ 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 6c97bc0

Please sign in to comment.