Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hotkey for decrementing profile number #1130

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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 @@ -547,6 +547,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 @@ -119,6 +119,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 @@ -247,6 +247,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
Loading