Confirmed users
53
edits
(Adding a note about the index property) |
(Notes about the index property) |
||
| Line 259: | Line 259: | ||
readonly attribute nsIVariant buttons; | readonly attribute nsIVariant buttons; | ||
readonly attribute nsIVariant axes; | readonly attribute nsIVariant axes; | ||
readonly attribute unsigned long index; | |||
}; | }; | ||
</pre> | </pre> | ||
| Line 269: | Line 270: | ||
The '''axe''' attribute is an array of all the axes present on the device. Each entry in the array is a float value in the range -1.0 to 1.0, representing the axis position from the lowest value (-1.0) to the highest value (1.0). Each physical stick on a gamepad will expose two axes, one for changes in X (left-right), and the other for changes in Y (up-down) positioning. | The '''axe''' attribute is an array of all the axes present on the device. Each entry in the array is a float value in the range -1.0 to 1.0, representing the axis position from the lowest value (-1.0) to the highest value (1.0). Each physical stick on a gamepad will expose two axes, one for changes in X (left-right), and the other for changes in Y (up-down) positioning. | ||
The '''index''' attribute is a unique auto-incrementing number for each gamepad connected to the system. If a gamepad is disconnected and reconnected, it will retain the same index number. | |||
The lifetime of an nsIDOMGamepad object is more than the lifetime of a '''MozGamepad*''' event. Web content may save a reference to a '''MozGamepad*''' event's '''gamepad''' property and refer to it at any time to determine the current state of the device. The state will not be updated while the content script is executing, only between script executions. For example, the state will not be updated during the course of a setTimeout callback, but it may be updated the next time the callback is called. | The lifetime of an nsIDOMGamepad object is more than the lifetime of a '''MozGamepad*''' event. Web content may save a reference to a '''MozGamepad*''' event's '''gamepad''' property and refer to it at any time to determine the current state of the device. The state will not be updated while the content script is executing, only between script executions. For example, the state will not be updated during the course of a setTimeout callback, but it may be updated the next time the callback is called. | ||