Add `held` boolean argument to `AButtonUp` callback and kin

It would be convenient for the button up callbacks to include a boolean which indicates whether the button was held. (In other words, whether or not the corresponding button held callback fired between button down and button up.)

It's certainly not hard to track this on one's own, but since the event system already has knowledge of this it would help avoid some busywork. This would make it much cleaner to set up event handling for mutually exclusive actions for e.g. A pressed and A held (where "pressed" means released but not held).

A couple simple examples:

  1. Doing a regular attack vs. a charge attack
  2. Toggling/cycling two independent states, for example "game mode" and "local/global" on a high score screen
3 Likes

While we're here - i think it'd be convenient if there was leftButtonHeld or something like it. I may be naive to some reason why it's not needed.

The SDK does have playdate.AButtonHeld etc already; is there a reason you can't use that callback?

Yes, I tried to provide examples but maybe I wasn't as clear as I could have been. The use case is any situation where you want to take one of two mutually exclusive actions in response to a button press depending on its duration. You can trigger the "button held" action on AButttonHeld, but you can't trigger the "button pressed but not held" action on AButtonDown since you need to wait to see if it is held first, and you only want to trigger it on AButtonUp iff it wasn't held. So you need to set a flag in AButtonHeld which can then be checked and reset in AButtonUp. It's really not a big deal to track the extra flag, but I figured the system could just provide that flag as an argument to AButtonUp to avoid the busywork.

To sum up, this is a request of minor convenience only — the desired functionality is entirely achievable using the available callbacks.

Sure, that makes total sense, thanks for the request, we'll get it into our tracker.

1 Like