Skip to main content

Pads

Above being able to draw and everything else, A human interface is important. Supports rumble and pressure sensitivity.

analog_graph

Buttons List

TypeButtons
NavigationPads.UP, Pads.DOWN, Pads.LEFT, Pads.RIGHT
ActionPads.TRIANGLE, Pads.CIRCLE, Pads.CROSS, Pads.SQUARE
FunctionPads.SELECT, Pads.START
ShoulderPads.L1, Pads.R1, Pads.L2, Pads.R2
StickPads.L3, Pads.R3

Methods

get

Returns a pad object

const pad = Pads.get(port?);

Properties

  • pad.btns: Button state on the current check.
  • pad.old_btns: Button state on the last check.
  • pad.lx: Left analog horizontal position (left = -127, default = 0, right = 128).
  • pad.ly: Left analog vertical position (up = -127, default = 0, down = 128).
  • pad.rx: Right analog horizontal position (left = -127, default = 0, right = 128).
  • pad.ry: Right analog vertical position (up = -127, default = 0, down = 128).

update

Updates all pads pressed and stick positions data.

update();

pressed

Checks if a button is being pressed (continuously).

pressed(button);

justPressed

Checks if a button was pressed only once.

justPressed(button);

setEventHandler

Sets the pad object to listen events defined by Pads.newEvent, so it doesn't need to be updated.

setEventHandler();

newEvent

const event_id = Pads.newEvent(button, kind, function);

Creates an asynchronous pad event, returns the event id.

warning

Remember to set the pad object event handler first!

Pad Events
  • Pads.PRESSED
  • Pads.JUST_PRESSED
  • Pads.NON_PRESSED

deleteEvent

Deletes the event created by Pads.newEvent.

Pads.deleteEvent(event_id);

getType

Gets gamepad type in the specified port.

const type = Pads.getType(port?);
Pad Types
  • Pads.DIGITAL
  • Pads.ANALOG
  • Pads.DUALSHOCK

getPressure

Get button pressure level.

const press = Pads.getPressure(port?, button);

rumble

Rumble your gamepad.

Pads.rumble(port, big, small);