When exactly button callbacks and input handlers are called?

When exactly in the game lifecycle button callbacks and input handlers are called? I see two possible options:

  1. Right after the playdate.update()
  2. Immediately when the event happens (playdate.update() is interrupted in order for the callback to be executed)

From my experiments on the Simulator it seems that (1) is true. However, the documentation does not cover this question and I want to be sure.

Update() is not interrupted. The button state is tracked internally and the callbacks are called on the next run loop pass. Hope that helps.

What does “next run loop pass” mean in this context? After the update() call on the frame button press happened has finished?

Yup. The update call is allowed to finish, it won't be preempted by a button press.

1 Like