rednode API - v0.80.1
    Preparing search index...

    Variable inputConst

    input: {
        gamepad(): GamepadState;
        onGamepad(handler: (pad: GamepadState) => void): () => void;
    } = ...

    The player's controller.

    Type Declaration

    • gamepad: function
    • onGamepad: function
      • Calls handler with the controller's state each time it changes: a button down or up, a trigger moving a step or reaching 0 or 1, the controller connected or gone. Changes come only while the game is in front (out of it, nothing counts as held).

        Parameters

        Returns () => void

        A function that stops listening.

        import { input } from "rednode";

        let held = false;
        input.onGamepad((pad) => {
        if (!held && pad.rt > 0.5) { held = true; console.log("right trigger down"); }
        if (held && pad.rt < 0.2) { held = false; console.log("right trigger up"); }
        if (pad.pressed.includes("y")) console.log("Y pressed");
        });