ObsoleteThis 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 technologyCheck 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
.
Syntax
var hardwareID = VRDevice.hardwareUnitId;
Value
A DOMString
containing the ID of the overall hardware unit.
Examples
The following snippet (see our [[../../../../../../../mdn.github.io/webvr-tests/vrdevice/index|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);
}
}
Browser compatibility
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
No support No |
Edge
No support No |
Firefox
No support No |
IE
No support No |
Opera
? |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
? |
Opera Android
? |
Safari iOS
? |
Samsung Internet Android
No support No |
Legend
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
See also
- WebVR API homepage.
- MozVr.com — demos, downloads, and other resources from the Mozilla VR team.
VRDevice.hardwareUnitId by Mozilla Contributors is licensed under CC-BY-SA 2.5.