Button Events

Usage for “non-standard” different button setups seems pretty rare, which probably contributes to the lack of information, so I’m hoping some light can be shed on them.

In common/events.h:

enum BUTTON : uint32_t {
  BUTTON_NONE = 0,   // used for gestures and the like
  BUTTON_POWER = 1,
  BUTTON_AUX = 2,
  BUTTON_AUX2 = 4,
  BUTTON_UP = 8,
  BUTTON_DOWN = 16,
  BUTTON_LEFT = 32,
  BUTTON_RIGHT = 64,
  BUTTON_SELECT = 128,

  // D-pad and FIRE//MODE_SELECT/CLIP_DETECT/RELOAD and RANGE have the same numbers,
  // so you can't have a D-pad in a blaster.
  BUTTON_FIRE = 8,
  BUTTON_MODE_SELECT = 16,
  BUTTON_CLIP_DETECT = 32,
  BUTTON_RELOAD = 64,
  BUTTON_RANGE = 128,

  BUTTON_BLADE_DETECT = 256,
  MODE_ANY_BUTTON = 512,

  BUTTON_TRIGGER_ONE = 1,
  BUTTON_TRIGGER_TWO = 2,
  BUTTON_TRIGGER_THREE = 4,
  BUTTON_TRIGGER_FOUR = 8,
  BUTTON_TRIGGER_FIVE = 16,
  BUTTON_TRIGGER_SIX = 32,
  BUTTON_TRIGGER_SEVEN = 64,
  BUTTON_TRIGGER_EIGHT = 128,
    
  MODE_ON = 1024,
  MODE_OFF = 0,
};

All these are events that can be triggered by a button, right?

It seems like certain events like BUTTON_BLADE_DETECT would be what’s triggered when, well, blade detect is shorted, and thus you wouldn’t want to use that for a button, but you could, right?

What is MODE_ANY_BUTTON? How about MODE_ON and MODE_OFF?

These seem like things used elsewhere in ProffieOS/having some other meaning, so just want to know if they’re even relevant to button configuration or if I can safely ignore them.

No, these are all the different kind of buttons supported by ProffieOS.
The events are listed further down in the same file:

Yes, you could theoretically use that for a button.

So, in Event2() any buttons that are currently held (apart from the current buttton) becomes part of the “mode” This allows you do do events like:

      case EVENTID(BUTTON_AUX, EVENT_CLICK_SHORT, MODE_ON | BUTTON_POWER):

In the “mode” field of the event, we have “MODE_ON | BUTTON_POWER”, which means that the saber has to be on, and the power button has to be held for this event to match.

MODE_ANY_BUTTON lets you write an EVENT() which will match regardless of what buttons are actually held. Example:

They are used in button matching inside the prop file.

1 Like