Web/API/Gamepad/displayId

From Get docs

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 Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

displayId

Experimental'Deprecated'

Chrome No support ? — 80

Notes' Disabled'

No support ? — 80

Notes' Disabled'

Notes' Only works on desktop in an experimental version of Chrome (other builds won't return any devices when Navigator.getVRDisplays() is invoked). Disabled' Until version 80 (exclusive): this feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.

Edge

Full support 15

Firefox Full support 55

Notes'

Full support 55

Notes'

Notes' Windows support was enabled in Firefox 55. Full support 64

Notes'

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

Notes'

No support ? — 80

Notes'

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

Notes'

No support ? — 13.0

Notes'

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