Is it possible to swap pwr and aux while blade is on?

HI

I know you can set which pin is which pin is which in the config but I was wondering if it was possible to swap the button functionality around whilst the blade was activated?


blade = off

Pwr = Pwr

Aux = Aux


Blade = on

Pwr = Aux

Aux = Pwr


Is it possible?

It’s definitely possible, but it’s not a feature that exists today, so you would need to write the code for it. Relatively simple if you know a little coding, or willing to learn.

Thanks profezzorn and can I say it is an honor to speak to you lol.

I know a little bit of coding and was thinking if this type of code needed to be implemented in the saber config file or do I need to modify the saber_fett263_buttons file?

It’s probably easiest to just modify the prop file.

Like a very little required.
Something like this, right before the switch in Event2() would probably do the trick?

  bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override {
    if (SaberBase::IsOn()) {
      if (button == BUTTON_POWER) button = BUTTON_AUX;
      else if (button == BUTTON_AUX) button = BUTTON_POWER;
    }
    switch (EVENTID(button, event, modifiers)) {............

You could also guard it with a #define if you wanted it to be an option on a per-config file basis.

Sorry if I shouldn’t chime in and let @Welsh_Dragon figure it out :upside_down_face:

Since there are separate case EVENT(...) for ON and OFF, you don’t even need to do that, you just go through each case statement that has MODE_ON in it and switch the buttons.

Even ChatGPT could do it.

Ok?
But there’s like 100+ MODE_ON cases. PLus modifiers.
That’s a lot of manual editing with a large margin of user error possible, no?

Effort and difficulty are two different things. :slight_smile:
Making 100 simple edits is still simple.
You are correct that the chance of making an error goes up though.

Both ways work, and now that we have explained the pros and cons, @Welsh_Dragon should be able to decide which one to use.

1 Like

actually the modifiers need love too

This is pretty much spot on to what I did and it works a treat too.

Cheers

bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override {

// === SWAP BUTTONS WHEN BLADE IS ON ===

if (SaberBase::IsOn()) {

if (button == BUTTON_POWER) {

button = BUTTON_AUX;

} else if (button == BUTTON_AUX) {

button = BUTTON_POWER;

}

}


Cool but what about “while holding AUX” for example?
Don’t you need to address all of the buttons that are in the modifier parameter?
I think you’re dealing with bitwise stuff there.