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 a hotkey to cycle between profiles. #1031

Merged
merged 7 commits into from
Jun 3, 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 @@ -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;
bsstephan marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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