diff options
author | Joe Ludwig <joe@valvesoftware.com> | 2018-05-11 21:56:31 +0300 |
---|---|---|
committer | Joe Ludwig <joe@valvesoftware.com> | 2018-05-11 21:56:31 +0300 |
commit | 60eb187801956ad277f1cae6680e3a410ee0873b (patch) | |
tree | 887ba0bd20ec40a673c608cc4a6ed41c6febcfe6 | |
parent | 7027f517983ccaae7d972b7735891bb8244e59fb (diff) |
OpenVR SDK 1.0.15v1.0.15
Added support for the new SteamVR Input system. Please see the documentation for details:
* https://github.com/ValveSoftware/openvr/wiki/SteamVR-Input
Added support for tracked devices to provide access to their raw inertial measurement unit (IMU) data stream. Please see the documentation for details:
* https://github.com/ValveSoftware/openvr/wiki/ImuSample_t
The stream of IMU data in the form of vr::ImuSample_t structures is provided through a new way of sharing data between applications and drivers called IVRIOBuffers. For details, see the documentation:
* https://github.com/ValveSoftware/openvr/wiki/IVRIOBuffer
A new section in the steamvr.vrsettings file supports tracked devices overriding the tracking of other devices. Please see the documentation for details:
* https://github.com/ValveSoftware/openvr/wiki/TrackingOverrides
[git-p4: depot-paths = "//vr/steamvr/sdk_release/": change = 4505287]
27 files changed, 1759 insertions, 108 deletions
diff --git a/bin/linux32/libopenvr_api.so b/bin/linux32/libopenvr_api.so Binary files differindex 32e222a..ede8ac7 100755 --- a/bin/linux32/libopenvr_api.so +++ b/bin/linux32/libopenvr_api.so diff --git a/bin/linux32/libopenvr_api.so.dbg b/bin/linux32/libopenvr_api.so.dbg Binary files differindex 4a58f8c..6f9c578 100755 --- a/bin/linux32/libopenvr_api.so.dbg +++ b/bin/linux32/libopenvr_api.so.dbg diff --git a/bin/linux64/libopenvr_api.so b/bin/linux64/libopenvr_api.so Binary files differindex a2ae438..28e9f33 100755 --- a/bin/linux64/libopenvr_api.so +++ b/bin/linux64/libopenvr_api.so diff --git a/bin/linux64/libopenvr_api.so.dbg b/bin/linux64/libopenvr_api.so.dbg Binary files differindex 78f38ca..50e8d62 100755 --- a/bin/linux64/libopenvr_api.so.dbg +++ b/bin/linux64/libopenvr_api.so.dbg diff --git a/bin/osx32/libopenvr_api.dylib b/bin/osx32/libopenvr_api.dylib Binary files differindex e8ea3b6..1be0a9b 100755 --- a/bin/osx32/libopenvr_api.dylib +++ b/bin/osx32/libopenvr_api.dylib diff --git a/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib b/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib Binary files differindex 13fae3f..9b783da 100644 --- a/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib +++ b/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib diff --git a/bin/win32/openvr_api.dll b/bin/win32/openvr_api.dll Binary files differindex b686939..9fab152 100644 --- a/bin/win32/openvr_api.dll +++ b/bin/win32/openvr_api.dll diff --git a/bin/win32/openvr_api.pdb b/bin/win32/openvr_api.pdb Binary files differindex 28b3bfb..5dcbf24 100644 --- a/bin/win32/openvr_api.pdb +++ b/bin/win32/openvr_api.pdb diff --git a/bin/win64/openvr_api.dll b/bin/win64/openvr_api.dll Binary files differindex 64c879b..b193003 100644 --- a/bin/win64/openvr_api.dll +++ b/bin/win64/openvr_api.dll diff --git a/bin/win64/openvr_api.pdb b/bin/win64/openvr_api.pdb Binary files differindex 2c9279e..bc675e2 100644 --- a/bin/win64/openvr_api.pdb +++ b/bin/win64/openvr_api.pdb diff --git a/headers/openvr.h b/headers/openvr.h index f79db7a..801a690 100644 --- a/headers/openvr.h +++ b/headers/openvr.h @@ -73,6 +73,11 @@ struct HmdQuaternion_t double w, x, y, z; }; +struct HmdQuaternionf_t +{ + float w, x, y, z; +}; + struct HmdColor_t { float r, g, b, a; @@ -234,6 +239,7 @@ static const PropertyTypeTag_t k_unActionPropertyTag = 32; static const PropertyTypeTag_t k_unInputValuePropertyTag = 33; static const PropertyTypeTag_t k_unWildcardPropertyTag = 34; static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35; +static const PropertyTypeTag_t k_unSkeletonPropertyTag = 36; static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; @@ -350,6 +356,11 @@ enum ETrackedDeviceProperty Prop_MinimumIpdStepMeters_Float = 2060, Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + Prop_ImuToHeadTransform_Matrix34 = 2063, + Prop_ImuFactoryGyroBias_Vector3 = 2064, + Prop_ImuFactoryGyroScale_Vector3 = 2065, + Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, // Properties that are unique to TrackedDeviceClass_Controller Prop_AttachedDeviceId_String = 3000, @@ -689,6 +700,8 @@ enum EVREventType VREvent_MessageOverlayCloseRequested = 1651, VREvent_Input_HapticVibration = 1700, // data is hapticVibration + VREvent_Input_BindingLoadFailed = 1701, // data is process + VREvent_Input_BindingLoadSuccessful = 1702, // data is process // Vendors are free to expose private events in this reserved region VREvent_VendorSpecific_Reserved_Start = 10000, @@ -921,6 +934,14 @@ struct VREvent_WebConsole_t WebConsoleHandle_t webConsoleHandle; }; +struct VREvent_InputBindingLoad_t +{ + vr::PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; +}; + + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ typedef union { @@ -947,6 +968,7 @@ typedef union VREvent_DualAnalog_t dualAnalog; VREvent_HapticVibration_t hapticVibration; VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; } VREvent_Data_t; @@ -982,6 +1004,12 @@ enum EVRInputError VRInputError_IPCError = 7, VRInputError_NoActiveActionSet = 8, VRInputError_InvalidDevice = 9, + VRInputError_InvalidSkeleton = 10, + VRInputError_InvalidBoneCount = 11, + VRInputError_InvalidCompressedData = 12, + VRInputError_NoData = 13, + VRInputError_BufferTooSmall = 14, + VRInputError_MismatchedActionManifest = 15, }; @@ -1166,6 +1194,14 @@ enum EVRNotificationError }; +/** Holds the transform for a single bone */ +struct VRBoneTransform_t +{ + HmdVector4_t position; + HmdQuaternionf_t orientation; +}; + + /** error codes returned by Vr_Init */ // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp @@ -1359,6 +1395,25 @@ enum EVSync VSync_NoWaitRender, // do not block following render work (allow to get started early) }; +/** raw IMU data provided by IVRIOBuffer from paths to tracked devices with IMUs */ +enum Imu_OffScaleFlags +{ + OffScale_AccelX = 0x01, + OffScale_AccelY = 0x02, + OffScale_AccelZ = 0x04, + OffScale_GyroX = 0x08, + OffScale_GyroY = 0x10, + OffScale_GyroZ = 0x20, +}; + +struct ImuSample_t +{ + double fSampleTime; + HmdVector3d_t vAccel; + HmdVector3d_t vGyro; + uint32_t unOffScaleFlags; +}; + #pragma pack( pop ) // figure out how to import from the VR API dll @@ -2029,6 +2084,7 @@ namespace vr static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; static const char * const k_pch_SteamVR_DebugInput = "debugInput"; static const char * const k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; + static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; //----------------------------------------------------------------------------- // lighthouse keys @@ -2159,6 +2215,18 @@ namespace vr static const char* const k_pch_WebInterface_Section = "WebInterface"; static const char* const k_pch_WebInterface_WebPort_String = "WebPort"; + //----------------------------------------------------------------------------- + // tracking overrides - keys are device paths, values are the device paths their + // tracking/pose information overrides + static const char* const k_pch_TrackingOverride_Section = "TrackingOverrides"; + + //----------------------------------------------------------------------------- + // per-app keys - the section name for these is the app key itself. Some of these are prefixed by the controller type + static const char* const k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + static const char* const k_pch_App_ActionManifestURL_String = "ActionManifestURL"; + } // namespace vr // ivrchaperone.h @@ -3665,6 +3733,242 @@ static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; } // namespace vr + +// ivrinput.h +namespace vr +{ + + typedef uint64_t VRActionHandle_t; + typedef uint64_t VRActionSetHandle_t; + typedef uint64_t VRInputValueHandle_t; + + static const VRActionHandle_t k_ulInvalidActionHandle = 0; + static const VRActionSetHandle_t k_ulInvalidActionSetHandle = 0; + static const VRInputValueHandle_t k_ulInvalidInputValueHandle = 0; + + static const uint32_t k_unMaxActionNameLength = 64; + static const uint32_t k_unMaxActionSetNameLength = 64; + static const uint32_t k_unMaxActionOriginCount = 16; + + struct InputAnalogActionData_t + { + // Whether or not this action is currently available to be bound in the active action set + bool bActive; + + // The origin that caused this action's current state + VRInputValueHandle_t activeOrigin; + + // The current state of this action; will be delta updates for mouse actions + float x, y, z; + + // Deltas since the previous call to UpdateActionState() + float deltaX, deltaY, deltaZ; + + // Time relative to now when this event happened. Will be negative to indicate a past time. + float fUpdateTime; + }; + + struct InputDigitalActionData_t + { + // Whether or not this action is currently available to be bound in the active action set + bool bActive; + + // The origin that caused this action's current state + VRInputValueHandle_t activeOrigin; + + // The current state of this action; will be true if currently pressed + bool bState; + + // This is true if the state has changed since the last frame + bool bChanged; + + // Time relative to now when this event happened. Will be negative to indicate a past time. + float fUpdateTime; + }; + + struct InputPoseActionData_t + { + // Whether or not this action is currently available to be bound in the active action set + bool bActive; + + // The origin that caused this action's current state + VRInputValueHandle_t activeOrigin; + + // The current state of this action + TrackedDevicePose_t pose; + }; + + enum EVRSkeletalTransformSpace + { + VRSkeletalTransformSpace_Action = 0, + VRSkeletalTransformSpace_Parent = 1, + VRSkeletalTransformSpace_Additive = 2, + }; + + + struct InputSkeletonActionData_t + { + // Whether or not this action is currently available to be bound in the active action set + bool bActive; + + // The origin that caused this action's current state + VRInputValueHandle_t activeOrigin; + }; + + enum EVRInputFilterCancelType + { + VRInputFilterCancel_Timers = 0, + VRInputFilterCancel_Momentum = 1, + }; + + struct InputOriginInfo_t + { + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char rchRenderModelComponentName[128]; + }; + + struct VRActiveActionSet_t + { + /** This is the handle of the action set to activate for this frame. */ + VRActionSetHandle_t ulActionSet; + + /** This is the handle of a device path that this action set should be active for. To + * activate for all devices, set this to k_ulInvalidInputValueHandle. */ + VRInputValueHandle_t ulRestrictedToDevice; + + /** The action set to activate for all devices other than ulRestrictedDevice. If + * ulRestrictedToDevice is set to k_ulInvalidInputValueHandle, this parameter is + * ignored. */ + VRActionSetHandle_t ulSecondaryActionSet; + }; + + + class IVRInput + { + public: + + // --------------- Handle management --------------- // + + /** Sets the path to the action manifest JSON file that is used by this application. If this information + * was set on the Steam partner site, calls to this function are ignored. If the Steam partner site + * setting and the path provided by this call are different, VRInputError_MismatchedActionManifest is returned. + * This call must be made before the first call to UpdateActionState or IVRSystem::PollNextEvent. */ + virtual EVRInputError SetActionManifestPath( const char *pchActionManifestPath ) = 0; + + /** Returns a handle for an action set. This handle is used for all performance-sensitive calls. */ + virtual EVRInputError GetActionSetHandle( const char *pchActionSetName, VRActionSetHandle_t *pHandle ) = 0; + + /** Returns a handle for an action. This handle is used for all performance-sensitive calls. */ + virtual EVRInputError GetActionHandle( const char *pchActionName, VRActionHandle_t *pHandle ) = 0; + + /** Returns a handle for any path in the input system. E.g. /user/hand/right */ + virtual EVRInputError GetInputSourceHandle( const char *pchInputSourcePath, VRInputValueHandle_t *pHandle ) = 0; + + // --------------- Reading action state ------------------- // + + /** Reads the current state into all actions. After this call, the results of Get*Action calls + * will be the same until the next call to UpdateActionState. */ + virtual EVRInputError UpdateActionState( VR_ARRAY_COUNT( unSetCount ) VRActiveActionSet_t *pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount ) = 0; + + /** Reads the state of a digital action given its handle. This will return VRInputError_WrongType if the type of + * action is something other than digital */ + virtual EVRInputError GetDigitalActionData( VRActionHandle_t action, InputDigitalActionData_t *pActionData, uint32_t unActionDataSize ) = 0; + + /** Reads the state of an analog action given its handle. This will return VRInputError_WrongType if the type of + * action is something other than analog */ + virtual EVRInputError GetAnalogActionData( VRActionHandle_t action, InputAnalogActionData_t *pActionData, uint32_t unActionDataSize ) = 0; + + /** Reads the state of a pose action given its handle. */ + virtual EVRInputError GetPoseActionData( VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t *pActionData, uint32_t unActionDataSize ) = 0; + + /** Reads the state of a skeletal action given its handle. */ + virtual EVRInputError GetSkeletalActionData( VRActionHandle_t action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, InputSkeletonActionData_t *pActionData, uint32_t unActionDataSize, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + /** Reads the state of a skeletal action given its handle in a compressed form that is suitable for + * sending over the network. The required buffer size will never exceed ( sizeof(VR_BoneTransform_t)*boneCount + 2). + * Usually the size will be much smaller. */ + virtual EVRInputError GetSkeletalActionDataCompressed( VRActionHandle_t action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, VR_OUT_BUFFER_COUNT( unCompressedSize ) void *pvCompressedData, uint32_t unCompressedSize, uint32_t *punRequiredCompressedSize ) = 0; + + /** Turns a compressed buffer from GetSkeletalActionDataCompressed and turns it back into a bone transform array. */ + virtual EVRInputError UncompressSkeletalActionData( void *pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace *peBoneParent, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + // --------------- Haptics ------------------- // + + /** Triggers a haptic event as described by the specified action */ + virtual EVRInputError TriggerHapticVibrationAction( VRActionHandle_t action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude ) = 0; + + // --------------- Action Origins ---------------- // + + /** Retrieve origin handles for an action */ + virtual EVRInputError GetActionOrigins( VRActionSetHandle_t actionSetHandle, VRActionHandle_t digitalActionHandle, VR_ARRAY_COUNT( originOutCount ) VRInputValueHandle_t *originsOut, uint32_t originOutCount ) = 0; + + /** Retrieves the name of the origin in the current language */ + virtual EVRInputError GetOriginLocalizedName( VRInputValueHandle_t origin, VR_OUT_STRING() char *pchNameArray, uint32_t unNameArraySize ) = 0; + + /** Retrieves useful information for the origin of this action */ + virtual EVRInputError GetOriginTrackedDeviceInfo( VRInputValueHandle_t origin, InputOriginInfo_t *pOriginInfo, uint32_t unOriginInfoSize ) = 0; + + /** Shows the current binding for the action in-headset */ + virtual EVRInputError ShowActionOrigins( VRActionSetHandle_t actionSetHandle, VRActionHandle_t ulActionHandle ) = 0; + + /** Shows the current binding all the actions in the specified action sets */ + virtual EVRInputError ShowBindingsForActionSet( VR_ARRAY_COUNT( unSetCount ) VRActiveActionSet_t *pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount, VRInputValueHandle_t originToHighlight ) = 0; + }; + + static const char * const IVRInput_Version = "IVRInput_003"; + +} // namespace vr + +// ivriobuffer.h +namespace vr +{ + +typedef uint64_t IOBufferHandle_t; +static const uint64_t k_ulInvalidIOBufferHandle = 0; + + enum EIOBufferError + { + IOBuffer_Success = 0, + IOBuffer_OperationFailed = 100, + IOBuffer_InvalidHandle = 101, + IOBuffer_InvalidArgument = 102, + IOBuffer_PathExists = 103, + IOBuffer_PathDoesNotExist = 104, + IOBuffer_Permission = 105, + }; + + enum EIOBufferMode + { + IOBufferMode_Read = 0x0001, + IOBufferMode_Write = 0x0002, + IOBufferMode_Create = 0x0200, + }; + + // ---------------------------------------------------------------------------------------------- + // Purpose: + // ---------------------------------------------------------------------------------------------- + class IVRIOBuffer + { + public: + /** opens an existing or creates a new IOBuffer of unSize bytes */ + virtual vr::EIOBufferError Open( const char *pchPath, vr::EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, vr::IOBufferHandle_t *pulBuffer ) = 0; + + /** closes a previously opened or created buffer */ + virtual vr::EIOBufferError Close( vr::IOBufferHandle_t ulBuffer ) = 0; + + /** reads up to unBytes from buffer into *pDst, returning number of bytes read in *punRead */ + virtual vr::EIOBufferError Read( vr::IOBufferHandle_t ulBuffer, void *pDst, uint32_t unBytes, uint32_t *punRead ) = 0; + + /** writes unBytes of data from *pSrc into a buffer. */ + virtual vr::EIOBufferError Write( vr::IOBufferHandle_t ulBuffer, void *pSrc, uint32_t unBytes ) = 0; + + /** retrieves the property container of an buffer. */ + virtual vr::PropertyContainerHandle_t PropertyContainer( vr::IOBufferHandle_t ulBuffer ) = 0; + }; + + static const char *IVRIOBuffer_Version = "IVRIOBuffer_001"; +} // End #endif // _OPENVR_API @@ -3899,6 +4203,27 @@ namespace vr return m_pVRDriverManager; } + IVRInput *VRInput() + { + CheckClear(); + if ( !m_pVRInput ) + { + EVRInitError eError; + m_pVRInput = (IVRInput *)VR_GetGenericInterface( IVRInput_Version, &eError ); + } + return m_pVRInput; + } + + IVRIOBuffer *VRIOBuffer() + { + if ( !m_pVRIOBuffer ) + { + EVRInitError eError; + m_pVRIOBuffer = ( IVRIOBuffer * )VR_GetGenericInterface( IVRIOBuffer_Version, &eError ); + } + return m_pVRIOBuffer; + } + private: IVRSystem *m_pVRSystem; IVRChaperone *m_pVRChaperone; @@ -3913,6 +4238,8 @@ namespace vr IVRTrackedCamera *m_pVRTrackedCamera; IVRScreenshots *m_pVRScreenshots; IVRDriverManager *m_pVRDriverManager; + IVRInput *m_pVRInput; + IVRIOBuffer *m_pVRIOBuffer; }; inline COpenVRContext &OpenVRInternal_ModuleContext() @@ -3934,6 +4261,8 @@ namespace vr inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); } inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); } inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleContext().VRDriverManager(); } + inline IVRInput *VR_CALLTYPE VRInput() { return OpenVRInternal_ModuleContext().VRInput(); } + inline IVRIOBuffer *VR_CALLTYPE VRIOBuffer() { return OpenVRInternal_ModuleContext().VRIOBuffer(); } inline void COpenVRContext::Clear() { @@ -3950,6 +4279,8 @@ namespace vr m_pVRResources = nullptr; m_pVRScreenshots = nullptr; m_pVRDriverManager = nullptr; + m_pVRInput = nullptr; + m_pVRIOBuffer = nullptr; } VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); diff --git a/headers/openvr_api.cs b/headers/openvr_api.cs index 72ea176..e8764c4 100644 --- a/headers/openvr_api.cs +++ b/headers/openvr_api.cs @@ -1532,6 +1532,126 @@ public struct IVRDriverManager } +[StructLayout(LayoutKind.Sequential)] +public struct IVRInput +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _SetActionManifestPath(string pchActionManifestPath); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetActionManifestPath SetActionManifestPath; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetActionSetHandle(string pchActionSetName, ref ulong pHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionSetHandle GetActionSetHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetActionHandle(string pchActionName, ref ulong pHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionHandle GetActionHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetInputSourceHandle(string pchInputSourcePath, ref ulong pHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetInputSourceHandle GetInputSourceHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _UpdateActionState([In, Out] VRActiveActionSet_t[] pSets, uint unSizeOfVRSelectedActionSet_t, uint unSetCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _UpdateActionState UpdateActionState; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetDigitalActionData(ulong action, ref InputDigitalActionData_t pActionData, uint unActionDataSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDigitalActionData GetDigitalActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetAnalogActionData(ulong action, ref InputAnalogActionData_t pActionData, uint unActionDataSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetAnalogActionData GetAnalogActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetPoseActionData(ulong action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, ref InputPoseActionData_t pActionData, uint unActionDataSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetPoseActionData GetPoseActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalActionData(ulong action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, ref InputSkeletonActionData_t pActionData, uint unActionDataSize, [In, Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalActionData GetSkeletalActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalActionDataCompressed(ulong action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, IntPtr pvCompressedData, uint unCompressedSize, ref uint punRequiredCompressedSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalActionDataCompressed GetSkeletalActionDataCompressed; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _UncompressSkeletalActionData(IntPtr pvCompressedBuffer, uint unCompressedBufferSize, ref EVRSkeletalTransformSpace peBoneParent, [In, Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _UncompressSkeletalActionData UncompressSkeletalActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _TriggerHapticVibrationAction(ulong action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _TriggerHapticVibrationAction TriggerHapticVibrationAction; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetActionOrigins(ulong actionSetHandle, ulong digitalActionHandle, [In, Out] ulong[] originsOut, uint originOutCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionOrigins GetActionOrigins; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetOriginLocalizedName(ulong origin, System.Text.StringBuilder pchNameArray, uint unNameArraySize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOriginLocalizedName GetOriginLocalizedName; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetOriginTrackedDeviceInfo(ulong origin, ref InputOriginInfo_t pOriginInfo, uint unOriginInfoSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOriginTrackedDeviceInfo GetOriginTrackedDeviceInfo; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _ShowActionOrigins(ulong actionSetHandle, ulong ulActionHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ShowActionOrigins ShowActionOrigins; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _ShowBindingsForActionSet([In, Out] VRActiveActionSet_t[] pSets, uint unSizeOfVRSelectedActionSet_t, uint unSetCount, ulong originToHighlight); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ShowBindingsForActionSet ShowBindingsForActionSet; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRIOBuffer +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EIOBufferError _Open(string pchPath, EIOBufferMode mode, uint unElementSize, uint unElements, ref ulong pulBuffer); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Open Open; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EIOBufferError _Close(ulong ulBuffer); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Close Close; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EIOBufferError _Read(ulong ulBuffer, IntPtr pDst, uint unBytes, ref uint punRead); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Read Read; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EIOBufferError _Write(ulong ulBuffer, IntPtr pSrc, uint unBytes); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Write Write; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ulong _PropertyContainer(ulong ulBuffer); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _PropertyContainer PropertyContainer; + +} + public class CVRSystem { @@ -3270,6 +3390,142 @@ public class CVRDriverManager } +public class CVRInput +{ + IVRInput FnTable; + internal CVRInput(IntPtr pInterface) + { + FnTable = (IVRInput)Marshal.PtrToStructure(pInterface, typeof(IVRInput)); + } + public EVRInputError SetActionManifestPath(string pchActionManifestPath) + { + EVRInputError result = FnTable.SetActionManifestPath(pchActionManifestPath); + return result; + } + public EVRInputError GetActionSetHandle(string pchActionSetName,ref ulong pHandle) + { + pHandle = 0; + EVRInputError result = FnTable.GetActionSetHandle(pchActionSetName,ref pHandle); + return result; + } + public EVRInputError GetActionHandle(string pchActionName,ref ulong pHandle) + { + pHandle = 0; + EVRInputError result = FnTable.GetActionHandle(pchActionName,ref pHandle); + return result; + } + public EVRInputError GetInputSourceHandle(string pchInputSourcePath,ref ulong pHandle) + { + pHandle = 0; + EVRInputError result = FnTable.GetInputSourceHandle(pchInputSourcePath,ref pHandle); + return result; + } + public EVRInputError UpdateActionState(VRActiveActionSet_t [] pSets,uint unSizeOfVRSelectedActionSet_t) + { + EVRInputError result = FnTable.UpdateActionState(pSets,unSizeOfVRSelectedActionSet_t,(uint) pSets.Length); + return result; + } + public EVRInputError GetDigitalActionData(ulong action,ref InputDigitalActionData_t pActionData,uint unActionDataSize) + { + EVRInputError result = FnTable.GetDigitalActionData(action,ref pActionData,unActionDataSize); + return result; + } + public EVRInputError GetAnalogActionData(ulong action,ref InputAnalogActionData_t pActionData,uint unActionDataSize) + { + EVRInputError result = FnTable.GetAnalogActionData(action,ref pActionData,unActionDataSize); + return result; + } + public EVRInputError GetPoseActionData(ulong action,ETrackingUniverseOrigin eOrigin,float fPredictedSecondsFromNow,ref InputPoseActionData_t pActionData,uint unActionDataSize) + { + EVRInputError result = FnTable.GetPoseActionData(action,eOrigin,fPredictedSecondsFromNow,ref pActionData,unActionDataSize); + return result; + } + public EVRInputError GetSkeletalActionData(ulong action,EVRSkeletalTransformSpace eBoneParent,float fPredictedSecondsFromNow,ref InputSkeletonActionData_t pActionData,uint unActionDataSize,VRBoneTransform_t [] pTransformArray) + { + EVRInputError result = FnTable.GetSkeletalActionData(action,eBoneParent,fPredictedSecondsFromNow,ref pActionData,unActionDataSize,pTransformArray,(uint) pTransformArray.Length); + return result; + } + public EVRInputError GetSkeletalActionDataCompressed(ulong action,EVRSkeletalTransformSpace eBoneParent,float fPredictedSecondsFromNow,IntPtr pvCompressedData,uint unCompressedSize,ref uint punRequiredCompressedSize) + { + punRequiredCompressedSize = 0; + EVRInputError result = FnTable.GetSkeletalActionDataCompressed(action,eBoneParent,fPredictedSecondsFromNow,pvCompressedData,unCompressedSize,ref punRequiredCompressedSize); + return result; + } + public EVRInputError UncompressSkeletalActionData(IntPtr pvCompressedBuffer,uint unCompressedBufferSize,ref EVRSkeletalTransformSpace peBoneParent,VRBoneTransform_t [] pTransformArray) + { + EVRInputError result = FnTable.UncompressSkeletalActionData(pvCompressedBuffer,unCompressedBufferSize,ref peBoneParent,pTransformArray,(uint) pTransformArray.Length); + return result; + } + public EVRInputError TriggerHapticVibrationAction(ulong action,float fStartSecondsFromNow,float fDurationSeconds,float fFrequency,float fAmplitude) + { + EVRInputError result = FnTable.TriggerHapticVibrationAction(action,fStartSecondsFromNow,fDurationSeconds,fFrequency,fAmplitude); + return result; + } + public EVRInputError GetActionOrigins(ulong actionSetHandle,ulong digitalActionHandle,ulong [] originsOut) + { + EVRInputError result = FnTable.GetActionOrigins(actionSetHandle,digitalActionHandle,originsOut,(uint) originsOut.Length); + return result; + } + public EVRInputError GetOriginLocalizedName(ulong origin,System.Text.StringBuilder pchNameArray,uint unNameArraySize) + { + EVRInputError result = FnTable.GetOriginLocalizedName(origin,pchNameArray,unNameArraySize); + return result; + } + public EVRInputError GetOriginTrackedDeviceInfo(ulong origin,ref InputOriginInfo_t pOriginInfo,uint unOriginInfoSize) + { + EVRInputError result = FnTable.GetOriginTrackedDeviceInfo(origin,ref pOriginInfo,unOriginInfoSize); + return result; + } + public EVRInputError ShowActionOrigins(ulong actionSetHandle,ulong ulActionHandle) + { + EVRInputError result = FnTable.ShowActionOrigins(actionSetHandle,ulActionHandle); + return result; + } + public EVRInputError ShowBindingsForActionSet(VRActiveActionSet_t [] pSets,uint unSizeOfVRSelectedActionSet_t,ulong originToHighlight) + { + EVRInputError result = FnTable.ShowBindingsForActionSet(pSets,unSizeOfVRSelectedActionSet_t,(uint) pSets.Length,originToHighlight); + return result; + } +} + + +public class CVRIOBuffer +{ + IVRIOBuffer FnTable; + internal CVRIOBuffer(IntPtr pInterface) + { + FnTable = (IVRIOBuffer)Marshal.PtrToStructure(pInterface, typeof(IVRIOBuffer)); + } + public EIOBufferError Open(string pchPath,EIOBufferMode mode,uint unElementSize,uint unElements,ref ulong pulBuffer) + { + pulBuffer = 0; + EIOBufferError result = FnTable.Open(pchPath,mode,unElementSize,unElements,ref pulBuffer); + return result; + } + public EIOBufferError Close(ulong ulBuffer) + { + EIOBufferError result = FnTable.Close(ulBuffer); + return result; + } + public EIOBufferError Read(ulong ulBuffer,IntPtr pDst,uint unBytes,ref uint punRead) + { + punRead = 0; + EIOBufferError result = FnTable.Read(ulBuffer,pDst,unBytes,ref punRead); + return result; + } + public EIOBufferError Write(ulong ulBuffer,IntPtr pSrc,uint unBytes) + { + EIOBufferError result = FnTable.Write(ulBuffer,pSrc,unBytes); + return result; + } + public ulong PropertyContainer(ulong ulBuffer) + { + ulong result = FnTable.PropertyContainer(ulBuffer); + return result; + } +} + + public class OpenVRInterop { [DllImportAttribute("openvr_api", EntryPoint = "VR_InitInternal", CallingConvention = CallingConvention.Cdecl)] @@ -3447,6 +3703,11 @@ public enum ETrackedDeviceProperty Prop_MinimumIpdStepMeters_Float = 2060, Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + Prop_ImuToHeadTransform_Matrix34 = 2063, + Prop_ImuFactoryGyroBias_Vector3 = 2064, + Prop_ImuFactoryGyroScale_Vector3 = 2065, + Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, Prop_AttachedDeviceId_String = 3000, Prop_SupportedButtons_Uint64 = 3001, Prop_Axis0Type_Int32 = 3002, @@ -3663,6 +3924,8 @@ public enum EVREventType VREvent_MessageOverlay_Closed = 1650, VREvent_MessageOverlayCloseRequested = 1651, VREvent_Input_HapticVibration = 1700, + VREvent_Input_BindingLoadFailed = 1701, + VREvent_Input_BindingLoadSuccessful = 1702, VREvent_VendorSpecific_Reserved_Start = 10000, VREvent_VendorSpecific_Reserved_End = 19999, } @@ -3718,6 +3981,12 @@ public enum EVRInputError IPCError = 7, NoActiveActionSet = 8, InvalidDevice = 9, + InvalidSkeleton = 10, + InvalidBoneCount = 11, + InvalidCompressedData = 12, + NoData = 13, + BufferTooSmall = 14, + MismatchedActionManifest = 15, } public enum EHiddenAreaMeshType { @@ -3944,6 +4213,15 @@ public enum EVSync WaitRender = 1, NoWaitRender = 2, } +public enum Imu_OffScaleFlags +{ + OffScale_AccelX = 1, + OffScale_AccelY = 2, + OffScale_AccelZ = 4, + OffScale_GyroX = 8, + OffScale_GyroY = 16, + OffScale_GyroZ = 32, +} public enum EVRApplicationError { None = 0, @@ -4160,6 +4438,33 @@ public enum EVRScreenshotError BufferTooSmall = 102, ScreenshotAlreadyInProgress = 108, } +public enum EVRSkeletalTransformSpace +{ + Action = 0, + Parent = 1, + Additive = 2, +} +public enum EVRInputFilterCancelType +{ + VRInputFilterCancel_Timers = 0, + VRInputFilterCancel_Momentum = 1, +} +public enum EIOBufferError +{ + IOBuffer_Success = 0, + IOBuffer_OperationFailed = 100, + IOBuffer_InvalidHandle = 101, + IOBuffer_InvalidArgument = 102, + IOBuffer_PathExists = 103, + IOBuffer_PathDoesNotExist = 104, + IOBuffer_Permission = 105, +} +public enum EIOBufferMode +{ + Read = 1, + Write = 2, + Create = 512, +} [StructLayout(LayoutKind.Explicit)] public struct VREvent_Data_t { @@ -4260,6 +4565,13 @@ public enum EVRScreenshotError public double y; public double z; } +[StructLayout(LayoutKind.Sequential)] public struct HmdQuaternionf_t +{ + public float w; + public float x; + public float y; + public float z; +} [StructLayout(LayoutKind.Sequential)] public struct HmdColor_t { public float r; @@ -4474,6 +4786,12 @@ public enum EVRScreenshotError { public ulong webConsoleHandle; } +[StructLayout(LayoutKind.Sequential)] public struct VREvent_InputBindingLoad_t +{ + public ulong ulAppContainer; + public ulong pathMessage; + public ulong pathUrl; +} [StructLayout(LayoutKind.Sequential)] public struct VREvent_t { public uint eventType; @@ -4577,6 +4895,11 @@ public enum EVRScreenshotError public float gridScale; public HmdMatrix44_t transform; } +[StructLayout(LayoutKind.Sequential)] public struct VRBoneTransform_t +{ + public HmdVector4_t position; + public HmdQuaternionf_t orientation; +} [StructLayout(LayoutKind.Sequential)] public struct CameraVideoStreamFrameHeader_t { public EVRTrackedCameraFrameType eFrameType; @@ -4594,6 +4917,13 @@ public enum EVRScreenshotError public uint m_nNumDroppedFrames; public uint m_nReprojectionFlags; } +[StructLayout(LayoutKind.Sequential)] public struct ImuSample_t +{ + public double fSampleTime; + public HmdVector3d_t vAccel; + public HmdVector3d_t vGyro; + public uint unOffScaleFlags; +} [StructLayout(LayoutKind.Sequential)] public struct AppOverrideKeys_t { public IntPtr pchKey; // const char * @@ -4758,6 +5088,55 @@ public enum EVRScreenshotError public int m_nHeight; public int m_nBytesPerPixel; } +[StructLayout(LayoutKind.Sequential)] public struct InputAnalogActionData_t +{ + [MarshalAs(UnmanagedType.I1)] + public bool bActive; + public ulong activeOrigin; + public float x; + public float y; + public float z; + public float deltaX; + public float deltaY; + public float deltaZ; + public float fUpdateTime; +} +[StructLayout(LayoutKind.Sequential)] public struct InputDigitalActionData_t +{ + [MarshalAs(UnmanagedType.I1)] + public bool bActive; + public ulong activeOrigin; + [MarshalAs(UnmanagedType.I1)] + public bool bState; + [MarshalAs(UnmanagedType.I1)] + public bool bChanged; + public float fUpdateTime; +} +[StructLayout(LayoutKind.Sequential)] public struct InputPoseActionData_t +{ + [MarshalAs(UnmanagedType.I1)] + public bool bActive; + public ulong activeOrigin; + public TrackedDevicePose_t pose; +} +[StructLayout(LayoutKind.Sequential)] public struct InputSkeletonActionData_t +{ + [MarshalAs(UnmanagedType.I1)] + public bool bActive; + public ulong activeOrigin; +} +[StructLayout(LayoutKind.Sequential)] public struct InputOriginInfo_t +{ + public ulong devicePath; + public uint trackedDeviceIndex; + public byte rchRenderModelComponentName0,rchRenderModelComponentName1,rchRenderModelComponentName2,rchRenderModelComponentName3,rchRenderModelComponentName4,rchRenderModelComponentName5,rchRenderModelComponentName6,rchRenderModelComponentName7,rchRenderModelComponentName8,rchRenderModelComponentName9,rchRenderModelComponentName10,rchRenderModelComponentName11,rchRenderModelComponentName12,rchRenderModelComponentName13,rchRenderModelComponentName14,rchRenderModelComponentName15,rchRenderModelComponentName16,rchRenderModelComponentName17,rchRenderModelComponentName18,rchRenderModelComponentName19,rchRenderModelComponentName20,rchRenderModelComponentName21,rchRenderModelComponentName22,rchRenderModelComponentName23,rchRenderModelComponentName24,rchRenderModelComponentName25,rchRenderModelComponentName26,rchRenderModelComponentName27,rchRenderModelComponentName28,rchRenderModelComponentName29,rchRenderModelComponentName30,rchRenderModelComponentName31,rchRenderModelComponentName32,rchRenderModelComponentName33,rchRenderModelComponentName34,rchRenderModelComponentName35,rchRenderModelComponentName36,rchRenderModelComponentName37,rchRenderModelComponentName38,rchRenderModelComponentName39,rchRenderModelComponentName40,rchRenderModelComponentName41,rchRenderModelComponentName42,rchRenderModelComponentName43,rchRenderModelComponentName44,rchRenderModelComponentName45,rchRenderModelComponentName46,rchRenderModelComponentName47,rchRenderModelComponentName48,rchRenderModelComponentName49,rchRenderModelComponentName50,rchRenderModelComponentName51,rchRenderModelComponentName52,rchRenderModelComponentName53,rchRenderModelComponentName54,rchRenderModelComponentName55,rchRenderModelComponentName56,rchRenderModelComponentName57,rchRenderModelComponentName58,rchRenderModelComponentName59,rchRenderModelComponentName60,rchRenderModelComponentName61,rchRenderModelComponentName62,rchRenderModelComponentName63,rchRenderModelComponentName64,rchRenderModelComponentName65,rchRenderModelComponentName66,rchRenderModelComponentName67,rchRenderModelComponentName68,rchRenderModelComponentName69,rchRenderModelComponentName70,rchRenderModelComponentName71,rchRenderModelComponentName72,rchRenderModelComponentName73,rchRenderModelComponentName74,rchRenderModelComponentName75,rchRenderModelComponentName76,rchRenderModelComponentName77,rchRenderModelComponentName78,rchRenderModelComponentName79,rchRenderModelComponentName80,rchRenderModelComponentName81,rchRenderModelComponentName82,rchRenderModelComponentName83,rchRenderModelComponentName84,rchRenderModelComponentName85,rchRenderModelComponentName86,rchRenderModelComponentName87,rchRenderModelComponentName88,rchRenderModelComponentName89,rchRenderModelComponentName90,rchRenderModelComponentName91,rchRenderModelComponentName92,rchRenderModelComponentName93,rchRenderModelComponentName94,rchRenderModelComponentName95,rchRenderModelComponentName96,rchRenderModelComponentName97,rchRenderModelComponentName98,rchRenderModelComponentName99,rchRenderModelComponentName100,rchRenderModelComponentName101,rchRenderModelComponentName102,rchRenderModelComponentName103,rchRenderModelComponentName104,rchRenderModelComponentName105,rchRenderModelComponentName106,rchRenderModelComponentName107,rchRenderModelComponentName108,rchRenderModelComponentName109,rchRenderModelComponentName110,rchRenderModelComponentName111,rchRenderModelComponentName112,rchRenderModelComponentName113,rchRenderModelComponentName114,rchRenderModelComponentName115,rchRenderModelComponentName116,rchRenderModelComponentName117,rchRenderModelComponentName118,rchRenderModelComponentName119,rchRenderModelComponentName120,rchRenderModelComponentName121,rchRenderModelComponentName122,rchRenderModelComponentName123,rchRenderModelComponentName124,rchRenderModelComponentName125,rchRenderModelComponentName126,rchRenderModelComponentName127; +} +[StructLayout(LayoutKind.Sequential)] public struct VRActiveActionSet_t +{ + public ulong ulActionSet; + public ulong ulRestrictedToDevice; + public ulong ulSecondaryActionSet; +} [StructLayout(LayoutKind.Sequential)] public struct COpenVRContext { public IntPtr m_pVRSystem; // class vr::IVRSystem * @@ -4773,6 +5152,8 @@ public enum EVRScreenshotError public IntPtr m_pVRTrackedCamera; // class vr::IVRTrackedCamera * public IntPtr m_pVRScreenshots; // class vr::IVRScreenshots * public IntPtr m_pVRDriverManager; // class vr::IVRDriverManager * + public IntPtr m_pVRInput; // class vr::IVRInput * + public IntPtr m_pVRIOBuffer; // class vr::IVRIOBuffer * } public class OpenVR @@ -4842,6 +5223,7 @@ public class OpenVR public const uint k_unInputValuePropertyTag = 33; public const uint k_unWildcardPropertyTag = 34; public const uint k_unHapticVibrationPropertyTag = 35; + public const uint k_unSkeletonPropertyTag = 36; public const uint k_unOpenVRInternalReserved_Start = 1000; public const uint k_unOpenVRInternalReserved_End = 10000; public const uint k_unMaxPropertyStringSize = 32768; @@ -4923,6 +5305,7 @@ public class OpenVR public const string k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; public const string k_pch_SteamVR_DebugInput = "debugInput"; public const string k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; + public const string k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; public const string k_pch_Lighthouse_Section = "driver_lighthouse"; public const string k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; public const string k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; @@ -5010,9 +5393,23 @@ public class OpenVR public const string k_pch_Driver_Enable_Bool = "enable"; public const string k_pch_WebInterface_Section = "WebInterface"; public const string k_pch_WebInterface_WebPort_String = "WebPort"; + public const string k_pch_TrackingOverride_Section = "TrackingOverrides"; + public const string k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + public const string k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + public const string k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + public const string k_pch_App_ActionManifestURL_String = "ActionManifestURL"; public const string IVRScreenshots_Version = "IVRScreenshots_001"; public const string IVRResources_Version = "IVRResources_001"; public const string IVRDriverManager_Version = "IVRDriverManager_001"; + public const ulong k_ulInvalidActionHandle = 0; + public const ulong k_ulInvalidActionSetHandle = 0; + public const ulong k_ulInvalidInputValueHandle = 0; + public const uint k_unMaxActionNameLength = 64; + public const uint k_unMaxActionSetNameLength = 64; + public const uint k_unMaxActionOriginCount = 16; + public const string IVRInput_Version = "IVRInput_003"; + public const ulong k_ulInvalidIOBufferHandle = 0; + public const string IVRIOBuffer_Version = "IVRIOBuffer_001"; static uint VRToken { get; set; } @@ -5035,6 +5432,7 @@ public class OpenVR m_pVRApplications = null; m_pVRScreenshots = null; m_pVRTrackedCamera = null; + m_pVRInput = null; } void CheckClear() @@ -5189,6 +5587,19 @@ public class OpenVR return m_pVRTrackedCamera; } + public CVRInput VRInput() + { + CheckClear(); + if (m_pVRInput == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix+IVRInput_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRInput = new CVRInput(pInterface); + } + return m_pVRInput; + } + private CVRSystem m_pVRSystem; private CVRChaperone m_pVRChaperone; private CVRChaperoneSetup m_pVRChaperoneSetup; @@ -5200,6 +5611,7 @@ public class OpenVR private CVRApplications m_pVRApplications; private CVRScreenshots m_pVRScreenshots; private CVRTrackedCamera m_pVRTrackedCamera; + private CVRInput m_pVRInput; }; private static COpenVRContext _OpenVRInternal_ModuleContext = null; @@ -5224,6 +5636,7 @@ public class OpenVR public static CVRApplications Applications { get { return OpenVRInternal_ModuleContext.VRApplications(); } } public static CVRScreenshots Screenshots { get { return OpenVRInternal_ModuleContext.VRScreenshots(); } } public static CVRTrackedCamera TrackedCamera { get { return OpenVRInternal_ModuleContext.VRTrackedCamera(); } } + public static CVRInput Input { get { return OpenVRInternal_ModuleContext.VRInput(); } } /** Finds the active installation of vrclient.dll and initializes it */ public static CVRSystem Init(ref EVRInitError peError, EVRApplicationType eApplicationType = EVRApplicationType.VRApplication_Scene) diff --git a/headers/openvr_api.json b/headers/openvr_api.json index b5516b6..a6bd7cb 100644 --- a/headers/openvr_api.json +++ b/headers/openvr_api.json @@ -17,6 +17,10 @@ ,{"typedef": "vr::VRComponentProperties","type": "uint32_t"} ,{"typedef": "vr::TextureID_t","type": "int32_t"} ,{"typedef": "vr::VRNotificationId","type": "uint32_t"} +,{"typedef": "vr::VRActionHandle_t","type": "uint64_t"} +,{"typedef": "vr::VRActionSetHandle_t","type": "uint64_t"} +,{"typedef": "vr::VRInputValueHandle_t","type": "uint64_t"} +,{"typedef": "vr::IOBufferHandle_t","type": "uint64_t"} ,{"typedef": "vr::HmdError","type": "enum vr::EVRInitError"} ,{"typedef": "vr::Hmd_Eye","type": "enum vr::EVREye"} ,{"typedef": "vr::ColorSpace","type": "enum vr::EColorSpace"} @@ -182,6 +186,11 @@ ,{"name": "Prop_MinimumIpdStepMeters_Float","value": "2060"} ,{"name": "Prop_AudioBridgeFirmwareVersion_Uint64","value": "2061"} ,{"name": "Prop_ImageBridgeFirmwareVersion_Uint64","value": "2062"} + ,{"name": "Prop_ImuToHeadTransform_Matrix34","value": "2063"} + ,{"name": "Prop_ImuFactoryGyroBias_Vector3","value": "2064"} + ,{"name": "Prop_ImuFactoryGyroScale_Vector3","value": "2065"} + ,{"name": "Prop_ImuFactoryAccelerometerBias_Vector3","value": "2066"} + ,{"name": "Prop_ImuFactoryAccelerometerScale_Vector3","value": "2067"} ,{"name": "Prop_AttachedDeviceId_String","value": "3000"} ,{"name": "Prop_SupportedButtons_Uint64","value": "3001"} ,{"name": "Prop_Axis0Type_Int32","value": "3002"} @@ -394,6 +403,8 @@ ,{"name": "VREvent_MessageOverlay_Closed","value": "1650"} ,{"name": "VREvent_MessageOverlayCloseRequested","value": "1651"} ,{"name": "VREvent_Input_HapticVibration","value": "1700"} + ,{"name": "VREvent_Input_BindingLoadFailed","value": "1701"} + ,{"name": "VREvent_Input_BindingLoadSuccessful","value": "1702"} ,{"name": "VREvent_VendorSpecific_Reserved_Start","value": "10000"} ,{"name": "VREvent_VendorSpecific_Reserved_End","value": "19999"} ]} @@ -444,6 +455,12 @@ ,{"name": "VRInputError_IPCError","value": "7"} ,{"name": "VRInputError_NoActiveActionSet","value": "8"} ,{"name": "VRInputError_InvalidDevice","value": "9"} + ,{"name": "VRInputError_InvalidSkeleton","value": "10"} + ,{"name": "VRInputError_InvalidBoneCount","value": "11"} + ,{"name": "VRInputError_InvalidCompressedData","value": "12"} + ,{"name": "VRInputError_NoData","value": "13"} + ,{"name": "VRInputError_BufferTooSmall","value": "14"} + ,{"name": "VRInputError_MismatchedActionManifest","value": "15"} ]} , {"enumname": "vr::EHiddenAreaMeshType","values": [ {"name": "k_eHiddenAreaMesh_Standard","value": "0"} @@ -655,6 +672,14 @@ ,{"name": "VSync_WaitRender","value": "1"} ,{"name": "VSync_NoWaitRender","value": "2"} ]} +, {"enumname": "vr::Imu_OffScaleFlags","values": [ + {"name": "OffScale_AccelX","value": "1"} + ,{"name": "OffScale_AccelY","value": "2"} + ,{"name": "OffScale_AccelZ","value": "4"} + ,{"name": "OffScale_GyroX","value": "8"} + ,{"name": "OffScale_GyroY","value": "16"} + ,{"name": "OffScale_GyroZ","value": "32"} +]} , {"enumname": "vr::EVRApplicationError","values": [ {"name": "VRApplicationError_None","value": "0"} ,{"name": "VRApplicationError_AppKeyAlreadyExists","value": "100"} @@ -849,6 +874,29 @@ ,{"name": "VRScreenshotError_BufferTooSmall","value": "102"} ,{"name": "VRScreenshotError_ScreenshotAlreadyInProgress","value": "108"} ]} +, {"enumname": "vr::EVRSkeletalTransformSpace","values": [ + {"name": "VRSkeletalTransformSpace_Action","value": "0"} + ,{"name": "VRSkeletalTransformSpace_Parent","value": "1"} + ,{"name": "VRSkeletalTransformSpace_Additive","value": "2"} +]} +, {"enumname": "vr::EVRInputFilterCancelType","values": [ + {"name": "VRInputFilterCancel_Timers","value": "0"} + ,{"name": "VRInputFilterCancel_Momentum","value": "1"} +]} +, {"enumname": "vr::EIOBufferError","values": [ + {"name": "IOBuffer_Success","value": "0"} + ,{"name": "IOBuffer_OperationFailed","value": "100"} + ,{"name": "IOBuffer_InvalidHandle","value": "101"} + ,{"name": "IOBuffer_InvalidArgument","value": "102"} + ,{"name": "IOBuffer_PathExists","value": "103"} + ,{"name": "IOBuffer_PathDoesNotExist","value": "104"} + ,{"name": "IOBuffer_Permission","value": "105"} +]} +, {"enumname": "vr::EIOBufferMode","values": [ + {"name": "IOBufferMode_Read","value": "1"} + ,{"name": "IOBufferMode_Write","value": "2"} + ,{"name": "IOBufferMode_Create","value": "512"} +]} ], "consts":[{ "constname": "k_nDriverNone","consttype": "const uint32_t", "constval": "4294967295"} @@ -899,6 +947,8 @@ ,{ "constname": "k_unHapticVibrationPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "35"} ,{ + "constname": "k_unSkeletonPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "36"} +,{ "constname": "k_unOpenVRInternalReserved_Start","consttype": "const PropertyTypeTag_t", "constval": "1000"} ,{ "constname": "k_unOpenVRInternalReserved_End","consttype": "const PropertyTypeTag_t", "constval": "10000"} @@ -1061,6 +1111,8 @@ ,{ "constname": "k_pch_SteamVR_LegacyInputRebinding","consttype": "const char *const", "constval": "legacyInputRebinding"} ,{ + "constname": "k_pch_SteamVR_DebugInputBinding","consttype": "const char *const", "constval": "debugInputBinding"} +,{ "constname": "k_pch_Lighthouse_Section","consttype": "const char *const", "constval": "driver_lighthouse"} ,{ "constname": "k_pch_Lighthouse_DisableIMU_Bool","consttype": "const char *const", "constval": "disableimu"} @@ -1235,11 +1287,39 @@ ,{ "constname": "k_pch_WebInterface_WebPort_String","consttype": "const char *const", "constval": "WebPort"} ,{ + "constname": "k_pch_TrackingOverride_Section","consttype": "const char *const", "constval": "TrackingOverrides"} +,{ + "constname": "k_pch_App_BindingAutosaveURLSuffix_String","consttype": "const char *const", "constval": "AutosaveURL"} +,{ + "constname": "k_pch_App_BindingCurrentURLSuffix_String","consttype": "const char *const", "constval": "CurrentURL"} +,{ + "constname": "k_pch_App_NeedToUpdateAutosaveSuffix_Bool","consttype": "const char *const", "constval": "NeedToUpdateAutosave"} +,{ + "constname": "k_pch_App_ActionManifestURL_String","consttype": "const char *const", "constval": "ActionManifestURL"} +,{ "constname": "IVRScreenshots_Version","consttype": "const char *const", "constval": "IVRScreenshots_001"} ,{ "constname": "IVRResources_Version","consttype": "const char *const", "constval": "IVRResources_001"} ,{ "constname": "IVRDriverManager_Version","consttype": "const char *const", "constval": "IVRDriverManager_001"} +,{ + "constname": "k_ulInvalidActionHandle","consttype": "const VRActionHandle_t", "constval": "0"} +,{ + "constname": "k_ulInvalidActionSetHandle","consttype": "const VRActionSetHandle_t", "constval": "0"} +,{ + "constname": "k_ulInvalidInputValueHandle","consttype": "const VRInputValueHandle_t", "constval": "0"} +,{ + "constname": "k_unMaxActionNameLength","consttype": "const uint32_t", "constval": "64"} +,{ + "constname": "k_unMaxActionSetNameLength","consttype": "const uint32_t", "constval": "64"} +,{ + "constname": "k_unMaxActionOriginCount","consttype": "const uint32_t", "constval": "16"} +,{ + "constname": "IVRInput_Version","consttype": "const char *const", "constval": "IVRInput_003"} +,{ + "constname": "k_ulInvalidIOBufferHandle","consttype": "const uint64_t", "constval": "0"} +,{ + "constname": "IVRIOBuffer_Version","consttype": "const char *", "constval": "IVRIOBuffer_001"} ], "structs":[{"struct": "vr::HmdMatrix34_t","fields": [ { "fieldname": "m", "fieldtype": "float [3][4]"}]} @@ -1258,6 +1338,11 @@ { "fieldname": "x", "fieldtype": "double"}, { "fieldname": "y", "fieldtype": "double"}, { "fieldname": "z", "fieldtype": "double"}]} +,{"struct": "vr::HmdQuaternionf_t","fields": [ +{ "fieldname": "w", "fieldtype": "float"}, +{ "fieldname": "x", "fieldtype": "float"}, +{ "fieldname": "y", "fieldtype": "float"}, +{ "fieldname": "z", "fieldtype": "float"}]} ,{"struct": "vr::HmdColor_t","fields": [ { "fieldname": "r", "fieldtype": "float"}, { "fieldname": "g", "fieldtype": "float"}, @@ -1389,6 +1474,10 @@ { "fieldname": "fAmplitude", "fieldtype": "float"}]} ,{"struct": "vr::VREvent_WebConsole_t","fields": [ { "fieldname": "webConsoleHandle", "fieldtype": "WebConsoleHandle_t"}]} +,{"struct": "vr::VREvent_InputBindingLoad_t","fields": [ +{ "fieldname": "ulAppContainer", "fieldtype": "vr::PropertyContainerHandle_t"}, +{ "fieldname": "pathMessage", "fieldtype": "uint64_t"}, +{ "fieldname": "pathUrl", "fieldtype": "uint64_t"}]} ,{"struct": "vr::(anonymous)","fields": [ { "fieldname": "reserved", "fieldtype": "struct vr::VREvent_Reserved_t"}, { "fieldname": "controller", "fieldtype": "struct vr::VREvent_Controller_t"}, @@ -1412,7 +1501,8 @@ { "fieldname": "property", "fieldtype": "struct vr::VREvent_Property_t"}, { "fieldname": "dualAnalog", "fieldtype": "struct vr::VREvent_DualAnalog_t"}, { "fieldname": "hapticVibration", "fieldtype": "struct vr::VREvent_HapticVibration_t"}, -{ "fieldname": "webConsole", "fieldtype": "struct vr::VREvent_WebConsole_t"}]} +{ "fieldname": "webConsole", "fieldtype": "struct vr::VREvent_WebConsole_t"}, +{ "fieldname": "inputBinding", "fieldtype": "struct vr::VREvent_InputBindingLoad_t"}]} ,{"struct": "vr::VREvent_t","fields": [ { "fieldname": "eventType", "fieldtype": "uint32_t"}, { "fieldname": "trackedDeviceIndex", "fieldtype": "TrackedDeviceIndex_t"}, @@ -1444,6 +1534,9 @@ { "fieldname": "gridWidth", "fieldtype": "float"}, { "fieldname": "gridScale", "fieldtype": "float"}, { "fieldname": "transform", "fieldtype": "struct vr::HmdMatrix44_t"}]} +,{"struct": "vr::VRBoneTransform_t","fields": [ +{ "fieldname": "position", "fieldtype": "struct vr::HmdVector4_t"}, +{ "fieldname": "orientation", "fieldtype": "struct vr::HmdQuaternionf_t"}]} ,{"struct": "vr::CameraVideoStreamFrameHeader_t","fields": [ { "fieldname": "eFrameType", "fieldtype": "enum vr::EVRTrackedCameraFrameType"}, { "fieldname": "nWidth", "fieldtype": "uint32_t"}, @@ -1457,6 +1550,11 @@ { "fieldname": "m_nNumMisPresented", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumDroppedFrames", "fieldtype": "uint32_t"}, { "fieldname": "m_nReprojectionFlags", "fieldtype": "uint32_t"}]} +,{"struct": "vr::ImuSample_t","fields": [ +{ "fieldname": "fSampleTime", "fieldtype": "double"}, +{ "fieldname": "vAccel", "fieldtype": "struct vr::HmdVector3d_t"}, +{ "fieldname": "vGyro", "fieldtype": "struct vr::HmdVector3d_t"}, +{ "fieldname": "unOffScaleFlags", "fieldtype": "uint32_t"}]} ,{"struct": "vr::AppOverrideKeys_t","fields": [ { "fieldname": "pchKey", "fieldtype": "const char *"}, { "fieldname": "pchValue", "fieldtype": "const char *"}]} @@ -1550,6 +1648,37 @@ { "fieldname": "m_nWidth", "fieldtype": "int32_t"}, { "fieldname": "m_nHeight", "fieldtype": "int32_t"}, { "fieldname": "m_nBytesPerPixel", "fieldtype": "int32_t"}]} +,{"struct": "vr::InputAnalogActionData_t","fields": [ +{ "fieldname": "bActive", "fieldtype": "_Bool"}, +{ "fieldname": "activeOrigin", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "x", "fieldtype": "float"}, +{ "fieldname": "y", "fieldtype": "float"}, +{ "fieldname": "z", "fieldtype": "float"}, +{ "fieldname": "deltaX", "fieldtype": "float"}, +{ "fieldname": "deltaY", "fieldtype": "float"}, +{ "fieldname": "deltaZ", "fieldtype": "float"}, +{ "fieldname": "fUpdateTime", "fieldtype": "float"}]} +,{"struct": "vr::InputDigitalActionData_t","fields": [ +{ "fieldname": "bActive", "fieldtype": "_Bool"}, +{ "fieldname": "activeOrigin", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "bState", "fieldtype": "_Bool"}, +{ "fieldname": "bChanged", "fieldtype": "_Bool"}, +{ "fieldname": "fUpdateTime", "fieldtype": "float"}]} +,{"struct": "vr::InputPoseActionData_t","fields": [ +{ "fieldname": "bActive", "fieldtype": "_Bool"}, +{ "fieldname": "activeOrigin", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "pose", "fieldtype": "struct vr::TrackedDevicePose_t"}]} +,{"struct": "vr::InputSkeletonActionData_t","fields": [ +{ "fieldname": "bActive", "fieldtype": "_Bool"}, +{ "fieldname": "activeOrigin", "fieldtype": "VRInputValueHandle_t"}]} +,{"struct": "vr::InputOriginInfo_t","fields": [ +{ "fieldname": "devicePath", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "trackedDeviceIndex", "fieldtype": "TrackedDeviceIndex_t"}, +{ "fieldname": "rchRenderModelComponentName", "fieldtype": "char [128]"}]} +,{"struct": "vr::VRActiveActionSet_t","fields": [ +{ "fieldname": "ulActionSet", "fieldtype": "VRActionSetHandle_t"}, +{ "fieldname": "ulRestrictedToDevice", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "ulSecondaryActionSet", "fieldtype": "VRActionSetHandle_t"}]} ,{"struct": "vr::COpenVRContext","fields": [ { "fieldname": "m_pVRSystem", "fieldtype": "class vr::IVRSystem *"}, { "fieldname": "m_pVRChaperone", "fieldtype": "class vr::IVRChaperone *"}, @@ -1563,7 +1692,9 @@ { "fieldname": "m_pVRApplications", "fieldtype": "class vr::IVRApplications *"}, { "fieldname": "m_pVRTrackedCamera", "fieldtype": "class vr::IVRTrackedCamera *"}, { "fieldname": "m_pVRScreenshots", "fieldtype": "class vr::IVRScreenshots *"}, -{ "fieldname": "m_pVRDriverManager", "fieldtype": "class vr::IVRDriverManager *"}]} +{ "fieldname": "m_pVRDriverManager", "fieldtype": "class vr::IVRDriverManager *"}, +{ "fieldname": "m_pVRInput", "fieldtype": "class vr::IVRInput *"}, +{ "fieldname": "m_pVRIOBuffer", "fieldtype": "class vr::IVRIOBuffer *"}]} ], "methods":[{ "classname": "vr::IVRSystem", @@ -4126,5 +4257,233 @@ { "paramname": "pchDriverName" ,"paramtype": "const char *"} ] } +,{ + "classname": "vr::IVRInput", + "methodname": "SetActionManifestPath", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchActionManifestPath" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetActionSetHandle", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchActionSetName" ,"paramtype": "const char *"}, +{ "paramname": "pHandle" ,"paramtype": "vr::VRActionSetHandle_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetActionHandle", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchActionName" ,"paramtype": "const char *"}, +{ "paramname": "pHandle" ,"paramtype": "vr::VRActionHandle_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetInputSourceHandle", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchInputSourcePath" ,"paramtype": "const char *"}, +{ "paramname": "pHandle" ,"paramtype": "vr::VRInputValueHandle_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "UpdateActionState", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pSets" ,"array_count": "unSetCount" ,"paramtype": "struct vr::VRActiveActionSet_t *"}, +{ "paramname": "unSizeOfVRSelectedActionSet_t" ,"paramtype": "uint32_t"}, +{ "paramname": "unSetCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetDigitalActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputDigitalActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetAnalogActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputAnalogActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetPoseActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eOrigin" ,"paramtype": "vr::ETrackingUniverseOrigin"}, +{ "paramname": "fPredictedSecondsFromNow" ,"paramtype": "float"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputPoseActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eBoneParent" ,"paramtype": "vr::EVRSkeletalTransformSpace"}, +{ "paramname": "fPredictedSecondsFromNow" ,"paramtype": "float"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputSkeletonActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"}, +{ "paramname": "pTransformArray" ,"array_count": "unTransformArrayCount" ,"paramtype": "struct vr::VRBoneTransform_t *"}, +{ "paramname": "unTransformArrayCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalActionDataCompressed", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eBoneParent" ,"paramtype": "vr::EVRSkeletalTransformSpace"}, +{ "paramname": "fPredictedSecondsFromNow" ,"paramtype": "float"}, +{ "paramname": "pvCompressedData" ,"out_buffer_count": "unCompressedSize" ,"paramtype": "void *"}, +{ "paramname": "unCompressedSize" ,"paramtype": "uint32_t"}, +{ "paramname": "punRequiredCompressedSize" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "UncompressSkeletalActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pvCompressedBuffer" ,"paramtype": "void *"}, +{ "paramname": "unCompressedBufferSize" ,"paramtype": "uint32_t"}, +{ "paramname": "peBoneParent" ,"paramtype": "vr::EVRSkeletalTransformSpace *"}, +{ "paramname": "pTransformArray" ,"array_count": "unTransformArrayCount" ,"paramtype": "struct vr::VRBoneTransform_t *"}, +{ "paramname": "unTransformArrayCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "TriggerHapticVibrationAction", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "fStartSecondsFromNow" ,"paramtype": "float"}, +{ "paramname": "fDurationSeconds" ,"paramtype": "float"}, +{ "paramname": "fFrequency" ,"paramtype": "float"}, +{ "paramname": "fAmplitude" ,"paramtype": "float"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetActionOrigins", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "actionSetHandle" ,"paramtype": "vr::VRActionSetHandle_t"}, +{ "paramname": "digitalActionHandle" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "originsOut" ,"array_count": "originOutCount" ,"paramtype": "vr::VRInputValueHandle_t *"}, +{ "paramname": "originOutCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetOriginLocalizedName", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "origin" ,"paramtype": "vr::VRInputValueHandle_t"}, +{ "paramname": "pchNameArray" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unNameArraySize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetOriginTrackedDeviceInfo", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "origin" ,"paramtype": "vr::VRInputValueHandle_t"}, +{ "paramname": "pOriginInfo" ,"paramtype": "struct vr::InputOriginInfo_t *"}, +{ "paramname": "unOriginInfoSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "ShowActionOrigins", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "actionSetHandle" ,"paramtype": "vr::VRActionSetHandle_t"}, +{ "paramname": "ulActionHandle" ,"paramtype": "vr::VRActionHandle_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "ShowBindingsForActionSet", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pSets" ,"array_count": "unSetCount" ,"paramtype": "struct vr::VRActiveActionSet_t *"}, +{ "paramname": "unSizeOfVRSelectedActionSet_t" ,"paramtype": "uint32_t"}, +{ "paramname": "unSetCount" ,"paramtype": "uint32_t"}, +{ "paramname": "originToHighlight" ,"paramtype": "vr::VRInputValueHandle_t"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "Open", + "returntype": "vr::EIOBufferError", + "params": [ +{ "paramname": "pchPath" ,"paramtype": "const char *"}, +{ "paramname": "mode" ,"paramtype": "vr::EIOBufferMode"}, +{ "paramname": "unElementSize" ,"paramtype": "uint32_t"}, +{ "paramname": "unElements" ,"paramtype": "uint32_t"}, +{ "paramname": "pulBuffer" ,"paramtype": "vr::IOBufferHandle_t *"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "Close", + "returntype": "vr::EIOBufferError", + "params": [ +{ "paramname": "ulBuffer" ,"paramtype": "vr::IOBufferHandle_t"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "Read", + "returntype": "vr::EIOBufferError", + "params": [ +{ "paramname": "ulBuffer" ,"paramtype": "vr::IOBufferHandle_t"}, +{ "paramname": "pDst" ,"paramtype": "void *"}, +{ "paramname": "unBytes" ,"paramtype": "uint32_t"}, +{ "paramname": "punRead" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "Write", + "returntype": "vr::EIOBufferError", + "params": [ +{ "paramname": "ulBuffer" ,"paramtype": "vr::IOBufferHandle_t"}, +{ "paramname": "pSrc" ,"paramtype": "void *"}, +{ "paramname": "unBytes" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "PropertyContainer", + "returntype": "vr::PropertyContainerHandle_t", + "params": [ +{ "paramname": "ulBuffer" ,"paramtype": "vr::IOBufferHandle_t"} + ] +} ] }
\ No newline at end of file diff --git a/headers/openvr_capi.h b/headers/openvr_capi.h index 652e535..ee24e90 100644 --- a/headers/openvr_capi.h +++ b/headers/openvr_capi.h @@ -87,6 +87,7 @@ static const unsigned int k_unActionPropertyTag = 32; static const unsigned int k_unInputValuePropertyTag = 33; static const unsigned int k_unWildcardPropertyTag = 34; static const unsigned int k_unHapticVibrationPropertyTag = 35; +static const unsigned int k_unSkeletonPropertyTag = 36; static const unsigned int k_unOpenVRInternalReserved_Start = 1000; static const unsigned int k_unOpenVRInternalReserved_End = 10000; static const unsigned int k_unMaxPropertyStringSize = 32768; @@ -168,6 +169,7 @@ static const char * k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bo static const char * k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; static const char * k_pch_SteamVR_DebugInput = "debugInput"; static const char * k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; +static const char * k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; static const char * k_pch_Lighthouse_Section = "driver_lighthouse"; static const char * k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; static const char * k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; @@ -255,9 +257,23 @@ static const char * k_pch_modelskin_Section = "modelskins"; static const char * k_pch_Driver_Enable_Bool = "enable"; static const char * k_pch_WebInterface_Section = "WebInterface"; static const char * k_pch_WebInterface_WebPort_String = "WebPort"; +static const char * k_pch_TrackingOverride_Section = "TrackingOverrides"; +static const char * k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; +static const char * k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; +static const char * k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; +static const char * k_pch_App_ActionManifestURL_String = "ActionManifestURL"; static const char * IVRScreenshots_Version = "IVRScreenshots_001"; static const char * IVRResources_Version = "IVRResources_001"; static const char * IVRDriverManager_Version = "IVRDriverManager_001"; +static const unsigned long k_ulInvalidActionHandle = 0; +static const unsigned long k_ulInvalidActionSetHandle = 0; +static const unsigned long k_ulInvalidInputValueHandle = 0; +static const unsigned int k_unMaxActionNameLength = 64; +static const unsigned int k_unMaxActionSetNameLength = 64; +static const unsigned int k_unMaxActionOriginCount = 16; +static const char * IVRInput_Version = "IVRInput_003"; +static const unsigned long k_ulInvalidIOBufferHandle = 0; +static const char * IVRIOBuffer_Version = "IVRIOBuffer_001"; // OpenVR Enums @@ -424,6 +440,11 @@ typedef enum ETrackedDeviceProperty ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060, ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063, + ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064, + ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065, + ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000, ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001, ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002, @@ -644,6 +665,8 @@ typedef enum EVREventType EVREventType_VREvent_MessageOverlay_Closed = 1650, EVREventType_VREvent_MessageOverlayCloseRequested = 1651, EVREventType_VREvent_Input_HapticVibration = 1700, + EVREventType_VREvent_Input_BindingLoadFailed = 1701, + EVREventType_VREvent_Input_BindingLoadSuccessful = 1702, EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000, EVREventType_VREvent_VendorSpecific_Reserved_End = 19999, } EVREventType; @@ -704,6 +727,12 @@ typedef enum EVRInputError EVRInputError_VRInputError_IPCError = 7, EVRInputError_VRInputError_NoActiveActionSet = 8, EVRInputError_VRInputError_InvalidDevice = 9, + EVRInputError_VRInputError_InvalidSkeleton = 10, + EVRInputError_VRInputError_InvalidBoneCount = 11, + EVRInputError_VRInputError_InvalidCompressedData = 12, + EVRInputError_VRInputError_NoData = 13, + EVRInputError_VRInputError_BufferTooSmall = 14, + EVRInputError_VRInputError_MismatchedActionManifest = 15, } EVRInputError; typedef enum EHiddenAreaMeshType @@ -946,6 +975,16 @@ typedef enum EVSync EVSync_VSync_NoWaitRender = 2, } EVSync; +typedef enum Imu_OffScaleFlags +{ + Imu_OffScaleFlags_OffScale_AccelX = 1, + Imu_OffScaleFlags_OffScale_AccelY = 2, + Imu_OffScaleFlags_OffScale_AccelZ = 4, + Imu_OffScaleFlags_OffScale_GyroX = 8, + Imu_OffScaleFlags_OffScale_GyroY = 16, + Imu_OffScaleFlags_OffScale_GyroZ = 32, +} Imu_OffScaleFlags; + typedef enum EVRApplicationError { EVRApplicationError_VRApplicationError_None = 0, @@ -1184,6 +1223,37 @@ typedef enum EVRScreenshotError EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108, } EVRScreenshotError; +typedef enum EVRSkeletalTransformSpace +{ + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Action = 0, + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1, + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Additive = 2, +} EVRSkeletalTransformSpace; + +typedef enum EVRInputFilterCancelType +{ + EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0, + EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1, +} EVRInputFilterCancelType; + +typedef enum EIOBufferError +{ + EIOBufferError_IOBuffer_Success = 0, + EIOBufferError_IOBuffer_OperationFailed = 100, + EIOBufferError_IOBuffer_InvalidHandle = 101, + EIOBufferError_IOBuffer_InvalidArgument = 102, + EIOBufferError_IOBuffer_PathExists = 103, + EIOBufferError_IOBuffer_PathDoesNotExist = 104, + EIOBufferError_IOBuffer_Permission = 105, +} EIOBufferError; + +typedef enum EIOBufferMode +{ + EIOBufferMode_IOBufferMode_Read = 1, + EIOBufferMode_IOBufferMode_Write = 2, + EIOBufferMode_IOBufferMode_Create = 512, +} EIOBufferMode; + // OpenVR typedefs @@ -1207,6 +1277,10 @@ typedef uint32_t ScreenshotHandle_t; typedef uint32_t VRComponentProperties; typedef int32_t TextureID_t; typedef uint32_t VRNotificationId; +typedef uint64_t VRActionHandle_t; +typedef uint64_t VRActionSetHandle_t; +typedef uint64_t VRInputValueHandle_t; +typedef uint64_t IOBufferHandle_t; typedef EVRInitError HmdError; typedef EVREye Hmd_Eye; typedef EColorSpace ColorSpace; @@ -1263,6 +1337,14 @@ typedef struct HmdQuaternion_t double z; } HmdQuaternion_t; +typedef struct HmdQuaternionf_t +{ + float w; + float x; + float y; + float z; +} HmdQuaternionf_t; + typedef struct HmdColor_t { float r; @@ -1502,6 +1584,13 @@ typedef struct VREvent_WebConsole_t WebConsoleHandle_t webConsoleHandle; } VREvent_WebConsole_t; +typedef struct VREvent_InputBindingLoad_t +{ + PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; +} VREvent_InputBindingLoad_t; + typedef struct HiddenAreaMesh_t { struct HmdVector2_t * pVertexData; // const struct vr::HmdVector2_t * @@ -1540,6 +1629,12 @@ typedef struct Compositor_OverlaySettings struct HmdMatrix44_t transform; } Compositor_OverlaySettings; +typedef struct VRBoneTransform_t +{ + struct HmdVector4_t position; + struct HmdQuaternionf_t orientation; +} VRBoneTransform_t; + typedef struct CameraVideoStreamFrameHeader_t { enum EVRTrackedCameraFrameType eFrameType; @@ -1559,6 +1654,14 @@ typedef struct DriverDirectMode_FrameTiming uint32_t m_nReprojectionFlags; } DriverDirectMode_FrameTiming; +typedef struct ImuSample_t +{ + double fSampleTime; + struct HmdVector3d_t vAccel; + struct HmdVector3d_t vGyro; + uint32_t unOffScaleFlags; +} ImuSample_t; + typedef struct AppOverrideKeys_t { char * pchKey; // const char * @@ -1697,6 +1800,55 @@ typedef struct NotificationBitmap_t int32_t m_nBytesPerPixel; } NotificationBitmap_t; +typedef struct InputAnalogActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + float x; + float y; + float z; + float deltaX; + float deltaY; + float deltaZ; + float fUpdateTime; +} InputAnalogActionData_t; + +typedef struct InputDigitalActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + bool bState; + bool bChanged; + float fUpdateTime; +} InputDigitalActionData_t; + +typedef struct InputPoseActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + struct TrackedDevicePose_t pose; +} InputPoseActionData_t; + +typedef struct InputSkeletonActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; +} InputSkeletonActionData_t; + +typedef struct InputOriginInfo_t +{ + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char * rchRenderModelComponentName[128]; //char[128] +} InputOriginInfo_t; + +typedef struct VRActiveActionSet_t +{ + VRActionSetHandle_t ulActionSet; + VRInputValueHandle_t ulRestrictedToDevice; + VRActionSetHandle_t ulSecondaryActionSet; +} VRActiveActionSet_t; + typedef struct COpenVRContext { intptr_t m_pVRSystem; // class vr::IVRSystem * @@ -1712,6 +1864,8 @@ typedef struct COpenVRContext intptr_t m_pVRTrackedCamera; // class vr::IVRTrackedCamera * intptr_t m_pVRScreenshots; // class vr::IVRScreenshots * intptr_t m_pVRDriverManager; // class vr::IVRDriverManager * + intptr_t m_pVRInput; // class vr::IVRInput * + intptr_t m_pVRIOBuffer; // class vr::IVRIOBuffer * } COpenVRContext; @@ -2105,6 +2259,36 @@ struct VR_IVRDriverManager_FnTable DriverHandle_t (OPENVR_FNTABLE_CALLTYPE *GetDriverHandle)(char * pchDriverName); }; +struct VR_IVRInput_FnTable +{ + EVRInputError (OPENVR_FNTABLE_CALLTYPE *SetActionManifestPath)(char * pchActionManifestPath); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionSetHandle)(char * pchActionSetName, VRActionSetHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionHandle)(char * pchActionName, VRActionHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetInputSourceHandle)(char * pchInputSourcePath, VRInputValueHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *UpdateActionState)(struct VRActiveActionSet_t * pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetDigitalActionData)(VRActionHandle_t action, struct InputDigitalActionData_t * pActionData, uint32_t unActionDataSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetAnalogActionData)(VRActionHandle_t action, struct InputAnalogActionData_t * pActionData, uint32_t unActionDataSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetPoseActionData)(VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, struct InputPoseActionData_t * pActionData, uint32_t unActionDataSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalActionData)(VRActionHandle_t action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, struct InputSkeletonActionData_t * pActionData, uint32_t unActionDataSize, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalActionDataCompressed)(VRActionHandle_t action, EVRSkeletalTransformSpace eBoneParent, float fPredictedSecondsFromNow, void * pvCompressedData, uint32_t unCompressedSize, uint32_t * punRequiredCompressedSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *UncompressSkeletalActionData)(void * pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace * peBoneParent, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *TriggerHapticVibrationAction)(VRActionHandle_t action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionOrigins)(VRActionSetHandle_t actionSetHandle, VRActionHandle_t digitalActionHandle, VRInputValueHandle_t * originsOut, uint32_t originOutCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetOriginLocalizedName)(VRInputValueHandle_t origin, char * pchNameArray, uint32_t unNameArraySize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetOriginTrackedDeviceInfo)(VRInputValueHandle_t origin, struct InputOriginInfo_t * pOriginInfo, uint32_t unOriginInfoSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *ShowActionOrigins)(VRActionSetHandle_t actionSetHandle, VRActionHandle_t ulActionHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *ShowBindingsForActionSet)(struct VRActiveActionSet_t * pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount, VRInputValueHandle_t originToHighlight); +}; + +struct VR_IVRIOBuffer_FnTable +{ + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Open)(char * pchPath, EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, IOBufferHandle_t * pulBuffer); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Close)(IOBufferHandle_t ulBuffer); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Read)(IOBufferHandle_t ulBuffer, void * pDst, uint32_t unBytes, uint32_t * punRead); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Write)(IOBufferHandle_t ulBuffer, void * pSrc, uint32_t unBytes); + PropertyContainerHandle_t (OPENVR_FNTABLE_CALLTYPE *PropertyContainer)(IOBufferHandle_t ulBuffer); +}; + #if 0 // Global entry points diff --git a/headers/openvr_driver.h b/headers/openvr_driver.h index 0406f85..5ece0a0 100644 --- a/headers/openvr_driver.h +++ b/headers/openvr_driver.h @@ -73,6 +73,11 @@ struct HmdQuaternion_t double w, x, y, z; }; +struct HmdQuaternionf_t +{ + float w, x, y, z; +}; + struct HmdColor_t { float r, g, b, a; @@ -234,6 +239,7 @@ static const PropertyTypeTag_t k_unActionPropertyTag = 32; static const PropertyTypeTag_t k_unInputValuePropertyTag = 33; static const PropertyTypeTag_t k_unWildcardPropertyTag = 34; static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35; +static const PropertyTypeTag_t k_unSkeletonPropertyTag = 36; static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; @@ -350,6 +356,11 @@ enum ETrackedDeviceProperty Prop_MinimumIpdStepMeters_Float = 2060, Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + Prop_ImuToHeadTransform_Matrix34 = 2063, + Prop_ImuFactoryGyroBias_Vector3 = 2064, + Prop_ImuFactoryGyroScale_Vector3 = 2065, + Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, // Properties that are unique to TrackedDeviceClass_Controller Prop_AttachedDeviceId_String = 3000, @@ -689,6 +700,8 @@ enum EVREventType VREvent_MessageOverlayCloseRequested = 1651, VREvent_Input_HapticVibration = 1700, // data is hapticVibration + VREvent_Input_BindingLoadFailed = 1701, // data is process + VREvent_Input_BindingLoadSuccessful = 1702, // data is process // Vendors are free to expose private events in this reserved region VREvent_VendorSpecific_Reserved_Start = 10000, @@ -921,6 +934,14 @@ struct VREvent_WebConsole_t WebConsoleHandle_t webConsoleHandle; }; +struct VREvent_InputBindingLoad_t +{ + vr::PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; +}; + + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ typedef union { @@ -947,6 +968,7 @@ typedef union VREvent_DualAnalog_t dualAnalog; VREvent_HapticVibration_t hapticVibration; VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; } VREvent_Data_t; @@ -982,6 +1004,12 @@ enum EVRInputError VRInputError_IPCError = 7, VRInputError_NoActiveActionSet = 8, VRInputError_InvalidDevice = 9, + VRInputError_InvalidSkeleton = 10, + VRInputError_InvalidBoneCount = 11, + VRInputError_InvalidCompressedData = 12, + VRInputError_NoData = 13, + VRInputError_BufferTooSmall = 14, + VRInputError_MismatchedActionManifest = 15, }; @@ -1166,6 +1194,14 @@ enum EVRNotificationError }; +/** Holds the transform for a single bone */ +struct VRBoneTransform_t +{ + HmdVector4_t position; + HmdQuaternionf_t orientation; +}; + + /** error codes returned by Vr_Init */ // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp @@ -1359,6 +1395,25 @@ enum EVSync VSync_NoWaitRender, // do not block following render work (allow to get started early) }; +/** raw IMU data provided by IVRIOBuffer from paths to tracked devices with IMUs */ +enum Imu_OffScaleFlags +{ + OffScale_AccelX = 0x01, + OffScale_AccelY = 0x02, + OffScale_AccelZ = 0x04, + OffScale_GyroX = 0x08, + OffScale_GyroY = 0x10, + OffScale_GyroZ = 0x20, +}; + +struct ImuSample_t +{ + double fSampleTime; + HmdVector3d_t vAccel; + HmdVector3d_t vGyro; + uint32_t unOffScaleFlags; +}; + #pragma pack( pop ) // figure out how to import from the VR API dll @@ -1608,6 +1663,7 @@ namespace vr static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; static const char * const k_pch_SteamVR_DebugInput = "debugInput"; static const char * const k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; + static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; //----------------------------------------------------------------------------- // lighthouse keys @@ -1738,6 +1794,18 @@ namespace vr static const char* const k_pch_WebInterface_Section = "WebInterface"; static const char* const k_pch_WebInterface_WebPort_String = "WebPort"; + //----------------------------------------------------------------------------- + // tracking overrides - keys are device paths, values are the device paths their + // tracking/pose information overrides + static const char* const k_pch_TrackingOverride_Section = "TrackingOverrides"; + + //----------------------------------------------------------------------------- + // per-app keys - the section name for these is the app key itself. Some of these are prefixed by the controller type + static const char* const k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + static const char* const k_pch_App_ActionManifestURL_String = "ActionManifestURL"; + } // namespace vr // iservertrackeddevicedriver.h @@ -2533,6 +2601,12 @@ namespace vr /** Creates a haptic component for the device */ virtual EVRInputError CreateHapticComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0; + /** Creates a skeleton component. */ + virtual EVRInputError CreateSkeletonComponent( PropertyContainerHandle_t ulContainer, const char *pchName, const char *pchSkeletonPath, const char *pchBasePosePath, const VRBoneTransform_t *pGripLimitTransforms, uint32_t unGripLimitTransformCount, VRInputComponentHandle_t *pHandle ) = 0; + + /** Updates a skeleton component. */ + virtual EVRInputError UpdateSkeletonComponent( VRInputComponentHandle_t ulComponent, const VRBoneTransform_t *pTransforms, uint32_t unTransformCount ) = 0; + }; static const char * const IVRDriverInput_Version = "IVRDriverInput_001"; @@ -2740,6 +2814,56 @@ static const char * const IVRResources_Version = "IVRResources_001"; } +// ivriobuffer.h +namespace vr +{ + +typedef uint64_t IOBufferHandle_t; +static const uint64_t k_ulInvalidIOBufferHandle = 0; + + enum EIOBufferError + { + IOBuffer_Success = 0, + IOBuffer_OperationFailed = 100, + IOBuffer_InvalidHandle = 101, + IOBuffer_InvalidArgument = 102, + IOBuffer_PathExists = 103, + IOBuffer_PathDoesNotExist = 104, + IOBuffer_Permission = 105, + }; + + enum EIOBufferMode + { + IOBufferMode_Read = 0x0001, + IOBufferMode_Write = 0x0002, + IOBufferMode_Create = 0x0200, + }; + + // ---------------------------------------------------------------------------------------------- + // Purpose: + // ---------------------------------------------------------------------------------------------- + class IVRIOBuffer + { + public: + /** opens an existing or creates a new IOBuffer of unSize bytes */ + virtual vr::EIOBufferError Open( const char *pchPath, vr::EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, vr::IOBufferHandle_t *pulBuffer ) = 0; + + /** closes a previously opened or created buffer */ + virtual vr::EIOBufferError Close( vr::IOBufferHandle_t ulBuffer ) = 0; + + /** reads up to unBytes from buffer into *pDst, returning number of bytes read in *punRead */ + virtual vr::EIOBufferError Read( vr::IOBufferHandle_t ulBuffer, void *pDst, uint32_t unBytes, uint32_t *punRead ) = 0; + + /** writes unBytes of data from *pSrc into a buffer. */ + virtual vr::EIOBufferError Write( vr::IOBufferHandle_t ulBuffer, void *pSrc, uint32_t unBytes ) = 0; + + /** retrieves the property container of an buffer. */ + virtual vr::PropertyContainerHandle_t PropertyContainer( vr::IOBufferHandle_t ulBuffer ) = 0; + }; + + static const char *IVRIOBuffer_Version = "IVRIOBuffer_001"; +} + // ivrdrivermanager.h namespace vr { @@ -2894,6 +3018,16 @@ namespace vr return m_pVRDriverInput; } + IVRIOBuffer *VRIOBuffer() + { + if ( !m_pVRIOBuffer ) + { + EVRInitError eError; + m_pVRIOBuffer = (IVRIOBuffer *)VRDriverContext()->GetGenericInterface( IVRIOBuffer_Version, &eError ); + } + return m_pVRIOBuffer; + } + private: CVRPropertyHelpers m_propertyHelpers; CVRHiddenAreaHelpers m_hiddenAreaHelpers; @@ -2906,6 +3040,7 @@ namespace vr IVRDriverManager *m_pVRDriverManager; IVRResources *m_pVRResources; IVRDriverInput *m_pVRDriverInput; + IVRIOBuffer *m_pVRIOBuffer; }; inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext() @@ -2925,6 +3060,7 @@ namespace vr inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleServerDriverContext().VRDriverManager(); } inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleServerDriverContext().VRResources(); } inline IVRDriverInput *VR_CALLTYPE VRDriverInput() { return OpenVRInternal_ModuleServerDriverContext().VRDriverInput(); } + inline IVRIOBuffer *VR_CALLTYPE VRIOBuffer() { return OpenVRInternal_ModuleServerDriverContext().VRIOBuffer(); } inline void COpenVRDriverContext::Clear() { @@ -2936,6 +3072,7 @@ namespace vr m_pVRDriverManager = nullptr; m_pVRResources = nullptr; m_pVRDriverInput = nullptr; + m_pVRIOBuffer = nullptr; } inline EVRInitError COpenVRDriverContext::InitServer() diff --git a/lib/linux32/libopenvr_api.so b/lib/linux32/libopenvr_api.so Binary files differindex d58dcc9..50f365d 100755 --- a/lib/linux32/libopenvr_api.so +++ b/lib/linux32/libopenvr_api.so diff --git a/lib/linux64/libopenvr_api.so b/lib/linux64/libopenvr_api.so Binary files differindex e20f53e..db220fe 100755 --- a/lib/linux64/libopenvr_api.so +++ b/lib/linux64/libopenvr_api.so diff --git a/lib/win32/openvr_api.lib b/lib/win32/openvr_api.lib Binary files differindex dd4a203..fd18448 100644 --- a/lib/win32/openvr_api.lib +++ b/lib/win32/openvr_api.lib diff --git a/lib/win64/openvr_api.lib b/lib/win64/openvr_api.lib Binary files differindex 623f77e..ea46774 100644 --- a/lib/win64/openvr_api.lib +++ b/lib/win64/openvr_api.lib diff --git a/samples/bin/hellovr_actions.json b/samples/bin/hellovr_actions.json new file mode 100644 index 0000000..bb0327c --- /dev/null +++ b/samples/bin/hellovr_actions.json @@ -0,0 +1,54 @@ +{ + "default_bindings": [ + { + "controller_type" : "vive_controller", + "binding_url" : "hellovr_bindings_vive_controller" + } + ], + "actions": [ + { + "name": "/actions/demo/in/HideCubes", + "type": "boolean" + }, + { + "name": "/actions/demo/in/HideThisController", + "type": "boolean" + }, + { + "name": "/actions/demo/in/TriggerHaptic", + "type": "boolean" + }, + { + "name": "/actions/demo/in/AnalogInput", + "type": "vector2" + }, + { + "name": "/actions/demo/in/Hand_Right", + "type": "pose" + }, + { + "name": "/actions/demo/in/Hand_Left", + "type": "pose" + }, + { + "name": "/actions/demo/out/Haptic_Left", + "type": "vibration" + }, + { + "name": "/actions/demo/out/Haptic_Right", + "type": "vibration" + } + ], + "localization" : [ + { + "language_tag": "en", + "/actions/demo/in/HideCubes" : "Hide Cubes", + "/actions/demo/in/TriggerHaptic" : "Trigger Haptic Pulse", + "/actions/demo/in/AnalogInput" : "Analog Input", + "/actions/demo/in/Hand_Right" : "Right Hand Pose", + "/actions/demo/in/Hand_Left" : "Left Hand Pose", + "/actions/demo/out/Haptic_Left" : "Left Haptic Feedback", + "/actions/demo/out/Haptic_Right" : "Right Haptic Feedback" + } + ] +} diff --git a/samples/bin/hellovr_bindings_vive_controller.json b/samples/bin/hellovr_bindings_vive_controller.json new file mode 100644 index 0000000..4fb3e5b --- /dev/null +++ b/samples/bin/hellovr_bindings_vive_controller.json @@ -0,0 +1,84 @@ +{ + "bindings" : { + "/actions/demo" : { + "poses" : [ + { + "output" : "/actions/demo/in/hand_left", + "path" : "/user/hand/left/pose/raw" + }, + { + "output" : "/actions/demo/in/hand_right", + "path" : "/user/hand/right/pose/raw" + } + ], + "sources" : [ + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/hidecubes" + } + }, + "mode" : "button", + "path" : "/user/hand/right/input/trigger" + }, + { + "inputs" : { + "position" : { + "output" : "/actions/demo/in/analoginput" + } + }, + "mode" : "trackpad", + "path" : "/user/hand/right/input/trackpad" + }, + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/triggerhaptic" + } + }, + "mode" : "button", + "path" : "/user/hand/right/input/grip" + }, + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/hidecubes" + } + }, + "mode" : "button", + "path" : "/user/hand/left/input/trigger" + }, + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/triggerhaptic" + } + }, + "mode" : "button", + "path" : "/user/hand/left/input/grip" + }, + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/hidethiscontroller" + } + }, + "mode" : "button", + "path" : "/user/hand/left/input/application_menu" + }, + { + "inputs" : { + "click" : { + "output" : "/actions/demo/in/hidethiscontroller" + } + }, + "mode" : "button", + "path" : "/user/hand/right/input/application_menu" + } + ] + } + }, + "controller_type" : "vive_controller", + "description" : "Bindings for the OpenVR SDK \"hellovr_opengl\" demo for the Vive controller", + "name" : "HelloVR bindings for Vive Controller" +} diff --git a/samples/bin/linux64/libopenvr_api.so b/samples/bin/linux64/libopenvr_api.so Binary files differindex a2ae438..28e9f33 100644 --- a/samples/bin/linux64/libopenvr_api.so +++ b/samples/bin/linux64/libopenvr_api.so diff --git a/samples/bin/osx32/libopenvr_api.dylib b/samples/bin/osx32/libopenvr_api.dylib Binary files differindex e8ea3b6..1be0a9b 100644 --- a/samples/bin/osx32/libopenvr_api.dylib +++ b/samples/bin/osx32/libopenvr_api.dylib diff --git a/samples/bin/win32/openvr_api.dll b/samples/bin/win32/openvr_api.dll Binary files differindex b686939..9fab152 100644 --- a/samples/bin/win32/openvr_api.dll +++ b/samples/bin/win32/openvr_api.dll diff --git a/samples/bin/win64/openvr_api.dll b/samples/bin/win64/openvr_api.dll Binary files differindex 64c879b..b193003 100644 --- a/samples/bin/win64/openvr_api.dll +++ b/samples/bin/win64/openvr_api.dll diff --git a/samples/hellovr_opengl/hellovr_opengl_main.cpp b/samples/hellovr_opengl/hellovr_opengl_main.cpp index f154b63..2e4b5e0 100644 --- a/samples/hellovr_opengl/hellovr_opengl_main.cpp +++ b/samples/hellovr_opengl/hellovr_opengl_main.cpp @@ -78,8 +78,6 @@ public: bool BInitGL(); bool BInitCompositor(); - void SetupRenderModels(); - void Shutdown(); void RunMainLoop(); @@ -113,7 +111,6 @@ public: GLuint CompileGLShader( const char *pchShaderName, const char *pchVertexShader, const char *pchFragmentShader ); bool CreateAllShaders(); - void SetupRenderModelForTrackedDevice( vr::TrackedDeviceIndex_t unTrackedDeviceIndex ); CGLRenderModel *FindOrLoadRenderModel( const char *pchRenderModelName ); private: @@ -124,12 +121,28 @@ private: bool m_bGlFinishHack; vr::IVRSystem *m_pHMD; - vr::IVRRenderModels *m_pRenderModels; std::string m_strDriver; std::string m_strDisplay; vr::TrackedDevicePose_t m_rTrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ]; Matrix4 m_rmat4DevicePose[ vr::k_unMaxTrackedDeviceCount ]; - bool m_rbShowTrackedDevice[ vr::k_unMaxTrackedDeviceCount ]; + + struct ControllerInfo_t + { + vr::VRInputValueHandle_t m_source = vr::k_ulInvalidInputValueHandle; + vr::VRActionHandle_t m_actionPose = vr::k_ulInvalidActionHandle; + vr::VRActionHandle_t m_actionHaptic = vr::k_ulInvalidActionHandle; + Matrix4 m_rmat4Pose; + CGLRenderModel *m_pRenderModel = nullptr; + std::string m_sRenderModelName; + bool m_bShowController; + }; + + enum EHand + { + Left = 0, + Right = 1, + }; + ControllerInfo_t m_rHand[2]; private: // SDL bookkeeping SDL_Window *m_pCompanionWindow; @@ -144,6 +157,7 @@ private: // OpenGL bookkeeping int m_iValidPoseCount; int m_iValidPoseCount_Last; bool m_bShowCubes; + Vector2 m_vAnalogValue; std::string m_strPoseClasses; // what classes we saw poses for this frame char m_rDevClassChar[ vr::k_unMaxTrackedDeviceCount ]; // for each device, a character representing its class @@ -222,9 +236,84 @@ private: // OpenGL bookkeeping uint32_t m_nRenderHeight; std::vector< CGLRenderModel * > m_vecRenderModels; - CGLRenderModel *m_rTrackedDeviceToRenderModel[ vr::k_unMaxTrackedDeviceCount ]; + + vr::VRActionHandle_t m_actionHideCubes = vr::k_ulInvalidActionHandle; + vr::VRActionHandle_t m_actionHideThisController = vr::k_ulInvalidActionHandle; + vr::VRActionHandle_t m_actionTriggerHaptic = vr::k_ulInvalidActionHandle; + vr::VRActionHandle_t m_actionAnalongInput = vr::k_ulInvalidActionHandle; + + vr::VRActionSetHandle_t m_actionsetDemo = vr::k_ulInvalidActionSetHandle; }; + +//--------------------------------------------------------------------------------------------------------------------- +// Purpose: Returns true if the action is active and had a rising edge +//--------------------------------------------------------------------------------------------------------------------- +bool GetDigitalActionRisingEdge(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr ) +{ + vr::InputDigitalActionData_t actionData; + vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData)); + if (pDevicePath) + { + *pDevicePath = vr::k_ulInvalidInputValueHandle; + if (actionData.bActive) + { + vr::InputOriginInfo_t originInfo; + if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) + { + *pDevicePath = originInfo.devicePath; + } + } + } + return actionData.bActive && actionData.bChanged && actionData.bState; +} + + +//--------------------------------------------------------------------------------------------------------------------- +// Purpose: Returns true if the action is active and had a falling edge +//--------------------------------------------------------------------------------------------------------------------- +bool GetDigitalActionFallingEdge(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr ) +{ + vr::InputDigitalActionData_t actionData; + vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData)); + if (pDevicePath) + { + *pDevicePath = vr::k_ulInvalidInputValueHandle; + if (actionData.bActive) + { + vr::InputOriginInfo_t originInfo; + if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) + { + *pDevicePath = originInfo.devicePath; + } + } + } + return actionData.bActive && actionData.bChanged && !actionData.bState; +} + + +//--------------------------------------------------------------------------------------------------------------------- +// Purpose: Returns true if the action is active and its state is true +//--------------------------------------------------------------------------------------------------------------------- +bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr ) +{ + vr::InputDigitalActionData_t actionData; + vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData)); + if (pDevicePath) + { + *pDevicePath = vr::k_ulInvalidInputValueHandle; + if (actionData.bActive) + { + vr::InputOriginInfo_t originInfo; + if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) + { + *pDevicePath = originInfo.devicePath; + } + } + } + return actionData.bActive && actionData.bState; +} + //----------------------------------------------------------------------------- // Purpose: Outputs a set of optional arguments to debugging output, using // the printf format setting specified in fmt*. @@ -257,7 +346,6 @@ CMainApplication::CMainApplication( int argc, char *argv[] ) , m_unControllerTransformProgramID( 0 ) , m_unRenderModelProgramID( 0 ) , m_pHMD( NULL ) - , m_pRenderModels( NULL ) , m_bDebugOpenGL( false ) , m_bVerbose( false ) , m_bPerf( false ) @@ -325,14 +413,14 @@ CMainApplication::~CMainApplication() // Purpose: Helper to get a string from a tracked device property and turn it // into a std::string //----------------------------------------------------------------------------- -std::string GetTrackedDeviceString( vr::IVRSystem *pHmd, vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError = NULL ) +std::string GetTrackedDeviceString( vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError = NULL ) { - uint32_t unRequiredBufferLen = pHmd->GetStringTrackedDeviceProperty( unDevice, prop, NULL, 0, peError ); + uint32_t unRequiredBufferLen = vr::VRSystem()->GetStringTrackedDeviceProperty( unDevice, prop, NULL, 0, peError ); if( unRequiredBufferLen == 0 ) return ""; char *pchBuffer = new char[ unRequiredBufferLen ]; - unRequiredBufferLen = pHmd->GetStringTrackedDeviceProperty( unDevice, prop, pchBuffer, unRequiredBufferLen, peError ); + unRequiredBufferLen = vr::VRSystem()->GetStringTrackedDeviceProperty( unDevice, prop, pchBuffer, unRequiredBufferLen, peError ); std::string sResult = pchBuffer; delete [] pchBuffer; return sResult; @@ -364,18 +452,6 @@ bool CMainApplication::BInit() } - m_pRenderModels = (vr::IVRRenderModels *)vr::VR_GetGenericInterface( vr::IVRRenderModels_Version, &eError ); - if( !m_pRenderModels ) - { - m_pHMD = NULL; - vr::VR_Shutdown(); - - char buf[1024]; - sprintf_s( buf, sizeof( buf ), "Unable to get render model interface: %s", vr::VR_GetVRInitErrorAsEnglishDescription( eError ) ); - SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_ERROR, "VR_Init Failed", buf, NULL ); - return false; - } - int nWindowPosX = 700; int nWindowPosY = 100; Uint32 unWindowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN; @@ -423,8 +499,8 @@ bool CMainApplication::BInit() m_strDriver = "No Driver"; m_strDisplay = "No Display"; - m_strDriver = GetTrackedDeviceString( m_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String ); - m_strDisplay = GetTrackedDeviceString( m_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String ); + m_strDriver = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String ); + m_strDisplay = GetTrackedDeviceString( vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SerialNumber_String ); std::string strWindowTitle = "hellovr - " + m_strDriver + " " + m_strDisplay; SDL_SetWindowTitle( m_pCompanionWindow, strWindowTitle.c_str() ); @@ -458,6 +534,23 @@ bool CMainApplication::BInit() return false; } + vr::VRInput()->SetActionManifestPath( Path_MakeAbsolute( "../hellovr_actions.json", Path_StripFilename( Path_GetExecutablePath() ) ).c_str() ); + + vr::VRInput()->GetActionHandle( "/actions/demo/in/HideCubes", &m_actionHideCubes ); + vr::VRInput()->GetActionHandle( "/actions/demo/in/HideThisController", &m_actionHideThisController); + vr::VRInput()->GetActionHandle( "/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic ); + vr::VRInput()->GetActionHandle( "/actions/demo/in/AnalogInput", &m_actionAnalongInput ); + + vr::VRInput()->GetActionSetHandle( "/actions/demo", &m_actionsetDemo ); + + vr::VRInput()->GetActionHandle( "/actions/demo/out/Haptic_Left", &m_rHand[Left].m_actionHaptic ); + vr::VRInput()->GetInputSourceHandle( "/user/hand/left", &m_rHand[Left].m_source ); + vr::VRInput()->GetActionHandle( "/actions/demo/in/Hand_Left", &m_rHand[Left].m_actionPose ); + + vr::VRInput()->GetActionHandle( "/actions/demo/out/Haptic_Right", &m_rHand[Right].m_actionHaptic ); + vr::VRInput()->GetInputSourceHandle( "/user/hand/right", &m_rHand[Right].m_source ); + vr::VRInput()->GetActionHandle( "/actions/demo/in/Hand_Right", &m_rHand[Right].m_actionPose ); + return true; } @@ -496,7 +589,6 @@ bool CMainApplication::BInitGL() SetupCameras(); SetupStereoRenderTargets(); SetupCompanionWindow(); - SetupRenderModels(); return true; } @@ -633,13 +725,74 @@ bool CMainApplication::HandleInput() ProcessVREvent( event ); } - // Process SteamVR controller state - for( vr::TrackedDeviceIndex_t unDevice = 0; unDevice < vr::k_unMaxTrackedDeviceCount; unDevice++ ) + // Process SteamVR action state + // UpdateActionState is called each frame to update the state of the actions themselves. The application + // controls which action sets are active with the provided array of VRActiveActionSet_t structs. + vr::VRActiveActionSet_t actionSet = { 0 }; + actionSet.ulActionSet = m_actionsetDemo; + vr::VRInput()->UpdateActionState( &actionSet, sizeof(actionSet), 1 ); + + m_bShowCubes = !GetDigitalActionState( m_actionHideCubes ); + + vr::VRInputValueHandle_t ulHapticDevice; + if ( GetDigitalActionRisingEdge( m_actionTriggerHaptic, &ulHapticDevice ) ) { - vr::VRControllerState_t state; - if( m_pHMD->GetControllerState( unDevice, &state, sizeof(state) ) ) + if ( ulHapticDevice == m_rHand[Left].m_source ) + { + vr::VRInput()->TriggerHapticVibrationAction( m_rHand[Left].m_actionHaptic, 0, 1, 4.f, 1.0f ); + } + if ( ulHapticDevice == m_rHand[Right].m_source ) { - m_rbShowTrackedDevice[ unDevice ] = state.ulButtonPressed == 0; + vr::VRInput()->TriggerHapticVibrationAction( m_rHand[Right].m_actionHaptic, 0, 1, 4.f, 1.0f ); + } + } + + vr::InputAnalogActionData_t analogData; + if ( vr::VRInput()->GetAnalogActionData( m_actionAnalongInput, &analogData, sizeof( analogData ) ) == vr::VRInputError_None && analogData.bActive ) + { + m_vAnalogValue[0] = analogData.x; + m_vAnalogValue[1] = analogData.y; + } + + m_rHand[Left].m_bShowController = true; + m_rHand[Right].m_bShowController = true; + + vr::VRInputValueHandle_t ulHideDevice; + if ( GetDigitalActionState( m_actionHideThisController, &ulHideDevice ) ) + { + if ( ulHideDevice == m_rHand[Left].m_source ) + { + m_rHand[Left].m_bShowController = false; + } + if ( ulHideDevice == m_rHand[Right].m_source ) + { + m_rHand[Right].m_bShowController = false; + } + } + + for ( EHand eHand = Left; eHand <= Right; ((int&)eHand)++ ) + { + vr::InputPoseActionData_t poseData; + if ( vr::VRInput()->GetPoseActionData( m_rHand[eHand].m_actionPose, vr::TrackingUniverseStanding, 0, &poseData, sizeof( poseData ) ) != vr::VRInputError_None + || !poseData.bActive || !poseData.pose.bPoseIsValid ) + { + m_rHand[eHand].m_bShowController = false; + } + else + { + m_rHand[eHand].m_rmat4Pose = ConvertSteamVRMatrixToMatrix4( poseData.pose.mDeviceToAbsoluteTracking ); + + vr::InputOriginInfo_t originInfo; + if ( vr::VRInput()->GetOriginTrackedDeviceInfo( poseData.activeOrigin, &originInfo, sizeof( originInfo ) ) == vr::VRInputError_None + && originInfo.trackedDeviceIndex != vr::k_unTrackedDeviceIndexInvalid ) + { + std::string sRenderModelName = GetTrackedDeviceString( originInfo.trackedDeviceIndex, vr::Prop_RenderModelName_String ); + if ( sRenderModelName != m_rHand[eHand].m_sRenderModelName ) + { + m_rHand[eHand].m_pRenderModel = FindOrLoadRenderModel( sRenderModelName.c_str() ); + m_rHand[eHand].m_sRenderModelName = sRenderModelName; + } + } } } @@ -674,12 +827,6 @@ void CMainApplication::ProcessVREvent( const vr::VREvent_t & event ) { switch( event.eventType ) { - case vr::VREvent_TrackedDeviceActivated: - { - SetupRenderModelForTrackedDevice( event.trackedDeviceIndex ); - dprintf( "Device %u attached. Setting up render model.\n", event.trackedDeviceIndex ); - } - break; case vr::VREvent_TrackedDeviceDeactivated: { dprintf( "Device %u detached.\n", event.trackedDeviceIndex ); @@ -1133,20 +1280,12 @@ void CMainApplication::RenderControllerAxes() m_uiControllerVertcount = 0; m_iTrackedControllerCount = 0; - for ( vr::TrackedDeviceIndex_t unTrackedDevice = vr::k_unTrackedDeviceIndex_Hmd + 1; unTrackedDevice < vr::k_unMaxTrackedDeviceCount; ++unTrackedDevice ) + for ( EHand eHand = Left; eHand <= Right; ((int&)eHand)++ ) { - if ( !m_pHMD->IsTrackedDeviceConnected( unTrackedDevice ) ) + if ( !m_rHand[eHand].m_bShowController ) continue; - if( m_pHMD->GetTrackedDeviceClass( unTrackedDevice ) != vr::TrackedDeviceClass_Controller ) - continue; - - m_iTrackedControllerCount += 1; - - if( !m_rTrackedDevicePose[ unTrackedDevice ].bPoseIsValid ) - continue; - - const Matrix4 & mat = m_rmat4DevicePose[unTrackedDevice]; + const Matrix4 & mat = m_rHand[eHand].m_rmat4Pose; Vector4 center = mat * Vector4( 0, 0, 0, 1 ); @@ -1425,23 +1564,16 @@ void CMainApplication::RenderScene( vr::Hmd_Eye nEye ) // ----- Render Model rendering ----- glUseProgram( m_unRenderModelProgramID ); - for( uint32_t unTrackedDevice = 0; unTrackedDevice < vr::k_unMaxTrackedDeviceCount; unTrackedDevice++ ) + for ( EHand eHand = Left; eHand <= Right; ((int&)eHand)++ ) { - if( !m_rTrackedDeviceToRenderModel[ unTrackedDevice ] || !m_rbShowTrackedDevice[ unTrackedDevice ] ) - continue; - - const vr::TrackedDevicePose_t & pose = m_rTrackedDevicePose[ unTrackedDevice ]; - if( !pose.bPoseIsValid ) + if ( !m_rHand[eHand].m_bShowController || !m_rHand[eHand].m_pRenderModel ) continue; - if( !bIsInputAvailable && m_pHMD->GetTrackedDeviceClass( unTrackedDevice ) == vr::TrackedDeviceClass_Controller ) - continue; - - const Matrix4 & matDeviceToTracking = m_rmat4DevicePose[ unTrackedDevice ]; + const Matrix4 & matDeviceToTracking = m_rHand[eHand].m_rmat4Pose; Matrix4 matMVP = GetCurrentViewProjectionMatrix( nEye ) * matDeviceToTracking; glUniformMatrix4fv( m_nRenderModelMatrixLocation, 1, GL_FALSE, matMVP.get() ); - m_rTrackedDeviceToRenderModel[ unTrackedDevice ]->Draw(); + m_rHand[eHand].m_pRenderModel->Draw(); } glUseProgram( 0 ); @@ -1652,51 +1784,6 @@ CGLRenderModel *CMainApplication::FindOrLoadRenderModel( const char *pchRenderMo //----------------------------------------------------------------------------- -// Purpose: Create/destroy GL a Render Model for a single tracked device -//----------------------------------------------------------------------------- -void CMainApplication::SetupRenderModelForTrackedDevice( vr::TrackedDeviceIndex_t unTrackedDeviceIndex ) -{ - if( unTrackedDeviceIndex >= vr::k_unMaxTrackedDeviceCount ) - return; - - // try to find a model we've already set up - std::string sRenderModelName = GetTrackedDeviceString( m_pHMD, unTrackedDeviceIndex, vr::Prop_RenderModelName_String ); - CGLRenderModel *pRenderModel = FindOrLoadRenderModel( sRenderModelName.c_str() ); - if( !pRenderModel ) - { - std::string sTrackingSystemName = GetTrackedDeviceString( m_pHMD, unTrackedDeviceIndex, vr::Prop_TrackingSystemName_String ); - dprintf( "Unable to load render model for tracked device %d (%s.%s)", unTrackedDeviceIndex, sTrackingSystemName.c_str(), sRenderModelName.c_str() ); - } - else - { - m_rTrackedDeviceToRenderModel[ unTrackedDeviceIndex ] = pRenderModel; - m_rbShowTrackedDevice[ unTrackedDeviceIndex ] = true; - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Create/destroy GL Render Models -//----------------------------------------------------------------------------- -void CMainApplication::SetupRenderModels() -{ - memset( m_rTrackedDeviceToRenderModel, 0, sizeof( m_rTrackedDeviceToRenderModel ) ); - - if( !m_pHMD ) - return; - - for( uint32_t unTrackedDevice = vr::k_unTrackedDeviceIndex_Hmd + 1; unTrackedDevice < vr::k_unMaxTrackedDeviceCount; unTrackedDevice++ ) - { - if( !m_pHMD->IsTrackedDeviceConnected( unTrackedDevice ) ) - continue; - - SetupRenderModelForTrackedDevice( unTrackedDevice ); - } - -} - - -//----------------------------------------------------------------------------- // Purpose: Converts a SteamVR matrix to our local matrix class //----------------------------------------------------------------------------- Matrix4 CMainApplication::ConvertSteamVRMatrixToMatrix4( const vr::HmdMatrix34_t &matPose ) diff --git a/src/vrcommon/pathtools_public.cpp b/src/vrcommon/pathtools_public.cpp index 67d2f4e..c9be6c7 100644 --- a/src/vrcommon/pathtools_public.cpp +++ b/src/vrcommon/pathtools_public.cpp @@ -746,9 +746,11 @@ bool Path_WriteStringToTextFileAtomic( const std::string &strFilename, const cha // ---------------------------------------------------------------------------------------------------------------------------- std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::string & sBasePath ) { - if ( !strnicmp( sRelativePath.c_str(), "http://", 7 ) - || !strnicmp( sRelativePath.c_str(), "https://", 8 ) - || !strnicmp( sRelativePath.c_str(), "file://", 7 ) ) + if ( StringHasPrefix( sRelativePath, "http://" ) + || StringHasPrefix( sRelativePath, "https://" ) + || StringHasPrefix( sRelativePath, "vr-input-workshop://" ) + || StringHasPrefix( sRelativePath, "file://" ) + ) { return sRelativePath; } |