By default, PICO-8 does not track mouse inputs. In order to access the mouse and full keyboard inputs, you first need to enable devkit input mode with this poke:

poke( 0x5f2d, flags )

There are 3 flags that you can send with this memory poke:

Flag Result
0x1 Enable devkit mode
0x2 Mouse buttons trigger buttons (#4-6)
0x4 Mouse pointer tracking 

Warning from the Manual: "Note that not every PICO-8 will have a keyboard or mouse attached to it, so when posting carts to the Lexaloffle BBS, it is encouraged to make keyboard and/or mouse control optional and off by default, if possible. When devkit input mode is enabled, a message is displayed to BBS users warning them that the program may be expecting input beyond the standard 6-button controllers."

After enabling the devkit mode and the mouse inputs, you will need to use stat to get the mouse data for your game.

The state of the mouse and keyboard can be found in stat(x):

STAT(30) (Boolean) True when a keypress is available
STAT(31) (String) character returned by keyboard
STAT(32) Mouse X
STAT(33) Mouse Y
STAT(34) Mouse buttons (bitfield)
STAT(36) Mouse wheel event
STAT(38) Relative x movement (in host desktop pixels)
-- requires flag 0x4
STAT(39) Relative y movement (in host desktop pixels)
-- requires flag 0x4


3 Apr 2024