I'm trying to find out if there is a way to determine which Vive controller is being used when there is only a single one. With OpenVR this information is available. I'm wondering if this is possible with A-Frame?
Asked
Active
Viewed 270 times
1 Answers
0
When you set the controllers, you set the handedness:
<a-entity id="leftHand" vive-controls="hand: left"></a-entity>
<a-entity id="rightHand" vive-controls="hand: right"></a-entity>
Just see which one of those hands becomes active. You could check its position/rotation are non-zero. Or in the upcoming release, you could do like:
AFRAME.registerComponent('controller-connected', {
init: function () {
var el = this.el;
el.addEventListener('controllerconnected', function (evt) {
console.log(evt.detail.component.data.hand);
// Or... console.log(el.getAttribute(evt.detail.name).hand)
});
}
});
<a-entity controller-connected id="leftHand" vive-controls="hand: left"></a-entity>
<a-entity controller-connected id="rightHand" vive-controls="hand: right"></a-entity>
A-Frame currently uses just the index of the Gamepad array to determine left/right. To manually check which controller is connected, you can call the Gamepad API:
navigator.getGamepads();

ngokevin
- 12,980
- 2
- 38
- 84
-
Also notice that on Vive, handneness is not pre assigned to a specific controller (as oppose to Oculus Touch) but determined at run time depending on the relative position of the controller to the head. – Diego Marcos May 25 '17 at 12:43