November 6, 2019 update:
  • There's a new open source Cardboard SDK for iOS and Android NDK that offers a streamlined API, improved device compatibility, and built-in viewer profile QR code scanning. A corresponding Unity package (SDK) is planned for a future release. We recommend that all developers actively building for Google Cardboard migrate (iOS, Android NDK) to the new Cardboard SDK.
October 15, 2019 update:
  • The Daydream View VR headset is no longer available for purchase. However, you can continue to use the existing Google VR SDK to update and distribute your apps to the Google Play Store, and make them available to users in the Daydream app.

ControllerManager

public class ControllerManager

ControllerManager manages the connection to a physical Daydream controller. It talks to the VR Service and creates a Controller object via the getController() method. This class is not thread-safe and should only be accessed on the main thread.

Nested Classes

class ControllerManager.ApiStatus Constants that represent the status of the controller API. 
interface ControllerManager.EventListener Receives VR Service events related to the Daydream controller. 

Public Constructors

Public Methods

Controller
getController(int controllerId)
Gets the Controller identified by the given index.
Controller
void
refreshAllControllers()
Call this when the TrackingConfiguration set by this application has been changed.
void
start()
Connects to the VR Service and begins listening for a Controller connection.
void
stop()
Tears down the connection to the VR Service.

Inherited Methods

Public Constructors

public ControllerManager (Context context, ControllerManager.EventListener listener)

Parameters
context
listener

Public Methods

public Controller getController (int controllerId)

Gets the Controller identified by the given index.

Any controller returned by this will only be valid between calls to start() and stop(). Multiple calls with the same argument will return the same Controller object unless you have called refreshAllControllers(). This is only valid to be called after receiving an OK event.

Parameters
controllerId the index of the controller to use.
Returns
  • the Controller corresponding to the given index, or null if none exists for this index.

public Controller getController ()

Gets a Controller. This can be called at any time, but the controller will only be valid between calls to start() and stop(). Multiple calls will return the same Controller object unless you have called refreshAllControllers().

Returns

public void refreshAllControllers ()

Call this when the TrackingConfiguration set by this application has been changed.

Following this call, all current instances of Controller are no longer valid and have undefined behavior. For each desired controller, getController(int) should be called to obtain a valid controller instance. This is only valid to be called after receiving an OK event.

public void start ()

Connects to the VR Service and begins listening for a Controller connection.

Errors related to this connection are sent via ControllerManager.EventListener. If the connection is successful, the Controller acquired via getController() will receive onConnectionStateChanged(int) events.

public void stop ()

Tears down the connection to the VR Service.