WVR_GetControllerPoseMode

WVR_EXPORT bool WVR_GetControllerPoseMode(WVR_DeviceType type, WVR_ControllerPoseMode * mode)

Function to get current enabled controller pose mode.

Return
True means mode obtained successfully; False means mode obtained unsuccessfully.
Version
API Level 6
Parameters
  • type: Indicates what device type. (refer to WVR_DeviceType). This should be the controller type.
  • mode: Returns the current enabled controller pose mode. (It should not be a null pointer.)

How to use

  1. See also three related functions about controller pose mode

Note

  1. These three functions work only when the configurations of controller pose mode are configured in controller device service.
  2. If the obtained mode offset - translation is (0.0f, 0.0f, 0.0f) and quaternion is (1.0f, 0.0f, 0.0f, 0.0f), it means this mode is not supported. The the controller pose won’t be changed. VR application developer does nothing for controller model.
  1. Here is an example for the function:
#include <wvr/wvr_device.h>
#include <wvr/wvr_events.h>
#include <wvr/wvr_types.h>
 bool gIsOffsetReady = false;

 void ProcessEvent() {
     WVR_Event_t event;
     while(WVR_PollEventQueue(&event)) {
         switch (event.common.type) {
             /* Setp 1. Receive event WVR_EventType_ControllerPoseModeOffsetReady
                        to know the offsets of controller pose mode are ready.*/
             case WVR_EventType_ControllerPoseModeOffsetReady:
                 {
                     gIsOffsetReady = true;
                 }
                 break;

             /* Setp 2. Receive event WVR_EventType_ControllerPoseModeChanged
                        after calling WVR_SetControllerPoseMode.*/
             case WVR_EventType_ControllerPoseModeChanged:
                 {
                     bool result = false;
                     WVR_ControllerPoseMode currMode = WVR_ControllerPoseMode_Raw;

                     // Setp 3. Get current enabled (changed) controller pose mode
                     result = WVR_GetControllerPoseMode(event.device.deviceType, &currMode);
                     LOGI("WVR_GetControllerPoseMode, type(%d), result(%d), mode(%d)", event.device.deviceType, result, currMode);

                     if (result && gIsOffsetReady && currMode != WVR_ControllerPoseMode_Raw) {
                         WVR_Vector3f_t translation;
                         WVR_Quatf_t quaternion;

                         // Setp 4. Get pose offset of current enabled (changed) controller pose mode
                         result = WVR_GetControllerPoseModeOffset(event.device.deviceType, currMode, &translation, &quaternion);

                         LOGI("WVR_GetControllerPoseModeOffset, type(%d), result(%d), mode(%d), transXYZ(%f, %f, %f), quatWXYZ(%f, %f, %f, %f)",
                             event.device.deviceType, result, currMode,
                             translation.v[0], translation.v[1], translation.v[2],
                             quaternion.w, quaternion.x, quaternion.y, quaternion.z);

                         if (result) {
                             /* Setp 5. TODO for VR application developer:
                                If developer does "NOT" use the controller model of HTC Wave VR unity/unreal engine,
                                developer "SOULD" apply this set of controller pose mode offset
                                (translation, quaternion) to self-customized controller model. */
                         }
                     }
                 }
                 break;
         }
     }
}