PICO-8 Wiki
Register
Advertisement
WARNING
The functionality described below may not be safe to use in some or many cases.
Read all warnings and technical notes and understand all possible consequences before use.
_update_buttons( )
Update the gamepad state.

This internal, undocumented function is how the PICO-8 application updates the gamepad state.

While the user's code is first being run, the gamepad state is expected to be undefined and unreliable, as calls to functions like btn() or btnp() are only expected to be done inside of _update() and possibly _draw(), which will not occur until after all of the user's code has been run through.

If, however, the user wishes to do some processing of inputs over an extended period of time before control returns to the outer loop that calls update/draw, they may force updates to the gamepad state by calling _update_buttons(). Typically, one would call this between a call to flip() and the logic that depends on the buttons.

Warning[]

As an undocumented function, _update_buttons() cannot be relied on for a game. Its functionality may change or be removed in future versions. Still, some may find a pragmatic use for it in tools or demos. Just be aware that you use it at your own risk.

Examples[]

print("press any button to continue")
repeat
  flip()
  _update_buttons()
until btn() != 0
Advertisement