Back to Events

controllerupdate

The controllerupdate is a VR event which will be fired at every frame if your device has at least one active controller.

The handle function of controllerupdate event takes one argument, an object with one property called states. The states is an array corresponding each controller's detail information, such as id, index, position, orientation, button and axes.

For example, the following is an example of Gamepad controller:

api.player.addTool({
  controllerupdate: function(ev) {
    console.log(ev.states[0]);
  },
});

// will log the following object, output will be different for different controller
/* 
  {
    axes: Array[2], 
    button: Array[4], //four buttons each controller
    id: 'OpenVR Gamepad',
    index: 0,
    orientation: quaternion
    position: 3D vector
  }
*/

See VR Controller Event as an example. Note your device must have controller for this event.