gameplate - v2.2.0
    Preparing search index...

    Interface Gamepad

    Normalized gamepad reader.

    interface Gamepad {
        isDown: (button: number | StandardButton, padIndex?: number) => boolean;
        wasPressed: (button: number | StandardButton, padIndex?: number) => boolean;
        wasReleased: (
            button: number | StandardButton,
            padIndex?: number,
        ) => boolean;
        value: (button: number | StandardButton, padIndex?: number) => number;
        axis: (axis: number | StandardAxis, padIndex?: number) => number;
        stick: (
            which: "left" | "right",
            padIndex?: number,
        ) => { x: number; y: number };
        count: () => number;
        connected: () => boolean;
        pads: () => readonly GamepadState[];
        poll: () => void;
        onConnect: (handler: (pad: GamepadState) => void) => Unsubscribe;
        onDisconnect: (handler: (pad: GamepadState) => void) => Unsubscribe;
        destroy: () => void;
    }
    Index

    Properties

    isDown: (button: number | StandardButton, padIndex?: number) => boolean

    true while button is currently held on padIndex (default 0).

    wasPressed: (button: number | StandardButton, padIndex?: number) => boolean

    Pressed this poll (false-to-true edge since the previous poll).

    wasReleased: (button: number | StandardButton, padIndex?: number) => boolean

    Released this poll (true-to-false edge since the previous poll).

    value: (button: number | StandardButton, padIndex?: number) => number

    Analog value 0..1 for a button (triggers, mostly). Digital buttons read 0 or 1.

    axis: (axis: number | StandardAxis, padIndex?: number) => number

    Per-axis read, with the configured deadzone applied — values within ±deadzone read as 0.

    stick: (which: "left" | "right", padIndex?: number) => { x: number; y: number }

    Stick as a {x, y} vector with radial deadzone (vector length is what's gated).

    count: () => number

    Count of slots with connected: true.

    connected: () => boolean

    true when at least one pad is connected.

    pads: () => readonly GamepadState[]

    Snapshot of every pad slot. Empty slots show as connected: false stubs.

    poll: () => void

    Sample the platform and advance the edge-detection bookkeeping. Call once per frame. createGame does this for you. No-op after destroy.

    onConnect: (handler: (pad: GamepadState) => void) => Unsubscribe

    Fires the first time a slot transitions disconnected → connected. On the very first poll, any already-connected pad fires immediately — so 'Press A to begin' works without a separate enumeration pass.

    onDisconnect: (handler: (pad: GamepadState) => void) => Unsubscribe

    Fires when a slot transitions connected → disconnected.

    destroy: () => void

    Detach handlers and stop polling. Idempotent.