Input events are triggered through controllers like the Daydream Controller or Oculus Gear Touchpad, or through touch input on AR devices. Viro UI controls respond to input events via event handlers in a bubbled up fashion: events are passed up the Node hierarchy until they encounter a Node that can handle and potentially swallow the event.
There are many kinds of events: click, drag, fuse, pinch, rotate, and more. However, not all platforms support all events; it is largely dependent on the controller type. All events originate from a given source. The source identifies which input button is being pressed, and from which controller (for platforms that feature multiple hand-held controllers, for example).
Each Viro event handler callback provides a unique numeric source identifier that corresponds to an input source on the physical controller. You can view a mapping of input source IDs to Gear, Cardboard, and Daydream below.
These methods are used to register listeners to respond to controller-driven events. Events start at the "hovered" (or focused) Node. If that Node cannot respond to the event (e.g. if it does not have the appropriate listener installed), the event will bubble up the scene graph to that Node's parent, and so on, until a Node that can handle the event is found.
All events are also received by the Controller, which provides a centralized place to respond to all events regardless of what Nodes they targeted.
Click events are fired when the user taps while focused on a Node.
Drag events are fired when a Node is being dragged by the user; that is, when the user performs a click down on a Node, holds that click, and then physically moves the controller (or tilts the headset). The view will automatically drag in VR, and as it does so, the DragListener event callback is continually triggered with the latest 3D location of the object. It is also important to note that the DragListener must be assigned to a Node to make that Node draggable.
Hover events are fired when the user moves his or her reticle over a Node, or stops hovering over a Node.
Fuse events are fired when the user hovers his or her reticle over the Node and remain hovered for
timeToFuse milliseconds. The
timeToFuse parameter is optional and is defaulted to 2000ms. This parameter is set via Node.setTimeToFuse(float).
Touch, swipe, and scroll events are fired a Node is touched, swiped, or scrolled using a touchpad by the user; that is, when the user performs an action on a touchpad while hovering on top of the targeted Node. For the scroll listener, the distance the user has scrolled by is given as a unit ratio of the touch pad from 0.0 to 1.0 for both X and Y coordinates. These events are mainly used by the Gear VR platform, which features a touchpad on the headset.
Gesture pinch and rotate events are fired when the user uses multitouch to 'pinch' over a Node or 'swivel' over the Node to create a rotation. These events are used by AR platforms, where the controller is the screen.
At the very least,
Click is guaranteed to be supported across all platforms. However, due to the physical limitations of controllers on each platform, certain events as shown below may not be supported.
|Events||Daydream||GearVR||Android Cardboard||IOS Cardboard||iOS AR||Android AR|
|Fuse||Supported||Supported||Supported||Not Supported||Not Supported||Not Supported|
|Scroll||Supported||Not Supported||Not Supported||Not Supported||Not Supported||Not Supported|
|Swipe||Supported||Supported||Not Supported||Not Supported||Not Supported||Not Supported|
|Touch||Supported||Supported||Not Supported||Not Supported||Not Supported||Not Supported|
|Pinch||Not Supported||Not Supported||Not Supported||Not Supported||Supported||Supported|
|Rotate||Not Supported||Not Supported||Not Supported||Not Supported||Supported||Supported|
Different types of controllers may result in different forms of interactivity or UI. For example, users can easily scroll through galleries with Daydream's touch pad, but additional UI buttons may be needed for Cardboard.
As mentioned above, a unique numeric source identifier that corresponds to an input source on the physical controller. This section will go through the mappings of sources for Cardboard, GearVR and Daydream.
Input Source Value
Primary Cardboard Trigger
Input Source Value
Gear Touch Pad
Gear Back Button
Input Source Value
Daydream App Button
Daydream Home Button
Volume Up Button
Volume Down Button
Updated less than a minute ago