WVR_GetTrackerInputDeviceAnalogType¶
-
WVR_EXPORT WVR_AnalogType WVR_GetTrackerInputDeviceAnalogType(WVR_TrackerId trackerId, WVR_InputId inputId)
Function to get the analog type of the input device of the tracker device.
- Return
- Analog type for WVR_InputId. (Refer to WVR_AnalogType.)
- Version
- API Level 8
- Parameters
trackerId
: Indicates what id of the tracker device. (Refer to WVR_TrackerId.)inputId
: One of WVR_InputId.
How to use¶
Here is an example for the function:
- 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 variables for WVR_TrackerId_0
WVR_TrackerCapabilities_t gCapabilitiesId0; // device capabilities
WVR_AnalogType gTriggerAnalogTypeId0 = WVR_AnalogType_None;
- 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(WVR_TrackerId_0, &gCapabilitiesId0);
// Needs gCapabilitiesId0.supportsInputDevice
}
- (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("TrackerId_%d, capabilities(ret: %d): %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;
}
}
}
- Use function WVR_GetTrackerInputDeviceCapability (with parameter WVR_InputType_Analog) to check whether the button element supports analog data feature or not.
- Then use function WVR_GetTrackerInputDeviceAnalogType to get supported analog Type of button. (for further using function WVR_GetTrackerInputAnalogAxis)
if (gRunningTR &&
gCapabilitiesId0.supportsInputDevice &&
WVR_IsTrackerConnected(WVR_TrackerId_0)) {
int32_t triggerBit17Value = 1 << 17;
// Get the bit map of supporting analog data feature for all buttons.
int32_t analogCap = WVR_GetTrackerInputDeviceCapability(WVR_TrackerId_0, WVR_InputType_Analog);
if (analogCap & triggerBit17Value) {
// Trigger supports analog data feature. Then check supported analog Type of Trigger.
gTriggerAnalogTypeId0 = WVR_GetTrackerInputDeviceAnalogType(WVR_TrackerId_0, WVR_InputId_Alias1_Trigger);
}
}
Note
- This function works when capability supportsInputDevice of tracker device is true. If button feature is not supported, the returned value will be WVR_AnalogType_None.
- Trigger and Grip support 1D analog value. Touchpad and Thumbstick(Joystick) support 2D analog value. But the tracker device may not include these button elements physically.
- See also WVR_GetTrackerInputAnalogAxis to get analog data of button element.