WVR_GetTrackerInputDeviceCapability

WVR_EXPORT int32_t WVR_GetTrackerInputDeviceCapability(WVR_TrackerId trackerId, WVR_InputType inputType)

Function to get the input device capability of the tracker device for WVR_InputType.

Return
int32_t, bitmask for WVR_InputId. A value of -1 means an error has occurred.
Version
API Level 8
Parameters

How to use

Here is an example for the function:

  1. Header & global variables.
#include <wvr/wvr.h> // for enum WVR_SupportedFeature
#include <wvr/wvr_events.h>
#include <wvr/wvr_tracker.h>
#include <wvr/wvr_types.h>

bool gRunningTR = false;

// Global variable for device capabilities of WVR_TrackerId_0
WVR_TrackerCapabilities_t gCapabilitiesId0;
  1. Start tracker feature first if it has not been started yet. (See also WVR Supported Features)
    • And (Timing 1 - After starting tracker feature successfully) use function WVR_GetTrackerCapabilities to get tracker capabilities to check whether button feature (capability supportsInputDevice) is supported or not.
if (WVR_GetSupportedFeatures() & WVR_SupportedFeature_Tracker) { // the tracker feature is supported or not
    WVR_Result res = WVR_StartTracker();
    if (res == WVR_Success) gRunningTR = true;
}

// Timing 1: Update the tracker capabilities after WVR_StartTracker for the tracker device which has been connected before.
if (gRunningTR && WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    WVR_Result ret = WVR_GetTrackerCapabilities(event.tracker.trackerId, &gCapabilitiesId0);
    // Needs gCapabilitiesId0.supportsInputDevice
}
  1. (Timing 2 - When receiving event WVR_EventType_TrackerConnected) Use function WVR_GetTrackerCapabilities to get tracker capabilities to check whether button feature (capability supportsInputDevice) is supported or not.
void ProcessEvent() {
    WVR_Event_t event;
    while(WVR_PollEventQueue(&event)) {
        switch (event.common.type) {
            /* Timing 2: Update tracker capabilities when tracker device has just been connected.*/
            case WVR_EventType_TrackerConnected:
                {
                    if (gRunningTR && event.tracker.trackerId == WVR_TrackerId_0) {
                        WVR_Result ret = WVR_GetTrackerCapabilities(event.tracker.trackerId, &gCapabilitiesId0);
                        LOGI("Tracker capabilities of TrackerId_%d: ret: %d, capabilities: %d, %d, %d, %d, %d, %d",
                            event.tracker.trackerId, ret,
                            gCapabilitiesId0.supportsOrientationTracking,
                            gCapabilitiesId0.supportsPositionTracking,
                            gCapabilitiesId0.supportsInputDevice,
                            gCapabilitiesId0.supportsHapticVibration,
                            gCapabilitiesId0.supportsBatteryLevel,
                            gCapabilitiesId0.supportsExtendedData);
                    }
                }
                break;
            default:
                break;
        }
    }
}
  1. Use function WVR_GetTrackerInputDeviceCapability (with different parameters) to check supported button features (eg. press & unpress, touch & untouch, analog data) of all button elements.

Note

  1. This function works when capability supportsInputDevice of tracker device is true.
  2. If button feature is not supported, the returned value will be -1.
if (gRunningTR &&
    gCapabilitiesId0.supportsInputDevice &&
    WVR_IsTrackerConnected(WVR_TrackerId_0)) {
    int32_t clickCap = 0, touchCap = 0, analogCap = 0;
    // 1. Get the bit map of supporting press & unpress features for all buttons.
    clickCap = WVR_GetTrackerInputDeviceCapability(WVR_TrackerId_0, WVR_InputType_Button);

    // 2. Get the bit map of supporting touch & untouch features for all buttons.
    touchCap = WVR_GetTrackerInputDeviceCapability(WVR_TrackerId_0, WVR_InputType_Touch);

    // 3. Get the bit map of supporting analog data feature for all buttons.
    analogCap = WVR_GetTrackerInputDeviceCapability(WVR_TrackerId_0, WVR_InputType_Analog);
}
  • Explanation

    1. Call function with parameter WVR_InputType_Button. (See also enum WVR_InputId on Types in wvr.h for button definition)

      If the returned value of clickCap is 408703 (binary number: 01100011110001111111), that means the button elements which support press & unpress features are:

      • bit0: WVR_InputId_Alias1_System
      • bit1: WVR_InputId_Alias1_Menu
      • bit2: WVR_InputId_Alias1_Grip
      • bit3: WVR_InputId_Alias1_DPad_Left
      • bit4: WVR_InputId_Alias1_DPad_Up
      • bit5: WVR_InputId_Alias1_DPad_Right
      • bit6: WVR_InputId_Alias1_DPad_Down
      • bit10: WVR_InputId_Alias1_A
      • bit11: WVR_InputId_Alias1_B
      • bit12: WVR_InputId_Alias1_X
      • bit13: WVR_InputId_Alias1_Y
      • bit17: WVR_InputId_Alias1_Trigger
      • bit18: WVR_InputId_Alias1_Thumbstick
    2. Call function with parameter WVR_InputType_Touch.

      If the returned value of touchCap is 932871 (binary number: 11100011110000000111), that means the button elements which support touch & untouch features are:

      • bit0: WVR_InputId_Alias1_System
      • bit1: WVR_InputId_Alias1_Menu
      • bit2: WVR_InputId_Alias1_Grip
      • bit10: WVR_InputId_Alias1_A
      • bit11: WVR_InputId_Alias1_B
      • bit12: WVR_InputId_Alias1_X
      • bit13: WVR_InputId_Alias1_Y
      • bit17: WVR_InputId_Alias1_Trigger
      • bit18: WVR_InputId_Alias1_Thumbstick
      • bit19: WVR_InputId_Alias1_Parking
    3. Call function with parameter WVR_InputType_Analog.

      If the returned value of analogCap is 393216 (binary number: 01100000000000000000), that means the button elements which support analog data feature are:

      • bit17: WVR_InputId_Alias1_Trigger
      • bit18: WVR_InputId_Alias1_Thumbstick

Note

  1. See also WVR_GetTrackerInputButtonState to get pressed / unpressed state of button element.
  2. See also WVR_GetTrackerInputTouchState to get touched / untouched state of button element.
  3. See also WVR_GetTrackerInputDeviceAnalogType to get the supported analog type of button element.
  4. See also WVR_GetTrackerInputAnalogAxis to get analog value of button element.