Is a controller currently connected in this slot?
ReadonlyindexThe slot this device represents (0-3), matching
navigator.getGamepads()'s indices
*
*
ReadonlyleftThe left analog stick, each axis in [-1, 1]
Left (-1) to right (1)
Up (-1) to down (1)
The left trigger's analog value, in [0, 1] (0 if the controller only reports it as a digital button)
ReadonlyrightThe right analog stick, each axis in [-1, 1]
Left (-1) to right (1)
Up (-1) to down (1)
The right trigger's analog value, in [0, 1] (0 if the controller only reports it as a digital button)
Reset this device's handlers (e.g., between levels)
Report whether button is currently held down, as of the last poll.
setButtonPressHandler deliberately only fires once, on the down
transition (see its docstring), so for a digital button that needs
hold/repeat semantics -- the gamepad equivalent of holding an arrow
key -- poll this every tick (e.g. from Scene.repeatEvents) instead,
the same way leftStick/rightStick are already meant to be polled
for analog hold-to-move input.
The button to check
Set a handler to run when a button is pressed. Named "Press", not
"Down", specifically because it's unlike KeyboardDevice.setKeyDownHandler:
this does not re-fire while the button is held -- it fires once, on the
down transition.
The button to listen for
The code to run
Set a handler to run when a button is released
The button to listen for
The code to run
GamepadDevice represents a single controller slot (there are up to four, matching the browser's
navigator.getGamepads()indices -- seeStage.gamepads). UnlikeKeyboardDevice, there's no browser event for "a gamepad button was pressed" -- the API is poll-only, sopoll()is called once per render tick (seeStage.pollGamepads), regardless of whether the world, HUD, or an overlay is what's currently active. That last part matters: it's what lets a pause overlay register its own gamepad handlers (e.g. A to resume) the same way it can register keyboard ones, instead of input going dead the moment a menu opens.