Skip to content

Commit

Permalink
have getProfilePinMappings return whole GpioMappingInfos
Browse files Browse the repository at this point in the history
before it returned just the actions, which was fine, but now we're
adding more stuff to the infos, so return the whole struct rather than
just the GpioAction within it
  • Loading branch information
bsstephan committed Feb 13, 2024
1 parent 0476d1c commit 180e5c3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions headers/storagemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Storage {
AddonOptions& getAddonOptions() { return config.addonOptions; }
AnimationOptions_Proto& getAnimationOptions() { return config.animationOptions; }
ProfileOptions& getProfileOptions() { return config.profileOptions; }
GpioAction* getProfilePinMappings() { return functionalPinMappings; }
GpioMappingInfo* getProfilePinMappings() { return functionalPinMappings; }
PeripheralOptions& getPeripheralOptions() { return config.peripheralOptions; }

bool save();
Expand Down Expand Up @@ -84,7 +84,7 @@ class Storage {
critical_section_t animationOptionsCs;
uint32_t animationOptionsCrc = 0;
AnimationOptions animationOptionsToSave = {};
GpioAction functionalPinMappings[NUM_BANK0_GPIOS];
GpioMappingInfo functionalPinMappings[NUM_BANK0_GPIOS];
};

#endif
4 changes: 2 additions & 2 deletions src/addons/dualdirectional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ void DualDirectionalInput::setup() {
mapDpadLeft = new GamepadButtonMapping(GAMEPAD_MASK_LEFT);
mapDpadRight = new GamepadButtonMapping(GAMEPAD_MASK_RIGHT);

GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
switch (pinMappings[pin]) {
switch (pinMappings[pin].action) {
case GpioAction::BUTTON_PRESS_DDI_UP: mapDpadUp->pinMask |= 1 << pin; break;
case GpioAction::BUTTON_PRESS_DDI_DOWN: mapDpadDown->pinMask |= 1 << pin; break;
case GpioAction::BUTTON_PRESS_DDI_LEFT: mapDpadLeft->pinMask |= 1 << pin; break;
Expand Down
4 changes: 2 additions & 2 deletions src/addons/jslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ bool JSliderInput::available() {

void JSliderInput::setup()
{
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
switch (pinMappings[pin]) {
switch (pinMappings[pin].action) {
case SUSTAIN_DP_MODE_DP: dpModeMask |= 1 << pin; break;
case SUSTAIN_DP_MODE_LS: lsModeMask |= 1 << pin; break;
case SUSTAIN_DP_MODE_RS: rsModeMask |= 1 << pin; break;
Expand Down
4 changes: 2 additions & 2 deletions src/addons/slider_socd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ bool SliderSOCDInput::available() {

void SliderSOCDInput::setup()
{
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
switch (pinMappings[pin]) {
switch (pinMappings[pin].action) {
case SUSTAIN_SOCD_MODE_UP_PRIO: upPrioModeMask |= 1 << pin; break;
case SUSTAIN_SOCD_MODE_NEUTRAL: neutralModeMask |= 1 << pin; break;
case SUSTAIN_SOCD_MODE_SECOND_WIN: secondInputModeMask |= 1 << pin; break;
Expand Down
4 changes: 2 additions & 2 deletions src/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gamepad::Gamepad() :
void Gamepad::setup()
{
// Configure pin mapping
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();

mapDpadUp = new GamepadButtonMapping(GAMEPAD_MASK_UP);
mapDpadDown = new GamepadButtonMapping(GAMEPAD_MASK_DOWN);
Expand All @@ -58,7 +58,7 @@ void Gamepad::setup()

for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
switch (pinMappings[pin]) {
switch (pinMappings[pin].action) {
case GpioAction::BUTTON_PRESS_UP: mapDpadUp->pinMask |= 1 << pin; break;
case GpioAction::BUTTON_PRESS_DOWN: mapDpadDown->pinMask |= 1 << pin; break;
case GpioAction::BUTTON_PRESS_LEFT: mapDpadLeft->pinMask |= 1 << pin; break;
Expand Down
8 changes: 4 additions & 4 deletions src/gp2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ void GP2040::setup() {
* @brief Initialize standard input button GPIOs that are present in the currently loaded profile.
*/
void GP2040::initializeStandardGpio() {
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
// (NONE=-10, RESERVED=-5, ASSIGNED_TO_ADDON=0, everything else is ours)
if (pinMappings[pin] > 0)
if (pinMappings[pin].action > 0)
{
gpio_init(pin); // Initialize pin
gpio_set_dir(pin, GPIO_IN); // Set as INPUT
Expand All @@ -188,11 +188,11 @@ void GP2040::initializeStandardGpio() {
* @brief Deinitialize standard input button GPIOs that are present in the currently loaded profile.
*/
void GP2040::deinitializeStandardGpio() {
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
// (NONE=-10, RESERVED=-5, ASSIGNED_TO_ADDON=0, everything else is ours)
if (pinMappings[pin] > 0)
if (pinMappings[pin].action > 0)
{
gpio_deinit(pin);
}
Expand Down
4 changes: 2 additions & 2 deletions src/storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ void Storage::setFunctionalPinMappings()
alts[pin].action != GpioAction::ASSIGNED_TO_ADDON &&
this->config.gpioMappings.pins[pin].action != GpioAction::RESERVED &&
this->config.gpioMappings.pins[pin].action != GpioAction::ASSIGNED_TO_ADDON) {
functionalPinMappings[pin] = alts[pin].action;
functionalPinMappings[pin] = alts[pin];
} else {
functionalPinMappings[pin] = this->config.gpioMappings.pins[pin].action;
functionalPinMappings[pin] = this->config.gpioMappings.pins[pin];
}
}
}
Expand Down

0 comments on commit 180e5c3

Please sign in to comment.