Most visited

Recently visited

Controller

public class Controller
extends Object

java.lang.Object
   ↳ com.viro.core.Controller


Controller represents the UI through which the user interacts with the Scene. The exact form of Controller depends on the underlying platform. For example, for Daydream this represents the Daydream controller (the laser pointer). For Cardboard and GearVR, Controller is effectively the head-mounted display itself (and its tap button).

Controllers are also able to listen to all events. The Controller is is notified of all events that occur within the Scene, regardless of what Node those events are associated with (with the exception of Hover events). This is useful if you wish to be alerted of all events occurring in the Scene in a centralized place.

Controller should not be constructed by your app. It is retrieved via getController().

For an extended discussion on Controller types and input events, refer to the Input Event Guide.

Summary

Public methods

void dispose()

Release native resources associated with this Controller.

ClickListener getClickListener()

Get the ClickListener that is currently installed for this Controller.

ControllerStatusListener getControllerStatusListener()

Get the ControllerStatusListener that is currently installed for this Controller.

DragListener getDragListener()

Get the DragListener that is currently installed for this Controller.

Vector getForwardVector()

Get the direction in which the Controller is pointing.

FuseListener getFuseListener()

Get the FuseListener that is currently installed for this Controller.

GesturePinchListener getGesturePinchListener()

Get the GesturePinchListener that is currently installed for this Controller.

GestureRotateListener getGestureRotateListener()

Get the GestureRotateListener that is currently installed for this Controller.

TouchpadScrollListener getTouchpadScrollListener()

Get the TouchpadScrollListener that is currently installed for this Controller.

TouchpadSwipeListener getTouchpadSwipeListener()

Get the TouchpadSwipeListener that is currently installed for this Controller.

TouchpadTouchListener getTouchpadTouchListener()

Get the TouchpadTouchListener that is currently installed for this Controller.

boolean isControllerVisible()

Returns true if the Controller is currently visible.

boolean isReticleVisible()

Returns true if the reticle is currently visible.

void setClickListener(ClickListener listener)

Set a ClickListener to respond when users click with the Controller.

void setControllerStatusListener(ControllerStatusListener listener)

Set the ControllerStatusListener to respond when a Controller connects, disconnects, or enters an error state.

void setControllerVisible(boolean visible)

Set the controller to visible or invisible.

void setDragListener(DragListener listener)

Set the DragListener to respond when a user attempts to drag a Node.

void setFuseListener(FuseListener listener)

Set the FuseListener to respond when a user hovers over a Node long enough to cause a fuse.

void setGesturePinchListener(GesturePinchListener listener)

Set the GesturePinchListener to respond when a user pinches with two fingers over a Node using a screen Controller.

void setGestureRotateListener(GestureRotateListener listener)

Set the GestureRotateListener to respond when a user rotates with two fingers over a Node using a screen Controller.

void setReticleVisible(boolean visible)

Set the reticle visibility on or off.

void setTouchpadScrollListener(TouchpadScrollListener listener)

Set the TouchpadScrollListener to respond when a user scrolls a touchpad.

void setTouchpadSwipeListener(TouchpadSwipeListener listener)

Set the TouchpadSwipeListener to respond when a user swipes across a touchpad Controller.

void setTouchpadTouchListener(TouchpadTouchListener listener)

Set the TouchpadTouchListener to respond when a user touches or moves across a touchpad Controller.

Public methods

dispose

void dispose ()

Release native resources associated with this Controller.

getClickListener

ClickListener getClickListener ()

Get the ClickListener that is currently installed for this Controller.

Returns
ClickListener The installed listener, or null if none is installed.

getControllerStatusListener

ControllerStatusListener getControllerStatusListener ()

Get the ControllerStatusListener that is currently installed for this Controller.

Returns
ControllerStatusListener The installed listener, or null if none is installed.

getDragListener

DragListener getDragListener ()

Get the DragListener that is currently installed for this Controller.

Returns
DragListener The installed listener, or null if none is installed.

getForwardVector

Vector getForwardVector ()

Get the direction in which the Controller is pointing. For Daydream devices this returns the direction the pointer if pointing, and for other devices it returns the direction the user is facing (e.g. in the direction of the reticle).

Returns
Vector The direction the Controller is pointing.

getFuseListener

FuseListener getFuseListener ()

