Scott Witte
Scott Witte

Reputation: 389

Can a Web App access Oculus Proximity Sensor?

Is there a way to set a JS eventlistener on the state of the Oculus or Gear VR proximity sensor? My goal is to detect when someone has removed the headset? This will be used to trigger a reset of the web app to its initial state, ready for the next user. For instance, it might call location.reload().

Upvotes: 0

Views: 147

Answers (1)

Dominic Cooney
Dominic Cooney

Reputation: 6535

The proximity sensor is not available to web pages as far as I know.

Does your scenario happen in the browser without opening new tabs? You could use the page visibility API:

<!DOCTYPE html>
<script>
document.addEventListener('visibilitychange', (e) => {
  document.body.append(Date() + ' head set is ' + (document.hidden ? 'off' : 'on'));
  document.body.append(document.createElement('br'));
});
</script>

Upvotes: 0

Related Questions