Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The hardwareUnitId
read-only property of the VRDevice
interface returns the distinct hardware ID for the overall hardware unit that this VRDevice
is a part of. All devices that are part of the same physical piece of hardware will have the same hardwareUnitId
.
var hardwareID = VRDevice.hardwareUnitId;
A DOMString
containing the ID of the overall hardware unit.
The following snippet (see our VRDevice example) returns an array of all the VRDevice
s connected to your computer via Navigator.getVRDevices()
. For each connected device it then prints out the hardwareUnitId
, VRDevice.deviceId
, and VRDevice.deviceName
.
var list = document.querySelector('ul'); var info = document.querySelector('p'); if(navigator.getVRDevices) { navigator.getVRDevices().then(function(myDevices) { reportDevices(myDevices); }); } else { info.textContent = 'WebVR API not supported by this browser.' } function reportDevices(devices) { for(i = 0; i < devices.length; i++) { var listItem = document.createElement('li'); listItem.innerHTML = 'Device ' + (i+1) + ': <strong>Hardware ID</strong>: ' + devices[i].hardwareUnitId + ', <strong>VD Device ID</strong>: ' + devices[i].deviceId + ', <strong>VR Device Name</strong>: ' + devices[i].deviceName + '.'; list.appendChild(listItem); } }
Specification | Status | Comment |
---|---|---|
Unknown The definition of 'hardwareUnitId' in that specification. | Unknown | Initial definition |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No | No | No | No | ? | ? |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | No | No | No | ? | No | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/hardwareUnitId