Add BUTTON_LATCHED_MOMENTARY type, to allow a pushbutton to mimic the behavior of a toggle switch.

This commit is contained in:
Anna Rose Wiggins 2021-11-01 15:24:05 -04:00
parent c37e4a6789
commit 6a692687f5
3 changed files with 37 additions and 3 deletions

View file

@ -22,7 +22,8 @@ enum ButtonType {
BUTTON_PASSTHRU = 0x1, // always use the (debounced) absolute state of the input
BUTTON_PULSED = 0x2, // on button press, send an on signal followed immediately by an off signal.
BUTTON_PULSED_DOUBLE_ACTION = 0x4, // Send a button press twice - once for press and once for release.
BUTTON_PULSED_DOUBLE_ACTION_SPLIT = 0x8 // Send two separate button presses - one button on press, another on release.
BUTTON_PULSED_DOUBLE_ACTION_SPLIT = 0x8, // Send two separate button presses - one button on press, another on release.
BUTTON_LATCHED_MOMENTARY = 0x10
};
struct JoyReport {
@ -34,7 +35,8 @@ struct Button {
ButtonType type;
Bounce bouncer;
uint8_t index0;
uint8_t index1;
uint8_t index1; // only used by BUTTON_PULSED_DOUBLE_ACTION_SPLIT
bool pressed = false; // only used by BUTTON_LATCHED_MOMENTARY
bool inverted = false; // if true, send button press on release and vice versa.
};