This is an experimental technologyCheck 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.1The definition of 'displayId' in that specification. | Draft | Initial definition |
Browser compatibility
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome No support ? — 80 No support ? — 80 Notes' Only works on desktop in an experimental version of Chrome (other builds won't return any devices when |
Edge
Full support 15 |
Firefox Full support 55 Full support 55 Notes' Windows support was enabled in Firefox 55. Full support 64 Notes' macOS support was enabled in Firefox 64. |
IE
No support No |
Opera
? |
Safari
No support No |
WebView Android
No support No |
Chrome Android No support ? — 80 No support ? — 80 Notes' Currently supported only by Google Daydream. |
Firefox Android
Full support 55 |
Opera Android
? |
Safari iOS
No support No |
Samsung Internet Android No support ? — 13.0 No support ? — 13.0 Notes' Currently supported only by Google Daydream. |
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.
Gamepad.displayId by Mozilla Contributors is licensed under CC-BY-SA 2.5.