Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit 66bb4f2

Browse files
committed
Add developer docs
1 parent 8b34cff commit 66bb4f2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ Alternatively check this repo out, run `python3 -m http.server 8080` in the repo
4646

4747
### PICO-8 development
4848

49-
To add Pinput support to your own cartridge, inspect mine, and take a look at the second tab. All of the functions and constants prefixed with `pi_` are the Pinput client code proper, and you should be able to copy that tab right into your cartridge to use it yourself.
49+
To add Pinput support to your own cartridge, take a look at [`pinput.lua`](PICO-8/pinput.lua) All of the functions and constants prefixed with `pi_` are the Pinput client code proper, and you can copy or `#include pinput.lua` that code right into your cartridge to use it yourself.
50+
51+
Call `pi_init()` to put the Pinput magic bytes into GPIO so one of the helper apps can find it and start communicating, and call `pi_btn()`, `pi_trigger()`, `pi_axis()`, etc. to read button, trigger, and thumbstick axis values. Note that (as in XInput) trigger values are in the range [0, 255] and axes are in the range [-32768, 32767].
52+
53+
```lua
54+
-- read player 2's left trigger and scale it to [0, 1]
55+
local t = pi_trigger(1, pi_lt) / 0xff
56+
```
57+
58+
Consult [`pinput_tester.p8`](PICO-8/pinput_tester.p8) (the test cartridge) for more usage examples.
5059

5160
## Current status
5261

0 commit comments

Comments
 (0)