Game controller input


The game.input vocabulary provides cross-platform access to game controller devices such as joysticks and gamepads. It also provides an interface for polling raw keyboard and mouse input.

The game input interface must be initialized before being used:
open-game-input ( -- )

close-game-input ( -- )

with-game-input ( quot -- )


Once the game input interface is open, connected controller devices can be enumerated:
get-controllers ( -- sequence )

find-controller-products ( product-id -- sequence )

find-controller-instance ( product-id instance-id -- controller/f )


These controller objects can be queried of their identity:
product-string ( controller -- string )

product-id ( controller -- id )

instance-id ( controller -- id )


A hook is provided for invoking the system calibration tool:
calibrate-controller ( controller -- )


The current state of a controller, the keyboard, and the mouse can be read:
read-controller ( controller -- controller-state )

read-keyboard ( -- keyboard-state )

read-mouse ( -- mouse-state )

controller-state

keyboard-state

mouse-state


Convenience functions are provided to convert a pair of key or button state sequences into a sequence of pressed/released deltas:
button-delta ( old? new? -- delta )

buttons-delta ( old-buttons new-buttons -- delta )

buttons-delta-as ( old-buttons new-buttons exemplar -- delta )