PokéRogue
    Preparing search index...

    Represents a single connected gamepad controller. Each Gamepad contains Button and Axis objects that are automatically created and updated by the Gamepad Plugin. You can access the directional sticks via the leftStick and rightStick Vector2 properties, individual buttons via the buttons array, and axes via the axes array. Gamepads are typically accessed through this.input.gamepad.pad1 through pad4 in a Scene.

    Hierarchy (View Summary)

    Index
    • Parameters

      • manager: GamepadPlugin

        A reference to the Gamepad Plugin.

      • pad: Pad

        The Gamepad object, as extracted from GamepadEvent.

      Returns Gamepad

    A: boolean

    Is the Gamepad's bottom button in the right button cluster being pressed? If the Gamepad doesn't have this button it will always return false. On a Dual Shock controller it's the X button. On an XBox controller it's the A button.

    axes: Axis[]

    An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any.

    B: boolean

    Is the Gamepad's right button in the right button cluster being pressed? If the Gamepad doesn't have this button it will always return false. On a Dual Shock controller it's the Circle button. On an XBox controller it's the B button.

    buttons: Button[]

    An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad.

    connected: boolean

    Is this Gamepad currently connected or not?

    down: boolean

    Is the Gamepad's Down button being pressed? If the Gamepad doesn't have this button it will always return false. This is the d-pad down button under standard Gamepad mapping.

    id: string

    A string containing some information about the controller.

    This is not strictly specified, but in Firefox it will contain three pieces of information separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and product id of the controller, and the name of the controller as provided by the driver. In Chrome it will contain the name of the controller as provided by the driver, followed by vendor and product 4-digit hexadecimal strings.

    index: number

    An integer that is unique for each Gamepad currently connected to the system. This can be used to distinguish multiple controllers. Note that disconnecting a device and then connecting a new device may reuse the previous index.

    L1: number

    Returns the value of the Gamepad's top left shoulder button. If the Gamepad doesn't have this button it will always return zero. The value is a float between 0 and 1, corresponding to how depressed the button is. On a Dual Shock controller it's the L1 button. On an XBox controller it's the LB button.

    L2: number

    Returns the value of the Gamepad's bottom left shoulder button. If the Gamepad doesn't have this button it will always return zero. The value is a float between 0 and 1, corresponding to how depressed the button is. On a Dual Shock controller it's the L2 button. On an XBox controller it's the LT button.

    left: boolean

    Is the Gamepad's Left button being pressed? If the Gamepad doesn't have this button it will always return false. This is the d-pad left button under standard Gamepad mapping.

    leftStick: Vector2

    A Vector2 containing the most recent values from the Gamepad's left axis stick. This is updated automatically as part of the Gamepad.update cycle. The H Axis is mapped to the Vector2.x property, and the V Axis to the Vector2.y property. The values are based on the Axis thresholds. If the Gamepad does not have a left axis stick, the values will always be zero.

    manager: GamepadPlugin

    A reference to the Gamepad Plugin.

    pad: any

    A reference to the native Gamepad object that is connected to the browser.

    R1: number

    Returns the value of the Gamepad's top right shoulder button. If the Gamepad doesn't have this button it will always return zero. The value is a float between 0 and 1, corresponding to how depressed the button is. On a Dual Shock controller it's the R1 button. On an XBox controller it's the RB button.

    R2: number

    Returns the value of the Gamepad's bottom right shoulder button. If the Gamepad doesn't have this button it will always return zero. The value is a float between 0 and 1, corresponding to how depressed the button is. On a Dual Shock controller it's the R2 button. On an XBox controller it's the RT button.

    right: boolean

    Is the Gamepad's Right button being pressed? If the Gamepad doesn't have this button it will always return false. This is the d-pad right button under standard Gamepad mapping.

    rightStick: Vector2

    A Vector2 containing the most recent values from the Gamepad's right axis stick. This is updated automatically as part of the Gamepad.update cycle. The H Axis is mapped to the Vector2.x property, and the V Axis to the Vector2.y property. The values are based on the Axis thresholds. If the Gamepad does not have a right axis stick, the values will always be zero.

    timestamp: number

    A timestamp containing the most recent time this Gamepad was updated.

    up: boolean

    Is the Gamepad's Up button being pressed? If the Gamepad doesn't have this button it will always return false. This is the d-pad up button under standard Gamepad mapping.

    The Gamepad's Haptic Actuator (Vibration / Rumble support). This is highly experimental and only set if both present on the device, and exposed by both the hardware and browser.

    X: boolean

    Is the Gamepad's left button in the right button cluster being pressed? If the Gamepad doesn't have this button it will always return false. On a Dual Shock controller it's the Square button. On an XBox controller it's the X button.

    Y: boolean

    Is the Gamepad's top button in the right button cluster being pressed? If the Gamepad doesn't have this button it will always return false. On a Dual Shock controller it's the Triangle button. On an XBox controller it's the Y button.

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • Destroys this Gamepad instance, its buttons and axes, and releases external references it holds.

      Returns void

    • Calls each of the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • ...args: any[]

        Additional arguments that will be passed to the event handler.

      Returns boolean

      true if the event had listeners, else false.

    • Return an array listing the events for which the emitter has registered listeners.undefined

      Returns (string | symbol)[]

      undefined

    • Gets the total number of axis this Gamepad claims to support.undefined

      Returns number

      The total number of axes this Gamepad claims to support.

    • Gets the value of an axis based on the given index. The index must be valid within the range of axes supported by this Gamepad. The return value will be a float between -1 and 1.

      Parameters

      • index: number

        The index of the axes to get the value for.

      Returns number

      The value of the axis, between -1 and 1.

    • Gets the total number of buttons this Gamepad claims to have.undefined

      Returns number

      The total number of buttons this Gamepad claims to have.

    • Gets the value of a button based on the given index. The index must be valid within the range of buttons supported by this Gamepad.

      The return value will be either 0 or 1 for a digital button, or a float between 0 and 1 for a pressure-sensitive analogue button, such as the shoulder buttons on a Dual Shock.

      Parameters

      • index: number

        The index of the button to get the value for.

      Returns number

      The value of the button, between 0 and 1.

    • Returns if the button is pressed down or not. The index must be valid within the range of buttons supported by this Gamepad.

      Parameters

      • index: number

        The index of the button to get the value for.

      Returns boolean

      true if the button is considered as being pressed down, otherwise false.

    • Return the number of listeners listening to a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns number

      The number of listeners.

    • Return the listeners registered for a given event.

      Parameters

      • event: string | symbol

        The event name.

      Returns Function[]

      The registered listeners.

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

      this.

    • Add a listener for a given event.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • Add a one-time listener for a given event. The listener is automatically removed the first time the event is emitted, so it will never be called more than once.

      Parameters

      • event: string | symbol

        The event name.

      • fn: Function

        The listener function.

      • Optionalcontext: any

        The context to invoke the listener with. Default this.

      Returns this

      this.

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: string | symbol

        The event name.

      Returns this

      this.

    • Remove the listeners of a given event.

      Parameters

      • event: string | symbol

        The event name.

      • Optionalfn: Function

        Only remove the listeners that match this function.

      • Optionalcontext: any

        Only remove the listeners that have this context.

      • Optionalonce: boolean

        Only remove one-time listeners.

      Returns this

      this.

    • Sets the threshold value of all axis on this Gamepad. The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved.

      Parameters

      • value: number

        A value between 0 and 1.

      Returns void

    • Removes all listeners from this EventEmitter. This method is called automatically by the Scene Systems when the parent Scene shuts down, ensuring that all event bindings are cleared and no stale references remain.

      Returns void