gamepad.jamo (built in)

gamepad: Xbox-style controllers, through Windows' XInput, for up to 4 players. use "gamepad.jamo"

Make one Gamepad for each player, call update() once a frame, then ask about its buttons and sticks. A controller that isn't plugged in just reads as nothing pressed, so a game works the same with or without one.

var pad = gamepad(0)
...each frame:
pad.update()
x += pad.left_x() * speed
if pad.pressed("a")
    jump()
end

Buttons: a, b, x, y, up, down, left, right, start, back, lb, rb, left_stick and right_stick

constGAMEPAD_DEAD_ZONE

const GAMEPAD_DEAD_ZONE = 7849

How far a stick must move, out of 32767, before it counts. Sticks rest a little off the middle

structGamepad

struct Gamepad
    player: int
    connected: bool
    buttons: int
    last_buttons: int
    state: int
end

funcgamepad

func gamepad(player: int): Gamepad

Player number 0 to 3

funcGamepad.update

func Gamepad.update()

Reads the controller. Call it once a frame, before asking about it

funcgamepad_bit

func gamepad_bit(name: string): int

funcgamepad_has

func gamepad_has(buttons: int, bit: int): bool

funcGamepad.down

func Gamepad.down(name: string): bool

True while the button is held down

funcGamepad.pressed

func Gamepad.pressed(name: string): bool

True only on the frame the button goes down

funcGamepad.released

func Gamepad.released(name: string): bool

True only on the frame the button comes back up

funcgamepad_axis

func gamepad_axis(raw: int, flip: bool): float

A stick's axis from -1.0 to 1.0, 0.0 inside the dead zone. Up is negative, like the screen's y

funcGamepad.left_x

func Gamepad.left_x(): float

funcGamepad.left_y

func Gamepad.left_y(): float

funcGamepad.right_x

func Gamepad.right_x(): float

funcGamepad.right_y

func Gamepad.right_y(): float

funcGamepad.left_trigger

func Gamepad.left_trigger(): float

A trigger from 0.0 (let go) to 1.0 (all the way in)

funcGamepad.right_trigger

func Gamepad.right_trigger(): float

funcGamepad.rumble

func Gamepad.rumble(left: float, right: float)

Shakes the controller: the left motor is slow and heavy, the right one fast and light, each from 0.0 to 1.0. rumble(0.0, 0.0) stops it

funcgamepad_clamp

func gamepad_clamp(value: float): float