Buttons

Introduction

Please refer to WaveVR API Level for API compatibility.

In the previous WaveVR SDK, we provide button events by default.

In the new SDK, the button event architecture is separated into WaveVRButtons prefab.

Without using WaveVRButtons prefab, you will not receive any button event.

Resources

Prefab WaveVRButtons is located in Assets/WaveVR/Prefabs/

Script WaveVR_ButtonList is located in Assets/WaveVR/Scripts/

Sample: Assets/Samples/Button_Test/

Prefab

Drag the WaveVRButtons prefab to the scene which needs button events.

The default values of WaveVRButtons are shown as the photo:

_images/WaveVR_ButtonList_01.png

You can modify the size to add or remove buttons.

Then you can receive the events of the buttons listed in WaveVRButtons

Please refer to WaveVR_Controller for the usage of button events.

Sample Code

Set up new button list in runtime

Use below code if you have to request different controller button events in runtime:

if (WaveVR_ButtonList.Instance != null)
{
        // Request DPad events.
        List<WaveVR_ButtonList.EControllerButtons> dominant_btns = new List<WaveVR_ButtonList.EControllerButtons> {
                                WaveVR_ButtonList.EControllerButtons.DPadDown,
                                WaveVR_ButtonList.EControllerButtons.DPadLeft,
                                WaveVR_ButtonList.EControllerButtons.DPadRight,
                                WaveVR_ButtonList.EControllerButtons.DPadUp
                        };

        // Set up the button list of Dominant hand.
        WaveVR_ButtonList.Instance.SetupControllerButtonList(WaveVR_Controller.EDeviceType.Dominant, dominant_btns);
}

Check whether a button event is available

If the number of requested button events is more than the number of buttons in the physical device, some button events will not be provided.

E.g. You requests 6 events, but the device has only 4 buttons – 4 buttons are mapping to 4 events, the other 2 events are not available.

You can check whether the button event is available:

// The type (Head / Dominant / NonDominant) of device with buttons.
private WaveVR_Controller.EDeviceType DeviceType = WaveVR_Controller.EDeviceType.Dominant;
// Grip button
private WVR_InputId button_id = WVR_InputId.WVR_InputId_Alias1_Grip;

if (WaveVR_ButtonList.Instance != null      // If prefab WaveVRButtons is not used, instance will be null.
    && WaveVR_ButtonList.Instance.IsButtonAvailable (this.DeviceType, button_id))    // check whether Grip button is available or not.