-
Notifications
You must be signed in to change notification settings - Fork 0
API Mouse and Keyboard Input
THE_ORONCO edited this page May 19, 2022
·
1 revision
__EXPERIMENTAL__ -- but mostly working on all platforms
Mouse and keyboard input can be achieved by enabling devkit input mode:
POKE(0x5F2D, flags) -- where flags are:
flag | description |
---|---|
0x1 | Enable |
0x2 | Mouse buttons trigger btn(4)โฆbtn(6) |
0x4 | Pointer lock (use stat 38โฆ39 to read movements) |
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.
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
- ๐ Keys
- ๐ Hello World
- ๐พ Example Cartridges
- ๐ File System
โคด๏ธ Loading and Saving- ๐ Using an External Text Editor
- ๐ฝ Backups
- ๐ง Configuration
- ๐ธ Screenshots and GIFs
- ๐ Sharing Cartridges
- ๐ SPLORE
- ๐ผ๏ธ Sprite Sheet / Label (.png)
- ๐ต SFX and Music (.wav)
- ๐ค MAP and CODE
- ๐พ Cartridges (.p8, .p8.png, .p8.rom)
- ๐ Web Applications (.html)
- ๐ค Binary Applications (.bin)
- ๐น๏ธ Uploading to itch.io
- ๐พ Exporting Multiple Cartridges
- ๐ฅ Running EXPORT from the host operating system