0

For my A-Frame WebVR game, I need to access a single "controller" button, regardless of platform. For a phone using a magic window or Google Cardboard, any screen tap would count. For Gear VR or Daydream, any button on the controller would count. For a PC VR rig, any button on either controller would count.

Don McCurdy's universal-controls (https://github.com/donmccurdy/aframe-extras/tree/master/src/controls) would seem to be relevant, yet it's not clear how I could use it to do what I want.

I could also go access the GamePad API directly, and separately detect screen taps.

What's the best way to proceed?

Doug Reeder
  • 698
  • 6
  • 12

2 Answers2

0

Perhaps the input mapping system, from Fernando Serrano could help: https://blog.mozvr.com/input-mapping/

Noam Almosnino
  • 866
  • 1
  • 6
  • 8
0

It turns out, if you want to treat all buttons alike, it's easier to listen for the buttonchanged event on the controls entity.

As Noam kindly pointed out, aframe-input-mapping-component is great for general mapping of buttons to actions.

[edit] I've created aframe-button-controls to handle this.

Doug Reeder
  • 698
  • 6
  • 12