Get the FuseListener that is currently installed for this Controller.

Returns
FuseListener The installed listener, or null if none is installed.

getGesturePinchListener

GesturePinchListener getGesturePinchListener ()

Get the GesturePinchListener that is currently installed for this Controller.

Returns
GesturePinchListener The installed listener, or null if none is installed.

getGestureRotateListener

GestureRotateListener getGestureRotateListener ()

Get the GestureRotateListener that is currently installed for this Controller.

Returns
GestureRotateListener The installed listener, or null if none is installed.

getTouchpadScrollListener

TouchpadScrollListener getTouchpadScrollListener ()

Get the TouchpadScrollListener that is currently installed for this Controller.

Returns
TouchpadScrollListener The installed listener, or null if none is installed.

getTouchpadSwipeListener

TouchpadSwipeListener getTouchpadSwipeListener ()

Get the TouchpadSwipeListener that is currently installed for this Controller.

Returns
TouchpadSwipeListener The installed listener, or null if none is installed.

getTouchpadTouchListener

TouchpadTouchListener getTouchpadTouchListener ()

Get the TouchpadTouchListener that is currently installed for this Controller.

Returns
TouchpadTouchListener The installed listener, or null if none is installed.

isControllerVisible

boolean isControllerVisible ()

Returns true if the Controller is currently visible.

Returns
boolean True if the Controller is visible.

isReticleVisible

boolean isReticleVisible ()

Returns true if the reticle is currently visible.

Returns
boolean True if the reticle is visible.

setClickListener

void setClickListener (ClickListener listener)

Set a ClickListener to respond when users click with the Controller.

Parameters
listener ClickListener: The listener to attach, or null to remove any installed listener.

setControllerStatusListener

void setControllerStatusListener (ControllerStatusListener listener)

Set the ControllerStatusListener to respond when a Controller connects, disconnects, or enters an error state.

Parameters
listener ControllerStatusListener: The listener to attach, or null to remove any installed listener.

setControllerVisible

void setControllerVisible (boolean visible)

Set the controller to visible or invisible. This currently only applies to the Daydream platform, and determines whether the Daydream controller is displayed on the screen.

Defaults to true.

Parameters
visible boolean: True to display the controller.

setDragListener

void setDragListener (DragListener listener)

Set the DragListener to respond when a user attempts to drag a Node.

Parameters
listener DragListener: The listener to attach, or null to remove any installed listener.

setFuseListener

void setFuseListener (FuseListener listener)

Set the FuseListener to respond when a user hovers over a Node long enough to cause a fuse.

Parameters
listener FuseListener: The listener to attach, or null to remove any installed listener.

setGesturePinchListener

void setGesturePinchListener (GesturePinchListener listener)

Set the GesturePinchListener to respond when a user pinches with two fingers over a Node using a screen Controller.

Parameters
listener GesturePinchListener: The listener to attach, or null to remove any installed listener.

setGestureRotateListener

void setGestureRotateListener (GestureRotateListener listener)

Set the GestureRotateListener to respond when a user rotates with two fingers over a Node using a screen Controller.

Parameters
listener GestureRotateListener: The listener to attach, or null to remove any installed listener.

setReticleVisible

void setReticleVisible (boolean visible)

Set the reticle visibility on or off. The reticle is the small pointer that appears at the center of the screen, which is useful for tapping and fusing on objects.

Defaults to true.

Parameters
visible boolean: True to make the reticle visible, false to make it invisible.

setTouchpadScrollListener

void setTouchpadScrollListener (TouchpadScrollListener listener)

Set the TouchpadScrollListener to respond when a user scrolls a touchpad.

Parameters
listener TouchpadScrollListener: The listener to attach, or null to remove any installed listener.

setTouchpadSwipeListener

void setTouchpadSwipeListener (TouchpadSwipeListener listener)

Set the TouchpadSwipeListener to respond when a user swipes across a touchpad Controller.

Parameters
listener TouchpadSwipeListener: The listener to attach, or null to remove any installed listener.

setTouchpadTouchListener

void setTouchpadTouchListener (TouchpadTouchListener listener)

Set the TouchpadTouchListener to respond when a user touches or moves across a touchpad Controller.

Parameters
listener TouchpadTouchListener: The listener to attach, or null to remove any installed listener.

Hooray!