VRDevice

VRDevice provides a common interface for DeviceService. All the basic functions defined in VRDevice.

List

Connect

isConnected returns true if there is a device connected in this slot.

@Override
public boolean isConnected() {
    return true;
}

Note

This is an abstract function and must be implemented.

Configure

setupConfig returns the device configuration data before the connection. It provides the driver information to DeviceService. Check VRDevice.Config.

@Override
public Config setupConfig() {
    Config configure = new Config();
    configure.trackingSystemName = "Mobile Emulator";
    return configure;
}

Note

This is an abstract function and must be implemented.

Lifecycle

onStart()

onStart() will always be called before any display or tracking methods.

@Override
public void onStart() {
    //start to connect to server and data transmission
}

oStop()

oStop() is called when there is no VR APP on background and foreground. The VRDevice object should clean whatever memory and stop all data transmissions.

@Override
public void oStop() {
    //stop connecting to server
}

onPause()

onPause() is called when the VR app goes to the background. This method is typically used to commit unsaved changes to persistent data, stop data transmission, other things that may be consuming CPU resources, and more. Make sure when onPause() is called, all events for the device (e.g.tracker thread) will wait for the onResume() function to be called.

@Override
public void onPause() {
    //stop data transmission
}

onResume()

onResume() is called when the VR app goes to the foreground. When called, all data transmissions to the server will be restarted. Make sure when onResume() is called, all events for the device will be resumed.

@Override
public void onResume() {
    //restart all the transmission
}

Attribute

Define what value you expect to get from different attribute values.

Integer-typed Attribute

getInt() returns an integer attribute. If the attribute is not supported by the device, the device service should return 0 and set the return error type AttributeError.NotSupported.

@Override
public long getInt(int Attr,AttributeError error) {
    switch(Attr)
    {
        case WVR.Attr_BatteryStatus_Int32:
        return WVR.BatteryStatus_Normal;
        //Define the integer attribute return value,
        //when assigned attribute will be called
    }
    error.setResult(AttributeError.NotSupported);
    return 0;
}

Float-typed Attribute

getFloat() returns a float attribute. If the attribute is not supported by the device, the device service should return 0 and set the return error type AttributeError.NotSupported.

@Overriden
public float getFloat(int Attr,AttributeError error) {
    switch(Attr)
    {
        case WVR.Attr_BatteryTemperature_Float:
        return 10f;
        //Define the Float attribute return value,
        //when assigned attribute will be called
    }
    error.setResult(AttributeError.NotSupported);
    return 0;
}

Update Attribute

updateAttribute() this function is called when the device is activated to notify the server if the DeviceService attribute changes.

//If Attr_BatteryTemperatureStatus_Int32 returned value changed,
//call this function.
updateAttribute(WVR.Attr_BatteryTemperatureStatus_Int32);

Attribute return error type

Used to return different typed errors that occur when reading attributes.

Attribute Error
AttributeError.SUCCESS
AttributeError.Unknown
AttributeError.NotSupported

List all the Attribute which is Must or Optional.

Attribute Must or Optional
Attr_DeviceBatteryPercentage_Float Must
Attr_UserIpdMeters_Float Optional
Attr_BatteryStatus_Int32 Must
Attr_ChargeStatus_Int32 Must
Attr_BatteryTemperature_Float Must
Attr_BatteryTemperatureStatus_Int32 Must
Attr_IsReadyRecenter_Bool Optional
Attr_Is6DoFTracking_Bool Must
Attr_IsHWRecenter_Bool Must
Attr_SkinTemperatureStatus_Int32 Optional
Attr_6DofWorkArea_Uint64 Must
Attr_ThresholdNear_Int32 Optional
Attr_ThresholdFar_Int32 Optional

DeviceError

setDeviceErrorStatus() is called to add/remove the device error code to server. Also see WVR.DeviceError

//If device error occur, call this function.
//DeviceService will send event to notify server.
setDeviceErrorStatus(WVR.DeviceError_DeviceConnectFail);

Parameter

setParameters() provides to set a parameter string to the device service. App developer can use WVR_SetParameters function to communicate with DeviceService.

See also WVR_SetParameters.

@Override
 public void setParameters(String keyValue) {
     Debug.Log("setParameters " + keyValue);
     switch (keyValue) {
         case "camera=true":
             Debug.Log("device is support camera " );
             break;
     }
 }

getParameters() provides to get a parameter string from device service. App developer can use WVR_GetParameters function to communicate with DeviceService.

See also WVR_GetParameters.

@Override
public String getParameters(String keyValue) {
    Debug.Log("getParameters " + keyValue);
    switch (keyValue) {
        case "IsDeviceSupportCamera":
            return "true";
     }
    return " ";
}