Gamepad.displayId

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
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support Yes
Notes Disabled
Full support Yes
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 This feature is behind the WebVR preference. To change preferences in Chrome, visit chrome://flags.
Edge Full support 15Firefox Full support 56
Notes
Full support 56
Notes
Notes Currently only Windows support is enabled by default. Mac support is available in Firefox Nightly.
IE No support NoOpera ? Safari ? WebView Android No support NoChrome Android Full support Yes
Notes
Full support Yes
Notes
Notes Currently supported only by Google Daydream.
Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? 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.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills
Last updated by: fscholz,