Skip to content

pad: gamepads

pad.get([n]) → mask

Without an argument: any pad, the OR of all the gamepads (and, on the board, of the USER button and the console's keyboard). This is what a menu or a one-player game wants, whichever slot the gamepad is in. pad.get(n): player n, 1 to 4; an error beyond.

The input is frozen once per frame: two pad.get() in the same _update() return the same value, and that value is the one that goes into the trace (see the rules).

No table of booleans: this is the form the hardware delivers, and the rising edge comes for free.

local pressed = p & ~prev
prev = p
constant value
pad.LEFT pad.RIGHT pad.UP pad.DOWN 0x01 0x02 0x04 0x08
pad.A pad.B pad.X pad.Y 0x10 0x20 0x40 0x80
pad.L pad.R pad.START pad.SELECT 0x100 0x200 0x400 0x800

On the board only

These exist on the board and are not available in the simulator: pad.rumble, pad.led, pad.color (vibration, player LED, light bar), and sys.pads(), sys.pair, sys.forget, sys.disconnect for Bluetooth pairing (see sys).