WVR_PollEventQueue¶
- WVR_EXPORT bool WVR_PollEventQueue(WVR_Event_t * event)
Function to get next event in event queue.
- Return
- true means fill event struct with the next event in the queue, false means no event in the queue
- Parameters
- event -
a struct of Event information
- event -
The WVR SDK WVR_Event has 4 categories for WVR_Event include
- union WVR_Event¶
- #include <wvr_events.h>
WVR_Event, event type has been designed as union type to provide an efficient way of using the same memory location for different event type. Developer can get the same member type to know the gotten event belongs to which WVR_Event type, then get the specific memory region.
- WVR_CommonEvent
- struct WVR_CommonEvent¶
Common Event, including WVR_EventType, timestamp.
Public Members
- WVR_EventType type¶
The types of event
- int64_t timestamp¶
Delivered time in nanoseconds.
- WVR_DeviceEvent
- struct WVR_DeviceEvent¶
Device Event, including WVR_EventType, timestamp, WVR_DeviceType.
- WVR_InputEvent
- struct WVR_InputEvent¶
Input Event, including WVR_EventType, timestamp, WVR_DeviceType, WVR_InputId.
- WVR_ErrorStatusEvent
- struct WVR_ErrorStatusEvent¶
Error Status Event, including WVR_EventType, timestamp, WVR_DeviceType, WVR_DeviceErrorStatus.
- WVR_TrackingModeEvent
- struct WVR_TrackingModeEvent¶
Tracking mode setting changed Event, including WVR_EventType, timestamp, 3dof/6dof tracking mode.
Public Members
- WVR_CommonEvent_t common¶
The info of Common Event (refer to WVR_CommonEvent)
- WVR_NumDoF trackingMode¶
The changed tracking mode (3 DoF/6 DoF)
The following table shows each WVR_EventType which belongs to WVR_Event.
WVR_EventType | WVR_Event |
---|---|
WVR_EventType_Quit | WVR_CommonEvent |
WVR_EventType_DeviceConnected | WVR_DeviceEvent |
WVR_EventType_DeviceDisconnected | WVR_DeviceEvent |
WVR_EventType_DeviceStatusUpdate | WVR_DeviceEvent |
WVR_EventType_IpdChanged | WVR_CommonEvent |
WVR_EventType_DeviceSuspend | WVR_DeviceEvent |
WVR_EventType_DeviceResume | WVR_DeviceEvent |
WVR_EventType_DeviceRoleChanged | WVR_DeviceEvent |
WVR_EventType_BatteryStatus_Update | WVR_DeviceEvent |
WVR_EventType_ChargeStatus_Update | WVR_DeviceEvent |
WVR_EventType_DeviceErrorStatus_Update | WVR_ErrorStatusEvent |
WVR_EventType_BatteryTemperatureStatus_Update | WVR_DeviceEvent |
WVR_EventType_RecenterSuccess | WVR_DeviceEvent |
WVR_EventType_RecenterFail | WVR_DeviceEvent |
WVR_EventType_RecenterSuccess_3DoF | WVR_DeviceEvent |
WVR_EventType_RecenterFail_3DoF | WVR_DeviceEvent |
WVR_EventType_TouchpadSwipe_LeftToRight | WVR_InputEvent |
WVR_EventType_TouchpadSwipe_RightToLeft | WVR_InputEvent |
WVR_EventType_TouchpadSwipe_DownToUp | WVR_InputEvent |
WVR_EventType_TouchpadSwipe_UpToDown | WVR_InputEvent |
WVR_EventType_Settings_Controller | WVR_CommonEvent |
WVR_EventType_ButtonPressed | WVR_InputEvent |
WVR_EventType_ButtonUnpressed | WVR_InputEvent |
WVR_EventType_TouchTapped | WVR_InputEvent |
WVR_EventType_TouchUntapped | WVR_InputEvent |
WVR_EventType_TrackingModeChanged | WVR_CommonEvent |
How to use¶
Here is an example for the function:
#include <wvr/wvr_events.h>
void ProcessEvent() {
WVR_Event_t event;
while(WVR_PollEventQueue(&event)) {
switch (event.common.type) {
case WVR_EventType_Quit:
return;
case WVR_EventType_DeviceConnected:
if (event.device.deviceType == WVR_DeviceType_HMD)
HideWelcome();
else if (event.device.deviceType == WVR_DeviceType_Controller_Right)
ShowRightHand();
else if (event.device.deviceType == WVR_DeviceType_Controller_Left)
ShowLeftHand();
break;
case WVR_EventType_DeviceDisconnected:
if (event.device.deviceType == WVR_DeviceType_HMD)
return;
else if (event.device.deviceType == WVR_DeviceType_Controller_Right)
HideRightHand();
else if (event.device.deviceType == WVR_DeviceType_Controller_Left)
HideLeftHand();
break;
case WVR_EventType_TouchTapped:
StartGetAxis(event.device.deviceType, event.input.inputId);
break;
case WVR_EventType_TouchUntapped:
StopGetAxis(event.device.deviceType, event.input.inputId);
break;
case WVR_EventType_ButtonPressed:
if (event.input.inputId == WVR_InputId_Alias1_Touchpad)
StartShoot();
else if (event.input.inputId == WVR_InputId_Alias1_Menu)
ShowMenu();
break;
case WVR_EventType_ButtonUnpressed:
if (event.input.inputId == WVR_InputId_Alias1_Touchpad)
StopShoot();
else if (event.input.inputId == WVR_InputId_Alias1_Menu)
HideMenu();
break;
case WVR_EventType_TrackingModeChanged
// Get notification of changed tracking mode(0: WVR_NumDoF_3DoF, 1: WVR_NumDoF_6DoF)
WVR_NumDoF numDof;
// Get the changed Dof (Degree Of Freedom) of HMD pose
numDof = WVR_GetDegreeOfFreedom(WVR_DeviceType_HMD);
break;
default:
break;
}
}
}