Class to handle displaying the state of a gamepad on the screen. This class will not draw anything to the screen. Instead it will update the classes / transforms of the elements you provide to represent the buttons and axes of the gamepad. See the examples for more information.

Hierarchy

  • GamepadDisplay

Constructors

Properties

apiWrapper: GamepadApiWrapper
axisChangeListener: ((gpadIndex: number, gpadState: Gamepad, axisChangesMask: boolean[]) => void)

Type declaration

    • (gpadIndex: number, gpadState: Gamepad, axisChangesMask: boolean[]): void
    • Parameters

      • gpadIndex: number
      • gpadState: Gamepad
      • axisChangesMask: boolean[]

      Returns void

btnChangeListener: ((gpadIndex: number, gpadState: Gamepad, buttonChangesMask: (false | buttonChangeDetails)[]) => void)

Type declaration

    • (gpadIndex: number, gpadState: Gamepad, buttonChangesMask: (false | buttonChangeDetails)[]): void
    • Parameters

      Returns void

Methods

  • Cleanup function to remove all event listeners created by the GamepadDisplay Call this function before removing the gamepad display from the DOM or deleting the GamepadDisplay instance to prevent memory leaks

    Returns void

  • Function called by default when any gamepad buttons change (called separately for each button (as configured in this GamepadDisplay)) If you specify your own buttonDisplayFunction in the config, this function won't get called. Instead, you can call this function with the same parameters as passed to the buttonDisplayFunction if you want to keep the default behaviour (and then you can add your own custom behaviour on top)

    Parameters

    Returns void

  • Function called by default when the gamepad axies change for a joystick (as configured in this GamepadDisplay) If you specify your own joystickDisplayFunction in the config, this function won't get called. Instead, you can call this function with the same parameters as passed to the joystickDisplayFunction if you want to keep the default behaviour (and then you can add your own custom behaviour on top)

    Parameters

    Returns void

  • This function is registered as the callback for GamepadApiWrapper.onGamepadButtonChange it calls the buttonDisplayFunction (if specified) or the DisplayGamepad.defaultButtonDisplayFunction otherwise for every button that has changed since the last update

    Returns

    Parameters

    • gpadIndex: number

      The index of the gamepad that has changed

    • gpadState: Gamepad

      The new state of the gamepad as reported by the browser / GamepadApiWrapper.onGamepadButtonChange

    • buttonChangesMask: (false | buttonChangeDetails)[]

    Returns void

  • This function is registered as the callback for GamepadApiWrapper.onGamepadAxisChange it calls the joystickDisplayFunction (if specified) or the DisplayGamepad.defaultJoystickDisplayFunction otherwise for each configured joystick with axies that have changed

    Parameters

    • gpadIndex: number

      The index of the gamepad that has changed

    • gpadState: Gamepad

      The new state of the gamepad as reported by the browser / GamepadApiWrapper.onGamepadAxisChange

    • axisChangesMask: boolean[]

      An array of booleans, where each true indicates that the corresponding axis has changed since the last update

    Returns void

Generated using TypeDoc