1

I'm currently using A-Frame to build WebXR (WebVR) applications, and it's not always that I'm able to have the controllers (Oculus Touch, Vive Controls) with me to test them out. Is there a way to "simulate" the events that the different controllers emit?

Jose A
  • 10,053
  • 11
  • 75
  • 108
  • 1
    It currently emulates an older version of the WebVR API, but this may work for you: https://chrome.google.com/webstore/detail/webvr-api-emulation/gbdnpaebafagioggnhkacnaaahpiefil?hl=en – Don McCurdy Jun 01 '18 at 18:34
  • Thanks :) Do I have a way to emulate the controllers with the API emulation? – Jose A Jun 01 '18 at 19:29

1 Answers1

1

I'm not sure about lower levels, but i have an idea on a higher one: If you have your vive controllers, and want to test out oculus touch events, you could do some mapping.

I'd do a component, intercepting the original events, and emitting new ones with the same details:

AFRAME.registerComponent("event-mapper", {
  init: function() {
    let viveEvents = ["menuup", "menudown"]
    let oculusEvents = ["gripdown", "gripup"]
    viveEvents .forEach((event, index) => {
      this.el.addEventListener(event, (e) => {
        this.el.emit(oculusEvents [index], {detail: e})
      })
    })
  }
}

If you want it to be "dynamic" you could use a real Map() instead of two arrays, but here it seems redundant.

Furthermore, by including the detail in the emitted event, all details, values, targets also get passed with the new event.


So when you want your entity to react to the mapped events, you can just do:
<a-entity event-mapper></a-entity>

Check it out in my fiddle (mapped some mouse events, onto made up ones)

Piotr Adam Milewski
  • 14,150
  • 3
  • 21
  • 42
  • Interesting approach :) .By any chance, do the emitted events give you the exact output from the original devices. I mean, will they output the keys and values from the original gripdown event? (Or are they the same?) – Jose A Jun 01 '18 at 17:47
  • shoot, I forgot about the most important part :D I've updated my fiddle + anwser (the way the event is emitted) – Piotr Adam Milewski Jun 01 '18 at 17:56