A gamepad is the input_device of a game controller. Gamepads are
enabled by display<-gamepads,
which also returns the connected gamepads. The buttons and axes of a
gamepad generate events for the window with the keyboard focus, as keys
do:
gamepad_button_down, gamepad_button_upThese events are event->is_a.
Their event<-detail
is a gamepad_input, so event<-control
gives the name of the button or axis and event<-value
its value. Gamepad events are only generated while the application has
the keyboard focus. When a gamepad is connected or disconnected, the
window with the keyboard focus of each frame receives a device_added or
device_removed event.
The buttons and axes are named after their position rather than their label, so the names are the same for controllers of different brands:
south (A on an Xbox controller, cross on
a PlayStation controller), east, west and north.
back, guide, start, left_stick, right_stick,
left_shoulder, right_shoulder, dpad_up, dpad_down,
dpad_left, dpad_right, misc1 .. misc6, left_paddle1,
left_paddle2, right_paddle1, right_paddle2
and touchpad.
left_x, left_y, right_x, right_y
(-1 .. 1; positive is right and down) and left_trigger, right_trigger
(0 .. 1).
For example:
event(W, Ev:event) :->
( send(Ev, is_a, gamepad_button_down),
get(Ev, control, south)
-> send(W, fire)
; send_super(W, event, Ev)
).
.0..1.0, high=0.0..1.0,
milliseconds=int Rumble the low and high frequency motors with the given
strength for the given time. Fails if the gamepad cannot rumble..0..1.0, right=0.0..1.0,
milliseconds=int As gamepad->rumble,
for the motors in the triggers..g., xbox360, ps5,
or unknown.