GamepadAPI: Difference between revisions

182 bytes added ,  15 November 2011
Adding a note about the index property
(Wiki syntax is the worst)
(Adding a note about the index property)
Line 132: Line 132:
* '''id''': a unique id (string) for the gamepad.
* '''id''': a unique id (string) for the gamepad.
* '''connected''': true if the gamepad is still connected to the system.
* '''connected''': true if the gamepad is still connected to the system.
* '''buttons''': an array of the buttons present on the device. Each entry in the array is 0 if the button is not pressed, and non-zero if the button is pressed.
* '''buttons''': an array of the buttons present on the device. Each entry in the array is 0 if the button is not pressed, and non-zero (typically 1.0) if the button is pressed.
* '''axes''': an array of the axes present on the device. Each entry in the array is a float value in the range -1.0..1.0 representing the axis position from the lowest value (-1.0) to the highest value (1.0).
* '''axes''': an array of the axes present on the device. Each entry in the array is a float value in the range -1.0..1.0 representing the axis position from the lowest value (-1.0) to the highest value (1.0).
* '''index''': a unique auto-incrementing number for each gamepad connected to the system. A gamepad that is disconnected and reconnected will retain the same index.


The Gamepad object is often used in conjunction with an animation loop (e.g., requestAnimationFrame), where developers want to make decisions for the current frame based on the state of the gamepad or gamepads.
The Gamepad object is often used in conjunction with an animation loop (e.g., requestAnimationFrame), where developers want to make decisions for the current frame based on the state of the gamepad or gamepads.
Confirmed users
49

edits