Documentation
Hooks
useGamepad

useGamepad

Handle the user gamepad connections and changes.

LTLB
RBRT
selectstart
X
Y
A
B

Type Definitions

const getGamepadState: (gamepad: Gamepad) => {
    isConnected: boolean;
    A: GamepadButton | undefined;
    B: GamepadButton | undefined;
    X: GamepadButton | undefined;
    Y: GamepadButton | undefined;
    LB: GamepadButton | undefined;
    RB: GamepadButton | undefined;
    LT: GamepadButton | undefined;
    RT: GamepadButton | undefined;
    SELECT: GamepadButton | undefined;
    START: GamepadButton | undefined;
    UP: GamepadButton | undefined;
    DOWN: GamepadButton | undefined;
    LEFT: GamepadButton | undefined;
    RIGHT: GamepadButton | undefined;
    leftStick: {
        button: GamepadButton | undefined;
        x: number | undefined;
        y: number | undefined;
    };
    rightStick: {
        button: GamepadButton | undefined;
        x: number | undefined;
        y: number | undefined;
    };
};
type GamepadState = ReturnType<typeof getGamepadState>;
type GamepadHandler = (gamepad: GamepadState) => any;
 
const useGamepad: (args: {
    handler: GamepadHandler;
    index?: number;
}) => boolean;