Gamepad holds state information for a connected controller. See Gamepads for more information on handling controller input.

Hierarchy

  • Gamepad

Constructors

Properties

connected: boolean = false
events: EventEmitter<GamepadEvents> = ...
navigatorGamepad: NavigatorGamepad

Methods

  • Type Parameters

    • TEventName extends EventKey<GamepadEvents>

    Parameters

    • eventName: TEventName
    • event: GamepadEvents[TEventName]

    Returns void

  • Parameters

    • eventName: string
    • Optional event: any

    Returns void

  • Gets the given axis value between -1 and 1. Values below MinAxisMoveThreshold are considered 0.

    Parameters

    Returns number

  • Tests if a certain button is held down. This is persisted between frames.

    Parameters

    • button: Buttons

      The button to query

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • Whether or not the given button is pressed

    Deprecated

    will be removed in v0.28.0. Use isButtonHeld instead

    Parameters

    • button: Buttons

      The button to query

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • Type Parameters

    • TEventName extends EventKey<GamepadEvents>

    Parameters

    • eventName: TEventName
    • handler: Handler<GamepadEvents[TEventName]>

    Returns void

  • Parameters

    • eventName: string
    • handler: Handler<unknown>

    Returns void

  • Parameters

    • eventName: string

    Returns void

  • Parameters

    • axesIndex: number
    • value: number

    Returns void

  • Parameters

    • buttonIndex: number
    • value: number

    Returns void

  • Tests if a certain button was just pressed this frame. This is cleared at the end of the update frame.

    Parameters

    • button: Buttons

      Test whether a button was just pressed

    • threshold: number = 1

      The threshold over which the button is considered to be pressed

    Returns boolean

  • Tests if a certain button was just released this frame. This is cleared at the end of the update frame.

    Parameters

    • button: Buttons

      Test whether a button was just released

    Returns boolean