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
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
const GAMEPAD_DEAD_ZONE = 7849
How far a stick must move, out of 32767, before it counts. Sticks rest a little off the middle
struct Gamepad
player: int
connected: bool
buttons: int
last_buttons: int
state: int
endfunc gamepad(player: int): Gamepad
Player number 0 to 3
func Gamepad.update()
Reads the controller. Call it once a frame, before asking about it
func gamepad_bit(name: string): int
func gamepad_has(buttons: int, bit: int): bool
func Gamepad.down(name: string): bool
True while the button is held down
func Gamepad.pressed(name: string): bool
True only on the frame the button goes down
func Gamepad.released(name: string): bool
True only on the frame the button comes back up
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
func Gamepad.left_x(): float
func Gamepad.left_y(): float
func Gamepad.right_x(): float
func Gamepad.right_y(): float
func Gamepad.left_trigger(): float
A trigger from 0.0 (let go) to 1.0 (all the way in)
func Gamepad.right_trigger(): float
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
func gamepad_clamp(value: float): float