Class: Gamepad

Gamepad

The Gamepad class enables gamepad input in Input. The Javascript Gamepad API is currently still experimental, hence this input type should be handled with care. Gamepad objects should not be created manually unless you're querying the native gamepad API directly. Otherwise, get them from getGamepads or onGamepadConnected.

The button names for mapping are simply their integer indexes. Similar to axes, but they start from 0x100. For convenience, you can use the Gamepad.A, Gamepad.DPAD_UP, ... enum. The naming of these is based on the default Windows (XBox) and similar controllers. This will only apply if the mapping property is "standard". If the gamepad supports it, button "touches" rather than presses can also be mapped. If the buttons are analog, the communicated values will be between 0 and 1. Alternatively, you can also map "pressed" and "touched" states by providing (buttonName | Gamepad.PRESS) or (buttonName | Gamepad.TOUCH)


new Gamepad()

Properties:
Name Type Description
displayId

The id of the VR display this gamepad is associated with, if any.

id

The gamepad's id.

index

The gamepad's index. This matches the index in the array returned by getGamepads

mapping

The mapping the user agent applies to the buttons. If not "standard", the input may not behave as expected. If this is a specific type of gamepad or controller, you may want to provide custom mapping based on its id.

axisDeadzone

The range for the axes to be considered "0". This assumes a default controller scheme where

hand

Either Gamepad#HAND_LEFT or Gamepad#HAND_RIGHT. Used for VR controllers.

Author:
  • derschmale <http://www.derschmale.com>
See:

Members


<static> A

The bottom button in the right cluster. On PS: Cross.


<static> B

The right button in the right cluster. On PS: Circle.


<static> BACK

The back/select button.


<static> DPAD_DOWN

The down button on the directional pad.


<static> DPAD_LEFT

The left button on the directional pad.


<static> DPAD_RIGHT

The right button on the directional pad.


<static> DPAD_UP

The up button on the directional pad.


<static> L3

The left analog stick pressed down.


<static> LB

The top left trigger/bumper. On PS: L1.


<static> LT

The bottom left trigger. On PS: L2.


<static> PRESS

Combine with a button name to indicate that the action is only interested in the pressed state, not the analog value: gamepad.map(name | Gamepad.PRESSED, "action")


<static> R3

The right analog stick pressed down.


<static> RB

The top right trigger/bumper. On PS: R1.


<static> RT

The bottom right trigger. On PS: R2.


<static> START

The start button.


<static> STICK_LX

The horizontal axis of the left analog stick.


<static> STICK_LY

The vertical axis of the left analog stick.


<static> STICK_RX

The horizontal axis of the right analog stick.


<static> STICK_RY

The vertical axis of the right analog stick.


<static> TOUCH

Combine with a button name to indicate that the action is interested in the touched state, if the gamepad supports this. gamepad.map(name | Gamepad.TOUCHED, "action")


<static> X

The left button in the right cluster. On PS: Square.


<static> Y

The top button in the right cluster. On PS: Triangle.