OpenVR-Advanced-Settings / OpenVR-AdvancedSettings

OpenVR Advanced Settings Dashboard Overlay
GNU General Public License v3.0
1.33k stars 131 forks source link

Implement the new SteamVR IVRInput system #51

Closed username223 closed 5 years ago

username223 commented 5 years ago

The new SteamVR IVRInput system allows users to bind actions to custom buttons on most supported controllers. The current implementation of our input system has hard coded buttons in the source code, and is not portable across controllers.

Some of the functions that we're currently using are also marked as deprecated. It is unknown when these functions will be removed from OpenVR.

A quick glance reveals that at least these functions are marked as deprecated.

/** Fills the supplied struct with the current state of the controller. Returns false if the controller index
* is invalid. This function is deprecated in favor of the new IVRInput system. */
virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize ) = 0;

/** fills the supplied struct with the current state of the controller and the provided pose with the pose of 
* the controller when the controller state was updated most recently. Use this form if you need a precise controller
* pose as input to your application when the user presses or releases a button. This function is deprecated in favor of the new IVRInput system. */
virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize, TrackedDevicePose_t *pTrackedDevicePose ) = 0;

/** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller
* and axis combination for 5ms. This function is deprecated in favor of the new IVRInput system. */
virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0;

/** returns the name of an EVRButtonId enum value. This function is deprecated in favor of the new IVRInput system.  */
virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0;

Moving to the new system would allow increased flexibility in controller hotkeys and decreased development time for new features and general upkeep.

Currently, the support for overlay applications is not that great, meaning some tricks will need to be utilized in order to make use of the new system. However, even with those tricks the new system will most likely be simpler and easier to use and extend.

I will look into this issue.

username223 commented 5 years ago

Partially implemented with #59.

The media keys have now been implemented, I will look into migrating the legacy system next.

username223 commented 5 years ago

Using the new IVRInput system breaks legacy inputs.

Some legacy inputs use the settings file for profiles. Not being able to use the old profiles are a breaking change.

ykeara commented 5 years ago

I am closing, as I believe this has already been done now.