Stemkoski
Stemkoski

Reputation: 9045

Accessing Oculus Go trackpad axis data with A-Frame

I am using A-Frame (current master build), and my goal is to determine the location being touched on an Oculus Go controller. (This is not for moving the camera, so the movement-controls component will not help in this situation.) I have set up a scene containing a text object so that I can view the data while testing on the Oculus Go.

The relevant parts of the scene are:

<a-scene>    
    <a-entity id="textArea" text="data will be displayed here"> </a-entity>
    <a-entity oculus-go-controls updater> </a-entity>
</a-scene>

I am also using the following component, set up to display the data sent to the event handler:

AFRAME.registerComponent('updater', {

init: function()
{
    let textArea = document.querySelector('#textArea');

    this.el.addEventListener("axismove", function(event)
    {
        textArea.setAttribute("text", "value", "axismove: " + JSON.stringify(event) );
    });     
}   

});

However, after moving my thumb on the trackpad, the text object reads:

axismove: {'isTrusted': false}

My understanding based on https://aframe.io/docs/0.8.0/components/tracked-controls.html is that there should be axis data passed in the event. How can I access the axis information?

Upvotes: 1

Views: 433

Answers (1)

Diego Marcos
Diego Marcos

Reputation: 4585

Oculus Go is only supported in the master branch until 0.9.0 ships but you can use it now by pointing your script tag to https://rawgit.com/aframevr/aframe/6888165/dist/aframe-master.min.js

Use the oculus-go-controls component and listen for the trackpadchanged event. The axis values are in the event detail:

  controllerEl.addEventListener(‘trackpadchanged’, function (evt) {
   ...evt.detail...
});

Upvotes: 2

Related Questions