Questions about event triggers

I’m working on a prop file with custom button controls and I have a couple of questions about how certain events are triggered.

Suppose I have the following events defined:

      case EVENTID(BUTTON_POWER, EVENT_PRESSED, MODE_OFF):
        On();
        return true;
      case EVENTID(BUTTON_POWER, EVENT_PRESSED, MODE_OFF | BUTTON_AUX):
        StartOrStopTrack();
        return true;
      case EVENTID(BUTTON_AUX, EVENT_CLICK_SHORT, MODE_ON):
        SaberBase::DoBlast();
        return true;
  1. If the saber is off and I click the power button, will the mode of the saber change before the button is released, thus triggering a Blast immediately after the saber turns on?

  2. If the saber is off and I hold the aux button and press the power button, will the track player start/stop AND the saber turn on, or will only the track player start/stop be executed?

  1. yes
  2. only the track player

In general, I don’t recommend using the EVENT_PRESSED / EVENT_RELEASED events, as they don’t play nicely with double-clicks and a variety of other things. Click events have a bunch of logic that makes it so that once an event has returned true, it won’t trigger more events, however, none of that logic applies to EVENT_PRESSED and EVENT_RELEASED events, and the assumption is that you will write your own logic if needed when using these events.

When you hold aux, press and release power, then release aux, you get:

AUX, PRESSED, OFF
POWER, PRESSED, OFF | AUX
POWER, RELEASED, OFF | AUX
AUX, RELEASED, OFF

Of course, if you release them in the other order, you get something different at the end.

1 Like

In general, I don’t recommend using the EVENT_PRESSED / EVENT_RELEASED events, as they don’t play nicely with double-clicks and a variety of other things. Click events have a bunch of logic that makes it so that once an event has returned true, it won’t trigger more events, however, none of that logic applies to EVENT_PRESSED and EVENT_RELEASED events, and the assumption is that you will write your own logic if needed when using these events.

That’s the plan. I’m writing my own button config to handle a pared-down set of features. By eliminating certain effects and features I don’t need, I can improve button responsiveness for the things that matter most to me. I’ve managed to map the controls I want to a 2-button config. Based on what you’ve told me, I just need to build my own logic to prevent various effects from being triggered immediately after the saber changes state. I think I can solve this with a single boolean.