Page Summary
-
ControllerManagermanages the connection to a Daydream controller and provides access to aControllerobject. -
It communicates with the VR Service and handles controller connection events.
-
This class is not thread-safe and should be used on the main thread.
-
You can retrieve a
Controllerinstance usinggetController()orgetController(int). -
Use
start()to initiate the connection andstop()to disconnect from the VR service.
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 |
getController()
Gets a
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
Controllercorresponding to the given index, ornullif 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
- a
Controller.
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.