Gleam - v1.0.2
    Preparing search index...

    Class Controller

    Gamepad input. The first connected gamepad becomes "our" gamepad; later ones are ignored until ours disconnects. Connection / disconnection fires EventSystem "inputControllerConnected" / "inputControllerDisconnected".

    Poll buttons (indexed via CONTROLLER_KEYS) and poll from your update. State is cleared on window blur and on disconnect so held buttons / non-neutral sticks don't stay live across focus loss. Visualizing is not the controller's responsibility — see ControllerCursor for the built-in on-screen visualization, or read poll directly to drive your own.

    Logs to console.error if the browser doesn't expose the Gamepad API.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    buttons: boolean[] = []

    Pressed-state per button, indexed in the same order as the underlying Gamepad.buttons. Index with CONTROLLER_KEYS. Updated by poll; empty until the first non-cached poll.

    Methods

    • Read the current gamepad state and return one Vec2 per stick pair with a circular deadzone applied (0.25 inner radius, output magnitude clamped to [0, 1]). The returned array (and each Vec2 in it) is reused across calls — clone if you need to retain. Also refreshes buttons. Returns the cached array unchanged when the gamepad timestamp hasn't advanced.

      Returns Vec2[]

    • Clear buttons and the cached stick axes. Called automatically on window blur and on gamepad disconnect.

      Returns void

    • Trigger a 400 ms full-strength dual-rumble pulse. Returns false when no gamepad is connected or the pad has no vibrationActuator; true when the effect was dispatched.

      Returns boolean