Confirmed users
656
edits
| Line 128: | Line 128: | ||
The Joystick object's properties include: | The Joystick object's properties include: | ||
* id : a unique id (string) for the joystick. | * '''id''': a unique id (string) for the joystick. | ||
* connected : true if the joystick is still connected to the system. | * '''connected''': true if the joystick 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 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). | ||
The Joystick 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 joystick or joysticks. | The Joystick 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 joystick or joysticks. | ||