GamepadAxis# ( axis[,port] )

Parameters

axis - 1 left X, 2 left Y, 3 right X, 4 right Y, 5 left trigger, 6 right trigger.
port (optional) - stable controller slot, 0..15; 0 by default.

Description

Reads standard gamepad axes. Sticks use -1..1 with positive Y pointing down; triggers use 0..1, independently. The default radial stick dead zone is 0.15, and trigger dead zone is 0.05; values outside each dead zone are rescaled to retain full travel. Returns 0 if unmapped, absent, unfocused or invalid.

Supported on Windows, macOS, iOS, Android and web, subject to device and platform capabilities. Input requires application focus; device presence and names remain queryable in the background.

See also: Controller guide and button table, JoyType, FlushJoy, Controller playground.

Example

; GamepadAxis example
Graphics 800,480,32,2
SetBuffer BackBuffer()
While Not KeyHit(1)
    Cls
    Text 20,20,"Connect a controller, then press a pad button. Esc exits."
    Text 20,60,"GamepadAxis: "+GamepadAxis(1)
    Flip
Wend
End

Index