diff --git a/headers/storagemanager.h b/headers/storagemanager.h index 36a2d7e31..a8908b54e 100644 --- a/headers/storagemanager.h +++ b/headers/storagemanager.h @@ -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 diff --git a/proto/enums.proto b/proto/enums.proto index f1531f4b6..db76de54b 100644 --- a/proto/enums.proto +++ b/proto/enums.proto @@ -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 diff --git a/src/gamepad.cpp b/src/gamepad.cpp index f34aaca93..66af329c6 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -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; } diff --git a/src/storagemanager.cpp b/src/storagemanager.cpp index 0178ebe3a..3eb0c25a2 100644 --- a/src/storagemanager.cpp +++ b/src/storagemanager.cpp @@ -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() { diff --git a/www/src/Locales/en/SettingsPage.jsx b/www/src/Locales/en/SettingsPage.jsx index 6c4f2c425..3e85ee61e 100644 --- a/www/src/Locales/en/SettingsPage.jsx +++ b/www/src/Locales/en/SettingsPage.jsx @@ -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': { diff --git a/www/src/Pages/SettingsPage.jsx b/www/src/Pages/SettingsPage.jsx index 033c5eba9..c5c1273b9 100644 --- a/www/src/Pages/SettingsPage.jsx +++ b/www/src/Pages/SettingsPage.jsx @@ -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 },