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 Mar 25, 2024
1 parent 1e698f8 commit 55fb9e5
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 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 @@ -18,10 +18,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 @@ -16,10 +16,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 @@ -15,10 +15,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/addons/turbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
bool TurboInput::available() {
// Turbo Button initialized by void Gamepad::setup()
bool hasTurboAssigned = false;
GpioAction* pinMappings = Storage::getInstance().getProfilePinMappings();
GpioMappingInfo* pinMappings = Storage::getInstance().getProfilePinMappings();
for (Pin_t pin = 0; pin < (Pin_t)NUM_BANK0_GPIOS; pin++)
{
if ( pinMappings[pin] == GpioAction::BUTTON_PRESS_TURBO ) {
if ( pinMappings[pin].action == GpioAction::BUTTON_PRESS_TURBO ) {
hasTurboAssigned = true;
turboPin = 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 @@ -33,7 +33,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 @@ -57,7 +57,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 @@ -178,12 +178,12 @@ 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();
buttonGpios = 0;
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 @@ -197,11 +197,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 @@ -139,9 +139,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 55fb9e5

Please sign in to comment.