WaveVR System Events

Contents

Introduction

Important: do NOT use API WVR_PollEventQueue, we provide broadcast of events those can be used for developers.

In WaveVR, there are some system events can be received in Unity.

public enum WVR_EventType
{
    WVR_EventType_Quit                               = 99,

    /* Device events region */
    WVR_EventType_DeviceConnected                    = 100,
    WVR_EventType_DeviceDisconnected                 = 101,
    WVR_EventType_DeviceStatusUpdate                 = 102,   // Occur when DeviceService's device configure change
    WVR_EventType_IpdChanged                         = 105,   // HMD only
    WVR_EventType_DeviceSuspend                      = 106,   // HMD only
    WVR_EventType_DeviceResume                       = 107,   // HMD only
    WVR_EventType_DeviceRoleChanged                  = 108,
    WVR_EventType_BatteryStatus_Update               = 30004,
    WVR_EventType_ChargeStatus_Update                = 30005, // HMD
    WVR_EventType_DeviceErrorStatus_Update           = 30006,
    WVR_EventType_BatteryTemperatureStatus_Update    = 30007,
    WVR_EventType_RecenterSuccess                    = 30010,
    WVR_EventType_RecenterFail                       = 30011,
    WVR_EventType_RecenterSuccess_3DoF               = 30012,
    WVR_EventType_RecenterFail_3DoF                  = 30013,
    WVR_EventType_TouchpadSwipe_LeftToRight          = 30014,
    WVR_EventType_TouchpadSwipe_RightToLeft          = 30015,
    WVR_EventType_TouchpadSwipe_DownToUp             = 30016,
    WVR_EventType_TouchpadSwipe_UpToDown             = 30017,
    WVR_EventType_Settings_Controller                = 30022,
    WVR_EventType_TrackingModeChanged                = 30106,

    /* Input Button Event region */
    WVR_EventType_ButtonPressed                      = 200,
    WVR_EventType_ButtonUnpressed                    = 201,
    /* Input Touch Event region  */
    WVR_EventType_TouchTapped                        = 202,
    WVR_EventType_TouchUntapped                      = 203,
}

All Events

In MonoBehaviour script, use sample code below to listen to broadcasts of events:

void OnEnable()
{   // Listen to event
    WaveVR_Utils.Event.Listen (WaveVR_Utils.Event.ALL_VREVENT, OnEvent);
}

/// Event handling function
void OnEvent(params object[] args)
{
    WVR_Event_t _event = (WVR_Event_t)args[0];
    // Check the event, eq. WVR_EventType_RecenterSuccess
    if (_event.common.type == WVR_EventType.WVR_EventType_RecenterSuccess)
    {
    }
}

DPad Operation Events

Developer can listen to ALL_VREVENT to check DPad operation events.

Here introducing another broadcast for DPad operation evetns.

Description

  • WVR_EventType_TouchpadSwipe_LeftToRight: triggered when swiping from left to right on touchpad.
  • WVR_EventType_TouchpadSwipe_RightToLeft: triggered when swiping from right to left on touchpad.
  • WVR_EventType_TouchpadSwipe_DownToUp: triggered when swiping from down to up on touchpad.
  • WVR_EventType_TouchpadSwipe_UpToDown: triggered when swiping from up to down on touchpad.

Resources

Sample scene Event_Test is located under Assets/Samples/Event_Test

Sample script Event_Test.cs is located under Assets/Samples/Event_Test

Sample Code

Event_Test listens to broadcast SWIPE_EVENT

void OnEnable()
{
    WaveVR_Utils.Event.Listen ("SWIPE_EVENT", OnEvent);
}

void OnDisable()
{
    WaveVR_Utils.Event.Remove ("SWIPE_EVENT", OnEvent);
}

After receiving event, handling event in OnEvent.

switch (_event)
{
case WVR_EventType.WVR_EventType_TouchpadSwipe_LeftToRight:
    transform.Rotate (0, 180 * (10 * Time.deltaTime), 0);
    break;
case WVR_EventType.WVR_EventType_TouchpadSwipe_RightToLeft:
    transform.Rotate (0, -180 * (10 * Time.deltaTime), 0);
    break;
case WVR_EventType.WVR_EventType_TouchpadSwipe_DownToUp:
    transform.Rotate (0, 0, 180 * (10 * Time.deltaTime));
    break;
case WVR_EventType.WVR_EventType_TouchpadSwipe_UpToDown:
    transform.Rotate (0, 0, -180 * (10 * Time.deltaTime));
    break;
}