This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The displayId
read-only property of the Gamepad
interface returns the VRDisplay.displayId
of the associated VRDisplay
— the VRDisplay
that the gamepad is controlling the displayed scene of.
A Gamepad is considered to be associated with a VRDisplay
if it reports a pose that is in the same space as the VRDisplay.pose
.
Syntax
var myDisplayId = gamepadInstance.displayId;
Value
A number representing the associated VRDisplay.displayId
. If the number is 0, then the gamepad is not associated with a VR display.
Examples
window.addEventListener("gamepadconnected", function(e) {
if(!e.gamepad.displayId) {
console.log('Gamepad connected');
} else {
console.log('Gamepad connected, associated with VR display ' + e.gamepad.displayId);
}
});
Specifications
Specification | Status | Comment |
---|---|---|
WebVR 1.1 The definition of 'displayId' in that specification. |
Draft | Initial definition |
Browser compatibility
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
displayId | Chrome
Full support
Yes
| Edge Full support 15 | Firefox
Full support
55
| IE No support No | Opera ? | Safari No support No | WebView Android No support No | Chrome Android
Full support
Yes
| Firefox Android Full support 55 | Opera Android ? | Safari iOS No support No | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
See also
- WebVR API homepage
- MozVr.com — demos, downloads, and other resources from the Mozilla VR team.