VRDeviceService

VRDeviceService provides an interface to implement DeviceService, in order to return a tracked (e.g. HMD or controller), such as an HMD, controller, or external device to the server.

Device Class

The device manufacturer needs to provide the vector for VRDevice. The device count and device class must be provided in this function.

// register VRDevice.
@Override
public void onCreate() {
    super.onCreate();
    VRDevice hmdDevice = new HmdDevice(this);
    registerDevice(hmdDevice);
    hmdDevice.connect();
    VRDevice ctrlDevice = new ControllerDevice(this);
    registerDevice(ctrlDevice);
    ctrlDevice.connect();
}

Note

This is an abstract function and must be implemented.

Bind Service

Check the diagram below for the VR DeviceService (onBind, onRebind, onUnbind) flow. If the device manufacturer needs to implement them for their request, the device manufacturer must call super.onBind(intent), super.onRebind(intent).

Runtime will automatically connect the device when super.onBind(intent) and super.onRebind(intent) are called. It will stop the device when super.onUnbind(intent) is called.

_images/DeviceSerice_bind_unbind_onUnBind.png
@Override
public IBinder onBind(Intent intent) {
    return super.onBind(intent);
}

Note

If the onBind function needs to be overridden, it must return super.onBind().

@Override
public void onRebind(Intent intent) {
    return super.onRebind(intent);
}

Note

If the onRebind function needs to be overridden, it must call super.onRebind()

@Override
public boolean onUnbind(Intent intent) {
    return super.onUnbind(intent);
}

Note

If the onUnbind function needs to be overridden, it must call super.onUnbind()

For more details about onBind, onRebind and onUnbind, see com/htc/vr/sdk/pluginkit/package-index and com/htc/vr/sdk/pluginkit/VRDeviceService.