WaveVR_Controller

Contents

Introduction

WaveVR_Controller.cs provides the developer an interface to access the controller.

By using WaveVR_Controller, the developer can easily get the button state & axis, pose of the controller.

_images/controller_test.png

Resources

Sample scene Controller_Test is located in Assets/Samples/Controller_Test/Scenes

Sample script ControllerTest.cs is located in Assets/Samples/Controller_Test/Scripts

How to Use

  1. Open sample scene Controller_Test.
_images/controller_test_scene.png _images/controller_test01.png
  1. Look at the Inspector of Right, Left and FakeHead, the sample script ControllerTest.cs is used. We put rCube, lCube or headCube to the Controlled Object that is controlled by Device.
_images/controller_test02.png _images/controller_test03.png _images/controller_test04.png

Sample Code

WaveVR_Controller is an API interface from which the events of the controller are received by specifying the Device.

By using WaveVR_Controller.Input(device), the developer can easily get device status:

if (WaveVR_Controller.Input(device).GetPressDown(buttonId))
{
    // if button with buttonId is pressed down.
}

The developer can listen to a specified button by changing the buttonId:

WVR_InputId[] buttonIds = new WVR_InputId[] {
    WVR_InputId.WVR_InputId_Alias1_Menu,
    WVR_InputId.WVR_InputId_Alias1_Grip,
    WVR_InputId.WVR_InputId_Alias1_DPad_Left,
    WVR_InputId.WVR_InputId_Alias1_DPad_Up,
    WVR_InputId.WVR_InputId_Alias1_DPad_Right,
    WVR_InputId.WVR_InputId_Alias1_DPad_Down,
    WVR_InputId.WVR_InputId_Alias1_Volume_Up,
    WVR_InputId.WVR_InputId_Alias1_Volume_Down,
    WVR_InputId.WVR_InputId_Alias1_Touchpad,
    WVR_InputId.WVR_InputId_Alias1_Trigger,
    WVR_InputId.WVR_InputId_Alias1_Digital_Trigger,
    WVR_InputId.WVR_InputId_Alias1_System
};

In this sample, the GameObject specified in Controlled Object will appear / disappear when the device button is pressed / unpressed.

Get the pose of device:

WaveVR_Controller.Input (device).transform

Get the device connection status:

WaveVR_Controller.Input (device).connected

Left-handed Mode

WaveVR provides left-handed mode to user.

In normal condition, the developer does NOT have to consider the left-handed mode handling in AP development.

Eq. Developers use

WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).connected

to check whether right hand controller is connected.

In left-handed mode, this code also works and does NOT have to change.

But if developers try to make different effects on a GameObject between left / right handed mode,

they will need to know which mode is now.

Check left-handed mode:

WaveVR_Controller.IsLeftHanded

Get left-handed mode type:

WaveVR_Controller.Input ( <original type> ).DeviceType

Eq. Considering the code about checking connection above:

if (WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).connected)
{
        if (WaveVR_Controller.IsLeftHanded)
        {       // actually left hardware controller is connected.
                // ... do something
        } else
        {       // actually right hardware controller is connected
                // ... do something
        }
}

Dominant Hand

Developer may confuse about the left-handed mode.

Don’t worry, WaveVR_Controller provides another controller definition – Dominant hand.

The Dominant hand means the device that player is used to use.

E.g. In right-handed mode, the dominant hand is right. In left-handed mode, the dominant is left.

Thus developer can use sample code below to get button states, device connection status and pose.

// e.g. whether trigger button is pressed down.
bool _pressed = WaveVR_Controller.Input (WaveVR_Controller.EDeviceType.Dominant).GetPressDown (WVR_InputId.WVR_InputId_Alias1_Trigger);
// e.g connection status
bool _conn = WaveVR_Controller.Input (WaveVR_Controller.EDeviceType.Dominant).connected;
// e.g. device pose
WaveVR_Utils.RigidTransform _rpose = WaveVR_Controller.Input (WaveVR_Controller.EDeviceType.Dominant).transform;

And if developer wants to know which device is used by dominant hand:

// get the device corresponding to dominant hand
WVR_DeviceType _dev = WaveVR_Controller.GetWVRTypeByEDevice (WaveVR_Controller.EDeviceType.Dominant);