Gamepad Class
Gamepad provides basic support for gamepads.
Some gamepads require a button press to being detected.
Gamepad implementation across browsers is still fragmented, every browser implements it a bit differently, so test it on every target before deploying an application using it.
For more information about the Gamepad API state take look at the W3C Gamepad API page https:// www.w3.org/TR/gamepad/.
Item Index
Methods
Methods
disconnect
()
Disconnect this gamepad object.
getAnalogueButton
-
button
Get analog button value between 0 and 1.
If the button is not analog enabled it will return 0 if button is not pressed or 1 if the button is pressed.
Parameters:
-
button
NumberButton to get analogue value from.
Returns:
Value between 0 and 1 depending how hard the button is pressed.
getAxis
-
Axis
Get axis value between -1 and 1 depending on the direction.
Parameters:
-
Axis
Numberto get value from.
Returns:
Value between -1 and 1 depending on the axis direction
setGamepad
-
Browser
Set which gamepad should be used by this Gamepad instance.
Can be used to override the gamepad attached to this object and enable multiple gamepad support.
Parameters:
-
Browser
Objectgamepad object.
setProductVendor
-
gamepad
Get vendor id and product id for the connected gamepad.
Parameters:
-
gamepad
ObjectGamepad object.
update
()
Update the gamepad state.
Should be called every frame before checking the buttons values.