WVR_GetDefaultControllerRole¶
-
WVR_EXPORT WVR_DeviceType WVR_GetDefaultControllerRole()
Function to get the default controller role that determines the role of the first controller that connects. When the controller role changes, the server will send an WVR_EventType_DeviceRoleChanged event to notify all applications. During this time, applications need to check the controller roles again with this API(WVR_GetDefaultControllerRole).
- Return
- The type of controller role, WVRDeviceType_Controller_Right or WVRDeviceType_Controller_Left. (refer to WVR_DeviceType)
- Version
- API Level 1
How to use¶
Here is an example for the function:
#include <wvr/wvr_types.h>
#include <wvr/wvr_events.h>
// Catch event that is sent from the VR server, device service, or settings app
WVR_Event_t event;
while (WVR_PollEventQueue(&event)) {
switch (event.common.type) {
…
case WVR_EventType_DeviceRoleChanged:
//Perform an action when the controller role changes
WVR_DeviceType role = WVR_GetDefaultControllerRole(); // get default controller role
if ( role == WVR_DeviceType_Controller_Right ) {
// first controller is right hand
…
} else if ( role == WVR_DeviceType_Controller_Left ) {
// first controller is left hand
…
}
if (WVR_IsDeviceConnected(role)) {
WVR_PoseState_t pose;
WVR_GetPoseState(role, WVR_PoseOriginModel_OriginOnHead, 0, &pose);
}
break;
…
}
}