ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.13k stars 1.28k forks source link

EVRControllerAxisType enumeration incorrect for Vive DK1 #56

Open bmwesting opened 8 years ago

bmwesting commented 8 years ago

Experimental usage is showing that the enumerations appear to be named incorrectly. According to OpenVR.h:

/** Identifies what kind of axis is on the controller at index n. Read this type 
* with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
*/
enum EVRControllerAxisType
{
    k_eControllerAxis_None = 0,
    k_eControllerAxis_TrackPad = 1,
    k_eControllerAxis_Joystick = 2,
    k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
};

However, in using the Vive DK1 controller, I see: k_eControllerAxis_None reporting the touchpad axis values, and k_eControllerAxis_TrackPad reporting the trigger values.

Perhaps this is a driver-side issue?

vilya commented 7 years ago

I just ran into exactly the same problem with OpenVR 1.0.6 and the consumer version of the Vive.

Just like for @bmwesting, after I call IVRSystem::GetControllerState(deviceIdx, &state, sizeof(state)), state.rAxis[k_eControllerAxis_None] reports the trackpad position and state.rAxis[k_eControllerAxis_TrackPad] reports the trigger value.

echeese commented 7 years ago

Those enums are returned by the tracked property methods to determine what type of input is attached to each axis.

For example, you can loop over the axis like so:

for(uint32_t i = 0; i < vr::k_unControllerStateAxisCount; i++) {
    vr::EVRControllerAxisType type = vr::VRSystem()->GetInt32TrackedDeviceProperty(deviceId, Prop_Axis0Type_Int32 + i);
    cout << "Axis " << i << " type: " << vr::VRSystem()->GetControllerAxisTypeNameFromEnum(type) << endl;
}

Will output something like:

Axis 0 type: k_eControllerAxis_TrackPad
Axis 1 type: k_eControllerAxis_Trigger

Though obviously this will depend on the controller you are using.

If you really want to hard code the axis like that, you could do something like this:

state.rAxis[vr::k_EButton_SteamVR_Touchpad-vr::k_EButton_Axis0]
state.rAxis[vr::k_EButton_SteamVR_Trigger-vr::k_EButton_Axis0]
vilya commented 7 years ago

Oh, that makes sense. Thank you!