On my quest to see how innovative we can all get with button input types on the Playdate, I'm looking to open a menu when both A+B are released. Currently, this way is working fine, but the way
getButtonState() works, there's not a ton of room for error with how soon together someone has to release both buttons for it to register during the next update cycle.
function globalInputHandlers() local current, justPressed, justReleased = playdate.getButtonState() if justReleased == playdate.kButtonA|playdate.kButtonB then -- Open a menu end end
For it to properly trigger, back-to-back cycles need to look like this:
-- Update cycle current = 48, justPressed = 0, justReleased = 0 -- Next update cycle current = 0, justPressed = 0, justReleased = 48
But if the user isn't relatively precise with releasing both buttons at the same time, it might look more like this:
-- Update cycle current = 48, justPressed = 0, justReleased = 0 -- Next update cycle current = 32, justPressed = 0, justReleased = 16 -- Next Next update cycle current = 0, justPressed = 0, justReleased = 32
... and then the original code won't get called. There's some obvious ways I can think to prevent this with a few extra conditionals and shenanigans inside of that if statement.. but just curious if this is something anyone else has encountered?
I don't find it particularly difficult to release both buttons synchronized enough to trigger it, but also I'm actively trying to do it and am aware of it. I'd hate for a user to feel frustrated that a button input works sometimes and doesn't work other times, and them not understanding why.
What's the best way to add some leeway for the input here?