diff --git a/ext/LibOVR/Include/Extras/OVR_CAPI_Util.h b/ext/LibOVR/Include/Extras/OVR_CAPI_Util.h index 9c7dafd..09b4a40 100644 --- a/ext/LibOVR/Include/Extras/OVR_CAPI_Util.h +++ b/ext/LibOVR/Include/Extras/OVR_CAPI_Util.h @@ -1,77 +1,107 @@ -/********************************************************************************//** -\file OVR_CAPI_Util.h -\brief This header provides LibOVR utility function declarations -\copyright Copyright 2015-2016 Oculus VR, LLC All Rights reserved. -*************************************************************************************/ +/********************************************************************************/ /** + \file OVR_CAPI_Util.h + \brief This header provides LibOVR utility function declarations + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + *************************************************************************************/ #ifndef OVR_CAPI_Util_h #define OVR_CAPI_Util_h - #include "OVR_CAPI.h" - #ifdef __cplusplus extern "C" { #endif - /// Enumerates modifications to the projection matrix based on the application's needs. /// /// \see ovrMatrix4f_Projection /// -typedef enum ovrProjectionModifier_ -{ - /// Use for generating a default projection matrix that is: - /// * Right-handed. - /// * Near depth values stored in the depth buffer are smaller than far depth values. - /// * Both near and far are explicitly defined. - /// * With a clipping range that is (0 to w). - ovrProjection_None = 0x00, - - /// Enable if using left-handed transformations in your application. - ovrProjection_LeftHanded = 0x01, - - /// After the projection transform is applied, far values stored in the depth buffer will be less than closer depth values. - /// NOTE: Enable only if the application is using a floating-point depth buffer for proper precision. - ovrProjection_FarLessThanNear = 0x02, - - /// When this flag is used, the zfar value pushed into ovrMatrix4f_Projection() will be ignored - /// NOTE: Enable only if ovrProjection_FarLessThanNear is also enabled where the far clipping plane will be pushed to infinity. - ovrProjection_FarClipAtInfinity = 0x04, - - /// Enable if the application is rendering with OpenGL and expects a projection matrix with a clipping range of (-w to w). - /// Ignore this flag if your application already handles the conversion from D3D range (0 to w) to OpenGL. - ovrProjection_ClipRangeOpenGL = 0x08, +typedef enum ovrProjectionModifier_ { + /// Use for generating a default projection matrix that is: + /// * Right-handed. + /// * Near depth values stored in the depth buffer are smaller than far depth values. + /// * Both near and far are explicitly defined. + /// * With a clipping range that is (0 to w). + ovrProjection_None = 0x00, + + /// Enable if using left-handed transformations in your application. + ovrProjection_LeftHanded = 0x01, + + /// After the projection transform is applied, far values stored in the depth buffer will be less + /// than closer depth values. + /// NOTE: Enable only if the application is using a floating-point depth buffer for proper + /// precision. + ovrProjection_FarLessThanNear = 0x02, + + /// When this flag is used, the zfar value pushed into ovrMatrix4f_Projection() will be ignored + /// NOTE: Enable only if ovrProjection_FarLessThanNear is also enabled where the far clipping + /// plane will be pushed to infinity. + ovrProjection_FarClipAtInfinity = 0x04, + + /// Enable if the application is rendering with OpenGL and expects a projection matrix with a + /// clipping range of (-w to w). + /// Ignore this flag if your application already handles the conversion from D3D range (0 to w) to + /// OpenGL. + ovrProjection_ClipRangeOpenGL = 0x08, } ovrProjectionModifier; - /// Return values for ovr_Detect. /// /// \see ovr_Detect /// -typedef struct OVR_ALIGNAS(8) ovrDetectResult_ -{ - /// Is ovrFalse when the Oculus Service is not running. - /// This means that the Oculus Service is either uninstalled or stopped. - /// IsOculusHMDConnected will be ovrFalse in this case. - /// Is ovrTrue when the Oculus Service is running. - /// This means that the Oculus Service is installed and running. - /// IsOculusHMDConnected will reflect the state of the HMD. - ovrBool IsOculusServiceRunning; - - /// Is ovrFalse when an Oculus HMD is not detected. - /// If the Oculus Service is not running, this will be ovrFalse. - /// Is ovrTrue when an Oculus HMD is detected. - /// This implies that the Oculus Service is also installed and running. - ovrBool IsOculusHMDConnected; - - OVR_UNUSED_STRUCT_PAD(pad0, 6) ///< \internal struct padding +typedef struct OVR_ALIGNAS(8) ovrDetectResult_ { + /// Is ovrFalse when the Oculus Service is not running. + /// This means that the Oculus Service is either uninstalled or stopped. + /// IsOculusHMDConnected will be ovrFalse in this case. + /// Is ovrTrue when the Oculus Service is running. + /// This means that the Oculus Service is installed and running. + /// IsOculusHMDConnected will reflect the state of the HMD. + ovrBool IsOculusServiceRunning; + + /// Is ovrFalse when an Oculus HMD is not detected. + /// If the Oculus Service is not running, this will be ovrFalse. + /// Is ovrTrue when an Oculus HMD is detected. + /// This implies that the Oculus Service is also installed and running. + ovrBool IsOculusHMDConnected; + + OVR_UNUSED_STRUCT_PAD(pad0, 6) ///< \internal struct padding } ovrDetectResult; OVR_STATIC_ASSERT(sizeof(ovrDetectResult) == 8, "ovrDetectResult size mismatch"); +/// Modes used to generate Touch Haptics from audio PCM buffer. +/// +typedef enum ovrHapticsGenMode_ { + /// Point sample original signal at Haptics frequency + ovrHapticsGenMode_PointSample, + ovrHapticsGenMode_Count +} ovrHapticsGenMode; + +/// Store audio PCM data (as 32b float samples) for an audio channel. +/// Note: needs to be released with ovr_ReleaseAudioChannelData to avoid memory leak. +/// +typedef struct ovrAudioChannelData_ { + /// Samples stored as floats [-1.0f, 1.0f]. + const float* Samples; + + /// Number of samples + int SamplesCount; + + /// Frequency (e.g. 44100) + int Frequency; +} ovrAudioChannelData; + +/// Store a full Haptics clip, which can be used as data source for multiple ovrHapticsBuffers. +/// +typedef struct ovrHapticsClip_ { + /// Samples stored in opaque format + const void* Samples; + + /// Number of samples + int SamplesCount; +} ovrHapticsClip; /// Detects Oculus Runtime and Device Status /// @@ -89,11 +119,10 @@ OVR_PUBLIC_FUNCTION(ovrDetectResult) ovr_Detect(int timeoutMilliseconds); // On the Windows platform, #ifdef _WIN32 - /// This is the Windows Named Event name that is used to check for HMD connected state. - #define OVR_HMD_CONNECTED_EVENT_NAME L"OculusHMDConnected" +/// This is the Windows Named Event name that is used to check for HMD connected state. +#define OVR_HMD_CONNECTED_EVENT_NAME L"OculusHMDConnected" #endif // _WIN32 - /// Used to generate projection from ovrEyeDesc::Fov. /// /// \param[in] fov Specifies the ovrFovPort to use. @@ -102,21 +131,22 @@ OVR_PUBLIC_FUNCTION(ovrDetectResult) ovr_Detect(int timeoutMilliseconds); /// \param[in] projectionModFlags A combination of the ovrProjectionModifier flags. /// /// \return Returns the calculated projection matrix. -/// +/// /// \see ovrProjectionModifier /// -OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, unsigned int projectionModFlags); - +OVR_PUBLIC_FUNCTION(ovrMatrix4f) +ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, unsigned int projectionModFlags); /// Extracts the required data from the result of ovrMatrix4f_Projection. /// -/// \param[in] projection Specifies the project matrix from which to extract ovrTimewarpProjectionDesc. +/// \param[in] projection Specifies the project matrix from which to +/// extract ovrTimewarpProjectionDesc. /// \param[in] projectionModFlags A combination of the ovrProjectionModifier flags. /// \return Returns the extracted ovrTimewarpProjectionDesc. /// \see ovrTimewarpProjectionDesc /// -OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) ovrTimewarpProjectionDesc_FromProjection(ovrMatrix4f projection, unsigned int projectionModFlags); - +OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) +ovrTimewarpProjectionDesc_FromProjection(ovrMatrix4f projection, unsigned int projectionModFlags); /// Generates an orthographic sub-projection. /// @@ -129,50 +159,68 @@ OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) ovrTimewarpProjectionDesc_FromPro /// /// \return Returns the calculated projection matrix. /// -OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale, - float orthoDistance, float HmdToEyeOffsetX); - - +OVR_PUBLIC_FUNCTION(ovrMatrix4f) +ovrMatrix4f_OrthoSubProjection( + ovrMatrix4f projection, + ovrVector2f orthoScale, + float orthoDistance, + float HmdToEyeOffsetX); /// Computes offset eye poses based on headPose returned by ovrTrackingState. /// /// \param[in] headPose Indicates the HMD position and orientation to use for the calculation. -/// \param[in] hmdToEyeOffset Can be ovrEyeRenderDesc.HmdToEyeOffset returned from -/// ovr_GetRenderDesc. For monoscopic rendering, use a vector that is the average -/// of the two vectors for both eyes. -/// \param[out] outEyePoses If outEyePoses are used for rendering, they should be passed to +/// \param[in] hmdToEyePose Can be ovrEyeRenderDesc.HmdToEyePose returned from +/// ovr_GetRenderDesc. For monoscopic rendering, use a position vector that is average +/// of the two position vectors for each eyes. +/// \param[out] outEyePoses If outEyePoses are used for rendering, they should be passed to /// ovr_SubmitFrame in ovrLayerEyeFov::RenderPose or ovrLayerEyeFovDepth::RenderPose. /// -OVR_PUBLIC_FUNCTION(void) ovr_CalcEyePoses(ovrPosef headPose, - const ovrVector3f hmdToEyeOffset[2], - ovrPosef outEyePoses[2]); - +#undef ovr_CalcEyePoses +OVR_PUBLIC_FUNCTION(void) +ovr_CalcEyePoses(ovrPosef headPose, const ovrVector3f hmdToEyeOffset[2], ovrPosef outEyePoses[2]); +OVR_PRIVATE_FUNCTION(void) +ovr_CalcEyePoses2(ovrPosef headPose, const ovrPosef HmdToEyePose[2], ovrPosef outEyePoses[2]); +#define ovr_CalcEyePoses ovr_CalcEyePoses2 /// Returns the predicted head pose in outHmdTrackingState and offset eye poses in outEyePoses. /// /// This is a thread-safe function where caller should increment frameIndex with every frame /// and pass that index where applicable to functions called on the rendering thread. /// Assuming outEyePoses are used for rendering, it should be passed as a part of ovrLayerEyeFov. -/// The caller does not need to worry about applying HmdToEyeOffset to the returned outEyePoses variables. +/// The caller does not need to worry about applying HmdToEyePose to the returned outEyePoses +/// variables. /// /// \param[in] hmd Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] frameIndex Specifies the targeted frame index, or 0 to refer to one frame after +/// \param[in] frameIndex Specifies the targeted frame index, or 0 to refer to one frame after /// the last time ovr_SubmitFrame was called. /// \param[in] latencyMarker Specifies that this call is the point in time where /// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer /// provides "SensorSampleTimestamp", that will override the value stored here. -/// \param[in] hmdToEyeOffset Can be ovrEyeRenderDesc.HmdToEyeOffset returned from -/// ovr_GetRenderDesc. For monoscopic rendering, use a vector that is the average -/// of the two vectors for both eyes. +/// \param[in] hmdToEyePose Can be ovrEyeRenderDesc.HmdToEyePose returned from +/// ovr_GetRenderDesc. For monoscopic rendering, use a position vector that is average +/// of the two position vectors for each eyes. /// \param[out] outEyePoses The predicted eye poses. -/// \param[out] outSensorSampleTime The time when this function was called. May be NULL, in which case it is ignored. +/// \param[out] outSensorSampleTime The time when this function was called. May be NULL, in which +/// case it is ignored. /// -OVR_PUBLIC_FUNCTION(void) ovr_GetEyePoses(ovrSession session, long long frameIndex, ovrBool latencyMarker, - const ovrVector3f hmdToEyeOffset[2], - ovrPosef outEyePoses[2], - double* outSensorSampleTime); - - +#undef ovr_GetEyePoses +OVR_PUBLIC_FUNCTION(void) +ovr_GetEyePoses( + ovrSession session, + long long frameIndex, + ovrBool latencyMarker, + const ovrVector3f hmdToEyeOffset[2], + ovrPosef outEyePoses[2], + double* outSensorSampleTime); +OVR_PRIVATE_FUNCTION(void) +ovr_GetEyePoses2( + ovrSession session, + long long frameIndex, + ovrBool latencyMarker, + const ovrPosef HmdToEyePose[2], + ovrPosef outEyePoses[2], + double* outSensorSampleTime); +#define ovr_GetEyePoses ovr_GetEyePoses2 /// Tracking poses provided by the SDK come in a right-handed coordinate system. If an application /// is passing in ovrProjection_LeftHanded into ovrMatrix4f_Projection, then it should also use @@ -181,16 +229,55 @@ OVR_PUBLIC_FUNCTION(void) ovr_GetEyePoses(ovrSession session, long long frameInd /// While this utility function is intended to convert a left-handed ovrPosef into a right-handed /// coordinate system, it will also work for converting right-handed to left-handed since the /// flip operation is the same for both cases. -/// +/// /// \param[in] inPose that is right-handed /// \param[out] outPose that is requested to be left-handed (can be the same pointer to inPose) /// OVR_PUBLIC_FUNCTION(void) ovrPosef_FlipHandedness(const ovrPosef* inPose, ovrPosef* outPose); +/// Reads an audio channel from Wav (Waveform Audio File) data. +/// Input must be a byte buffer representing a valid Wav file. Audio samples from the specified +/// channel are read, +/// converted to float [-1.0f, 1.0f] and returned through ovrAudioChannelData. +/// +/// Supported formats: PCM 8b, 16b, 32b and IEEE float (little-endian only). +/// +/// \param[out] outAudioChannel output audio channel data. +/// \param[in] inputData a binary buffer representing a valid Wav file data. +/// \param[in] dataSizeInBytes size of the buffer in bytes. +/// \param[in] stereoChannelToUse audio channel index to extract (0 for mono). +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_ReadWavFromBuffer( + ovrAudioChannelData* outAudioChannel, + const void* inputData, + int dataSizeInBytes, + int stereoChannelToUse); + +/// Generates playable Touch Haptics data from an audio channel. +/// +/// \param[out] outHapticsClip generated Haptics clip. +/// \param[in] audioChannel input audio channel data. +/// \param[in] genMode mode used to convert and audio channel data to Haptics data. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GenHapticsFromAudioData( + ovrHapticsClip* outHapticsClip, + const ovrAudioChannelData* audioChannel, + ovrHapticsGenMode genMode); + +/// Releases memory allocated for ovrAudioChannelData. Must be called to avoid memory leak. +/// \param[in] audioChannel pointer to an audio channel +/// +OVR_PUBLIC_FUNCTION(void) ovr_ReleaseAudioChannelData(ovrAudioChannelData* audioChannel); + +/// Releases memory allocated for ovrHapticsClip. Must be called to avoid memory leak. +/// \param[in] hapticsClip pointer to a haptics clip +/// +OVR_PUBLIC_FUNCTION(void) ovr_ReleaseHapticsClip(ovrHapticsClip* hapticsClip); #ifdef __cplusplus } /* extern "C" */ #endif - #endif // Header include guard diff --git a/ext/LibOVR/Include/Extras/OVR_Math.h b/ext/LibOVR/Include/Extras/OVR_Math.h index c182ed5..1008b33 100644 --- a/ext/LibOVR/Include/Extras/OVR_Math.h +++ b/ext/LibOVR/Include/Extras/OVR_Math.h @@ -1,14 +1,13 @@ -/********************************************************************************//** -\file OVR_Math.h -\brief Implementation of 3D primitives such as vectors, matrices. -\copyright Copyright 2014-2016 Oculus VR, LLC All Rights reserved. -*************************************************************************************/ +/********************************************************************************/ /** + \file OVR_Math.h + \brief Implementation of 3D primitives such as vectors, matrices. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + *************************************************************************************/ #ifndef OVR_Math_h #define OVR_Math_h - -// This file is intended to be independent of the rest of LibOVR and LibOVRKernel and thus +// This file is intended to be independent of the rest of LibOVR and LibOVRKernel and thus // has no #include dependencies on either. #include @@ -17,38 +16,42 @@ #include #include #include -#include "../OVR_CAPI.h" // Currently required due to a dependence on the ovrFovPort_ declaration. -#if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable: 4127) // conditional expression is constant +#ifndef OVR_EXCLUDE_CAPI_FROM_MATH +#include "../OVR_CAPI.h" // Required due to a dependence on the ovrFovPort_ declaration. #endif +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4127) // conditional expression is constant + +#if _MSC_VER < 1800 // isfinite was introduced in VS2013 +#define isfinite(x) _finite((x)) +#endif +#endif #if defined(_MSC_VER) - #define OVRMath_sprintf sprintf_s +#define OVRMath_sprintf sprintf_s #else - #define OVRMath_sprintf snprintf +#define OVRMath_sprintf snprintf #endif - //------------------------------------------------------------------------------------- // ***** OVR_MATH_ASSERT // // Independent debug break implementation for OVR_Math.h. #if !defined(OVR_MATH_DEBUG_BREAK) - #if defined(_DEBUG) - #if defined(_MSC_VER) - #define OVR_MATH_DEBUG_BREAK __debugbreak() - #else - #define OVR_MATH_DEBUG_BREAK __builtin_trap() - #endif - #else - #define OVR_MATH_DEBUG_BREAK ((void)0) - #endif +#if defined(_DEBUG) +#if defined(_MSC_VER) +#define OVR_MATH_DEBUG_BREAK __debugbreak() +#else +#define OVR_MATH_DEBUG_BREAK __builtin_trap() +#endif +#else +#define OVR_MATH_DEBUG_BREAK ((void)0) +#endif #endif - //------------------------------------------------------------------------------------- // ***** OVR_MATH_ASSERT @@ -56,13 +59,15 @@ // Independent OVR_MATH_ASSERT implementation for OVR_Math.h. #if !defined(OVR_MATH_ASSERT) - #if defined(_DEBUG) - #define OVR_MATH_ASSERT(p) if (!(p)) { OVR_MATH_DEBUG_BREAK; } - #else - #define OVR_MATH_ASSERT(p) ((void)0) - #endif +#if defined(_DEBUG) +#define OVR_MATH_ASSERT(p) \ + if (!(p)) { \ + OVR_MATH_DEBUG_BREAK; \ + } +#else +#define OVR_MATH_ASSERT(p) ((void)0) +#endif #endif - //------------------------------------------------------------------------------------- // ***** OVR_MATH_STATIC_ASSERT @@ -70,48 +75,50 @@ // Independent OVR_MATH_ASSERT implementation for OVR_Math.h. #if !defined(OVR_MATH_STATIC_ASSERT) - #if defined(__cplusplus) && ((defined(_MSC_VER) && (defined(_MSC_VER) >= 1600)) || defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)) - #define OVR_MATH_STATIC_ASSERT static_assert - #else - #if !defined(OVR_SA_UNUSED) - #if defined(__GNUC__) || defined(__clang__) - #define OVR_SA_UNUSED __attribute__((unused)) - #else - #define OVR_SA_UNUSED - #endif - #define OVR_SA_PASTE(a,b) a##b - #define OVR_SA_HELP(a,b) OVR_SA_PASTE(a,b) - #endif - - #define OVR_MATH_STATIC_ASSERT(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __LINE__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED - #endif +#if defined(__cplusplus) && \ + ((defined(_MSC_VER) && (defined(_MSC_VER) >= 1600)) || defined(__GXX_EXPERIMENTAL_CXX0X__) || \ + (__cplusplus >= 201103L)) +#define OVR_MATH_STATIC_ASSERT static_assert +#else +#if !defined(OVR_SA_UNUSED) +#if defined(__GNUC__) || defined(__clang__) +#define OVR_SA_UNUSED __attribute__((unused)) +#else +#define OVR_SA_UNUSED +#endif +#define OVR_SA_PASTE(a, b) a##b +#define OVR_SA_HELP(a, b) OVR_SA_PASTE(a, b) #endif - +#define OVR_MATH_STATIC_ASSERT(expression, msg) \ + typedef char OVR_SA_HELP(compileTimeAssert, __LINE__)[((expression) != 0) ? 1 : -1] OVR_SA_UNUSED +#endif +#endif namespace OVR { -template -const T OVRMath_Min(const T a, const T b) -{ return (a < b) ? a : b; } - -template -const T OVRMath_Max(const T a, const T b) -{ return (b < a) ? a : b; } +template +const T OVRMath_Min(const T a, const T b) { + return (a < b) ? a : b; +} -template -void OVRMath_Swap(T& a, T& b) -{ T temp(a); a = b; b = temp; } +template +const T OVRMath_Max(const T a, const T b) { + return (b < a) ? a : b; +} +template +void OVRMath_Swap(T& a, T& b) { + T temp(a); + a = b; + b = temp; +} //------------------------------------------------------------------------------------- // ***** Constants for 3D world/axis definitions. // Definitions of axes for coordinate and rotation conversions. -enum Axis -{ - Axis_X = 0, Axis_Y = 1, Axis_Z = 2 -}; +enum Axis { Axis_X = 0, Axis_Y = 1, Axis_Z = 2 }; // RotateDirection describes the rotation direction around an axis, interpreted as follows: // CW - Clockwise while looking "down" from positive axis towards the origin. @@ -120,41 +127,31 @@ enum Axis // CCW is the default for the RHS coordinate system. Oculus standard RHS coordinate // system defines Y up, X right, and Z back (pointing out from the screen). In this // system Rotate_CCW around Z will specifies counter-clockwise rotation in XY plane. -enum RotateDirection -{ - Rotate_CCW = 1, - Rotate_CW = -1 -}; +enum RotateDirection { Rotate_CCW = 1, Rotate_CW = -1 }; // Constants for right handed and left handed coordinate systems -enum HandedSystem -{ - Handed_R = 1, Handed_L = -1 -}; +enum HandedSystem { Handed_R = 1, Handed_L = -1 }; // AxisDirection describes which way the coordinate axis points. Used by WorldAxes. -enum AxisDirection -{ - Axis_Up = 2, - Axis_Down = -2, - Axis_Right = 1, - Axis_Left = -1, - Axis_In = 3, - Axis_Out = -3 +enum AxisDirection { + Axis_Up = 2, + Axis_Down = -2, + Axis_Right = 1, + Axis_Left = -1, + Axis_In = 3, + Axis_Out = -3 }; -struct WorldAxes -{ - AxisDirection XAxis, YAxis, ZAxis; +struct WorldAxes { + AxisDirection XAxis, YAxis, ZAxis; - WorldAxes(AxisDirection x, AxisDirection y, AxisDirection z) - : XAxis(x), YAxis(y), ZAxis(z) - { OVR_MATH_ASSERT(abs(x) != abs(y) && abs(y) != abs(z) && abs(z) != abs(x));} + WorldAxes(AxisDirection x, AxisDirection y, AxisDirection z) : XAxis(x), YAxis(y), ZAxis(z) { + OVR_MATH_ASSERT(abs(x) != abs(y) && abs(y) != abs(z) && abs(z) != abs(x)); + } }; } // namespace OVR - //------------------------------------------------------------------------------------// // ***** C Compatibility Types @@ -185,351 +182,521 @@ typedef struct ovrPosef_ ovrPosef; typedef struct ovrPosed_ ovrPosed; typedef struct ovrPoseStatef_ ovrPoseStatef; typedef struct ovrPoseStated_ ovrPoseStated; +typedef struct ovrFovPort_ ovrFovPort; namespace OVR { // Forward-declare our templates. -template class Quat; -template class Size; -template class Rect; -template class Vector2; -template class Vector3; -template class Vector4; -template class Matrix2; -template class Matrix3; -template class Matrix4; -template class Pose; -template class PoseState; +template +class Quat; +template +class Size; +template +class Rect; +template +class Vector2; +template +class Vector3; +template +class Vector4; +template +class Matrix2; +template +class Matrix3; +template +class Matrix4; +template +class Pose; +template +class PoseState; +struct FovPort; // CompatibleTypes::Type is used to lookup a compatible C-version of a C++ class. -template -struct CompatibleTypes -{ - // Declaration here seems necessary for MSVC; specializations are - // used instead. - typedef struct {} Type; +template +struct CompatibleTypes { + // Declaration here seems necessary for MSVC; specializations are + // used instead. + typedef struct { + } Type; }; // Specializations providing CompatibleTypes::Type value. -template<> struct CompatibleTypes > { typedef ovrQuatf Type; }; -template<> struct CompatibleTypes > { typedef ovrQuatd Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix2f Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix2d Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix3f Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix3d Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix4f Type; }; -template<> struct CompatibleTypes > { typedef ovrMatrix4d Type; }; -template<> struct CompatibleTypes > { typedef ovrSizei Type; }; -template<> struct CompatibleTypes > { typedef ovrSizef Type; }; -template<> struct CompatibleTypes > { typedef ovrSized Type; }; -template<> struct CompatibleTypes > { typedef ovrRecti Type; }; -template<> struct CompatibleTypes > { typedef ovrVector2i Type; }; -template<> struct CompatibleTypes > { typedef ovrVector2f Type; }; -template<> struct CompatibleTypes > { typedef ovrVector2d Type; }; -template<> struct CompatibleTypes > { typedef ovrVector3f Type; }; -template<> struct CompatibleTypes > { typedef ovrVector3d Type; }; -template<> struct CompatibleTypes > { typedef ovrVector4f Type; }; -template<> struct CompatibleTypes > { typedef ovrVector4d Type; }; -template<> struct CompatibleTypes > { typedef ovrPosef Type; }; -template<> struct CompatibleTypes > { typedef ovrPosed Type; }; +template <> +struct CompatibleTypes> { + typedef ovrQuatf Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrQuatd Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix2f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix2d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix3f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix3d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix4f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrMatrix4d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrSizei Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrSizef Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrSized Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrRecti Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector2i Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector2f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector2d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector3f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector3d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector4f Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrVector4d Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrPosef Type; +}; +template <> +struct CompatibleTypes> { + typedef ovrPosed Type; +}; +template <> +struct CompatibleTypes { + typedef ovrFovPort Type; +}; //------------------------------------------------------------------------------------// // ***** Math // // Math class contains constants and functions. This class is a template specialized // per type, with Math and Math being distinct. -template -class Math -{ -public: - // By default, support explicit conversion to float. This allows Vector2 to - // compile, for example. - typedef float OtherFloatType; - - static int Tolerance() { return 0; } // Default value so integer types compile +template +class Math { + public: + // By default, support explicit conversion to float. This allows Vector2 to + // compile, for example. + typedef float OtherFloatType; + + static int Tolerance() { + return 0; + } // Default value so integer types compile }; - //------------------------------------------------------------------------------------// // ***** double constants -#define MATH_DOUBLE_PI 3.14159265358979323846 -#define MATH_DOUBLE_TWOPI (2*MATH_DOUBLE_PI) -#define MATH_DOUBLE_PIOVER2 (0.5*MATH_DOUBLE_PI) -#define MATH_DOUBLE_PIOVER4 (0.25*MATH_DOUBLE_PI) -#define MATH_FLOAT_MAXVALUE (FLT_MAX) +#define MATH_DOUBLE_PI 3.14159265358979323846 +#define MATH_DOUBLE_TWOPI (2 * MATH_DOUBLE_PI) +#define MATH_DOUBLE_PIOVER2 (0.5 * MATH_DOUBLE_PI) +#define MATH_DOUBLE_PIOVER4 (0.25 * MATH_DOUBLE_PI) +#define MATH_FLOAT_MAXVALUE (FLT_MAX) #define MATH_DOUBLE_RADTODEGREEFACTOR (360.0 / MATH_DOUBLE_TWOPI) #define MATH_DOUBLE_DEGREETORADFACTOR (MATH_DOUBLE_TWOPI / 360.0) -#define MATH_DOUBLE_E 2.71828182845904523536 -#define MATH_DOUBLE_LOG2E 1.44269504088896340736 -#define MATH_DOUBLE_LOG10E 0.434294481903251827651 -#define MATH_DOUBLE_LN2 0.693147180559945309417 -#define MATH_DOUBLE_LN10 2.30258509299404568402 +#define MATH_DOUBLE_E 2.71828182845904523536 +#define MATH_DOUBLE_LOG2E 1.44269504088896340736 +#define MATH_DOUBLE_LOG10E 0.434294481903251827651 +#define MATH_DOUBLE_LN2 0.693147180559945309417 +#define MATH_DOUBLE_LN10 2.30258509299404568402 -#define MATH_DOUBLE_SQRT2 1.41421356237309504880 -#define MATH_DOUBLE_SQRT1_2 0.707106781186547524401 +#define MATH_DOUBLE_SQRT2 1.41421356237309504880 +#define MATH_DOUBLE_SQRT1_2 0.707106781186547524401 -#define MATH_DOUBLE_TOLERANCE 1e-12 // a default number for value equality tolerance: about 4500*Epsilon; -#define MATH_DOUBLE_SINGULARITYRADIUS 1e-12 // about 1-cos(.0001 degree), for gimbal lock numerical problems +#define MATH_DOUBLE_TOLERANCE \ + 1e-12 // a default number for value equality tolerance: about 4500*Epsilon; +#define MATH_DOUBLE_SINGULARITYRADIUS \ + 1e-12 // about 1-cos(.0001 degree), for gimbal lock numerical problems + +#define MATH_DOUBLE_HUGENUMBER 1.3407807929942596e+154 +#define MATH_DOUBLE_SMALLESTNONDENORMAL 2.2250738585072014e-308 //------------------------------------------------------------------------------------// // ***** float constants -#define MATH_FLOAT_PI float(MATH_DOUBLE_PI) -#define MATH_FLOAT_TWOPI float(MATH_DOUBLE_TWOPI) -#define MATH_FLOAT_PIOVER2 float(MATH_DOUBLE_PIOVER2) -#define MATH_FLOAT_PIOVER4 float(MATH_DOUBLE_PIOVER4) +#define MATH_FLOAT_PI float(MATH_DOUBLE_PI) +#define MATH_FLOAT_TWOPI float(MATH_DOUBLE_TWOPI) +#define MATH_FLOAT_PIOVER2 float(MATH_DOUBLE_PIOVER2) +#define MATH_FLOAT_PIOVER4 float(MATH_DOUBLE_PIOVER4) #define MATH_FLOAT_RADTODEGREEFACTOR float(MATH_DOUBLE_RADTODEGREEFACTOR) #define MATH_FLOAT_DEGREETORADFACTOR float(MATH_DOUBLE_DEGREETORADFACTOR) -#define MATH_FLOAT_E float(MATH_DOUBLE_E) -#define MATH_FLOAT_LOG2E float(MATH_DOUBLE_LOG2E) -#define MATH_FLOAT_LOG10E float(MATH_DOUBLE_LOG10E) -#define MATH_FLOAT_LN2 float(MATH_DOUBLE_LN2) -#define MATH_FLOAT_LN10 float(MATH_DOUBLE_LN10) - -#define MATH_FLOAT_SQRT2 float(MATH_DOUBLE_SQRT2) -#define MATH_FLOAT_SQRT1_2 float(MATH_DOUBLE_SQRT1_2) +#define MATH_FLOAT_E float(MATH_DOUBLE_E) +#define MATH_FLOAT_LOG2E float(MATH_DOUBLE_LOG2E) +#define MATH_FLOAT_LOG10E float(MATH_DOUBLE_LOG10E) +#define MATH_FLOAT_LN2 float(MATH_DOUBLE_LN2) +#define MATH_FLOAT_LN10 float(MATH_DOUBLE_LN10) -#define MATH_FLOAT_TOLERANCE 1e-5f // a default number for value equality tolerance: 1e-5, about 84*EPSILON; -#define MATH_FLOAT_SINGULARITYRADIUS 1e-7f // about 1-cos(.025 degree), for gimbal lock numerical problems +#define MATH_FLOAT_SQRT2 float(MATH_DOUBLE_SQRT2) +#define MATH_FLOAT_SQRT1_2 float(MATH_DOUBLE_SQRT1_2) +#define MATH_FLOAT_TOLERANCE \ + 1e-5f // a default number for value equality tolerance: 1e-5, about 84*EPSILON; +#define MATH_FLOAT_SINGULARITYRADIUS \ + 1e-7f // about 1-cos(.025 degree), for gimbal lock numerical problems +#define MATH_FLOAT_HUGENUMBER 1.8446742974197924e+019f +#define MATH_FLOAT_SMALLESTNONDENORMAL 1.1754943508222875e-038f // Single-precision Math constants class. -template<> -class Math -{ -public: - typedef double OtherFloatType; - - static inline float Tolerance() { return MATH_FLOAT_TOLERANCE; }; // a default number for value equality tolerance - static inline float SingularityRadius() { return MATH_FLOAT_SINGULARITYRADIUS; }; // for gimbal lock numerical problems +template <> +class Math { + public: + typedef double OtherFloatType; + + static inline float MaxValue() { + return FLT_MAX; + }; + static inline float Tolerance() { + return MATH_FLOAT_TOLERANCE; + }; // a default number for value equality tolerance + static inline float SingularityRadius() { + return MATH_FLOAT_SINGULARITYRADIUS; + }; // for gimbal lock numerical problems + static inline float HugeNumber() { + return MATH_FLOAT_HUGENUMBER; + } + static inline float SmallestNonDenormal() { + return MATH_FLOAT_SMALLESTNONDENORMAL; + } }; // Double-precision Math constants class -template<> -class Math -{ -public: - typedef float OtherFloatType; - - static inline double Tolerance() { return MATH_DOUBLE_TOLERANCE; }; // a default number for value equality tolerance - static inline double SingularityRadius() { return MATH_DOUBLE_SINGULARITYRADIUS; }; // for gimbal lock numerical problems +template <> +class Math { + public: + typedef float OtherFloatType; + + static inline double Tolerance() { + return MATH_DOUBLE_TOLERANCE; + }; // a default number for value equality tolerance + static inline double SingularityRadius() { + return MATH_DOUBLE_SINGULARITYRADIUS; + }; // for gimbal lock numerical problems + static inline double HugeNumber() { + return MATH_DOUBLE_HUGENUMBER; + } + static inline double SmallestNonDenormal() { + return MATH_DOUBLE_SMALLESTNONDENORMAL; + } }; -typedef Math Mathf; +typedef Math Mathf; typedef Math Mathd; // Conversion functions between degrees and radians // (non-templated to ensure passing int arguments causes warning) -inline float RadToDegree(float rad) { return rad * MATH_FLOAT_RADTODEGREEFACTOR; } -inline double RadToDegree(double rad) { return rad * MATH_DOUBLE_RADTODEGREEFACTOR; } +inline float RadToDegree(float rad) { + return rad * MATH_FLOAT_RADTODEGREEFACTOR; +} +inline double RadToDegree(double rad) { + return rad * MATH_DOUBLE_RADTODEGREEFACTOR; +} -inline float DegreeToRad(float deg) { return deg * MATH_FLOAT_DEGREETORADFACTOR; } -inline double DegreeToRad(double deg) { return deg * MATH_DOUBLE_DEGREETORADFACTOR; } +inline float DegreeToRad(float deg) { + return deg * MATH_FLOAT_DEGREETORADFACTOR; +} +inline double DegreeToRad(double deg) { + return deg * MATH_DOUBLE_DEGREETORADFACTOR; +} // Square function -template -inline T Sqr(T x) { return x*x; } +template +inline T Sqr(T x) { + return x * x; +} + +// MERGE_MOBILE_SDK +// Safe reciprocal square root. +template +T RcpSqrt(const T f) { + return (f >= Math::SmallestNonDenormal()) ? static_cast(1.0 / sqrt(f)) + : Math::HugeNumber(); +} +// MERGE_MOBILE_SDK // Sign: returns 0 if x == 0, -1 if x < 0, and 1 if x > 0 -template -inline T Sign(T x) { return (x != T(0)) ? (x < T(0) ? T(-1) : T(1)) : T(0); } +template +inline T Sign(T x) { + return (x != T(0)) ? (x < T(0) ? T(-1) : T(1)) : T(0); +} // Numerically stable acos function -inline float Acos(float x) { return (x > 1.0f) ? 0.0f : (x < -1.0f) ? MATH_FLOAT_PI : acosf(x); } -inline double Acos(double x) { return (x > 1.0) ? 0.0 : (x < -1.0) ? MATH_DOUBLE_PI : acos(x); } +inline float Acos(float x) { + return (x > 1.0f) ? 0.0f : (x < -1.0f) ? MATH_FLOAT_PI : acosf(x); +} +inline double Acos(double x) { + return (x > 1.0) ? 0.0 : (x < -1.0) ? MATH_DOUBLE_PI : acos(x); +} // Numerically stable asin function -inline float Asin(float x) { return (x > 1.0f) ? MATH_FLOAT_PIOVER2 : (x < -1.0f) ? -MATH_FLOAT_PIOVER2 : asinf(x); } -inline double Asin(double x) { return (x > 1.0) ? MATH_DOUBLE_PIOVER2 : (x < -1.0) ? -MATH_DOUBLE_PIOVER2 : asin(x); } - -#if defined(_MSC_VER) - inline int isnan(double x) { return ::_isnan(x); } -#elif !defined(isnan) // Some libraries #define isnan. - inline int isnan(double x) { return ::isnan(x); } -#endif +inline float Asin(float x) { + return (x > 1.0f) ? MATH_FLOAT_PIOVER2 : (x < -1.0f) ? -MATH_FLOAT_PIOVER2 : asinf(x); +} +inline double Asin(double x) { + return (x > 1.0) ? MATH_DOUBLE_PIOVER2 : (x < -1.0) ? -MATH_DOUBLE_PIOVER2 : asin(x); +} -template +template class Quat; - //------------------------------------------------------------------------------------- // ***** Vector2<> // Vector2f (Vector2d) represents a 2-dimensional vector or point in space, // consisting of coordinates x and y -template -class Vector2 -{ -public: - typedef T ElementType; - static const size_t ElementCount = 2; - - T x, y; - - Vector2() : x(0), y(0) { } - Vector2(T x_, T y_) : x(x_), y(y_) { } - explicit Vector2(T s) : x(s), y(s) { } - explicit Vector2(const Vector2::OtherFloatType> &src) - : x((T)src.x), y((T)src.y) { } - - static Vector2 Zero() { return Vector2(0, 0); } - - // C-interop support. - typedef typename CompatibleTypes >::Type CompatibleType; - - Vector2(const CompatibleType& s) : x(s.x), y(s.y) { } - - operator const CompatibleType& () const - { - OVR_MATH_STATIC_ASSERT(sizeof(Vector2) == sizeof(CompatibleType), "sizeof(Vector2) failure"); - return reinterpret_cast(*this); - } - - - bool operator== (const Vector2& b) const { return x == b.x && y == b.y; } - bool operator!= (const Vector2& b) const { return x != b.x || y != b.y; } - - Vector2 operator+ (const Vector2& b) const { return Vector2(x + b.x, y + b.y); } - Vector2& operator+= (const Vector2& b) { x += b.x; y += b.y; return *this; } - Vector2 operator- (const Vector2& b) const { return Vector2(x - b.x, y - b.y); } - Vector2& operator-= (const Vector2& b) { x -= b.x; y -= b.y; return *this; } - Vector2 operator- () const { return Vector2(-x, -y); } - - // Scalar multiplication/division scales vector. - Vector2 operator* (T s) const { return Vector2(x*s, y*s); } - Vector2& operator*= (T s) { x *= s; y *= s; return *this; } - - Vector2 operator/ (T s) const { T rcp = T(1)/s; - return Vector2(x*rcp, y*rcp); } - Vector2& operator/= (T s) { T rcp = T(1)/s; - x *= rcp; y *= rcp; - return *this; } - - static Vector2 Min(const Vector2& a, const Vector2& b) { return Vector2((a.x < b.x) ? a.x : b.x, - (a.y < b.y) ? a.y : b.y); } - static Vector2 Max(const Vector2& a, const Vector2& b) { return Vector2((a.x > b.x) ? a.x : b.x, - (a.y > b.y) ? a.y : b.y); } - - Vector2 Clamped(T maxMag) const - { - T magSquared = LengthSq(); - if (magSquared <= Sqr(maxMag)) - return *this; - else - return *this * (maxMag / sqrt(magSquared)); - } - - // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. - bool IsEqual(const Vector2& b, T tolerance =Math::Tolerance()) const - { - return (fabs(b.x-x) <= tolerance) && - (fabs(b.y-y) <= tolerance); - } - bool Compare(const Vector2& b, T tolerance = Math::Tolerance()) const - { - return IsEqual(b, tolerance); - } - - // Access element by index - T& operator[] (int idx) - { - OVR_MATH_ASSERT(0 <= idx && idx < 2); - return *(&x + idx); - } - const T& operator[] (int idx) const - { - OVR_MATH_ASSERT(0 <= idx && idx < 2); - return *(&x + idx); - } - - // Entry-wise product of two vectors - Vector2 EntrywiseMultiply(const Vector2& b) const { return Vector2(x * b.x, y * b.y);} - - - // Multiply and divide operators do entry-wise math. Used Dot() for dot product. - Vector2 operator* (const Vector2& b) const { return Vector2(x * b.x, y * b.y); } - Vector2 operator/ (const Vector2& b) const { return Vector2(x / b.x, y / b.y); } - - // Dot product - // Used to calculate angle q between two vectors among other things, - // as (A dot B) = |a||b|cos(q). - T Dot(const Vector2& b) const { return x*b.x + y*b.y; } - - // Returns the angle from this vector to b, in radians. - T Angle(const Vector2& b) const - { - T div = LengthSq()*b.LengthSq(); - OVR_MATH_ASSERT(div != T(0)); - T result = Acos((this->Dot(b))/sqrt(div)); - return result; - } - - // Return Length of the vector squared. - T LengthSq() const { return (x * x + y * y); } - - // Return vector length. - T Length() const { return sqrt(LengthSq()); } - - // Returns squared distance between two points represented by vectors. - T DistanceSq(const Vector2& b) const { return (*this - b).LengthSq(); } - - // Returns distance between two points represented by vectors. - T Distance(const Vector2& b) const { return (*this - b).Length(); } - - // Determine if this a unit vector. - bool IsNormalized() const { return fabs(LengthSq() - T(1)) < Math::Tolerance(); } - - // Normalize, convention vector length to 1. - void Normalize() - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - *this *= s; - } - - // Returns normalized (unit) version of the vector without modifying itself. - Vector2 Normalized() const - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - return *this * s; - } - - // Linearly interpolates from this vector to another. - // Factor should be between 0.0 and 1.0, with 0 giving full value to this. - Vector2 Lerp(const Vector2& b, T f) const { return *this*(T(1) - f) + b*f; } - - // Projects this vector onto the argument; in other words, - // A.Project(B) returns projection of vector A onto B. - Vector2 ProjectTo(const Vector2& b) const - { - T l2 = b.LengthSq(); - OVR_MATH_ASSERT(l2 != T(0)); - return b * ( Dot(b) / l2 ); - } - - // returns true if vector b is clockwise from this vector - bool IsClockwise(const Vector2& b) const - { - return (x * b.y - y * b.x) < 0; - } +template +class Vector2 { + public: + typedef T ElementType; + static const size_t ElementCount = 2; + + T x, y; + + Vector2() : x(0), y(0) {} + Vector2(T x_, T y_) : x(x_), y(y_) {} + explicit Vector2(T s) : x(s), y(s) {} + explicit Vector2(const Vector2::OtherFloatType>& src) + : x((T)src.x), y((T)src.y) {} + + static Vector2 Zero() { + return Vector2(0, 0); + } + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Vector2(const CompatibleType& s) : x(s.x), y(s.y) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT( + sizeof(Vector2) == sizeof(CompatibleType), "sizeof(Vector2) failure"); + return reinterpret_cast(*this); + } + + bool operator==(const Vector2& b) const { + return x == b.x && y == b.y; + } + bool operator!=(const Vector2& b) const { + return x != b.x || y != b.y; + } + + Vector2 operator+(const Vector2& b) const { + return Vector2(x + b.x, y + b.y); + } + Vector2& operator+=(const Vector2& b) { + x += b.x; + y += b.y; + return *this; + } + Vector2 operator-(const Vector2& b) const { + return Vector2(x - b.x, y - b.y); + } + Vector2& operator-=(const Vector2& b) { + x -= b.x; + y -= b.y; + return *this; + } + Vector2 operator-() const { + return Vector2(-x, -y); + } + + // Scalar multiplication/division scales vector. + Vector2 operator*(T s) const { + return Vector2(x * s, y * s); + } + Vector2& operator*=(T s) { + x *= s; + y *= s; + return *this; + } + + Vector2 operator/(T s) const { + T rcp = T(1) / s; + return Vector2(x * rcp, y * rcp); + } + Vector2& operator/=(T s) { + T rcp = T(1) / s; + x *= rcp; + y *= rcp; + return *this; + } + + static Vector2 Min(const Vector2& a, const Vector2& b) { + return Vector2((a.x < b.x) ? a.x : b.x, (a.y < b.y) ? a.y : b.y); + } + static Vector2 Max(const Vector2& a, const Vector2& b) { + return Vector2((a.x > b.x) ? a.x : b.x, (a.y > b.y) ? a.y : b.y); + } + + Vector2 Clamped(T maxMag) const { + T magSquared = LengthSq(); + if (magSquared <= Sqr(maxMag)) + return *this; + else + return *this * (maxMag / sqrt(magSquared)); + } + + // Compare two vectors for equality with tolerance. Returns true if vectors match within + // tolerance. + bool IsEqual(const Vector2& b, T tolerance = Math::Tolerance()) const { + return (fabs(b.x - x) <= tolerance) && (fabs(b.y - y) <= tolerance); + } + bool Compare(const Vector2& b, T tolerance = Math::Tolerance()) const { + return IsEqual(b, tolerance); + } + + // Access element by index + T& operator[](int idx) { + OVR_MATH_ASSERT(0 <= idx && idx < 2); + return *(&x + idx); + } + const T& operator[](int idx) const { + OVR_MATH_ASSERT(0 <= idx && idx < 2); + return *(&x + idx); + } + + // Entry-wise product of two vectors + Vector2 EntrywiseMultiply(const Vector2& b) const { + return Vector2(x * b.x, y * b.y); + } + + // Multiply and divide operators do entry-wise math. Used Dot() for dot product. + Vector2 operator*(const Vector2& b) const { + return Vector2(x * b.x, y * b.y); + } + Vector2 operator/(const Vector2& b) const { + return Vector2(x / b.x, y / b.y); + } + + // Dot product + // Used to calculate angle q between two vectors among other things, + // as (A dot B) = |a||b|cos(q). + T Dot(const Vector2& b) const { + return x * b.x + y * b.y; + } + + // Returns the angle from this vector to b, in radians. + T Angle(const Vector2& b) const { + T div = LengthSq() * b.LengthSq(); + OVR_MATH_ASSERT(div != T(0)); + T result = Acos((this->Dot(b)) / sqrt(div)); + return result; + } + + // Return Length of the vector squared. + T LengthSq() const { + return (x * x + y * y); + } + + // Return vector length. + T Length() const { + return sqrt(LengthSq()); + } + + // Returns squared distance between two points represented by vectors. + T DistanceSq(const Vector2& b) const { + return (*this - b).LengthSq(); + } + + // Returns distance between two points represented by vectors. + T Distance(const Vector2& b) const { + return (*this - b).Length(); + } + + // Determine if this a unit vector. + bool IsNormalized() const { + return fabs(LengthSq() - T(1)) < Math::Tolerance(); + } + + // Normalize, convention vector length to 1. + void Normalize() { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + *this *= s; + } + + // Returns normalized (unit) version of the vector without modifying itself. + Vector2 Normalized() const { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + return *this * s; + } + + // Linearly interpolates from this vector to another. + // Factor should be between 0.0 and 1.0, with 0 giving full value to this. + Vector2 Lerp(const Vector2& b, T f) const { + return *this * (T(1) - f) + b * f; + } + + // Projects this vector onto the argument; in other words, + // A.Project(B) returns projection of vector A onto B. + Vector2 ProjectTo(const Vector2& b) const { + T l2 = b.LengthSq(); + OVR_MATH_ASSERT(l2 != T(0)); + return b * (Dot(b) / l2); + } + + // returns true if vector b is clockwise from this vector + bool IsClockwise(const Vector2& b) const { + return (x * b.y - y * b.x) < 0; + } }; - -typedef Vector2 Vector2f; +typedef Vector2 Vector2f; typedef Vector2 Vector2d; -typedef Vector2 Vector2i; +typedef Vector2 Vector2i; -typedef Vector2 Point2f; +typedef Vector2 Point2f; typedef Vector2 Point2d; -typedef Vector2 Point2i; +typedef Vector2 Point2i; //------------------------------------------------------------------------------------- // ***** Vector3<> - 3D vector of {x, y, z} @@ -538,199 +705,239 @@ typedef Vector2 Point2i; // Vector3f (Vector3d) represents a 3-dimensional vector or point in space, // consisting of coordinates x, y and z. -template -class Vector3 -{ -public: - typedef T ElementType; - static const size_t ElementCount = 3; - - T x, y, z; - - // FIXME: default initialization of a vector class can be very expensive in a full-blown - // application. A few hundred thousand vector constructions is not unlikely and can add - // up to milliseconds of time on processors like the PS3 PPU. - Vector3() : x(0), y(0), z(0) { } - Vector3(T x_, T y_, T z_ = 0) : x(x_), y(y_), z(z_) { } - explicit Vector3(T s) : x(s), y(s), z(s) { } - explicit Vector3(const Vector3::OtherFloatType> &src) - : x((T)src.x), y((T)src.y), z((T)src.z) { } - - static Vector3 Zero() { return Vector3(0, 0, 0); } - - // C-interop support. - typedef typename CompatibleTypes >::Type CompatibleType; - - Vector3(const CompatibleType& s) : x(s.x), y(s.y), z(s.z) { } - - operator const CompatibleType& () const - { - OVR_MATH_STATIC_ASSERT(sizeof(Vector3) == sizeof(CompatibleType), "sizeof(Vector3) failure"); - return reinterpret_cast(*this); - } - - bool operator== (const Vector3& b) const { return x == b.x && y == b.y && z == b.z; } - bool operator!= (const Vector3& b) const { return x != b.x || y != b.y || z != b.z; } - - Vector3 operator+ (const Vector3& b) const { return Vector3(x + b.x, y + b.y, z + b.z); } - Vector3& operator+= (const Vector3& b) { x += b.x; y += b.y; z += b.z; return *this; } - Vector3 operator- (const Vector3& b) const { return Vector3(x - b.x, y - b.y, z - b.z); } - Vector3& operator-= (const Vector3& b) { x -= b.x; y -= b.y; z -= b.z; return *this; } - Vector3 operator- () const { return Vector3(-x, -y, -z); } - - // Scalar multiplication/division scales vector. - Vector3 operator* (T s) const { return Vector3(x*s, y*s, z*s); } - Vector3& operator*= (T s) { x *= s; y *= s; z *= s; return *this; } - - Vector3 operator/ (T s) const { T rcp = T(1)/s; - return Vector3(x*rcp, y*rcp, z*rcp); } - Vector3& operator/= (T s) { T rcp = T(1)/s; - x *= rcp; y *= rcp; z *= rcp; - return *this; } - - static Vector3 Min(const Vector3& a, const Vector3& b) - { - return Vector3((a.x < b.x) ? a.x : b.x, - (a.y < b.y) ? a.y : b.y, - (a.z < b.z) ? a.z : b.z); - } - static Vector3 Max(const Vector3& a, const Vector3& b) - { - return Vector3((a.x > b.x) ? a.x : b.x, - (a.y > b.y) ? a.y : b.y, - (a.z > b.z) ? a.z : b.z); - } - - Vector3 Clamped(T maxMag) const - { - T magSquared = LengthSq(); - if (magSquared <= Sqr(maxMag)) - return *this; - else - return *this * (maxMag / sqrt(magSquared)); - } - - // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. - bool IsEqual(const Vector3& b, T tolerance = Math::Tolerance()) const - { - return (fabs(b.x-x) <= tolerance) && - (fabs(b.y-y) <= tolerance) && - (fabs(b.z-z) <= tolerance); - } - bool Compare(const Vector3& b, T tolerance = Math::Tolerance()) const - { - return IsEqual(b, tolerance); - } - - T& operator[] (int idx) - { - OVR_MATH_ASSERT(0 <= idx && idx < 3); - return *(&x + idx); - } - - const T& operator[] (int idx) const - { - OVR_MATH_ASSERT(0 <= idx && idx < 3); - return *(&x + idx); - } - - // Entrywise product of two vectors - Vector3 EntrywiseMultiply(const Vector3& b) const { return Vector3(x * b.x, - y * b.y, - z * b.z);} - - // Multiply and divide operators do entry-wise math - Vector3 operator* (const Vector3& b) const { return Vector3(x * b.x, - y * b.y, - z * b.z); } - - Vector3 operator/ (const Vector3& b) const { return Vector3(x / b.x, - y / b.y, - z / b.z); } - - - // Dot product - // Used to calculate angle q between two vectors among other things, - // as (A dot B) = |a||b|cos(q). - T Dot(const Vector3& b) const { return x*b.x + y*b.y + z*b.z; } - - // Compute cross product, which generates a normal vector. - // Direction vector can be determined by right-hand rule: Pointing index finder in - // direction a and middle finger in direction b, thumb will point in a.Cross(b). - Vector3 Cross(const Vector3& b) const { return Vector3(y*b.z - z*b.y, - z*b.x - x*b.z, - x*b.y - y*b.x); } - - // Returns the angle from this vector to b, in radians. - T Angle(const Vector3& b) const - { - T div = LengthSq()*b.LengthSq(); - OVR_MATH_ASSERT(div != T(0)); - T result = Acos((this->Dot(b))/sqrt(div)); - return result; - } - - // Return Length of the vector squared. - T LengthSq() const { return (x * x + y * y + z * z); } - - // Return vector length. - T Length() const { return (T)sqrt(LengthSq()); } - - // Returns squared distance between two points represented by vectors. - T DistanceSq(Vector3 const& b) const { return (*this - b).LengthSq(); } - - // Returns distance between two points represented by vectors. - T Distance(Vector3 const& b) const { return (*this - b).Length(); } - - bool IsNormalized() const { return fabs(LengthSq() - T(1)) < Math::Tolerance(); } - - // Normalize, convention vector length to 1. - void Normalize() - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - *this *= s; - } - - // Returns normalized (unit) version of the vector without modifying itself. - Vector3 Normalized() const - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - return *this * s; - } - - // Linearly interpolates from this vector to another. - // Factor should be between 0.0 and 1.0, with 0 giving full value to this. - Vector3 Lerp(const Vector3& b, T f) const { return *this*(T(1) - f) + b*f; } - - // Projects this vector onto the argument; in other words, - // A.Project(B) returns projection of vector A onto B. - Vector3 ProjectTo(const Vector3& b) const - { - T l2 = b.LengthSq(); - OVR_MATH_ASSERT(l2 != T(0)); - return b * ( Dot(b) / l2 ); - } - - // Projects this vector onto a plane defined by a normal vector - Vector3 ProjectToPlane(const Vector3& normal) const { return *this - this->ProjectTo(normal); } +template +class Vector3 { + public: + typedef T ElementType; + static const size_t ElementCount = 3; + + T x, y, z; + + // FIXME: default initialization of a vector class can be very expensive in a full-blown + // application. A few hundred thousand vector constructions is not unlikely and can add + // up to milliseconds of time on processors like the PS3 PPU. + Vector3() : x(0), y(0), z(0) {} + Vector3(T x_, T y_, T z_ = 0) : x(x_), y(y_), z(z_) {} + explicit Vector3(T s) : x(s), y(s), z(s) {} + explicit Vector3(const Vector3::OtherFloatType>& src) + : x((T)src.x), y((T)src.y), z((T)src.z) {} + + static Vector3 Zero() { + return Vector3(0, 0, 0); + } + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Vector3(const CompatibleType& s) : x(s.x), y(s.y), z(s.z) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT( + sizeof(Vector3) == sizeof(CompatibleType), "sizeof(Vector3) failure"); + return reinterpret_cast(*this); + } + + bool operator==(const Vector3& b) const { + return x == b.x && y == b.y && z == b.z; + } + bool operator!=(const Vector3& b) const { + return x != b.x || y != b.y || z != b.z; + } + + Vector3 operator+(const Vector3& b) const { + return Vector3(x + b.x, y + b.y, z + b.z); + } + Vector3& operator+=(const Vector3& b) { + x += b.x; + y += b.y; + z += b.z; + return *this; + } + Vector3 operator-(const Vector3& b) const { + return Vector3(x - b.x, y - b.y, z - b.z); + } + Vector3& operator-=(const Vector3& b) { + x -= b.x; + y -= b.y; + z -= b.z; + return *this; + } + Vector3 operator-() const { + return Vector3(-x, -y, -z); + } + + // Scalar multiplication/division scales vector. + Vector3 operator*(T s) const { + return Vector3(x * s, y * s, z * s); + } + Vector3& operator*=(T s) { + x *= s; + y *= s; + z *= s; + return *this; + } + + Vector3 operator/(T s) const { + T rcp = T(1) / s; + return Vector3(x * rcp, y * rcp, z * rcp); + } + Vector3& operator/=(T s) { + T rcp = T(1) / s; + x *= rcp; + y *= rcp; + z *= rcp; + return *this; + } + + static Vector3 Min(const Vector3& a, const Vector3& b) { + return Vector3((a.x < b.x) ? a.x : b.x, (a.y < b.y) ? a.y : b.y, (a.z < b.z) ? a.z : b.z); + } + static Vector3 Max(const Vector3& a, const Vector3& b) { + return Vector3((a.x > b.x) ? a.x : b.x, (a.y > b.y) ? a.y : b.y, (a.z > b.z) ? a.z : b.z); + } + + Vector3 Clamped(T maxMag) const { + T magSquared = LengthSq(); + if (magSquared <= Sqr(maxMag)) + return *this; + else + return *this * (maxMag / sqrt(magSquared)); + } + + // Compare two vectors for equality with tolerance. Returns true if vectors match within + // tolerance. + bool IsEqual(const Vector3& b, T tolerance = Math::Tolerance()) const { + return (fabs(b.x - x) <= tolerance) && (fabs(b.y - y) <= tolerance) && + (fabs(b.z - z) <= tolerance); + } + bool Compare(const Vector3& b, T tolerance = Math::Tolerance()) const { + return IsEqual(b, tolerance); + } + + T& operator[](int idx) { + OVR_MATH_ASSERT(0 <= idx && idx < 3); + return *(&x + idx); + } + + const T& operator[](int idx) const { + OVR_MATH_ASSERT(0 <= idx && idx < 3); + return *(&x + idx); + } + + // Entrywise product of two vectors + Vector3 EntrywiseMultiply(const Vector3& b) const { + return Vector3(x * b.x, y * b.y, z * b.z); + } + + // Multiply and divide operators do entry-wise math + Vector3 operator*(const Vector3& b) const { + return Vector3(x * b.x, y * b.y, z * b.z); + } + + Vector3 operator/(const Vector3& b) const { + return Vector3(x / b.x, y / b.y, z / b.z); + } + + // Dot product + // Used to calculate angle q between two vectors among other things, + // as (A dot B) = |a||b|cos(q). + T Dot(const Vector3& b) const { + return x * b.x + y * b.y + z * b.z; + } + + // Compute cross product, which generates a normal vector. + // Direction vector can be determined by right-hand rule: Pointing index finder in + // direction a and middle finger in direction b, thumb will point in a.Cross(b). + Vector3 Cross(const Vector3& b) const { + return Vector3(y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x); + } + + // Returns the angle from this vector to b, in radians. + T Angle(const Vector3& b) const { + T div = LengthSq() * b.LengthSq(); + OVR_MATH_ASSERT(div != T(0)); + T result = Acos((this->Dot(b)) / sqrt(div)); + return result; + } + + // Return Length of the vector squared. + T LengthSq() const { + return (x * x + y * y + z * z); + } + + // Return vector length. + T Length() const { + return (T)sqrt(LengthSq()); + } + + // Returns squared distance between two points represented by vectors. + T DistanceSq(Vector3 const& b) const { + return (*this - b).LengthSq(); + } + + // Returns distance between two points represented by vectors. + T Distance(Vector3 const& b) const { + return (*this - b).Length(); + } + + bool IsNormalized() const { + return fabs(LengthSq() - T(1)) < Math::Tolerance(); + } + + // Normalize, convention vector length to 1. + void Normalize() { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + *this *= s; + } + + // Returns normalized (unit) version of the vector without modifying itself. + Vector3 Normalized() const { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + return *this * s; + } + + // Linearly interpolates from this vector to another. + // Factor should be between 0.0 and 1.0, with 0 giving full value to this. + Vector3 Lerp(const Vector3& b, T f) const { + return *this * (T(1) - f) + b * f; + } + + // Projects this vector onto the argument; in other words, + // A.Project(B) returns projection of vector A onto B. + Vector3 ProjectTo(const Vector3& b) const { + T l2 = b.LengthSq(); + OVR_MATH_ASSERT(l2 != T(0)); + return b * (Dot(b) / l2); + } + + // Projects this vector onto a plane defined by a normal vector + Vector3 ProjectToPlane(const Vector3& normal) const { + return *this - this->ProjectTo(normal); + } + + bool IsNan() const { + return !isfinite(x + y + z); + } + bool IsFinite() const { + return isfinite(x + y + z); + } }; -typedef Vector3 Vector3f; +typedef Vector3 Vector3f; typedef Vector3 Vector3d; -typedef Vector3 Vector3i; - -OVR_MATH_STATIC_ASSERT((sizeof(Vector3f) == 3*sizeof(float)), "sizeof(Vector3f) failure"); -OVR_MATH_STATIC_ASSERT((sizeof(Vector3d) == 3*sizeof(double)), "sizeof(Vector3d) failure"); -OVR_MATH_STATIC_ASSERT((sizeof(Vector3i) == 3*sizeof(int32_t)), "sizeof(Vector3i) failure"); +typedef Vector3 Vector3i; -typedef Vector3 Point3f; -typedef Vector3 Point3d; -typedef Vector3 Point3i; +OVR_MATH_STATIC_ASSERT((sizeof(Vector3f) == 3 * sizeof(float)), "sizeof(Vector3f) failure"); +OVR_MATH_STATIC_ASSERT((sizeof(Vector3d) == 3 * sizeof(double)), "sizeof(Vector3d) failure"); +OVR_MATH_STATIC_ASSERT((sizeof(Vector3i) == 3 * sizeof(int32_t)), "sizeof(Vector3i) failure"); +typedef Vector3 Point3f; +typedef Vector3 Point3d; +typedef Vector3 Point3i; //------------------------------------------------------------------------------------- // ***** Vector4<> - 4D vector of {x, y, z, w} @@ -739,211 +946,283 @@ typedef Vector3 Point3i; // Vector4f (Vector4d) represents a 3-dimensional vector or point in space, // consisting of coordinates x, y, z and w. -template -class Vector4 -{ -public: - typedef T ElementType; - static const size_t ElementCount = 4; - - T x, y, z, w; - - // FIXME: default initialization of a vector class can be very expensive in a full-blown - // application. A few hundred thousand vector constructions is not unlikely and can add - // up to milliseconds of time on processors like the PS3 PPU. - Vector4() : x(0), y(0), z(0), w(0) { } - Vector4(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) { } - explicit Vector4(T s) : x(s), y(s), z(s), w(s) { } - explicit Vector4(const Vector3& v, const T w_=T(1)) : x(v.x), y(v.y), z(v.z), w(w_) { } - explicit Vector4(const Vector4::OtherFloatType> &src) - : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) { } - - static Vector4 Zero() { return Vector4(0, 0, 0, 0); } - - // C-interop support. - typedef typename CompatibleTypes< Vector4 >::Type CompatibleType; - - Vector4(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) { } - - operator const CompatibleType& () const - { - OVR_MATH_STATIC_ASSERT(sizeof(Vector4) == sizeof(CompatibleType), "sizeof(Vector4) failure"); - return reinterpret_cast(*this); - } - - Vector4& operator= (const Vector3& other) { x=other.x; y=other.y; z=other.z; w=1; return *this; } - bool operator== (const Vector4& b) const { return x == b.x && y == b.y && z == b.z && w == b.w; } - bool operator!= (const Vector4& b) const { return x != b.x || y != b.y || z != b.z || w != b.w; } - - Vector4 operator+ (const Vector4& b) const { return Vector4(x + b.x, y + b.y, z + b.z, w + b.w); } - Vector4& operator+= (const Vector4& b) { x += b.x; y += b.y; z += b.z; w += b.w; return *this; } - Vector4 operator- (const Vector4& b) const { return Vector4(x - b.x, y - b.y, z - b.z, w - b.w); } - Vector4& operator-= (const Vector4& b) { x -= b.x; y -= b.y; z -= b.z; w -= b.w; return *this; } - Vector4 operator- () const { return Vector4(-x, -y, -z, -w); } - - // Scalar multiplication/division scales vector. - Vector4 operator* (T s) const { return Vector4(x*s, y*s, z*s, w*s); } - Vector4& operator*= (T s) { x *= s; y *= s; z *= s; w *= s;return *this; } - - Vector4 operator/ (T s) const { T rcp = T(1)/s; - return Vector4(x*rcp, y*rcp, z*rcp, w*rcp); } - Vector4& operator/= (T s) { T rcp = T(1)/s; - x *= rcp; y *= rcp; z *= rcp; w *= rcp; - return *this; } - - static Vector4 Min(const Vector4& a, const Vector4& b) - { - return Vector4((a.x < b.x) ? a.x : b.x, - (a.y < b.y) ? a.y : b.y, - (a.z < b.z) ? a.z : b.z, - (a.w < b.w) ? a.w : b.w); - } - static Vector4 Max(const Vector4& a, const Vector4& b) - { - return Vector4((a.x > b.x) ? a.x : b.x, - (a.y > b.y) ? a.y : b.y, - (a.z > b.z) ? a.z : b.z, - (a.w > b.w) ? a.w : b.w); - } - - Vector4 Clamped(T maxMag) const - { - T magSquared = LengthSq(); - if (magSquared <= Sqr(maxMag)) - return *this; - else - return *this * (maxMag / sqrt(magSquared)); - } - - // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. - bool IsEqual(const Vector4& b, T tolerance = Math::Tolerance()) const - { - return (fabs(b.x-x) <= tolerance) && - (fabs(b.y-y) <= tolerance) && - (fabs(b.z-z) <= tolerance) && - (fabs(b.w-w) <= tolerance); - } - bool Compare(const Vector4& b, T tolerance = Math::Tolerance()) const - { - return IsEqual(b, tolerance); - } - - T& operator[] (int idx) - { - OVR_MATH_ASSERT(0 <= idx && idx < 4); - return *(&x + idx); - } - - const T& operator[] (int idx) const - { - OVR_MATH_ASSERT(0 <= idx && idx < 4); - return *(&x + idx); - } - - // Entry wise product of two vectors - Vector4 EntrywiseMultiply(const Vector4& b) const { return Vector4(x * b.x, - y * b.y, - z * b.z, - w * b.w);} - - // Multiply and divide operators do entry-wise math - Vector4 operator* (const Vector4& b) const { return Vector4(x * b.x, - y * b.y, - z * b.z, - w * b.w); } - - Vector4 operator/ (const Vector4& b) const { return Vector4(x / b.x, - y / b.y, - z / b.z, - w / b.w); } - - - // Dot product - T Dot(const Vector4& b) const { return x*b.x + y*b.y + z*b.z + w*b.w; } - - // Return Length of the vector squared. - T LengthSq() const { return (x * x + y * y + z * z + w * w); } - - // Return vector length. - T Length() const { return sqrt(LengthSq()); } - - bool IsNormalized() const { return fabs(LengthSq() - T(1)) < Math::Tolerance(); } - - // Normalize, convention vector length to 1. - void Normalize() - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - *this *= s; - } - - // Returns normalized (unit) version of the vector without modifying itself. - Vector4 Normalized() const - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - return *this * s; - } - - // Linearly interpolates from this vector to another. - // Factor should be between 0.0 and 1.0, with 0 giving full value to this. - Vector4 Lerp(const Vector4& b, T f) const { return *this*(T(1) - f) + b*f; } +template +class Vector4 { + public: + typedef T ElementType; + static const size_t ElementCount = 4; + + T x, y, z, w; + + // FIXME: default initialization of a vector class can be very expensive in a full-blown + // application. A few hundred thousand vector constructions is not unlikely and can add + // up to milliseconds of time on processors like the PS3 PPU. + Vector4() : x(0), y(0), z(0), w(0) {} + Vector4(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) {} + explicit Vector4(T s) : x(s), y(s), z(s), w(s) {} + explicit Vector4(const Vector3& v, const T w_ = T(1)) : x(v.x), y(v.y), z(v.z), w(w_) {} + explicit Vector4(const Vector4::OtherFloatType>& src) + : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) {} + + static Vector4 Zero() { + return Vector4(0, 0, 0, 0); + } + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Vector4(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT( + sizeof(Vector4) == sizeof(CompatibleType), "sizeof(Vector4) failure"); + return reinterpret_cast(*this); + } + + Vector4& operator=(const Vector3& other) { + x = other.x; + y = other.y; + z = other.z; + w = 1; + return *this; + } + bool operator==(const Vector4& b) const { + return x == b.x && y == b.y && z == b.z && w == b.w; + } + bool operator!=(const Vector4& b) const { + return x != b.x || y != b.y || z != b.z || w != b.w; + } + + Vector4 operator+(const Vector4& b) const { + return Vector4(x + b.x, y + b.y, z + b.z, w + b.w); + } + Vector4& operator+=(const Vector4& b) { + x += b.x; + y += b.y; + z += b.z; + w += b.w; + return *this; + } + Vector4 operator-(const Vector4& b) const { + return Vector4(x - b.x, y - b.y, z - b.z, w - b.w); + } + Vector4& operator-=(const Vector4& b) { + x -= b.x; + y -= b.y; + z -= b.z; + w -= b.w; + return *this; + } + Vector4 operator-() const { + return Vector4(-x, -y, -z, -w); + } + + // Scalar multiplication/division scales vector. + Vector4 operator*(T s) const { + return Vector4(x * s, y * s, z * s, w * s); + } + Vector4& operator*=(T s) { + x *= s; + y *= s; + z *= s; + w *= s; + return *this; + } + + Vector4 operator/(T s) const { + T rcp = T(1) / s; + return Vector4(x * rcp, y * rcp, z * rcp, w * rcp); + } + Vector4& operator/=(T s) { + T rcp = T(1) / s; + x *= rcp; + y *= rcp; + z *= rcp; + w *= rcp; + return *this; + } + + static Vector4 Min(const Vector4& a, const Vector4& b) { + return Vector4( + (a.x < b.x) ? a.x : b.x, + (a.y < b.y) ? a.y : b.y, + (a.z < b.z) ? a.z : b.z, + (a.w < b.w) ? a.w : b.w); + } + static Vector4 Max(const Vector4& a, const Vector4& b) { + return Vector4( + (a.x > b.x) ? a.x : b.x, + (a.y > b.y) ? a.y : b.y, + (a.z > b.z) ? a.z : b.z, + (a.w > b.w) ? a.w : b.w); + } + + Vector4 Clamped(T maxMag) const { + T magSquared = LengthSq(); + if (magSquared <= Sqr(maxMag)) + return *this; + else + return *this * (maxMag / sqrt(magSquared)); + } + + // Compare two vectors for equality with tolerance. Returns true if vectors match within + // tolerance. + bool IsEqual(const Vector4& b, T tolerance = Math::Tolerance()) const { + return (fabs(b.x - x) <= tolerance) && (fabs(b.y - y) <= tolerance) && + (fabs(b.z - z) <= tolerance) && (fabs(b.w - w) <= tolerance); + } + bool Compare(const Vector4& b, T tolerance = Math::Tolerance()) const { + return IsEqual(b, tolerance); + } + + T& operator[](int idx) { + OVR_MATH_ASSERT(0 <= idx && idx < 4); + return *(&x + idx); + } + + const T& operator[](int idx) const { + OVR_MATH_ASSERT(0 <= idx && idx < 4); + return *(&x + idx); + } + + // Entry wise product of two vectors + Vector4 EntrywiseMultiply(const Vector4& b) const { + return Vector4(x * b.x, y * b.y, z * b.z, w * b.w); + } + + // Multiply and divide operators do entry-wise math + Vector4 operator*(const Vector4& b) const { + return Vector4(x * b.x, y * b.y, z * b.z, w * b.w); + } + + Vector4 operator/(const Vector4& b) const { + return Vector4(x / b.x, y / b.y, z / b.z, w / b.w); + } + + // Dot product + T Dot(const Vector4& b) const { + return x * b.x + y * b.y + z * b.z + w * b.w; + } + + // Return Length of the vector squared. + T LengthSq() const { + return (x * x + y * y + z * z + w * w); + } + + // Return vector length. + T Length() const { + return sqrt(LengthSq()); + } + + bool IsNormalized() const { + return fabs(LengthSq() - T(1)) < Math::Tolerance(); + } + + // Normalize, convention vector length to 1. + void Normalize() { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + *this *= s; + } + + // Returns normalized (unit) version of the vector without modifying itself. + Vector4 Normalized() const { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + return *this * s; + } + + // Linearly interpolates from this vector to another. + // Factor should be between 0.0 and 1.0, with 0 giving full value to this. + Vector4 Lerp(const Vector4& b, T f) const { + return *this * (T(1) - f) + b * f; + } }; -typedef Vector4 Vector4f; +typedef Vector4 Vector4f; typedef Vector4 Vector4d; -typedef Vector4 Vector4i; - +typedef Vector4 Vector4i; //------------------------------------------------------------------------------------- // ***** Bounds3 // Bounds class used to describe a 3D axis aligned bounding box. -template -class Bounds3 -{ -public: - Vector3 b[2]; - - Bounds3() - { - } - - Bounds3( const Vector3 & mins, const Vector3 & maxs ) -{ - b[0] = mins; - b[1] = maxs; - } - - void Clear() - { - b[0].x = b[0].y = b[0].z = Math::MaxValue; - b[1].x = b[1].y = b[1].z = -Math::MaxValue; - } - - void AddPoint( const Vector3 & v ) - { - b[0].x = (b[0].x < v.x ? b[0].x : v.x); - b[0].y = (b[0].y < v.y ? b[0].y : v.y); - b[0].z = (b[0].z < v.z ? b[0].z : v.z); - b[1].x = (v.x < b[1].x ? b[1].x : v.x); - b[1].y = (v.y < b[1].y ? b[1].y : v.y); - b[1].z = (v.z < b[1].z ? b[1].z : v.z); - } - - const Vector3 & GetMins() const { return b[0]; } - const Vector3 & GetMaxs() const { return b[1]; } - - Vector3 & GetMins() { return b[0]; } - Vector3 & GetMaxs() { return b[1]; } +template +class Bounds3 { + public: + Vector3 b[2]; + + Bounds3() { + Clear(); + } + + Bounds3(const Vector3& mins, const Vector3& maxs) { + b[0] = mins; + b[1] = maxs; + } + + void Clear() { + b[0].x = b[0].y = b[0].z = Math::MaxValue(); + b[1].x = b[1].y = b[1].z = -Math::MaxValue(); + } + + void AddPoint(const Vector3& v) { + b[0].x = (b[0].x < v.x ? b[0].x : v.x); + b[0].y = (b[0].y < v.y ? b[0].y : v.y); + b[0].z = (b[0].z < v.z ? b[0].z : v.z); + b[1].x = (v.x < b[1].x ? b[1].x : v.x); + b[1].y = (v.y < b[1].y ? b[1].y : v.y); + b[1].z = (v.z < b[1].z ? b[1].z : v.z); + } + + bool Excludes(const Vector3& v) const { + bool testing = false; + for (int32_t t = 0; t < 3; ++t) { + testing |= v[t] > b[1][t]; + testing |= v[t] < b[0][t]; + } + return testing; + } + + // exludes, ignoring vertical + bool ExcludesXZ(const Vector3& v) const { + bool testing = false; + testing |= v[0] > b[1][0]; + testing |= v[0] < b[0][0]; + testing |= v[2] > b[1][2]; + testing |= v[2] < b[0][2]; + return testing; + } + + bool Excludes(const Bounds3& bounds) const { + bool testing = false; + for (int32_t t = 0; t < 3; ++t) { + testing |= bounds.b[0][t] > b[1][t]; + testing |= bounds.b[1][t] < b[0][t]; + } + return testing; + } + + const Vector3& GetMins() const { + return b[0]; + } + const Vector3& GetMaxs() const { + return b[1]; + } + + Vector3& GetMins() { + return b[0]; + } + Vector3& GetMaxs() { + return b[1]; + } }; -typedef Bounds3 Bounds3f; -typedef Bounds3 Bounds3d; - +typedef Bounds3 Bounds3f; +typedef Bounds3 Bounds3d; //------------------------------------------------------------------------------------- // ***** Size @@ -951,929 +1230,1217 @@ typedef Bounds3 Bounds3d; // Size class represents 2D size with Width, Height components. // Used to describe distentions of render targets, etc. -template -class Size -{ -public: - T w, h; - - Size() : w(0), h(0) { } - Size(T w_, T h_) : w(w_), h(h_) { } - explicit Size(T s) : w(s), h(s) { } - explicit Size(const Size::OtherFloatType> &src) - : w((T)src.w), h((T)src.h) { } +template +class Size { + public: + T w, h; + + Size() : w(0), h(0) {} + Size(T w_, T h_) : w(w_), h(h_) {} + explicit Size(T s) : w(s), h(s) {} + explicit Size(const Size::OtherFloatType>& src) : w((T)src.w), h((T)src.h) {} + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Size(const CompatibleType& s) : w(s.w), h(s.h) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT(sizeof(Size) == sizeof(CompatibleType), "sizeof(Size) failure"); + return reinterpret_cast(*this); + } + + bool operator==(const Size& b) const { + return w == b.w && h == b.h; + } + bool operator!=(const Size& b) const { + return w != b.w || h != b.h; + } + + Size operator+(const Size& b) const { + return Size(w + b.w, h + b.h); + } + Size& operator+=(const Size& b) { + w += b.w; + h += b.h; + return *this; + } + Size operator-(const Size& b) const { + return Size(w - b.w, h - b.h); + } + Size& operator-=(const Size& b) { + w -= b.w; + h -= b.h; + return *this; + } + Size operator-() const { + return Size(-w, -h); + } + Size operator*(const Size& b) const { + return Size(w * b.w, h * b.h); + } + Size& operator*=(const Size& b) { + w *= b.w; + h *= b.h; + return *this; + } + Size operator/(const Size& b) const { + return Size(w / b.w, h / b.h); + } + Size& operator/=(const Size& b) { + w /= b.w; + h /= b.h; + return *this; + } + + // Scalar multiplication/division scales both components. + Size operator*(T s) const { + return Size(w * s, h * s); + } + Size& operator*=(T s) { + w *= s; + h *= s; + return *this; + } + Size operator/(T s) const { + return Size(w / s, h / s); + } + Size& operator/=(T s) { + w /= s; + h /= s; + return *this; + } + + static Size Min(const Size& a, const Size& b) { + return Size((a.w < b.w) ? a.w : b.w, (a.h < b.h) ? a.h : b.h); + } + static Size Max(const Size& a, const Size& b) { + return Size((a.w > b.w) ? a.w : b.w, (a.h > b.h) ? a.h : b.h); + } + + T Area() const { + return w * h; + } + + inline Vector2 ToVector() const { + return Vector2(w, h); + } +}; - // C-interop support. - typedef typename CompatibleTypes >::Type CompatibleType; +typedef Size Sizei; +typedef Size Sizeu; +typedef Size Sizef; +typedef Size Sized; - Size(const CompatibleType& s) : w(s.w), h(s.h) { } +//------------------------------------------------------------------------------------- +// ***** Size3 - operator const CompatibleType& () const - { - OVR_MATH_STATIC_ASSERT(sizeof(Size) == sizeof(CompatibleType), "sizeof(Size) failure"); - return reinterpret_cast(*this); - } +// Size3 class represents 3D size with Width, Height, Depth components. +// Used to describe distentions of render targets, etc. - bool operator== (const Size& b) const { return w == b.w && h == b.h; } - bool operator!= (const Size& b) const { return w != b.w || h != b.h; } - - Size operator+ (const Size& b) const { return Size(w + b.w, h + b.h); } - Size& operator+= (const Size& b) { w += b.w; h += b.h; return *this; } - Size operator- (const Size& b) const { return Size(w - b.w, h - b.h); } - Size& operator-= (const Size& b) { w -= b.w; h -= b.h; return *this; } - Size operator- () const { return Size(-w, -h); } - Size operator* (const Size& b) const { return Size(w * b.w, h * b.h); } - Size& operator*= (const Size& b) { w *= b.w; h *= b.h; return *this; } - Size operator/ (const Size& b) const { return Size(w / b.w, h / b.h); } - Size& operator/= (const Size& b) { w /= b.w; h /= b.h; return *this; } - - // Scalar multiplication/division scales both components. - Size operator* (T s) const { return Size(w*s, h*s); } - Size& operator*= (T s) { w *= s; h *= s; return *this; } - Size operator/ (T s) const { return Size(w/s, h/s); } - Size& operator/= (T s) { w /= s; h /= s; return *this; } - - static Size Min(const Size& a, const Size& b) { return Size((a.w < b.w) ? a.w : b.w, - (a.h < b.h) ? a.h : b.h); } - static Size Max(const Size& a, const Size& b) { return Size((a.w > b.w) ? a.w : b.w, - (a.h > b.h) ? a.h : b.h); } - - T Area() const { return w * h; } - - inline Vector2 ToVector() const { return Vector2(w, h); } +template +class Size3 { + public: + T w, h, d; + + Size3() : w(0), h(0), d(0) {} + Size3(T w_, T h_, T d_) : w(w_), h(h_), d(d_) {} + explicit Size3(T s) : w(s), h(s), d(s) {} + explicit Size3(const Size::OtherFloatType>& src) + : w((T)src.w), h((T)src.h), d((T)1) {} + explicit Size3(const Size3::OtherFloatType>& src) + : w((T)src.w), h((T)src.h), d((T)src.d) {} + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Size3(const CompatibleType& s) : w(s.w), h(s.h), d(s.d) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT(sizeof(Size3) == sizeof(CompatibleType), "sizeof(Size3) failure"); + return reinterpret_cast(*this); + } + + bool operator==(const Size3& b) const { + return w == b.w && h == b.h && d == b.d; + } + bool operator!=(const Size3& b) const { + return w != b.w || h != b.h || d != b.d; + } + + Size3 operator+(const Size3& b) const { + return Size3(w + b.w, h + b.h, d + b.d); + } + Size3& operator+=(const Size3& b) { + w += b.w; + h += b.h; + d += b.d; + return *this; + } + Size3 operator-(const Size3& b) const { + return Size3(w - b.w, h - b.h, d - b.d); + } + Size3& operator-=(const Size3& b) { + w -= b.w; + h -= b.h; + d -= b.d; + return *this; + } + Size3 operator-() const { + return Size3(-w, -h, -d); + } + Size3 operator*(const Size3& b) const { + return Size3(w * b.w, h * b.h, d * b.d); + } + Size3& operator*=(const Size3& b) { + w *= b.w; + h *= b.h; + d *= b.d; + return *this; + } + Size3 operator/(const Size3& b) const { + return Size3(w / b.w, h / b.h, d / b.d); + } + Size3& operator/=(const Size3& b) { + w /= b.w; + h /= b.h; + d /= b.d; + return *this; + } + + // Scalar multiplication/division scales both components. + Size3 operator*(T s) const { + return Size3(w * s, h * s, d * s); + } + Size3& operator*=(T s) { + w *= s; + h *= s; + d *= s; + return *this; + } + Size3 operator/(T s) const { + return Size3(w / s, h / s, d / s); + } + Size3& operator/=(T s) { + w /= s; + h /= s; + d /= s; + return *this; + } + + static Size3 Min(const Size3& a, const Size3& b) { + return Size3((a.w < b.w) ? a.w : b.w, (a.h < b.h) ? a.h : b.h, (a.d < b.d) ? a.d : b.d); + } + static Size3 Max(const Size3& a, const Size3& b) { + return Size3((a.w > b.w) ? a.w : b.w, (a.h > b.h) ? a.h : b.h, (a.d > b.d) ? a.d : b.d); + } + + T Volume() const { + return w * h * d; + } + + inline Vector3 ToVector() const { + return Vector3(w, h, d); + } }; - -typedef Size Sizei; -typedef Size Sizeu; -typedef Size Sizef; -typedef Size Sized; - - +typedef Size3 Size3u; //----------------------------------------------------------------------------------- // ***** Rect // Rect describes a rectangular area for rendering, that includes position and size. -template -class Rect -{ -public: - T x, y; - T w, h; - - Rect() { } - Rect(T x1, T y1, T w1, T h1) : x(x1), y(y1), w(w1), h(h1) { } - Rect(const Vector2& pos, const Size& sz) : x(pos.x), y(pos.y), w(sz.w), h(sz.h) { } - Rect(const Size& sz) : x(0), y(0), w(sz.w), h(sz.h) { } - - // C-interop support. - typedef typename CompatibleTypes >::Type CompatibleType; - - Rect(const CompatibleType& s) : x(s.Pos.x), y(s.Pos.y), w(s.Size.w), h(s.Size.h) { } - - operator const CompatibleType& () const - { - OVR_MATH_STATIC_ASSERT(sizeof(Rect) == sizeof(CompatibleType), "sizeof(Rect) failure"); - return reinterpret_cast(*this); - } - - Vector2 GetPos() const { return Vector2(x, y); } - Size GetSize() const { return Size(w, h); } - void SetPos(const Vector2& pos) { x = pos.x; y = pos.y; } - void SetSize(const Size& sz) { w = sz.w; h = sz.h; } - - bool operator == (const Rect& vp) const - { return (x == vp.x) && (y == vp.y) && (w == vp.w) && (h == vp.h); } - bool operator != (const Rect& vp) const - { return !operator == (vp); } +template +class Rect { + public: + T x, y; + T w, h; + + Rect() {} + Rect(T x1, T y1, T w1, T h1) : x(x1), y(y1), w(w1), h(h1) {} + Rect(const Vector2& pos, const Size& sz) : x(pos.x), y(pos.y), w(sz.w), h(sz.h) {} + Rect(const Size& sz) : x(0), y(0), w(sz.w), h(sz.h) {} + + // C-interop support. + typedef typename CompatibleTypes>::Type CompatibleType; + + Rect(const CompatibleType& s) : x(s.Pos.x), y(s.Pos.y), w(s.Size.w), h(s.Size.h) {} + + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT(sizeof(Rect) == sizeof(CompatibleType), "sizeof(Rect) failure"); + return reinterpret_cast(*this); + } + + Vector2 GetPos() const { + return Vector2(x, y); + } + Size GetSize() const { + return Size(w, h); + } + void SetPos(const Vector2& pos) { + x = pos.x; + y = pos.y; + } + void SetSize(const Size& sz) { + w = sz.w; + h = sz.h; + } + + bool operator==(const Rect& vp) const { + return (x == vp.x) && (y == vp.y) && (w == vp.w) && (h == vp.h); + } + bool operator!=(const Rect& vp) const { + return !operator==(vp); + } }; typedef Rect Recti; - //-------------------------------------------------------------------------------------// // ***** Quat // // Quatf represents a quaternion class used for rotations. -// +// // Quaternion multiplications are done in right-to-left order, to match the // behavior of matrices. +template +class Quat { + public: + typedef T ElementType; + static const size_t ElementCount = 4; + + // x,y,z = axis*sin(angle), w = cos(angle) + T x, y, z, w; + + Quat() : x(0), y(0), z(0), w(1) {} + Quat(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) {} + explicit Quat(const Quat::OtherFloatType>& src) + : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) { + // NOTE: Converting a normalized Quat to Quat + // will generally result in an un-normalized quaternion. + // But we don't normalize here in case the quaternion + // being converted is not a normalized rotation quaternion. + } + + typedef typename CompatibleTypes>::Type CompatibleType; + + // C-interop support. + Quat(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) {} + + operator CompatibleType() const { + CompatibleType result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; + } + + // Constructs quaternion for rotation around the axis by an angle. + Quat(const Vector3& axis, T angle) { + // Make sure we don't divide by zero. + if (axis.LengthSq() == T(0)) { + // Assert if the axis is zero, but the angle isn't + OVR_MATH_ASSERT(angle == T(0)); + x = y = z = T(0); + w = T(1); + return; + } + + Vector3 unitAxis = axis.Normalized(); + T sinHalfAngle = sin(angle * T(0.5)); + + w = cos(angle * T(0.5)); + x = unitAxis.x * sinHalfAngle; + y = unitAxis.y * sinHalfAngle; + z = unitAxis.z * sinHalfAngle; + } + + // Constructs quaternion for rotation around one of the coordinate axis by an angle. + Quat(Axis A, T angle, RotateDirection d = Rotate_CCW, HandedSystem s = Handed_R) { + T sinHalfAngle = s * d * sin(angle * T(0.5)); + T v[3]; + v[0] = v[1] = v[2] = T(0); + v[A] = sinHalfAngle; + + w = cos(angle * T(0.5)); + x = v[0]; + y = v[1]; + z = v[2]; + } + + Quat operator-() { + return Quat(-x, -y, -z, -w); + } // unary minus + + static Quat Identity() { + return Quat(0, 0, 0, 1); + } + + // Compute axis and angle from quaternion + void GetAxisAngle(Vector3* axis, T* angle) const { + if (x * x + y * y + z * z > Math::Tolerance() * Math::Tolerance()) { + *axis = Vector3(x, y, z).Normalized(); + *angle = 2 * Acos(w); + if (*angle > ((T)MATH_DOUBLE_PI)) // Reduce the magnitude of the angle, if necessary + { + *angle = ((T)MATH_DOUBLE_TWOPI) - *angle; + *axis = *axis * (-1); + } + } else { + *axis = Vector3(1, 0, 0); + *angle = T(0); + } + } + + // Convert a quaternion to a rotation vector, also known as + // Rodrigues vector, AxisAngle vector, SORA vector, exponential map. + // A rotation vector describes a rotation about an axis: + // the axis of rotation is the vector normalized, + // the angle of rotation is the magnitude of the vector. + Vector3 ToRotationVector() const { + // OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + T s = T(0); + T sinHalfAngle = sqrt(x * x + y * y + z * z); + if (sinHalfAngle > T(0)) { + T cosHalfAngle = w; + T halfAngle = atan2(sinHalfAngle, cosHalfAngle); + + // Ensure minimum rotation magnitude + if (cosHalfAngle < 0) + halfAngle -= T(MATH_DOUBLE_PI); + + s = T(2) * halfAngle / sinHalfAngle; + } + return Vector3(x * s, y * s, z * s); + } + + // Faster version of the above, optimized for use with small rotations, where rotation angle ~= + // sin(angle) + inline OVR::Vector3 FastToRotationVector() const { + OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + T s; + T sinHalfSquared = x * x + y * y + z * z; + if (sinHalfSquared < T(.0037)) // =~ sin(7/2 degrees)^2 + { + // Max rotation magnitude error is about .062% at 7 degrees rotation, or about .0043 degrees + s = T(2) * Sign(w); + } else { + T sinHalfAngle = sqrt(sinHalfSquared); + T cosHalfAngle = w; + T halfAngle = atan2(sinHalfAngle, cosHalfAngle); + + // Ensure minimum rotation magnitude + if (cosHalfAngle < 0) + halfAngle -= T(MATH_DOUBLE_PI); + + s = T(2) * halfAngle / sinHalfAngle; + } + return Vector3(x * s, y * s, z * s); + } + + // Given a rotation vector of form unitRotationAxis * angle, + // returns the equivalent quaternion (unitRotationAxis * sin(angle), cos(Angle)). + static Quat FromRotationVector(const Vector3& v) { + T angleSquared = v.LengthSq(); + T s = T(0); + T c = T(1); + if (angleSquared > T(0)) { + T angle = sqrt(angleSquared); + s = sin(angle * T(0.5)) / angle; // normalize + c = cos(angle * T(0.5)); + } + return Quat(s * v.x, s * v.y, s * v.z, c); + } + + // Faster version of above, optimized for use with small rotation magnitudes, where rotation angle + // =~ sin(angle). + // If normalize is false, small-angle quaternions are returned un-normalized. + inline static Quat FastFromRotationVector(const OVR::Vector3& v, bool normalize = true) { + T s, c; + T angleSquared = v.LengthSq(); + if (angleSquared < T(0.0076)) // =~ (5 degrees*pi/180)^2 + { + s = T(0.5); + c = T(1.0); + // Max rotation magnitude error (after normalization) is about .064% at 5 degrees rotation, or + // .0032 degrees + if (normalize && angleSquared > 0) { + // sin(angle/2)^2 ~= (angle/2)^2 and cos(angle/2)^2 ~= 1 + T invLen = T(1) / sqrt(angleSquared * T(0.25) + T(1)); // normalize + s = s * invLen; + c = c * invLen; + } + } else { + T angle = sqrt(angleSquared); + s = sin(angle * T(0.5)) / angle; + c = cos(angle * T(0.5)); + } + return Quat(s * v.x, s * v.y, s * v.z, c); + } + + // Constructs the quaternion from a rotation matrix + explicit Quat(const Matrix4& m) { + T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; + + // In almost all cases, the first part is executed. + // However, if the trace is not positive, the other + // cases arise. + if (trace > T(0)) { + T s = sqrt(trace + T(1)) * T(2); // s=4*qw + w = T(0.25) * s; + x = (m.M[2][1] - m.M[1][2]) / s; + y = (m.M[0][2] - m.M[2][0]) / s; + z = (m.M[1][0] - m.M[0][1]) / s; + } else if ((m.M[0][0] > m.M[1][1]) && (m.M[0][0] > m.M[2][2])) { + T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); + w = (m.M[2][1] - m.M[1][2]) / s; + x = T(0.25) * s; + y = (m.M[0][1] + m.M[1][0]) / s; + z = (m.M[2][0] + m.M[0][2]) / s; + } else if (m.M[1][1] > m.M[2][2]) { + T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy + w = (m.M[0][2] - m.M[2][0]) / s; + x = (m.M[0][1] + m.M[1][0]) / s; + y = T(0.25) * s; + z = (m.M[1][2] + m.M[2][1]) / s; + } else { + T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz + w = (m.M[1][0] - m.M[0][1]) / s; + x = (m.M[0][2] + m.M[2][0]) / s; + y = (m.M[1][2] + m.M[2][1]) / s; + z = T(0.25) * s; + } + OVR_MATH_ASSERT(IsNormalized()); // Ensure input matrix is orthogonal + } + + // Constructs the quaternion from a rotation matrix + explicit Quat(const Matrix3& m) { + T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; + + // In almost all cases, the first part is executed. + // However, if the trace is not positive, the other + // cases arise. + if (trace > T(0)) { + T s = sqrt(trace + T(1)) * T(2); // s=4*qw + w = T(0.25) * s; + x = (m.M[2][1] - m.M[1][2]) / s; + y = (m.M[0][2] - m.M[2][0]) / s; + z = (m.M[1][0] - m.M[0][1]) / s; + } else if ((m.M[0][0] > m.M[1][1]) && (m.M[0][0] > m.M[2][2])) { + T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); + w = (m.M[2][1] - m.M[1][2]) / s; + x = T(0.25) * s; + y = (m.M[0][1] + m.M[1][0]) / s; + z = (m.M[2][0] + m.M[0][2]) / s; + } else if (m.M[1][1] > m.M[2][2]) { + T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy + w = (m.M[0][2] - m.M[2][0]) / s; + x = (m.M[0][1] + m.M[1][0]) / s; + y = T(0.25) * s; + z = (m.M[1][2] + m.M[2][1]) / s; + } else { + T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz + w = (m.M[1][0] - m.M[0][1]) / s; + x = (m.M[0][2] + m.M[2][0]) / s; + y = (m.M[1][2] + m.M[2][1]) / s; + z = T(0.25) * s; + } + OVR_MATH_ASSERT(IsNormalized()); // Ensure input matrix is orthogonal + } + + // MERGE_MOBILE_SDK + // Constructs a quaternion that rotates 'from' to line up with 'to'. + explicit Quat(const Vector3& from, const Vector3& to) { + const T cx = from.y * to.z - from.z * to.y; + const T cy = from.z * to.x - from.x * to.z; + const T cz = from.x * to.y - from.y * to.x; + const T dot = from.x * to.x + from.y * to.y + from.z * to.z; + const T crossLengthSq = cx * cx + cy * cy + cz * cz; + const T magnitude = static_cast(sqrt(crossLengthSq + dot * dot)); + const T cw = dot + magnitude; + if (cw < Math::SmallestNonDenormal()) { + const T sx = to.y * to.y + to.z * to.z; + const T sz = to.x * to.x + to.y * to.y; + if (sx > sz) { + const T rcpLength = RcpSqrt(sx); + x = T(0); + y = to.z * rcpLength; + z = -to.y * rcpLength; + w = T(0); + } else { + const T rcpLength = RcpSqrt(sz); + x = to.y * rcpLength; + y = -to.x * rcpLength; + z = T(0); + w = T(0); + } + return; + } + const T rcpLength = RcpSqrt(crossLengthSq + cw * cw); + x = cx * rcpLength; + y = cy * rcpLength; + z = cz * rcpLength; + w = cw * rcpLength; + } + // MERGE_MOBILE_SDK + + bool operator==(const Quat& b) const { + return x == b.x && y == b.y && z == b.z && w == b.w; + } + bool operator!=(const Quat& b) const { + return x != b.x || y != b.y || z != b.z || w != b.w; + } + + Quat operator+(const Quat& b) const { + return Quat(x + b.x, y + b.y, z + b.z, w + b.w); + } + Quat& operator+=(const Quat& b) { + w += b.w; + x += b.x; + y += b.y; + z += b.z; + return *this; + } + Quat operator-(const Quat& b) const { + return Quat(x - b.x, y - b.y, z - b.z, w - b.w); + } + Quat& operator-=(const Quat& b) { + w -= b.w; + x -= b.x; + y -= b.y; + z -= b.z; + return *this; + } + + Quat operator*(T s) const { + return Quat(x * s, y * s, z * s, w * s); + } + Quat& operator*=(T s) { + w *= s; + x *= s; + y *= s; + z *= s; + return *this; + } + Quat operator/(T s) const { + T rcp = T(1) / s; + return Quat(x * rcp, y * rcp, z * rcp, w * rcp); + } + Quat& operator/=(T s) { + T rcp = T(1) / s; + w *= rcp; + x *= rcp; + y *= rcp; + z *= rcp; + return *this; + } + + // MERGE_MOBILE_SDK + Vector3 operator*(const Vector3& v) const { + return Rotate(v); + } + // MERGE_MOBILE_SDK + + // Compare two quats for equality within tolerance. Returns true if quats match within tolerance. + bool IsEqual(const Quat& b, T tolerance = Math::Tolerance()) const { + return Abs(Dot(b)) >= T(1) - tolerance; + } + + // Compare two quats for equality within tolerance while checking matching hemispheres. Returns + // true if quats match within tolerance. + bool IsEqualMatchHemisphere(Quat b, T tolerance = Math::Tolerance()) const { + b.EnsureSameHemisphere(*this); + return Abs(Dot(b)) >= T(1) - tolerance; + } + + static T Abs(const T v) { + return (v >= 0) ? v : -v; + } + + // Get Imaginary part vector + Vector3 Imag() const { + return Vector3(x, y, z); + } + + // Get quaternion length. + T Length() const { + return sqrt(LengthSq()); + } + + // Get quaternion length squared. + T LengthSq() const { + return (x * x + y * y + z * z + w * w); + } + + // Simple Euclidean distance in R^4 (not SLERP distance, but at least respects Haar measure) + T Distance(const Quat& q) const { + T d1 = (*this - q).Length(); + T d2 = (*this + q).Length(); // Antipodal point check + return (d1 < d2) ? d1 : d2; + } + + T DistanceSq(const Quat& q) const { + T d1 = (*this - q).LengthSq(); + T d2 = (*this + q).LengthSq(); // Antipodal point check + return (d1 < d2) ? d1 : d2; + } + + T Dot(const Quat& q) const { + return x * q.x + y * q.y + z * q.z + w * q.w; + } + + // Angle between two quaternions in radians + T Angle(const Quat& q) const { + return T(2) * Acos(Abs(Dot(q))); + } + + // Angle of quaternion + T Angle() const { + return T(2) * Acos(Abs(w)); + } + + // Normalize + bool IsNormalized() const { + return fabs(LengthSq() - T(1)) < Math::Tolerance(); + } + + void Normalize() { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + *this *= s; + } + + Quat Normalized() const { + T s = Length(); + if (s != T(0)) + s = T(1) / s; + return *this * s; + } + + inline void EnsureSameHemisphere(const Quat& o) { + if (Dot(o) < T(0)) { + x = -x; + y = -y; + z = -z; + w = -w; + } + } + + // Returns conjugate of the quaternion. Produces inverse rotation if quaternion is normalized. + Quat Conj() const { + return Quat(-x, -y, -z, w); + } + + // Quaternion multiplication. Combines quaternion rotations, performing the one on the + // right hand side first. + Quat operator*(const Quat& b) const { + return Quat( + w * b.x + x * b.w + y * b.z - z * b.y, + w * b.y - x * b.z + y * b.w + z * b.x, + w * b.z + x * b.y - y * b.x + z * b.w, + w * b.w - x * b.x - y * b.y - z * b.z); + } + const Quat& operator*=(const Quat& b) { + *this = *this * b; + return *this; + } + + // + // this^p normalized; same as rotating by this p times. + Quat PowNormalized(T p) const { + Vector3 v; + T a; + GetAxisAngle(&v, &a); + return Quat(v, a * p); + } + + // Compute quaternion that rotates v into alignTo: alignTo = Quat::Align(alignTo, v).Rotate(v). + // NOTE: alignTo and v must be normalized. + static Quat Align(const Vector3& alignTo, const Vector3& v) { + OVR_MATH_ASSERT(alignTo.IsNormalized() && v.IsNormalized()); + Vector3 bisector = (v + alignTo); + bisector.Normalize(); + T cosHalfAngle = v.Dot(bisector); // 0..1 + if (cosHalfAngle > T(0)) { + Vector3 imag = v.Cross(bisector); + return Quat(imag.x, imag.y, imag.z, cosHalfAngle); + } else { + // cosHalfAngle == 0: a 180 degree rotation. + // sinHalfAngle == 1, rotation axis is any axis perpendicular + // to alignTo. Choose axis to include largest magnitude components + if (fabs(v.x) > fabs(v.y)) { + // x or z is max magnitude component + // = Cross(v, (0,1,0)).Normalized(); + T invLen = sqrt(v.x * v.x + v.z * v.z); + if (invLen > T(0)) + invLen = T(1) / invLen; + return Quat(-v.z * invLen, 0, v.x * invLen, 0); + } else { + // y or z is max magnitude component + // = Cross(v, (1,0,0)).Normalized(); + T invLen = sqrt(v.y * v.y + v.z * v.z); + if (invLen > T(0)) + invLen = T(1) / invLen; + return Quat(0, v.z * invLen, -v.y * invLen, 0); + } + } + } + + // Decompose a quat into quat = swing * twist, where twist is a rotation about axis, + // and swing is a rotation perpendicular to axis. + Quat GetSwingTwist(const Vector3& axis, Quat* twist) const { + OVR_MATH_ASSERT(twist); + OVR_MATH_ASSERT(axis.IsNormalized()); + + // Create a normalized quaternion from projection of (x,y,z) onto axis + T d = axis.Dot(Vector3(x, y, z)); + *twist = Quat(axis.x * d, axis.y * d, axis.z * d, w); + T len = twist->Length(); + if (len == 0) + twist->w = T(1); // identity + else + *twist /= len; // normalize + + return *this * twist->Inverted(); + } + + // Normalized linear interpolation of quaternions + // NOTE: This function is a bad approximation of Slerp() + // when the angle between the *this and b is large. + // Use FastSlerp() or Slerp() instead. + Quat Lerp(const Quat& b, T s) const { + return (*this * (T(1) - s) + b * (Dot(b) < 0 ? -s : s)).Normalized(); + } + + // Spherical linear interpolation between rotations + Quat Slerp(const Quat& b, T s) const { + Vector3 delta = (b * this->Inverted()).ToRotationVector(); + return (FromRotationVector(delta * s) * *this) + .Normalized(); // normalize so errors don't accumulate + } + + // Spherical linear interpolation: much faster for small rotations, accurate for large rotations. + // See FastTo/FromRotationVector + Quat FastSlerp(const Quat& b, T s) const { + Vector3 delta = (b * this->Inverted()).FastToRotationVector(); + return (FastFromRotationVector(delta * s, false) * *this).Normalized(); + } + + // MERGE_MOBILE_SDK + // FIXME: This is opposite of Lerp for some reason. It goes from 1 to 0 instead of 0 to 1. + // Leaving it as a gift for future generations to deal with. + Quat Nlerp(const Quat& other, T a) const { + T sign = (Dot(other) >= 0.0f) ? 1.0f : -1.0f; + return (*this * sign * a + other * (1 - a)).Normalized(); + } + // MERGE_MOBILE_SDK + + // Rotate transforms vector in a manner that matches Matrix rotations (counter-clockwise, + // assuming negative direction of the axis). Standard formula: q(t) * V * q(t)^-1. + Vector3 Rotate(const Vector3& v) const { + OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + + // rv = q * (v,0) * q' + // Same as rv = v + real * cross(imag,v)*2 + cross(imag, cross(imag,v)*2); + + // uv = 2 * Imag().Cross(v); + T uvx = T(2) * (y * v.z - z * v.y); + T uvy = T(2) * (z * v.x - x * v.z); + T uvz = T(2) * (x * v.y - y * v.x); + + // return v + Real()*uv + Imag().Cross(uv); + return Vector3( + v.x + w * uvx + y * uvz - z * uvy, + v.y + w * uvy + z * uvx - x * uvz, + v.z + w * uvz + x * uvy - y * uvx); + } + + // Rotation by inverse of *this + Vector3 InverseRotate(const Vector3& v) const { + OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + + // rv = q' * (v,0) * q + // Same as rv = v + real * cross(-imag,v)*2 + cross(-imag, cross(-imag,v)*2); + // or rv = v - real * cross(imag,v)*2 + cross(imag, cross(imag,v)*2); + + // uv = 2 * Imag().Cross(v); + T uvx = T(2) * (y * v.z - z * v.y); + T uvy = T(2) * (z * v.x - x * v.z); + T uvz = T(2) * (x * v.y - y * v.x); + + // return v - Real()*uv + Imag().Cross(uv); + return Vector3( + v.x - w * uvx + y * uvz - z * uvy, + v.y - w * uvy + z * uvx - x * uvz, + v.z - w * uvz + x * uvy - y * uvx); + } + + // Inversed quaternion rotates in the opposite direction. + Quat Inverted() const { + return Quat(-x, -y, -z, w); + } + + Quat Inverse() const { + return Quat(-x, -y, -z, w); + } + + // Sets this quaternion to the one rotates in the opposite direction. + void Invert() { + *this = Quat(-x, -y, -z, w); + } + + // Time integration of constant angular velocity over dt + Quat TimeIntegrate(const Vector3& angularVelocity, T dt) const { + // solution is: this * exp( omega*dt/2 ); FromRotationVector(v) gives exp(v*.5). + return (*this * FastFromRotationVector(angularVelocity * dt, false)).Normalized(); + } + + // Time integration of constant angular acceleration and velocity over dt + // These are the first two terms of the "Magnus expansion" of the solution + // + // o = o * exp( W=(W1 + W2 + W3+...) * 0.5 ); + // + // omega1 = (omega + omegaDot*dt) + // W1 = (omega + omega1)*dt/2 + // W2 = cross(omega, omega1)/12*dt^2 % (= -cross(omega_dot, omega)/12*dt^3) + // Terms 3 and beyond are vanishingly small: + // W3 = cross(omega_dot, cross(omega_dot, omega))/240*dt^5 + // + Quat TimeIntegrate(const Vector3& angularVelocity, const Vector3& angularAcceleration, T dt) + const { + const Vector3& omega = angularVelocity; + const Vector3& omegaDot = angularAcceleration; + + Vector3 omega1 = (omega + omegaDot * dt); + Vector3 W = ((omega + omega1) + omega.Cross(omega1) * (dt / T(6))) * (dt / T(2)); + + // FromRotationVector(v) is exp(v*.5) + return (*this * FastFromRotationVector(W, false)).Normalized(); + } + + // Decompose rotation into three rotations: + // roll radians about Z axis, then pitch radians about X axis, then yaw radians about Y axis. + // Call with nullptr if a return value is not needed. + void GetYawPitchRoll(T* yaw, T* pitch, T* roll) const { + return GetEulerAngles(yaw, pitch, roll); + } + + // GetEulerAngles extracts Euler angles from the quaternion, in the specified order of + // axis rotations and the specified coordinate system. Right-handed coordinate system + // is the default, with CCW rotations while looking in the negative axis direction. + // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. + // Rotation order is c, b, a: + // rotation c around axis A3 + // is followed by rotation b around axis A2 + // is followed by rotation a around axis A1 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + // + template + void GetEulerAngles(T* a, T* b, T* c) const { + OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + OVR_MATH_STATIC_ASSERT( + (A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); + + T Q[3] = {x, y, z}; // Quaternion components x,y,z + + T ww = w * w; + T Q11 = Q[A1] * Q[A1]; + T Q22 = Q[A2] * Q[A2]; + T Q33 = Q[A3] * Q[A3]; + + T psign = T(-1); + // Determine whether even permutation + if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) + psign = T(1); + + T s2 = psign * T(2) * (psign * w * Q[A2] + Q[A1] * Q[A3]); + + T singularityRadius = Math::SingularityRadius(); + if (s2 < T(-1) + singularityRadius) { // South pole singularity + if (a) + *a = T(0); + if (b) + *b = -S * D * ((T)MATH_DOUBLE_PIOVER2); + if (c) + *c = S * D * atan2(T(2) * (psign * Q[A1] * Q[A2] + w * Q[A3]), ww + Q22 - Q11 - Q33); + } else if (s2 > T(1) - singularityRadius) { // North pole singularity + if (a) + *a = T(0); + if (b) + *b = S * D * ((T)MATH_DOUBLE_PIOVER2); + if (c) + *c = S * D * atan2(T(2) * (psign * Q[A1] * Q[A2] + w * Q[A3]), ww + Q22 - Q11 - Q33); + } else { + if (a) + *a = -S * D * atan2(T(-2) * (w * Q[A1] - psign * Q[A2] * Q[A3]), ww + Q33 - Q11 - Q22); + if (b) + *b = S * D * asin(s2); + if (c) + *c = S * D * atan2(T(2) * (w * Q[A3] - psign * Q[A1] * Q[A2]), ww + Q11 - Q22 - Q33); + } + } + + template + void GetEulerAngles(T* a, T* b, T* c) const { + GetEulerAngles(a, b, c); + } + + template + void GetEulerAngles(T* a, T* b, T* c) const { + GetEulerAngles(a, b, c); + } + + // GetEulerAnglesABA extracts Euler angles from the quaternion, in the specified order of + // axis rotations and the specified coordinate system. Right-handed coordinate system + // is the default, with CCW rotations while looking in the negative axis direction. + // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A1 + // Rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void GetEulerAnglesABA(T* a, T* b, T* c) const { + OVR_MATH_ASSERT(IsNormalized()); // If this fires, caller has a quat math bug + OVR_MATH_STATIC_ASSERT(A1 != A2, "A1 != A2"); + + T Q[3] = {x, y, z}; // Quaternion components + + // Determine the missing axis that was not supplied + int m = 3 - A1 - A2; + + T ww = w * w; + T Q11 = Q[A1] * Q[A1]; + T Q22 = Q[A2] * Q[A2]; + T Qmm = Q[m] * Q[m]; + + T psign = T(-1); + if ((A1 + 1) % 3 == A2) // Determine whether even permutation + { + psign = T(1); + } + + T c2 = ww + Q11 - Q22 - Qmm; + T singularityRadius = Math::SingularityRadius(); + if (c2 < T(-1) + singularityRadius) { // South pole singularity + if (a) + *a = T(0); + if (b) + *b = S * D * ((T)MATH_DOUBLE_PI); + if (c) + *c = S * D * atan2(T(2) * (w * Q[A1] - psign * Q[A2] * Q[m]), ww + Q22 - Q11 - Qmm); + } else if (c2 > T(1) - singularityRadius) { // North pole singularity + if (a) + *a = T(0); + if (b) + *b = T(0); + if (c) + *c = S * D * atan2(T(2) * (w * Q[A1] - psign * Q[A2] * Q[m]), ww + Q22 - Q11 - Qmm); + } else { + if (a) + *a = S * D * atan2(psign * w * Q[m] + Q[A1] * Q[A2], w * Q[A2] - psign * Q[A1] * Q[m]); + if (b) + *b = S * D * acos(c2); + if (c) + *c = S * D * atan2(-psign * w * Q[m] + Q[A1] * Q[A2], w * Q[A2] + psign * Q[A1] * Q[m]); + } + } + + bool IsNan() const { + return !isfinite(x + y + z + w); + } + bool IsFinite() const { + return isfinite(x + y + z + w); + } +}; -template -class Quat -{ -public: - typedef T ElementType; - static const size_t ElementCount = 4; - - // x,y,z = axis*sin(angle), w = cos(angle) - T x, y, z, w; - - Quat() : x(0), y(0), z(0), w(1) { } - Quat(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) { } - explicit Quat(const Quat::OtherFloatType> &src) - : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) - { - // NOTE: Converting a normalized Quat to Quat - // will generally result in an un-normalized quaternion. - // But we don't normalize here in case the quaternion - // being converted is not a normalized rotation quaternion. - } - - typedef typename CompatibleTypes >::Type CompatibleType; - - // C-interop support. - Quat(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) { } - - operator CompatibleType () const - { - CompatibleType result; - result.x = x; - result.y = y; - result.z = z; - result.w = w; - return result; - } - - // Constructs quaternion for rotation around the axis by an angle. - Quat(const Vector3& axis, T angle) - { - // Make sure we don't divide by zero. - if (axis.LengthSq() == T(0)) - { - // Assert if the axis is zero, but the angle isn't - OVR_MATH_ASSERT(angle == T(0)); - x = y = z = T(0); w = T(1); - return; - } - - Vector3 unitAxis = axis.Normalized(); - T sinHalfAngle = sin(angle * T(0.5)); +typedef Quat Quatf; +typedef Quat Quatd; - w = cos(angle * T(0.5)); - x = unitAxis.x * sinHalfAngle; - y = unitAxis.y * sinHalfAngle; - z = unitAxis.z * sinHalfAngle; - } +OVR_MATH_STATIC_ASSERT((sizeof(Quatf) == 4 * sizeof(float)), "sizeof(Quatf) failure"); +OVR_MATH_STATIC_ASSERT((sizeof(Quatd) == 4 * sizeof(double)), "sizeof(Quatd) failure"); - // Constructs quaternion for rotation around one of the coordinate axis by an angle. - Quat(Axis A, T angle, RotateDirection d = Rotate_CCW, HandedSystem s = Handed_R) - { - T sinHalfAngle = s * d *sin(angle * T(0.5)); - T v[3]; - v[0] = v[1] = v[2] = T(0); - v[A] = sinHalfAngle; - - w = cos(angle * T(0.5)); - x = v[0]; - y = v[1]; - z = v[2]; - } +//------------------------------------------------------------------------------------- +// ***** Pose +// +// Position and orientation combined. +// +// This structure needs to be the same size and layout on 32-bit and 64-bit arch. +// Update OVR_PadCheck.cpp when updating this object. +template +class Pose { + public: + typedef typename CompatibleTypes>::Type CompatibleType; + + Pose() {} + Pose(const Quat& orientation, const Vector3& pos) + : Rotation(orientation), Translation(pos) {} + Pose(const Pose& s) : Rotation(s.Rotation), Translation(s.Translation) {} + Pose(const Matrix3& R, const Vector3& t) : Rotation((Quat)R), Translation(t) {} + Pose(const CompatibleType& s) : Rotation(s.Orientation), Translation(s.Position) {} + + explicit Pose(const Pose::OtherFloatType>& s) + : Rotation(s.Rotation), Translation(s.Translation) { + // Ensure normalized rotation if converting from float to double + if (sizeof(T) > sizeof(typename Math::OtherFloatType)) + Rotation.Normalize(); + } + + static Pose Identity() { + return Pose(Quat(0, 0, 0, 1), Vector3(0, 0, 0)); + } + + void SetIdentity() { + Rotation = Quat(0, 0, 0, 1); + Translation = Vector3(0, 0, 0); + } + + // used to make things obviously broken if someone tries to use the value + void SetInvalid() { + Rotation = Quat(NAN, NAN, NAN, NAN); + Translation = Vector3(NAN, NAN, NAN); + } + + bool IsEqual(const Pose& b, T tolerance = Math::Tolerance()) const { + return Translation.IsEqual(b.Translation, tolerance) && Rotation.IsEqual(b.Rotation, tolerance); + } + + bool IsEqualMatchHemisphere(const Pose& b, T tolerance = Math::Tolerance()) const { + return Translation.IsEqual(b.Translation, tolerance) && + Rotation.IsEqualMatchHemisphere(b.Rotation, tolerance); + } + + operator typename CompatibleTypes>::Type() const { + typename CompatibleTypes>::Type result; + result.Orientation = Rotation; + result.Position = Translation; + return result; + } + + Quat Rotation; + Vector3 Translation; + + OVR_MATH_STATIC_ASSERT( + (sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float)), + "(sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float))"); + + void ToArray(T* arr) const { + T temp[7] = {Rotation.x, + Rotation.y, + Rotation.z, + Rotation.w, + Translation.x, + Translation.y, + Translation.z}; + for (int i = 0; i < 7; i++) + arr[i] = temp[i]; + } + + static Pose FromArray(const T* v) { + Quat rotation(v[0], v[1], v[2], v[3]); + Vector3 translation(v[4], v[5], v[6]); + // Ensure rotation is normalized, in case it was originally a float, stored in a .json file, + // etc. + return Pose(rotation.Normalized(), translation); + } + + Vector3 Rotate(const Vector3& v) const { + return Rotation.Rotate(v); + } + + Vector3 InverseRotate(const Vector3& v) const { + return Rotation.InverseRotate(v); + } + + Vector3 Translate(const Vector3& v) const { + return v + Translation; + } + + Vector3 Transform(const Vector3& v) const { + return Rotate(v) + Translation; + } + + Vector3 InverseTransform(const Vector3& v) const { + return InverseRotate(v - Translation); + } + + Vector3 TransformNormal(const Vector3& v) const { + return Rotate(v); + } + + Vector3 InverseTransformNormal(const Vector3& v) const { + return InverseRotate(v); + } + + Vector3 Apply(const Vector3& v) const { + return Transform(v); + } + + Pose operator*(const Pose& other) const { + return Pose(Rotation * other.Rotation, Apply(other.Translation)); + } + + Pose Inverted() const { + Quat inv = Rotation.Inverted(); + return Pose(inv, inv.Rotate(-Translation)); + } + + // Interpolation between two poses: translation is interpolated with Lerp(), + // and rotations are interpolated with Slerp(). + Pose Lerp(const Pose& b, T s) const { + return Pose(Rotation.Slerp(b.Rotation, s), Translation.Lerp(b.Translation, s)); + } + + // Similar to Lerp above, except faster in case of small rotation differences. See + // Quat::FastSlerp. + Pose FastLerp(const Pose& b, T s) const { + return Pose(Rotation.FastSlerp(b.Rotation, s), Translation.Lerp(b.Translation, s)); + } + + Pose TimeIntegrate(const Vector3& linearVelocity, const Vector3& angularVelocity, T dt) + const { + return Pose( + (Rotation * Quat::FastFromRotationVector(angularVelocity * dt, false)).Normalized(), + Translation + linearVelocity * dt); + } + + Pose TimeIntegrate( + const Vector3& linearVelocity, + const Vector3& linearAcceleration, + const Vector3& angularVelocity, + const Vector3& angularAcceleration, + T dt) const { + return Pose( + Rotation.TimeIntegrate(angularVelocity, angularAcceleration, dt), + Translation + linearVelocity * dt + linearAcceleration * dt * dt * T(0.5)); + } + + Pose Normalized() const { + return Pose(Rotation.Normalized(), Translation); + } + void Normalize() { + Rotation.Normalize(); + } + + bool IsNan() const { + return Translation.IsNan() || Rotation.IsNan(); + } + bool IsFinite() const { + return Translation.IsFinite() && Rotation.IsFinite(); + } +}; - Quat operator-() { return Quat(-x, -y, -z, -w); } // unary minus +typedef Pose Posef; +typedef Pose Posed; - static Quat Identity() { return Quat(0, 0, 0, 1); } - - // Compute axis and angle from quaternion - void GetAxisAngle(Vector3* axis, T* angle) const - { - if ( x*x + y*y + z*z > Math::Tolerance() * Math::Tolerance() ) { - *axis = Vector3(x, y, z).Normalized(); - *angle = 2 * Acos(w); - if (*angle > ((T)MATH_DOUBLE_PI)) // Reduce the magnitude of the angle, if necessary - { - *angle = ((T)MATH_DOUBLE_TWOPI) - *angle; - *axis = *axis * (-1); - } - } - else - { - *axis = Vector3(1, 0, 0); - *angle= T(0); - } - } - - // Convert a quaternion to a rotation vector, also known as - // Rodrigues vector, AxisAngle vector, SORA vector, exponential map. - // A rotation vector describes a rotation about an axis: - // the axis of rotation is the vector normalized, - // the angle of rotation is the magnitude of the vector. - Vector3 ToRotationVector() const - { - OVR_MATH_ASSERT(IsNormalized() || LengthSq() == 0); - T s = T(0); - T sinHalfAngle = sqrt(x*x + y*y + z*z); - if (sinHalfAngle > T(0)) - { - T cosHalfAngle = w; - T halfAngle = atan2(sinHalfAngle, cosHalfAngle); - - // Ensure minimum rotation magnitude - if (cosHalfAngle < 0) - halfAngle -= T(MATH_DOUBLE_PI); - - s = T(2) * halfAngle / sinHalfAngle; - } - return Vector3(x*s, y*s, z*s); - } - - // Faster version of the above, optimized for use with small rotations, where rotation angle ~= sin(angle) - inline OVR::Vector3 FastToRotationVector() const - { - OVR_MATH_ASSERT(IsNormalized()); - T s; - T sinHalfSquared = x*x + y*y + z*z; - if (sinHalfSquared < T(.0037)) // =~ sin(7/2 degrees)^2 - { - // Max rotation magnitude error is about .062% at 7 degrees rotation, or about .0043 degrees - s = T(2) * Sign(w); - } - else - { - T sinHalfAngle = sqrt(sinHalfSquared); - T cosHalfAngle = w; - T halfAngle = atan2(sinHalfAngle, cosHalfAngle); - - // Ensure minimum rotation magnitude - if (cosHalfAngle < 0) - halfAngle -= T(MATH_DOUBLE_PI); - - s = T(2) * halfAngle / sinHalfAngle; - } - return Vector3(x*s, y*s, z*s); - } - - // Given a rotation vector of form unitRotationAxis * angle, - // returns the equivalent quaternion (unitRotationAxis * sin(angle), cos(Angle)). - static Quat FromRotationVector(const Vector3& v) - { - T angleSquared = v.LengthSq(); - T s = T(0); - T c = T(1); - if (angleSquared > T(0)) - { - T angle = sqrt(angleSquared); - s = sin(angle * T(0.5)) / angle; // normalize - c = cos(angle * T(0.5)); - } - return Quat(s*v.x, s*v.y, s*v.z, c); - } - - // Faster version of above, optimized for use with small rotation magnitudes, where rotation angle =~ sin(angle). - // If normalize is false, small-angle quaternions are returned un-normalized. - inline static Quat FastFromRotationVector(const OVR::Vector3& v, bool normalize = true) - { - T s, c; - T angleSquared = v.LengthSq(); - if (angleSquared < T(0.0076)) // =~ (5 degrees*pi/180)^2 - { - s = T(0.5); - c = T(1.0); - // Max rotation magnitude error (after normalization) is about .064% at 5 degrees rotation, or .0032 degrees - if (normalize && angleSquared > 0) - { - // sin(angle/2)^2 ~= (angle/2)^2 and cos(angle/2)^2 ~= 1 - T invLen = T(1) / sqrt(angleSquared * T(0.25) + T(1)); // normalize - s = s * invLen; - c = c * invLen; - } - } - else - { - T angle = sqrt(angleSquared); - s = sin(angle * T(0.5)) / angle; - c = cos(angle * T(0.5)); - } - return Quat(s*v.x, s*v.y, s*v.z, c); - } - - // Constructs the quaternion from a rotation matrix - explicit Quat(const Matrix4& m) - { - T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; - - // In almost all cases, the first part is executed. - // However, if the trace is not positive, the other - // cases arise. - if (trace > T(0)) - { - T s = sqrt(trace + T(1)) * T(2); // s=4*qw - w = T(0.25) * s; - x = (m.M[2][1] - m.M[1][2]) / s; - y = (m.M[0][2] - m.M[2][0]) / s; - z = (m.M[1][0] - m.M[0][1]) / s; - } - else if ((m.M[0][0] > m.M[1][1])&&(m.M[0][0] > m.M[2][2])) - { - T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); - w = (m.M[2][1] - m.M[1][2]) / s; - x = T(0.25) * s; - y = (m.M[0][1] + m.M[1][0]) / s; - z = (m.M[2][0] + m.M[0][2]) / s; - } - else if (m.M[1][1] > m.M[2][2]) - { - T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy - w = (m.M[0][2] - m.M[2][0]) / s; - x = (m.M[0][1] + m.M[1][0]) / s; - y = T(0.25) * s; - z = (m.M[1][2] + m.M[2][1]) / s; - } - else - { - T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz - w = (m.M[1][0] - m.M[0][1]) / s; - x = (m.M[0][2] + m.M[2][0]) / s; - y = (m.M[1][2] + m.M[2][1]) / s; - z = T(0.25) * s; - } - OVR_MATH_ASSERT(IsNormalized()); // Ensure input matrix is orthogonal - } - - // Constructs the quaternion from a rotation matrix - explicit Quat(const Matrix3& m) - { - T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; - - // In almost all cases, the first part is executed. - // However, if the trace is not positive, the other - // cases arise. - if (trace > T(0)) - { - T s = sqrt(trace + T(1)) * T(2); // s=4*qw - w = T(0.25) * s; - x = (m.M[2][1] - m.M[1][2]) / s; - y = (m.M[0][2] - m.M[2][0]) / s; - z = (m.M[1][0] - m.M[0][1]) / s; - } - else if ((m.M[0][0] > m.M[1][1])&&(m.M[0][0] > m.M[2][2])) - { - T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); - w = (m.M[2][1] - m.M[1][2]) / s; - x = T(0.25) * s; - y = (m.M[0][1] + m.M[1][0]) / s; - z = (m.M[2][0] + m.M[0][2]) / s; - } - else if (m.M[1][1] > m.M[2][2]) - { - T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy - w = (m.M[0][2] - m.M[2][0]) / s; - x = (m.M[0][1] + m.M[1][0]) / s; - y = T(0.25) * s; - z = (m.M[1][2] + m.M[2][1]) / s; - } - else - { - T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz - w = (m.M[1][0] - m.M[0][1]) / s; - x = (m.M[0][2] + m.M[2][0]) / s; - y = (m.M[1][2] + m.M[2][1]) / s; - z = T(0.25) * s; - } - OVR_MATH_ASSERT(IsNormalized()); // Ensure input matrix is orthogonal - } - - bool operator== (const Quat& b) const { return x == b.x && y == b.y && z == b.z && w == b.w; } - bool operator!= (const Quat& b) const { return x != b.x || y != b.y || z != b.z || w != b.w; } - - Quat operator+ (const Quat& b) const { return Quat(x + b.x, y + b.y, z + b.z, w + b.w); } - Quat& operator+= (const Quat& b) { w += b.w; x += b.x; y += b.y; z += b.z; return *this; } - Quat operator- (const Quat& b) const { return Quat(x - b.x, y - b.y, z - b.z, w - b.w); } - Quat& operator-= (const Quat& b) { w -= b.w; x -= b.x; y -= b.y; z -= b.z; return *this; } - - Quat operator* (T s) const { return Quat(x * s, y * s, z * s, w * s); } - Quat& operator*= (T s) { w *= s; x *= s; y *= s; z *= s; return *this; } - Quat operator/ (T s) const { T rcp = T(1)/s; return Quat(x * rcp, y * rcp, z * rcp, w *rcp); } - Quat& operator/= (T s) { T rcp = T(1)/s; w *= rcp; x *= rcp; y *= rcp; z *= rcp; return *this; } - - // Compare two quats for equality within tolerance. Returns true if quats match withing tolerance. - bool IsEqual(const Quat& b, T tolerance = Math::Tolerance()) const - { - return Abs(Dot(b)) >= T(1) - tolerance; - } - - static T Abs(const T v) { return (v >= 0) ? v : -v; } - - // Get Imaginary part vector - Vector3 Imag() const { return Vector3(x,y,z); } - - // Get quaternion length. - T Length() const { return sqrt(LengthSq()); } - - // Get quaternion length squared. - T LengthSq() const { return (x * x + y * y + z * z + w * w); } - - // Simple Euclidean distance in R^4 (not SLERP distance, but at least respects Haar measure) - T Distance(const Quat& q) const - { - T d1 = (*this - q).Length(); - T d2 = (*this + q).Length(); // Antipodal point check - return (d1 < d2) ? d1 : d2; - } - - T DistanceSq(const Quat& q) const - { - T d1 = (*this - q).LengthSq(); - T d2 = (*this + q).LengthSq(); // Antipodal point check - return (d1 < d2) ? d1 : d2; - } - - T Dot(const Quat& q) const - { - return x * q.x + y * q.y + z * q.z + w * q.w; - } - - // Angle between two quaternions in radians - T Angle(const Quat& q) const - { - return T(2) * Acos(Abs(Dot(q))); - } - - // Angle of quaternion - T Angle() const - { - return T(2) * Acos(Abs(w)); - } - - // Normalize - bool IsNormalized() const { return fabs(LengthSq() - T(1)) < Math::Tolerance(); } - - void Normalize() - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - *this *= s; - } - - Quat Normalized() const - { - T s = Length(); - if (s != T(0)) - s = T(1) / s; - return *this * s; - } - - inline void EnsureSameHemisphere(const Quat& o) - { - if (Dot(o) < T(0)) - { - x = -x; - y = -y; - z = -z; - w = -w; - } - } - - // Returns conjugate of the quaternion. Produces inverse rotation if quaternion is normalized. - Quat Conj() const { return Quat(-x, -y, -z, w); } - - // Quaternion multiplication. Combines quaternion rotations, performing the one on the - // right hand side first. - Quat operator* (const Quat& b) const { return Quat(w * b.x + x * b.w + y * b.z - z * b.y, - w * b.y - x * b.z + y * b.w + z * b.x, - w * b.z + x * b.y - y * b.x + z * b.w, - w * b.w - x * b.x - y * b.y - z * b.z); } - const Quat& operator*= (const Quat& b) { *this = *this * b; return *this; } - - // - // this^p normalized; same as rotating by this p times. - Quat PowNormalized(T p) const - { - Vector3 v; - T a; - GetAxisAngle(&v, &a); - return Quat(v, a * p); - } - - // Compute quaternion that rotates v into alignTo: alignTo = Quat::Align(alignTo, v).Rotate(v). - // NOTE: alignTo and v must be normalized. - static Quat Align(const Vector3& alignTo, const Vector3& v) - { - OVR_MATH_ASSERT(alignTo.IsNormalized() && v.IsNormalized()); - Vector3 bisector = (v + alignTo); - bisector.Normalize(); - T cosHalfAngle = v.Dot(bisector); // 0..1 - if (cosHalfAngle > T(0)) - { - Vector3 imag = v.Cross(bisector); - return Quat(imag.x, imag.y, imag.z, cosHalfAngle); - } - else - { - // cosHalfAngle == 0: a 180 degree rotation. - // sinHalfAngle == 1, rotation axis is any axis perpendicular - // to alignTo. Choose axis to include largest magnitude components - if (fabs(v.x) > fabs(v.y)) - { - // x or z is max magnitude component - // = Cross(v, (0,1,0)).Normalized(); - T invLen = sqrt(v.x*v.x + v.z*v.z); - if (invLen > T(0)) - invLen = T(1) / invLen; - return Quat(-v.z*invLen, 0, v.x*invLen, 0); - } - else - { - // y or z is max magnitude component - // = Cross(v, (1,0,0)).Normalized(); - T invLen = sqrt(v.y*v.y + v.z*v.z); - if (invLen > T(0)) - invLen = T(1) / invLen; - return Quat(0, v.z*invLen, -v.y*invLen, 0); - } - } - } - - // Normalized linear interpolation of quaternions - // NOTE: This function is a bad approximation of Slerp() - // when the angle between the *this and b is large. - // Use FastSlerp() or Slerp() instead. - Quat Lerp(const Quat& b, T s) const - { - return (*this * (T(1) - s) + b * (Dot(b) < 0 ? -s : s)).Normalized(); - } - - // Spherical linear interpolation between rotations - Quat Slerp(const Quat& b, T s) const - { - Vector3 delta = (b * this->Inverted()).ToRotationVector(); - return FromRotationVector(delta * s) * *this; - } - - // Spherical linear interpolation: much faster for small rotations, accurate for large rotations. See FastTo/FromRotationVector - Quat FastSlerp(const Quat& b, T s) const - { - Vector3 delta = (b * this->Inverted()).FastToRotationVector(); - return (FastFromRotationVector(delta * s, false) * *this).Normalized(); - } - - // Rotate transforms vector in a manner that matches Matrix rotations (counter-clockwise, - // assuming negative direction of the axis). Standard formula: q(t) * V * q(t)^-1. - Vector3 Rotate(const Vector3& v) const - { - OVR_MATH_ASSERT(isnan(w) || IsNormalized()); - - // rv = q * (v,0) * q' - // Same as rv = v + real * cross(imag,v)*2 + cross(imag, cross(imag,v)*2); - - // uv = 2 * Imag().Cross(v); - T uvx = T(2) * (y*v.z - z*v.y); - T uvy = T(2) * (z*v.x - x*v.z); - T uvz = T(2) * (x*v.y - y*v.x); - - // return v + Real()*uv + Imag().Cross(uv); - return Vector3(v.x + w*uvx + y*uvz - z*uvy, - v.y + w*uvy + z*uvx - x*uvz, - v.z + w*uvz + x*uvy - y*uvx); - } - - // Rotation by inverse of *this - Vector3 InverseRotate(const Vector3& v) const - { - OVR_MATH_ASSERT(IsNormalized()); - - // rv = q' * (v,0) * q - // Same as rv = v + real * cross(-imag,v)*2 + cross(-imag, cross(-imag,v)*2); - // or rv = v - real * cross(imag,v)*2 + cross(imag, cross(imag,v)*2); - - // uv = 2 * Imag().Cross(v); - T uvx = T(2) * (y*v.z - z*v.y); - T uvy = T(2) * (z*v.x - x*v.z); - T uvz = T(2) * (x*v.y - y*v.x); - - // return v - Real()*uv + Imag().Cross(uv); - return Vector3(v.x - w*uvx + y*uvz - z*uvy, - v.y - w*uvy + z*uvx - x*uvz, - v.z - w*uvz + x*uvy - y*uvx); - } - - // Inversed quaternion rotates in the opposite direction. - Quat Inverted() const - { - return Quat(-x, -y, -z, w); - } - - Quat Inverse() const - { - return Quat(-x, -y, -z, w); - } - - // Sets this quaternion to the one rotates in the opposite direction. - void Invert() - { - *this = Quat(-x, -y, -z, w); - } - - // Time integration of constant angular velocity over dt - Quat TimeIntegrate(Vector3 angularVelocity, T dt) const - { - // solution is: this * exp( omega*dt/2 ); FromRotationVector(v) gives exp(v*.5). - return (*this * FastFromRotationVector(angularVelocity * dt, false)).Normalized(); - } - - // Time integration of constant angular acceleration and velocity over dt - // These are the first two terms of the "Magnus expansion" of the solution - // - // o = o * exp( W=(W1 + W2 + W3+...) * 0.5 ); - // - // omega1 = (omega + omegaDot*dt) - // W1 = (omega + omega1)*dt/2 - // W2 = cross(omega, omega1)/12*dt^2 % (= -cross(omega_dot, omega)/12*dt^3) - // Terms 3 and beyond are vanishingly small: - // W3 = cross(omega_dot, cross(omega_dot, omega))/240*dt^5 - // - Quat TimeIntegrate(Vector3 angularVelocity, Vector3 angularAcceleration, T dt) const - { - const Vector3& omega = angularVelocity; - const Vector3& omegaDot = angularAcceleration; - - Vector3 omega1 = (omega + omegaDot * dt); - Vector3 W = ( (omega + omega1) + omega.Cross(omega1) * (dt/T(6)) ) * (dt/T(2)); - - // FromRotationVector(v) is exp(v*.5) - return (*this * FastFromRotationVector(W, false)).Normalized(); - } - - // Decompose rotation into three rotations: - // roll radians about Z axis, then pitch radians about X axis, then yaw radians about Y axis. - // Call with nullptr if a return value is not needed. - void GetYawPitchRoll(T* yaw, T* pitch, T* roll) const - { - return GetEulerAngles(yaw, pitch, roll); - } - - // GetEulerAngles extracts Euler angles from the quaternion, in the specified order of - // axis rotations and the specified coordinate system. Right-handed coordinate system - // is the default, with CCW rotations while looking in the negative axis direction. - // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. - // Rotation order is c, b, a: - // rotation c around axis A3 - // is followed by rotation b around axis A2 - // is followed by rotation a around axis A1 - // rotations are CCW or CW (D) in LH or RH coordinate system (S) - // - template - void GetEulerAngles(T *a, T *b, T *c) const - { - OVR_MATH_ASSERT(IsNormalized()); - OVR_MATH_STATIC_ASSERT((A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); - - T Q[3] = { x, y, z }; //Quaternion components x,y,z - - T ww = w*w; - T Q11 = Q[A1]*Q[A1]; - T Q22 = Q[A2]*Q[A2]; - T Q33 = Q[A3]*Q[A3]; - - T psign = T(-1); - // Determine whether even permutation - if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) - psign = T(1); - - T s2 = psign * T(2) * (psign*w*Q[A2] + Q[A1]*Q[A3]); - - T singularityRadius = Math::SingularityRadius(); - if (s2 < T(-1) + singularityRadius) - { // South pole singularity - if (a) *a = T(0); - if (b) *b = -S*D*((T)MATH_DOUBLE_PIOVER2); - if (c) *c = S*D*atan2(T(2)*(psign*Q[A1] * Q[A2] + w*Q[A3]), ww + Q22 - Q11 - Q33 ); - } - else if (s2 > T(1) - singularityRadius) - { // North pole singularity - if (a) *a = T(0); - if (b) *b = S*D*((T)MATH_DOUBLE_PIOVER2); - if (c) *c = S*D*atan2(T(2)*(psign*Q[A1] * Q[A2] + w*Q[A3]), ww + Q22 - Q11 - Q33); - } - else - { - if (a) *a = -S*D*atan2(T(-2)*(w*Q[A1] - psign*Q[A2] * Q[A3]), ww + Q33 - Q11 - Q22); - if (b) *b = S*D*asin(s2); - if (c) *c = S*D*atan2(T(2)*(w*Q[A3] - psign*Q[A1] * Q[A2]), ww + Q11 - Q22 - Q33); - } - } - - template - void GetEulerAngles(T *a, T *b, T *c) const - { GetEulerAngles(a, b, c); } - - template - void GetEulerAngles(T *a, T *b, T *c) const - { GetEulerAngles(a, b, c); } - - // GetEulerAnglesABA extracts Euler angles from the quaternion, in the specified order of - // axis rotations and the specified coordinate system. Right-handed coordinate system - // is the default, with CCW rotations while looking in the negative axis direction. - // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. - // rotation a around axis A1 - // is followed by rotation b around axis A2 - // is followed by rotation c around axis A1 - // Rotations are CCW or CW (D) in LH or RH coordinate system (S) - template - void GetEulerAnglesABA(T *a, T *b, T *c) const - { - OVR_MATH_ASSERT(IsNormalized()); - OVR_MATH_STATIC_ASSERT(A1 != A2, "A1 != A2"); - - T Q[3] = {x, y, z}; // Quaternion components - - // Determine the missing axis that was not supplied - int m = 3 - A1 - A2; - - T ww = w*w; - T Q11 = Q[A1]*Q[A1]; - T Q22 = Q[A2]*Q[A2]; - T Qmm = Q[m]*Q[m]; - - T psign = T(-1); - if ((A1 + 1) % 3 == A2) // Determine whether even permutation - { - psign = T(1); - } - - T c2 = ww + Q11 - Q22 - Qmm; - T singularityRadius = Math::SingularityRadius(); - if (c2 < T(-1) + singularityRadius) - { // South pole singularity - if (a) *a = T(0); - if (b) *b = S*D*((T)MATH_DOUBLE_PI); - if (c) *c = S*D*atan2(T(2)*(w*Q[A1] - psign*Q[A2] * Q[m]), - ww + Q22 - Q11 - Qmm); - } - else if (c2 > T(1) - singularityRadius) - { // North pole singularity - if (a) *a = T(0); - if (b) *b = T(0); - if (c) *c = S*D*atan2(T(2)*(w*Q[A1] - psign*Q[A2] * Q[m]), - ww + Q22 - Q11 - Qmm); - } - else - { - if (a) *a = S*D*atan2(psign*w*Q[m] + Q[A1] * Q[A2], - w*Q[A2] -psign*Q[A1]*Q[m]); - if (b) *b = S*D*acos(c2); - if (c) *c = S*D*atan2(-psign*w*Q[m] + Q[A1] * Q[A2], - w*Q[A2] + psign*Q[A1]*Q[m]); - } - } -}; - -typedef Quat Quatf; -typedef Quat Quatd; - -OVR_MATH_STATIC_ASSERT((sizeof(Quatf) == 4*sizeof(float)), "sizeof(Quatf) failure"); -OVR_MATH_STATIC_ASSERT((sizeof(Quatd) == 4*sizeof(double)), "sizeof(Quatd) failure"); - -//------------------------------------------------------------------------------------- -// ***** Pose -// -// Position and orientation combined. -// -// This structure needs to be the same size and layout on 32-bit and 64-bit arch. -// Update OVR_PadCheck.cpp when updating this object. -template -class Pose -{ -public: - typedef typename CompatibleTypes >::Type CompatibleType; - - Pose() { } - Pose(const Quat& orientation, const Vector3& pos) - : Rotation(orientation), Translation(pos) { } - Pose(const Pose& s) - : Rotation(s.Rotation), Translation(s.Translation) { } - Pose(const Matrix3& R, const Vector3& t) - : Rotation((Quat)R), Translation(t) { } - Pose(const CompatibleType& s) - : Rotation(s.Orientation), Translation(s.Position) { } - - explicit Pose(const Pose::OtherFloatType> &s) - : Rotation(s.Rotation), Translation(s.Translation) - { - // Ensure normalized rotation if converting from float to double - if (sizeof(T) > sizeof(typename Math::OtherFloatType)) - Rotation.Normalize(); - } - - static Pose Identity() { return Pose(Quat(0, 0, 0, 1), Vector3(0, 0, 0)); } - - void SetIdentity() { Rotation = Quat(0, 0, 0, 1); Translation = Vector3(0, 0, 0); } - - // used to make things obviously broken if someone tries to use the value - void SetInvalid() { Rotation = Quat(NAN, NAN, NAN, NAN); Translation = Vector3(NAN, NAN, NAN); } - - bool IsEqual(const Pose&b, T tolerance = Math::Tolerance()) const - { - return Translation.IsEqual(b.Translation, tolerance) && Rotation.IsEqual(b.Rotation, tolerance); - } - - operator typename CompatibleTypes >::Type () const - { - typename CompatibleTypes >::Type result; - result.Orientation = Rotation; - result.Position = Translation; - return result; - } - - Quat Rotation; - Vector3 Translation; - - OVR_MATH_STATIC_ASSERT((sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float)), "(sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float))"); - - void ToArray(T* arr) const - { - T temp[7] = { Rotation.x, Rotation.y, Rotation.z, Rotation.w, Translation.x, Translation.y, Translation.z }; - for (int i = 0; i < 7; i++) arr[i] = temp[i]; - } - - static Pose FromArray(const T* v) - { - Quat rotation(v[0], v[1], v[2], v[3]); - Vector3 translation(v[4], v[5], v[6]); - // Ensure rotation is normalized, in case it was originally a float, stored in a .json file, etc. - return Pose(rotation.Normalized(), translation); - } - - Vector3 Rotate(const Vector3& v) const - { - return Rotation.Rotate(v); - } - - Vector3 InverseRotate(const Vector3& v) const - { - return Rotation.InverseRotate(v); - } - - Vector3 Translate(const Vector3& v) const - { - return v + Translation; - } - - Vector3 Transform(const Vector3& v) const - { - return Rotate(v) + Translation; - } - - Vector3 InverseTransform(const Vector3& v) const - { - return InverseRotate(v - Translation); - } - - - Vector3 Apply(const Vector3& v) const - { - return Transform(v); - } - - Pose operator*(const Pose& other) const - { - return Pose(Rotation * other.Rotation, Apply(other.Translation)); - } - - Pose Inverted() const - { - Quat inv = Rotation.Inverted(); - return Pose(inv, inv.Rotate(-Translation)); - } - - // Interpolation between two poses: translation is interpolated with Lerp(), - // and rotations are interpolated with Slerp(). - Pose Lerp(const Pose& b, T s) - { - return Pose(Rotation.Slerp(b.Rotation, s), Translation.Lerp(b.Translation, s)); - } - - // Similar to Lerp above, except faster in case of small rotation differences. See Quat::FastSlerp. - Pose FastLerp(const Pose& b, T s) - { - return Pose(Rotation.FastSlerp(b.Rotation, s), Translation.Lerp(b.Translation, s)); - } - - Pose TimeIntegrate(const Vector3& linearVelocity, const Vector3& angularVelocity, T dt) const - { - return Pose( - (Rotation * Quat::FastFromRotationVector(angularVelocity * dt, false)).Normalized(), - Translation + linearVelocity * dt); - } - - Pose TimeIntegrate(const Vector3& linearVelocity, const Vector3& linearAcceleration, - const Vector3& angularVelocity, const Vector3& angularAcceleration, - T dt) const - { - return Pose(Rotation.TimeIntegrate(angularVelocity, angularAcceleration, dt), - Translation + linearVelocity*dt + linearAcceleration*dt*dt * T(0.5)); - } -}; - -typedef Pose Posef; -typedef Pose Posed; - -OVR_MATH_STATIC_ASSERT((sizeof(Posed) == sizeof(Quatd) + sizeof(Vector3d)), "sizeof(Posed) failure"); -OVR_MATH_STATIC_ASSERT((sizeof(Posef) == sizeof(Quatf) + sizeof(Vector3f)), "sizeof(Posef) failure"); - +OVR_MATH_STATIC_ASSERT( + (sizeof(Posed) == sizeof(Quatd) + sizeof(Vector3d)), + "sizeof(Posed) failure"); +OVR_MATH_STATIC_ASSERT( + (sizeof(Posef) == sizeof(Quatf) + sizeof(Vector3f)), + "sizeof(Posef) failure"); //------------------------------------------------------------------------------------- // ***** Matrix4 @@ -1881,1636 +2448,1659 @@ OVR_MATH_STATIC_ASSERT((sizeof(Posef) == sizeof(Quatf) + sizeof(Vector3f)), "siz // Matrix4 is a 4x4 matrix used for 3d transformations and projections. // Translation stored in the last column. // The matrix is stored in row-major order in memory, meaning that values -// of the first row are stored before the next one. -// -// The arrangement of the matrix is chosen to be in Right-Handed -// coordinate system and counterclockwise rotations when looking down -// the axis -// -// Transformation Order: -// - Transformations are applied from right to left, so the expression -// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, -// followed by M2 and M1. -// -// Coordinate system: Right Handed -// -// Rotations: Counterclockwise when looking down the axis. All angles are in radians. -// -// | sx 01 02 tx | // First column (sx, 10, 20): Axis X basis vector. -// | 10 sy 12 ty | // Second column (01, sy, 21): Axis Y basis vector. -// | 20 21 sz tz | // Third columnt (02, 12, sz): Axis Z basis vector. -// | 30 31 32 33 | -// -// The basis vectors are first three columns. - -template -class Matrix4 -{ -public: - typedef T ElementType; - static const size_t Dimension = 4; - - T M[4][4]; - - enum NoInitType { NoInit }; - - // Construct with no memory initialization. - Matrix4(NoInitType) { } - - // By default, we construct identity matrix. - Matrix4() - { - M[0][0] = M[1][1] = M[2][2] = M[3][3] = T(1); - M[0][1] = M[1][0] = M[2][3] = M[3][1] = T(0); - M[0][2] = M[1][2] = M[2][0] = M[3][2] = T(0); - M[0][3] = M[1][3] = M[2][1] = M[3][0] = T(0); - } - - Matrix4(T m11, T m12, T m13, T m14, - T m21, T m22, T m23, T m24, - T m31, T m32, T m33, T m34, - T m41, T m42, T m43, T m44) - { - M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; M[0][3] = m14; - M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; M[1][3] = m24; - M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; M[2][3] = m34; - M[3][0] = m41; M[3][1] = m42; M[3][2] = m43; M[3][3] = m44; - } - - Matrix4(T m11, T m12, T m13, - T m21, T m22, T m23, - T m31, T m32, T m33) - { - M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; M[0][3] = T(0); - M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; M[1][3] = T(0); - M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; M[2][3] = T(0); - M[3][0] = T(0); M[3][1] = T(0); M[3][2] = T(0); M[3][3] = T(1); - } - - explicit Matrix4(const Matrix3& m) - { - M[0][0] = m.M[0][0]; M[0][1] = m.M[0][1]; M[0][2] = m.M[0][2]; M[0][3] = T(0); - M[1][0] = m.M[1][0]; M[1][1] = m.M[1][1]; M[1][2] = m.M[1][2]; M[1][3] = T(0); - M[2][0] = m.M[2][0]; M[2][1] = m.M[2][1]; M[2][2] = m.M[2][2]; M[2][3] = T(0); - M[3][0] = T(0); M[3][1] = T(0); M[3][2] = T(0); M[3][3] = T(1); - } - - explicit Matrix4(const Quat& q) - { - OVR_MATH_ASSERT(q.IsNormalized()); - T ww = q.w*q.w; - T xx = q.x*q.x; - T yy = q.y*q.y; - T zz = q.z*q.z; - - M[0][0] = ww + xx - yy - zz; M[0][1] = 2 * (q.x*q.y - q.w*q.z); M[0][2] = 2 * (q.x*q.z + q.w*q.y); M[0][3] = T(0); - M[1][0] = 2 * (q.x*q.y + q.w*q.z); M[1][1] = ww - xx + yy - zz; M[1][2] = 2 * (q.y*q.z - q.w*q.x); M[1][3] = T(0); - M[2][0] = 2 * (q.x*q.z - q.w*q.y); M[2][1] = 2 * (q.y*q.z + q.w*q.x); M[2][2] = ww - xx - yy + zz; M[2][3] = T(0); - M[3][0] = T(0); M[3][1] = T(0); M[3][2] = T(0); M[3][3] = T(1); - } - - explicit Matrix4(const Pose& p) - { - Matrix4 result(p.Rotation); - result.SetTranslation(p.Translation); - *this = result; - } - - - // C-interop support - explicit Matrix4(const Matrix4::OtherFloatType> &src) - { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - M[i][j] = (T)src.M[i][j]; - } - - // C-interop support. - Matrix4(const typename CompatibleTypes >::Type& s) - { - OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix4), "sizeof(s) == sizeof(Matrix4)"); - memcpy(M, s.M, sizeof(M)); - } - - operator typename CompatibleTypes >::Type () const - { - typename CompatibleTypes >::Type result; - OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix4), "sizeof(result) == sizeof(Matrix4)"); - memcpy(result.M, M, sizeof(M)); - return result; - } - - void ToString(char* dest, size_t destsize) const - { - size_t pos = 0; - for (int r=0; r<4; r++) - { - for (int c=0; c<4; c++) - { - pos += OVRMath_sprintf(dest+pos, destsize-pos, "%g ", M[r][c]); - } - } - } - - static Matrix4 FromString(const char* src) - { - Matrix4 result; - if (src) - { - for (int r = 0; r < 4; r++) - { - for (int c = 0; c < 4; c++) - { - result.M[r][c] = (T)atof(src); - while (*src && *src != ' ') - { - src++; - } - while (*src && *src == ' ') - { - src++; - } - } - } - } - return result; - } - - static Matrix4 Identity() { return Matrix4(); } - - void SetIdentity() - { - M[0][0] = M[1][1] = M[2][2] = M[3][3] = T(1); - M[0][1] = M[1][0] = M[2][3] = M[3][1] = T(0); - M[0][2] = M[1][2] = M[2][0] = M[3][2] = T(0); - M[0][3] = M[1][3] = M[2][1] = M[3][0] = T(0); - } - - void SetXBasis(const Vector3& v) - { - M[0][0] = v.x; - M[1][0] = v.y; - M[2][0] = v.z; - } - Vector3 GetXBasis() const - { - return Vector3(M[0][0], M[1][0], M[2][0]); - } - - void SetYBasis(const Vector3 & v) - { - M[0][1] = v.x; - M[1][1] = v.y; - M[2][1] = v.z; - } - Vector3 GetYBasis() const - { - return Vector3(M[0][1], M[1][1], M[2][1]); - } - - void SetZBasis(const Vector3 & v) - { - M[0][2] = v.x; - M[1][2] = v.y; - M[2][2] = v.z; - } - Vector3 GetZBasis() const - { - return Vector3(M[0][2], M[1][2], M[2][2]); - } - - bool operator== (const Matrix4& b) const - { - bool isEqual = true; - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - isEqual &= (M[i][j] == b.M[i][j]); - - return isEqual; - } - - Matrix4 operator+ (const Matrix4& b) const - { - Matrix4 result(*this); - result += b; - return result; - } - - Matrix4& operator+= (const Matrix4& b) - { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - M[i][j] += b.M[i][j]; - return *this; - } - - Matrix4 operator- (const Matrix4& b) const - { - Matrix4 result(*this); - result -= b; - return result; - } - - Matrix4& operator-= (const Matrix4& b) - { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - M[i][j] -= b.M[i][j]; - return *this; - } - - // Multiplies two matrices into destination with minimum copying. - static Matrix4& Multiply(Matrix4* d, const Matrix4& a, const Matrix4& b) - { - OVR_MATH_ASSERT((d != &a) && (d != &b)); - int i = 0; - do { - d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0] + a.M[i][3] * b.M[3][0]; - d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1] + a.M[i][3] * b.M[3][1]; - d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2] + a.M[i][3] * b.M[3][2]; - d->M[i][3] = a.M[i][0] * b.M[0][3] + a.M[i][1] * b.M[1][3] + a.M[i][2] * b.M[2][3] + a.M[i][3] * b.M[3][3]; - } while((++i) < 4); - - return *d; - } - - Matrix4 operator* (const Matrix4& b) const - { - Matrix4 result(Matrix4::NoInit); - Multiply(&result, *this, b); - return result; - } - - Matrix4& operator*= (const Matrix4& b) - { - return Multiply(this, Matrix4(*this), b); - } - - Matrix4 operator* (T s) const - { - Matrix4 result(*this); - result *= s; - return result; - } - - Matrix4& operator*= (T s) - { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - M[i][j] *= s; - return *this; - } - - - Matrix4 operator/ (T s) const - { - Matrix4 result(*this); - result /= s; - return result; - } - - Matrix4& operator/= (T s) - { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - M[i][j] /= s; - return *this; - } - - Vector3 Transform(const Vector3& v) const - { - const T rcpW = T(1) / (M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3]); - return Vector3((M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3]) * rcpW, - (M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3]) * rcpW, - (M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3]) * rcpW); - } - - Vector4 Transform(const Vector4& v) const - { - return Vector4(M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3] * v.w, - M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3] * v.w, - M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3] * v.w, - M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3] * v.w); - } - - Matrix4 Transposed() const - { - return Matrix4(M[0][0], M[1][0], M[2][0], M[3][0], - M[0][1], M[1][1], M[2][1], M[3][1], - M[0][2], M[1][2], M[2][2], M[3][2], - M[0][3], M[1][3], M[2][3], M[3][3]); - } - - void Transpose() - { - *this = Transposed(); - } - - - T SubDet (const size_t* rows, const size_t* cols) const - { - return M[rows[0]][cols[0]] * (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) - - M[rows[0]][cols[1]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) - + M[rows[0]][cols[2]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); - } - - T Cofactor(size_t I, size_t J) const - { - const size_t indices[4][3] = {{1,2,3},{0,2,3},{0,1,3},{0,1,2}}; - return ((I+J)&1) ? -SubDet(indices[I],indices[J]) : SubDet(indices[I],indices[J]); - } - - T Determinant() const - { - return M[0][0] * Cofactor(0,0) + M[0][1] * Cofactor(0,1) + M[0][2] * Cofactor(0,2) + M[0][3] * Cofactor(0,3); - } - - Matrix4 Adjugated() const - { - return Matrix4(Cofactor(0,0), Cofactor(1,0), Cofactor(2,0), Cofactor(3,0), - Cofactor(0,1), Cofactor(1,1), Cofactor(2,1), Cofactor(3,1), - Cofactor(0,2), Cofactor(1,2), Cofactor(2,2), Cofactor(3,2), - Cofactor(0,3), Cofactor(1,3), Cofactor(2,3), Cofactor(3,3)); - } - - Matrix4 Inverted() const - { - T det = Determinant(); - OVR_MATH_ASSERT(det != 0); - return Adjugated() * (T(1)/det); - } - - void Invert() - { - *this = Inverted(); - } - - // This is more efficient than general inverse, but ONLY works - // correctly if it is a homogeneous transform matrix (rot + trans) - Matrix4 InvertedHomogeneousTransform() const - { - // Make the inverse rotation matrix - Matrix4 rinv = this->Transposed(); - rinv.M[3][0] = rinv.M[3][1] = rinv.M[3][2] = T(0); - // Make the inverse translation matrix - Vector3 tvinv(-M[0][3],-M[1][3],-M[2][3]); - Matrix4 tinv = Matrix4::Translation(tvinv); - return rinv * tinv; // "untranslate", then "unrotate" - } - - // This is more efficient than general inverse, but ONLY works - // correctly if it is a homogeneous transform matrix (rot + trans) - void InvertHomogeneousTransform() - { - *this = InvertedHomogeneousTransform(); - } - - // Matrix to Euler Angles conversion - // a,b,c, are the YawPitchRoll angles to be returned - // rotation a around axis A1 - // is followed by rotation b around axis A2 - // is followed by rotation c around axis A3 - // rotations are CCW or CW (D) in LH or RH coordinate system (S) - template - void ToEulerAngles(T *a, T *b, T *c) const - { - OVR_MATH_STATIC_ASSERT((A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); - - T psign = T(-1); - if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) // Determine whether even permutation - psign = T(1); - - T pm = psign*M[A1][A3]; - T singularityRadius = Math::SingularityRadius(); - if (pm < T(-1) + singularityRadius) - { // South pole singularity - *a = T(0); - *b = -S*D*((T)MATH_DOUBLE_PIOVER2); - *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] ); - } - else if (pm > T(1) - singularityRadius) - { // North pole singularity - *a = T(0); - *b = S*D*((T)MATH_DOUBLE_PIOVER2); - *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] ); - } - else - { // Normal case (nonsingular) - *a = S*D*atan2( -psign*M[A2][A3], M[A3][A3] ); - *b = S*D*asin(pm); - *c = S*D*atan2( -psign*M[A1][A2], M[A1][A1] ); - } - } - - // Matrix to Euler Angles conversion - // a,b,c, are the YawPitchRoll angles to be returned - // rotation a around axis A1 - // is followed by rotation b around axis A2 - // is followed by rotation c around axis A1 - // rotations are CCW or CW (D) in LH or RH coordinate system (S) - template - void ToEulerAnglesABA(T *a, T *b, T *c) const - { - OVR_MATH_STATIC_ASSERT(A1 != A2, "A1 != A2"); - - // Determine the axis that was not supplied - int m = 3 - A1 - A2; - - T psign = T(-1); - if ((A1 + 1) % 3 == A2) // Determine whether even permutation - psign = T(1); - - T c2 = M[A1][A1]; - T singularityRadius = Math::SingularityRadius(); - if (c2 < T(-1) + singularityRadius) - { // South pole singularity - *a = T(0); - *b = S*D*((T)MATH_DOUBLE_PI); - *c = S*D*atan2( -psign*M[A2][m],M[A2][A2]); - } - else if (c2 > T(1) - singularityRadius) - { // North pole singularity - *a = T(0); - *b = T(0); - *c = S*D*atan2( -psign*M[A2][m],M[A2][A2]); - } - else - { // Normal case (nonsingular) - *a = S*D*atan2( M[A2][A1],-psign*M[m][A1]); - *b = S*D*acos(c2); - *c = S*D*atan2( M[A1][A2],psign*M[A1][m]); - } - } - - // Creates a matrix that converts the vertices from one coordinate system - // to another. - static Matrix4 AxisConversion(const WorldAxes& to, const WorldAxes& from) - { - // Holds axis values from the 'to' structure - int toArray[3] = { to.XAxis, to.YAxis, to.ZAxis }; - - // The inverse of the toArray - int inv[4]; - inv[0] = inv[abs(to.XAxis)] = 0; - inv[abs(to.YAxis)] = 1; - inv[abs(to.ZAxis)] = 2; - - Matrix4 m(0, 0, 0, - 0, 0, 0, - 0, 0, 0); - - // Only three values in the matrix need to be changed to 1 or -1. - m.M[inv[abs(from.XAxis)]][0] = T(from.XAxis/toArray[inv[abs(from.XAxis)]]); - m.M[inv[abs(from.YAxis)]][1] = T(from.YAxis/toArray[inv[abs(from.YAxis)]]); - m.M[inv[abs(from.ZAxis)]][2] = T(from.ZAxis/toArray[inv[abs(from.ZAxis)]]); - return m; - } - - - // Creates a matrix for translation by vector - static Matrix4 Translation(const Vector3& v) - { - Matrix4 t; - t.M[0][3] = v.x; - t.M[1][3] = v.y; - t.M[2][3] = v.z; - return t; - } - - // Creates a matrix for translation by vector - static Matrix4 Translation(T x, T y, T z = T(0)) - { - Matrix4 t; - t.M[0][3] = x; - t.M[1][3] = y; - t.M[2][3] = z; - return t; - } - - // Sets the translation part - void SetTranslation(const Vector3& v) - { - M[0][3] = v.x; - M[1][3] = v.y; - M[2][3] = v.z; - } - - Vector3 GetTranslation() const - { - return Vector3( M[0][3], M[1][3], M[2][3] ); - } - - // Creates a matrix for scaling by vector - static Matrix4 Scaling(const Vector3& v) - { - Matrix4 t; - t.M[0][0] = v.x; - t.M[1][1] = v.y; - t.M[2][2] = v.z; - return t; - } - - // Creates a matrix for scaling by vector - static Matrix4 Scaling(T x, T y, T z) - { - Matrix4 t; - t.M[0][0] = x; - t.M[1][1] = y; - t.M[2][2] = z; - return t; - } - - // Creates a matrix for scaling by constant - static Matrix4 Scaling(T s) - { - Matrix4 t; - t.M[0][0] = s; - t.M[1][1] = s; - t.M[2][2] = s; - return t; - } - - // Simple L1 distance in R^12 - T Distance(const Matrix4& m2) const - { - T d = fabs(M[0][0] - m2.M[0][0]) + fabs(M[0][1] - m2.M[0][1]); - d += fabs(M[0][2] - m2.M[0][2]) + fabs(M[0][3] - m2.M[0][3]); - d += fabs(M[1][0] - m2.M[1][0]) + fabs(M[1][1] - m2.M[1][1]); - d += fabs(M[1][2] - m2.M[1][2]) + fabs(M[1][3] - m2.M[1][3]); - d += fabs(M[2][0] - m2.M[2][0]) + fabs(M[2][1] - m2.M[2][1]); - d += fabs(M[2][2] - m2.M[2][2]) + fabs(M[2][3] - m2.M[2][3]); - d += fabs(M[3][0] - m2.M[3][0]) + fabs(M[3][1] - m2.M[3][1]); - d += fabs(M[3][2] - m2.M[3][2]) + fabs(M[3][3] - m2.M[3][3]); - return d; - } - - // Creates a rotation matrix rotating around the X axis by 'angle' radians. - // Just for quick testing. Not for final API. Need to remove case. - static Matrix4 RotationAxis(Axis A, T angle, RotateDirection d, HandedSystem s) - { - T sina = s * d *sin(angle); - T cosa = cos(angle); - - switch(A) - { - case Axis_X: - return Matrix4(1, 0, 0, - 0, cosa, -sina, - 0, sina, cosa); - case Axis_Y: - return Matrix4(cosa, 0, sina, - 0, 1, 0, - -sina, 0, cosa); - case Axis_Z: - return Matrix4(cosa, -sina, 0, - sina, cosa, 0, - 0, 0, 1); - default: - return Matrix4(); - } - } - - - // Creates a rotation matrix rotating around the X axis by 'angle' radians. - // Rotation direction is depends on the coordinate system: - // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), - // while looking in the negative axis direction. This is the - // same as looking down from positive axis values towards origin. - // LHS: Positive angle values rotate clock-wise (CW), while looking in the - // negative axis direction. - static Matrix4 RotationX(T angle) - { - T sina = sin(angle); - T cosa = cos(angle); - return Matrix4(1, 0, 0, - 0, cosa, -sina, - 0, sina, cosa); - } - - // Creates a rotation matrix rotating around the Y axis by 'angle' radians. - // Rotation direction is depends on the coordinate system: - // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), - // while looking in the negative axis direction. This is the - // same as looking down from positive axis values towards origin. - // LHS: Positive angle values rotate clock-wise (CW), while looking in the - // negative axis direction. - static Matrix4 RotationY(T angle) - { - T sina = (T)sin(angle); - T cosa = (T)cos(angle); - return Matrix4(cosa, 0, sina, - 0, 1, 0, - -sina, 0, cosa); - } - - // Creates a rotation matrix rotating around the Z axis by 'angle' radians. - // Rotation direction is depends on the coordinate system: - // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), - // while looking in the negative axis direction. This is the - // same as looking down from positive axis values towards origin. - // LHS: Positive angle values rotate clock-wise (CW), while looking in the - // negative axis direction. - static Matrix4 RotationZ(T angle) - { - T sina = sin(angle); - T cosa = cos(angle); - return Matrix4(cosa, -sina, 0, - sina, cosa, 0, - 0, 0, 1); - } - - // LookAtRH creates a View transformation matrix for right-handed coordinate system. - // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' - // specifying the up vector. The resulting matrix should be used with PerspectiveRH - // projection. - static Matrix4 LookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up) - { - Vector3 z = (eye - at).Normalized(); // Forward - Vector3 x = up.Cross(z).Normalized(); // Right - Vector3 y = z.Cross(x); - - Matrix4 m(x.x, x.y, x.z, -(x.Dot(eye)), - y.x, y.y, y.z, -(y.Dot(eye)), - z.x, z.y, z.z, -(z.Dot(eye)), - 0, 0, 0, 1 ); - return m; - } - - // LookAtLH creates a View transformation matrix for left-handed coordinate system. - // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' - // specifying the up vector. - static Matrix4 LookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up) - { - Vector3 z = (at - eye).Normalized(); // Forward - Vector3 x = up.Cross(z).Normalized(); // Right - Vector3 y = z.Cross(x); - - Matrix4 m(x.x, x.y, x.z, -(x.Dot(eye)), - y.x, y.y, y.z, -(y.Dot(eye)), - z.x, z.y, z.z, -(z.Dot(eye)), - 0, 0, 0, 1 ); - return m; - } - - // PerspectiveRH creates a right-handed perspective projection matrix that can be - // used with the Oculus sample renderer. - // yfov - Specifies vertical field of view in radians. - // aspect - Screen aspect ration, which is usually width/height for square pixels. - // Note that xfov = yfov * aspect. - // znear - Absolute value of near Z clipping clipping range. - // zfar - Absolute value of far Z clipping clipping range (larger then near). - // Even though RHS usually looks in the direction of negative Z, positive values - // are expected for znear and zfar. - static Matrix4 PerspectiveRH(T yfov, T aspect, T znear, T zfar) - { - Matrix4 m; - T tanHalfFov = tan(yfov * T(0.5)); - - m.M[0][0] = T(1) / (aspect * tanHalfFov); - m.M[1][1] = T(1) / tanHalfFov; - m.M[2][2] = zfar / (znear - zfar); - m.M[3][2] = T(-1); - m.M[2][3] = (zfar * znear) / (znear - zfar); - m.M[3][3] = T(0); - - // Note: Post-projection matrix result assumes Left-Handed coordinate system, - // with Y up, X right and Z forward. This supports positive z-buffer values. - // This is the case even for RHS coordinate input. - return m; - } - - // PerspectiveLH creates a left-handed perspective projection matrix that can be - // used with the Oculus sample renderer. - // yfov - Specifies vertical field of view in radians. - // aspect - Screen aspect ration, which is usually width/height for square pixels. - // Note that xfov = yfov * aspect. - // znear - Absolute value of near Z clipping clipping range. - // zfar - Absolute value of far Z clipping clipping range (larger then near). - static Matrix4 PerspectiveLH(T yfov, T aspect, T znear, T zfar) - { - Matrix4 m; - T tanHalfFov = tan(yfov * T(0.5)); - - m.M[0][0] = T(1) / (aspect * tanHalfFov); - m.M[1][1] = T(1) / tanHalfFov; - //m.M[2][2] = zfar / (znear - zfar); - m.M[2][2] = zfar / (zfar - znear); - m.M[3][2] = T(-1); - m.M[2][3] = (zfar * znear) / (znear - zfar); - m.M[3][3] = T(0); - - // Note: Post-projection matrix result assumes Left-Handed coordinate system, - // with Y up, X right and Z forward. This supports positive z-buffer values. - // This is the case even for RHS coordinate input. - return m; - } - - static Matrix4 Ortho2D(T w, T h) - { - Matrix4 m; - m.M[0][0] = T(2.0)/w; - m.M[1][1] = T(-2.0)/h; - m.M[0][3] = T(-1.0); - m.M[1][3] = T(1.0); - m.M[2][2] = T(0); - return m; - } -}; - -typedef Matrix4 Matrix4f; -typedef Matrix4 Matrix4d; - -//------------------------------------------------------------------------------------- -// ***** Matrix3 -// -// Matrix3 is a 3x3 matrix used for representing a rotation matrix. -// The matrix is stored in row-major order in memory, meaning that values -// of the first row are stored before the next one. -// -// The arrangement of the matrix is chosen to be in Right-Handed -// coordinate system and counterclockwise rotations when looking down -// the axis -// -// Transformation Order: -// - Transformations are applied from right to left, so the expression -// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, -// followed by M2 and M1. -// -// Coordinate system: Right Handed -// -// Rotations: Counterclockwise when looking down the axis. All angles are in radians. - -template -class Matrix3 -{ -public: - typedef T ElementType; - static const size_t Dimension = 3; - - T M[3][3]; - - enum NoInitType { NoInit }; - - // Construct with no memory initialization. - Matrix3(NoInitType) { } - - // By default, we construct identity matrix. - Matrix3() - { - M[0][0] = M[1][1] = M[2][2] = T(1); - M[0][1] = M[1][0] = M[2][0] = T(0); - M[0][2] = M[1][2] = M[2][1] = T(0); - } - - Matrix3(T m11, T m12, T m13, - T m21, T m22, T m23, - T m31, T m32, T m33) - { - M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; - M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; - M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; - } - - // Construction from X, Y, Z basis vectors - Matrix3(const Vector3& xBasis, const Vector3& yBasis, const Vector3& zBasis) - { - M[0][0] = xBasis.x; M[0][1] = yBasis.x; M[0][2] = zBasis.x; - M[1][0] = xBasis.y; M[1][1] = yBasis.y; M[1][2] = zBasis.y; - M[2][0] = xBasis.z; M[2][1] = yBasis.z; M[2][2] = zBasis.z; - } - - explicit Matrix3(const Quat& q) - { - OVR_MATH_ASSERT(q.IsNormalized()); - const T tx = q.x+q.x, ty = q.y+q.y, tz = q.z+q.z; - const T twx = q.w*tx, twy = q.w*ty, twz = q.w*tz; - const T txx = q.x*tx, txy = q.x*ty, txz = q.x*tz; - const T tyy = q.y*ty, tyz = q.y*tz, tzz = q.z*tz; - M[0][0] = T(1) - (tyy + tzz); M[0][1] = txy - twz; M[0][2] = txz + twy; - M[1][0] = txy + twz; M[1][1] = T(1) - (txx + tzz); M[1][2] = tyz - twx; - M[2][0] = txz - twy; M[2][1] = tyz + twx; M[2][2] = T(1) - (txx + tyy); - } - - inline explicit Matrix3(T s) - { - M[0][0] = M[1][1] = M[2][2] = s; - M[0][1] = M[0][2] = M[1][0] = M[1][2] = M[2][0] = M[2][1] = T(0); - } - - Matrix3(T m11, T m22, T m33) - { - M[0][0] = m11; M[0][1] = T(0); M[0][2] = T(0); - M[1][0] = T(0); M[1][1] = m22; M[1][2] = T(0); - M[2][0] = T(0); M[2][1] = T(0); M[2][2] = m33; - } - - explicit Matrix3(const Matrix3::OtherFloatType> &src) - { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - M[i][j] = (T)src.M[i][j]; - } - - // C-interop support. - Matrix3(const typename CompatibleTypes >::Type& s) - { - OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix3), "sizeof(s) == sizeof(Matrix3)"); - memcpy(M, s.M, sizeof(M)); - } - - operator const typename CompatibleTypes >::Type () const - { - typename CompatibleTypes >::Type result; - OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix3), "sizeof(result) == sizeof(Matrix3)"); - memcpy(result.M, M, sizeof(M)); - return result; - } - - T operator()(int i, int j) const { return M[i][j]; } - T& operator()(int i, int j) { return M[i][j]; } - - void ToString(char* dest, size_t destsize) const - { - size_t pos = 0; - for (int r=0; r<3; r++) - { - for (int c=0; c<3; c++) - pos += OVRMath_sprintf(dest+pos, destsize-pos, "%g ", M[r][c]); - } - } - - static Matrix3 FromString(const char* src) - { - Matrix3 result; - if (src) - { - for (int r=0; r<3; r++) - { - for (int c=0; c<3; c++) - { - result.M[r][c] = (T)atof(src); - while (*src && *src != ' ') - src++; - while (*src && *src == ' ') - src++; - } - } - } - return result; - } - - static Matrix3 Identity() { return Matrix3(); } - - void SetIdentity() - { - M[0][0] = M[1][1] = M[2][2] = T(1); - M[0][1] = M[1][0] = M[2][0] = T(0); - M[0][2] = M[1][2] = M[2][1] = T(0); - } - - static Matrix3 Diagonal(T m00, T m11, T m22) - { - return Matrix3(m00, 0, 0, - 0, m11, 0, - 0, 0, m22); - } - static Matrix3 Diagonal(const Vector3& v) { return Diagonal(v.x, v.y, v.z); } - - T Trace() const { return M[0][0] + M[1][1] + M[2][2]; } - - bool operator== (const Matrix3& b) const - { - bool isEqual = true; - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - isEqual &= (M[i][j] == b.M[i][j]); - } - - return isEqual; - } - - Matrix3 operator+ (const Matrix3& b) const - { - Matrix3 result(*this); - result += b; - return result; - } - - Matrix3& operator+= (const Matrix3& b) - { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - M[i][j] += b.M[i][j]; - return *this; - } - - void operator= (const Matrix3& b) - { - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - M[i][j] = b.M[i][j]; - } - - Matrix3 operator- (const Matrix3& b) const - { - Matrix3 result(*this); - result -= b; - return result; - } - - Matrix3& operator-= (const Matrix3& b) - { - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - M[i][j] -= b.M[i][j]; - } - - return *this; - } - - // Multiplies two matrices into destination with minimum copying. - static Matrix3& Multiply(Matrix3* d, const Matrix3& a, const Matrix3& b) - { - OVR_MATH_ASSERT((d != &a) && (d != &b)); - int i = 0; - do { - d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0]; - d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1]; - d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2]; - } while((++i) < 3); - - return *d; - } - - Matrix3 operator* (const Matrix3& b) const - { - Matrix3 result(Matrix3::NoInit); - Multiply(&result, *this, b); - return result; - } - - Matrix3& operator*= (const Matrix3& b) - { - return Multiply(this, Matrix3(*this), b); - } - - Matrix3 operator* (T s) const - { - Matrix3 result(*this); - result *= s; - return result; - } - - Matrix3& operator*= (T s) - { - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - M[i][j] *= s; - } - - return *this; - } - - Vector3 operator* (const Vector3 &b) const - { - Vector3 result; - result.x = M[0][0]*b.x + M[0][1]*b.y + M[0][2]*b.z; - result.y = M[1][0]*b.x + M[1][1]*b.y + M[1][2]*b.z; - result.z = M[2][0]*b.x + M[2][1]*b.y + M[2][2]*b.z; - - return result; - } - - Matrix3 operator/ (T s) const - { - Matrix3 result(*this); - result /= s; - return result; - } - - Matrix3& operator/= (T s) - { - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - M[i][j] /= s; - } - - return *this; - } - - Vector2 Transform(const Vector2& v) const - { - const T rcpZ = T(1) / (M[2][0] * v.x + M[2][1] * v.y + M[2][2]); - return Vector2((M[0][0] * v.x + M[0][1] * v.y + M[0][2]) * rcpZ, - (M[1][0] * v.x + M[1][1] * v.y + M[1][2]) * rcpZ); - } - - Vector3 Transform(const Vector3& v) const - { - return Vector3(M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z, - M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z, - M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z); - } - - Matrix3 Transposed() const - { - return Matrix3(M[0][0], M[1][0], M[2][0], - M[0][1], M[1][1], M[2][1], - M[0][2], M[1][2], M[2][2]); - } - - void Transpose() - { - *this = Transposed(); - } - - - T SubDet (const size_t* rows, const size_t* cols) const - { - return M[rows[0]][cols[0]] * (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) - - M[rows[0]][cols[1]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) - + M[rows[0]][cols[2]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); - } - - - // M += a*b.t() - inline void Rank1Add(const Vector3 &a, const Vector3 &b) - { - M[0][0] += a.x*b.x; M[0][1] += a.x*b.y; M[0][2] += a.x*b.z; - M[1][0] += a.y*b.x; M[1][1] += a.y*b.y; M[1][2] += a.y*b.z; - M[2][0] += a.z*b.x; M[2][1] += a.z*b.y; M[2][2] += a.z*b.z; - } - - // M -= a*b.t() - inline void Rank1Sub(const Vector3 &a, const Vector3 &b) - { - M[0][0] -= a.x*b.x; M[0][1] -= a.x*b.y; M[0][2] -= a.x*b.z; - M[1][0] -= a.y*b.x; M[1][1] -= a.y*b.y; M[1][2] -= a.y*b.z; - M[2][0] -= a.z*b.x; M[2][1] -= a.z*b.y; M[2][2] -= a.z*b.z; - } - - inline Vector3 Col(int c) const - { - return Vector3(M[0][c], M[1][c], M[2][c]); - } - - inline Vector3 Row(int r) const - { - return Vector3(M[r][0], M[r][1], M[r][2]); - } - - inline Vector3 GetColumn(int c) const - { - return Vector3(M[0][c], M[1][c], M[2][c]); - } - - inline Vector3 GetRow(int r) const - { - return Vector3(M[r][0], M[r][1], M[r][2]); - } - - inline void SetColumn(int c, const Vector3& v) - { - M[0][c] = v.x; - M[1][c] = v.y; - M[2][c] = v.z; - } - - inline void SetRow(int r, const Vector3& v) - { - M[r][0] = v.x; - M[r][1] = v.y; - M[r][2] = v.z; - } - - inline T Determinant() const - { - const Matrix3& m = *this; - T d; - - d = m.M[0][0] * (m.M[1][1]*m.M[2][2] - m.M[1][2] * m.M[2][1]); - d -= m.M[0][1] * (m.M[1][0]*m.M[2][2] - m.M[1][2] * m.M[2][0]); - d += m.M[0][2] * (m.M[1][0]*m.M[2][1] - m.M[1][1] * m.M[2][0]); - - return d; - } - - inline Matrix3 Inverse() const - { - Matrix3 a; - const Matrix3& m = *this; - T d = Determinant(); - - OVR_MATH_ASSERT(d != 0); - T s = T(1)/d; - - a.M[0][0] = s * (m.M[1][1] * m.M[2][2] - m.M[1][2] * m.M[2][1]); - a.M[1][0] = s * (m.M[1][2] * m.M[2][0] - m.M[1][0] * m.M[2][2]); - a.M[2][0] = s * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]); - - a.M[0][1] = s * (m.M[0][2] * m.M[2][1] - m.M[0][1] * m.M[2][2]); - a.M[1][1] = s * (m.M[0][0] * m.M[2][2] - m.M[0][2] * m.M[2][0]); - a.M[2][1] = s * (m.M[0][1] * m.M[2][0] - m.M[0][0] * m.M[2][1]); - - a.M[0][2] = s * (m.M[0][1] * m.M[1][2] - m.M[0][2] * m.M[1][1]); - a.M[1][2] = s * (m.M[0][2] * m.M[1][0] - m.M[0][0] * m.M[1][2]); - a.M[2][2] = s * (m.M[0][0] * m.M[1][1] - m.M[0][1] * m.M[1][0]); - - return a; - } - - // Outer Product of two column vectors: a * b.Transpose() - static Matrix3 OuterProduct(const Vector3& a, const Vector3& b) - { - return Matrix3(a.x*b.x, a.x*b.y, a.x*b.z, - a.y*b.x, a.y*b.y, a.y*b.z, - a.z*b.x, a.z*b.y, a.z*b.z); - } +// of the first row are stored before the next one. +// +// The arrangement of the matrix is chosen to be in Right-Handed +// coordinate system and counterclockwise rotations when looking down +// the axis +// +// Transformation Order: +// - Transformations are applied from right to left, so the expression +// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, +// followed by M2 and M1. +// +// Coordinate system: Right Handed +// +// Rotations: Counterclockwise when looking down the axis. All angles are in radians. +// +// | sx 01 02 tx | // First column (sx, 10, 20): Axis X basis vector. +// | 10 sy 12 ty | // Second column (01, sy, 21): Axis Y basis vector. +// | 20 21 sz tz | // Third columnt (02, 12, sz): Axis Z basis vector. +// | 30 31 32 33 | +// +// The basis vectors are first three columns. - // Vector cross product as a premultiply matrix: - // L.Cross(R) = LeftCrossAsMatrix(L) * R - static Matrix3 LeftCrossAsMatrix(const Vector3& L) - { - return Matrix3( - T(0), -L.z, +L.y, - +L.z, T(0), -L.x, - -L.y, +L.x, T(0)); - } +template +class Matrix4 { + public: + typedef T ElementType; + static const size_t Dimension = 4; + + T M[4][4]; + + enum NoInitType { NoInit }; + + // Construct with no memory initialization. + Matrix4(NoInitType) {} + + // By default, we construct identity matrix. + Matrix4() { + M[0][0] = M[1][1] = M[2][2] = M[3][3] = T(1); + M[0][1] = M[1][0] = M[2][3] = M[3][1] = T(0); + M[0][2] = M[1][2] = M[2][0] = M[3][2] = T(0); + M[0][3] = M[1][3] = M[2][1] = M[3][0] = T(0); + } + + Matrix4( + T m11, + T m12, + T m13, + T m14, + T m21, + T m22, + T m23, + T m24, + T m31, + T m32, + T m33, + T m34, + T m41, + T m42, + T m43, + T m44) { + M[0][0] = m11; + M[0][1] = m12; + M[0][2] = m13; + M[0][3] = m14; + M[1][0] = m21; + M[1][1] = m22; + M[1][2] = m23; + M[1][3] = m24; + M[2][0] = m31; + M[2][1] = m32; + M[2][2] = m33; + M[2][3] = m34; + M[3][0] = m41; + M[3][1] = m42; + M[3][2] = m43; + M[3][3] = m44; + } + + Matrix4(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33) { + M[0][0] = m11; + M[0][1] = m12; + M[0][2] = m13; + M[0][3] = T(0); + M[1][0] = m21; + M[1][1] = m22; + M[1][2] = m23; + M[1][3] = T(0); + M[2][0] = m31; + M[2][1] = m32; + M[2][2] = m33; + M[2][3] = T(0); + M[3][0] = T(0); + M[3][1] = T(0); + M[3][2] = T(0); + M[3][3] = T(1); + } + + explicit Matrix4(const Matrix3& m) { + M[0][0] = m.M[0][0]; + M[0][1] = m.M[0][1]; + M[0][2] = m.M[0][2]; + M[0][3] = T(0); + M[1][0] = m.M[1][0]; + M[1][1] = m.M[1][1]; + M[1][2] = m.M[1][2]; + M[1][3] = T(0); + M[2][0] = m.M[2][0]; + M[2][1] = m.M[2][1]; + M[2][2] = m.M[2][2]; + M[2][3] = T(0); + M[3][0] = T(0); + M[3][1] = T(0); + M[3][2] = T(0); + M[3][3] = T(1); + } + + explicit Matrix4(const Quat& q) { + OVR_MATH_ASSERT(q.IsNormalized()); // If this fires, caller has a quat math bug + T ww = q.w * q.w; + T xx = q.x * q.x; + T yy = q.y * q.y; + T zz = q.z * q.z; + + M[0][0] = ww + xx - yy - zz; + M[0][1] = 2 * (q.x * q.y - q.w * q.z); + M[0][2] = 2 * (q.x * q.z + q.w * q.y); + M[0][3] = T(0); + M[1][0] = 2 * (q.x * q.y + q.w * q.z); + M[1][1] = ww - xx + yy - zz; + M[1][2] = 2 * (q.y * q.z - q.w * q.x); + M[1][3] = T(0); + M[2][0] = 2 * (q.x * q.z - q.w * q.y); + M[2][1] = 2 * (q.y * q.z + q.w * q.x); + M[2][2] = ww - xx - yy + zz; + M[2][3] = T(0); + M[3][0] = T(0); + M[3][1] = T(0); + M[3][2] = T(0); + M[3][3] = T(1); + } + + explicit Matrix4(const Pose& p) { + Matrix4 result(p.Rotation); + result.SetTranslation(p.Translation); + *this = result; + } + + // C-interop support + explicit Matrix4(const Matrix4::OtherFloatType>& src) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] = (T)src.M[i][j]; + } + + // C-interop support. + Matrix4(const typename CompatibleTypes>::Type& s) { + OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix4), "sizeof(s) == sizeof(Matrix4)"); + memcpy(M, s.M, sizeof(M)); + } + + operator typename CompatibleTypes>::Type() const { + typename CompatibleTypes>::Type result; + OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix4), "sizeof(result) == sizeof(Matrix4)"); + memcpy(result.M, M, sizeof(M)); + return result; + } + + void ToString(char* dest, size_t destsize) const { + size_t pos = 0; + for (int r = 0; r < 4; r++) { + for (int c = 0; c < 4; c++) { + pos += OVRMath_sprintf(dest + pos, destsize - pos, "%g ", M[r][c]); + } + } + } + + static Matrix4 FromString(const char* src) { + Matrix4 result; + if (src) { + for (int r = 0; r < 4; r++) { + for (int c = 0; c < 4; c++) { + result.M[r][c] = (T)atof(src); + while (*src && *src != ' ') { + src++; + } + while (*src && *src == ' ') { + src++; + } + } + } + } + return result; + } + + static Matrix4 Identity() { + return Matrix4(); + } + + void SetIdentity() { + M[0][0] = M[1][1] = M[2][2] = M[3][3] = T(1); + M[0][1] = M[1][0] = M[2][3] = M[3][1] = T(0); + M[0][2] = M[1][2] = M[2][0] = M[3][2] = T(0); + M[0][3] = M[1][3] = M[2][1] = M[3][0] = T(0); + } + + void SetXBasis(const Vector3& v) { + M[0][0] = v.x; + M[1][0] = v.y; + M[2][0] = v.z; + } + Vector3 GetXBasis() const { + return Vector3(M[0][0], M[1][0], M[2][0]); + } + + void SetYBasis(const Vector3& v) { + M[0][1] = v.x; + M[1][1] = v.y; + M[2][1] = v.z; + } + Vector3 GetYBasis() const { + return Vector3(M[0][1], M[1][1], M[2][1]); + } + + void SetZBasis(const Vector3& v) { + M[0][2] = v.x; + M[1][2] = v.y; + M[2][2] = v.z; + } + Vector3 GetZBasis() const { + return Vector3(M[0][2], M[1][2], M[2][2]); + } + + bool operator==(const Matrix4& b) const { + bool isEqual = true; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + isEqual &= (M[i][j] == b.M[i][j]); + + return isEqual; + } + + Matrix4 operator+(const Matrix4& b) const { + Matrix4 result(*this); + result += b; + return result; + } + + Matrix4& operator+=(const Matrix4& b) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] += b.M[i][j]; + return *this; + } + + Matrix4 operator-(const Matrix4& b) const { + Matrix4 result(*this); + result -= b; + return result; + } + + Matrix4& operator-=(const Matrix4& b) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] -= b.M[i][j]; + return *this; + } + + // Multiplies two matrices into destination with minimum copying. + static Matrix4& Multiply(Matrix4* d, const Matrix4& a, const Matrix4& b) { + OVR_MATH_ASSERT((d != &a) && (d != &b)); + int i = 0; + do { + d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0] + + a.M[i][3] * b.M[3][0]; + d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1] + + a.M[i][3] * b.M[3][1]; + d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2] + + a.M[i][3] * b.M[3][2]; + d->M[i][3] = a.M[i][0] * b.M[0][3] + a.M[i][1] * b.M[1][3] + a.M[i][2] * b.M[2][3] + + a.M[i][3] * b.M[3][3]; + } while ((++i) < 4); + + return *d; + } + + Matrix4 operator*(const Matrix4& b) const { + Matrix4 result(Matrix4::NoInit); + Multiply(&result, *this, b); + return result; + } + + Matrix4& operator*=(const Matrix4& b) { + return Multiply(this, Matrix4(*this), b); + } + + Matrix4 operator*(T s) const { + Matrix4 result(*this); + result *= s; + return result; + } + + Matrix4& operator*=(T s) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] *= s; + return *this; + } + + Matrix4 operator/(T s) const { + Matrix4 result(*this); + result /= s; + return result; + } + + Matrix4& operator/=(T s) { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] /= s; + return *this; + } + + T operator()(int i, int j) const { + return M[i][j]; + } + T& operator()(int i, int j) { + return M[i][j]; + } + + Vector4 operator*(const Vector4& b) const { + return Transform(b); + } + + Vector3 Transform(const Vector3& v) const { + const T rcpW = T(1) / (M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3]); + return Vector3( + (M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3]) * rcpW, + (M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3]) * rcpW, + (M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3]) * rcpW); + } + + Vector4 Transform(const Vector4& v) const { + return Vector4( + M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3] * v.w, + M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3] * v.w, + M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3] * v.w, + M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3] * v.w); + } + + Matrix4 Transposed() const { + return Matrix4( + M[0][0], + M[1][0], + M[2][0], + M[3][0], + M[0][1], + M[1][1], + M[2][1], + M[3][1], + M[0][2], + M[1][2], + M[2][2], + M[3][2], + M[0][3], + M[1][3], + M[2][3], + M[3][3]); + } + + void Transpose() { + *this = Transposed(); + } + + T SubDet(const size_t* rows, const size_t* cols) const { + return M[rows[0]][cols[0]] * + (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) - + M[rows[0]][cols[1]] * + (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) + + M[rows[0]][cols[2]] * + (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); + } + + T Cofactor(size_t I, size_t J) const { + const size_t indices[4][3] = {{1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}}; + return ((I + J) & 1) ? -SubDet(indices[I], indices[J]) : SubDet(indices[I], indices[J]); + } + + T Determinant() const { + return M[0][0] * Cofactor(0, 0) + M[0][1] * Cofactor(0, 1) + M[0][2] * Cofactor(0, 2) + + M[0][3] * Cofactor(0, 3); + } + + Matrix4 Adjugated() const { + return Matrix4( + Cofactor(0, 0), + Cofactor(1, 0), + Cofactor(2, 0), + Cofactor(3, 0), + Cofactor(0, 1), + Cofactor(1, 1), + Cofactor(2, 1), + Cofactor(3, 1), + Cofactor(0, 2), + Cofactor(1, 2), + Cofactor(2, 2), + Cofactor(3, 2), + Cofactor(0, 3), + Cofactor(1, 3), + Cofactor(2, 3), + Cofactor(3, 3)); + } + + Matrix4 Inverted() const { + T det = Determinant(); + OVR_MATH_ASSERT(det != 0); + return Adjugated() * (T(1) / det); + } + + void Invert() { + *this = Inverted(); + } + + // This is more efficient than general inverse, but ONLY works + // correctly if it is a homogeneous transform matrix (rot + trans) + Matrix4 InvertedHomogeneousTransform() const { + // Make the inverse rotation matrix + Matrix4 rinv = this->Transposed(); + rinv.M[3][0] = rinv.M[3][1] = rinv.M[3][2] = T(0); + // Make the inverse translation matrix + Vector3 tvinv(-M[0][3], -M[1][3], -M[2][3]); + Matrix4 tinv = Matrix4::Translation(tvinv); + return rinv * tinv; // "untranslate", then "unrotate" + } + + // This is more efficient than general inverse, but ONLY works + // correctly if it is a homogeneous transform matrix (rot + trans) + void InvertHomogeneousTransform() { + *this = InvertedHomogeneousTransform(); + } + + // Matrix to Euler Angles conversion + // a,b,c, are the YawPitchRoll angles to be returned + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A3 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void ToEulerAngles(T* a, T* b, T* c) const { + OVR_MATH_STATIC_ASSERT( + (A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); + + T psign = T(-1); + if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) // Determine whether even permutation + psign = T(1); + + T pm = psign * M[A1][A3]; + T singularityRadius = Math::SingularityRadius(); + if (pm < T(-1) + singularityRadius) { // South pole singularity + *a = T(0); + *b = -S * D * ((T)MATH_DOUBLE_PIOVER2); + *c = S * D * atan2(psign * M[A2][A1], M[A2][A2]); + } else if (pm > T(1) - singularityRadius) { // North pole singularity + *a = T(0); + *b = S * D * ((T)MATH_DOUBLE_PIOVER2); + *c = S * D * atan2(psign * M[A2][A1], M[A2][A2]); + } else { // Normal case (nonsingular) + *a = S * D * atan2(-psign * M[A2][A3], M[A3][A3]); + *b = S * D * asin(pm); + *c = S * D * atan2(-psign * M[A1][A2], M[A1][A1]); + } + } + + // Matrix to Euler Angles conversion + // a,b,c, are the YawPitchRoll angles to be returned + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A1 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void ToEulerAnglesABA(T* a, T* b, T* c) const { + OVR_MATH_STATIC_ASSERT(A1 != A2, "A1 != A2"); + + // Determine the axis that was not supplied + int m = 3 - A1 - A2; + + T psign = T(-1); + if ((A1 + 1) % 3 == A2) // Determine whether even permutation + psign = T(1); + + T c2 = M[A1][A1]; + T singularityRadius = Math::SingularityRadius(); + if (c2 < T(-1) + singularityRadius) { // South pole singularity + *a = T(0); + *b = S * D * ((T)MATH_DOUBLE_PI); + *c = S * D * atan2(-psign * M[A2][m], M[A2][A2]); + } else if (c2 > T(1) - singularityRadius) { // North pole singularity + *a = T(0); + *b = T(0); + *c = S * D * atan2(-psign * M[A2][m], M[A2][A2]); + } else { // Normal case (nonsingular) + *a = S * D * atan2(M[A2][A1], -psign * M[m][A1]); + *b = S * D * acos(c2); + *c = S * D * atan2(M[A1][A2], psign * M[A1][m]); + } + } + + // Creates a matrix that converts the vertices from one coordinate system + // to another. + static Matrix4 AxisConversion(const WorldAxes& to, const WorldAxes& from) { + // Holds axis values from the 'to' structure + int toArray[3] = {to.XAxis, to.YAxis, to.ZAxis}; + + // The inverse of the toArray + int inv[4]; + inv[0] = inv[abs(to.XAxis)] = 0; + inv[abs(to.YAxis)] = 1; + inv[abs(to.ZAxis)] = 2; + + Matrix4 m(0, 0, 0, 0, 0, 0, 0, 0, 0); + + // Only three values in the matrix need to be changed to 1 or -1. + m.M[inv[abs(from.XAxis)]][0] = T(from.XAxis / toArray[inv[abs(from.XAxis)]]); + m.M[inv[abs(from.YAxis)]][1] = T(from.YAxis / toArray[inv[abs(from.YAxis)]]); + m.M[inv[abs(from.ZAxis)]][2] = T(from.ZAxis / toArray[inv[abs(from.ZAxis)]]); + return m; + } + + // Creates a matrix for translation by vector + static Matrix4 Translation(const Vector3& v) { + Matrix4 t; + t.M[0][3] = v.x; + t.M[1][3] = v.y; + t.M[2][3] = v.z; + return t; + } + + // Creates a matrix for translation by vector + static Matrix4 Translation(T x, T y, T z = T(0)) { + Matrix4 t; + t.M[0][3] = x; + t.M[1][3] = y; + t.M[2][3] = z; + return t; + } + + // Sets the translation part + void SetTranslation(const Vector3& v) { + M[0][3] = v.x; + M[1][3] = v.y; + M[2][3] = v.z; + } + + Vector3 GetTranslation() const { + return Vector3(M[0][3], M[1][3], M[2][3]); + } + + // Creates a matrix for scaling by vector + static Matrix4 Scaling(const Vector3& v) { + Matrix4 t; + t.M[0][0] = v.x; + t.M[1][1] = v.y; + t.M[2][2] = v.z; + return t; + } + + // Creates a matrix for scaling by vector + static Matrix4 Scaling(T x, T y, T z) { + Matrix4 t; + t.M[0][0] = x; + t.M[1][1] = y; + t.M[2][2] = z; + return t; + } + + // Creates a matrix for scaling by constant + static Matrix4 Scaling(T s) { + Matrix4 t; + t.M[0][0] = s; + t.M[1][1] = s; + t.M[2][2] = s; + return t; + } + + // Simple L1 distance in R^12 + T Distance(const Matrix4& m2) const { + T d = fabs(M[0][0] - m2.M[0][0]) + fabs(M[0][1] - m2.M[0][1]); + d += fabs(M[0][2] - m2.M[0][2]) + fabs(M[0][3] - m2.M[0][3]); + d += fabs(M[1][0] - m2.M[1][0]) + fabs(M[1][1] - m2.M[1][1]); + d += fabs(M[1][2] - m2.M[1][2]) + fabs(M[1][3] - m2.M[1][3]); + d += fabs(M[2][0] - m2.M[2][0]) + fabs(M[2][1] - m2.M[2][1]); + d += fabs(M[2][2] - m2.M[2][2]) + fabs(M[2][3] - m2.M[2][3]); + d += fabs(M[3][0] - m2.M[3][0]) + fabs(M[3][1] - m2.M[3][1]); + d += fabs(M[3][2] - m2.M[3][2]) + fabs(M[3][3] - m2.M[3][3]); + return d; + } + + // Creates a rotation matrix rotating around the X axis by 'angle' radians. + // Just for quick testing. Not for final API. Need to remove case. + static Matrix4 RotationAxis(Axis A, T angle, RotateDirection d, HandedSystem s) { + T sina = s * d * sin(angle); + T cosa = cos(angle); + + switch (A) { + case Axis_X: + return Matrix4(1, 0, 0, 0, cosa, -sina, 0, sina, cosa); + case Axis_Y: + return Matrix4(cosa, 0, sina, 0, 1, 0, -sina, 0, cosa); + case Axis_Z: + return Matrix4(cosa, -sina, 0, sina, cosa, 0, 0, 0, 1); + default: + return Matrix4(); + } + } + + // Creates a rotation matrix rotating around the X axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationX(T angle) { + T sina = sin(angle); + T cosa = cos(angle); + return Matrix4(1, 0, 0, 0, cosa, -sina, 0, sina, cosa); + } + + // Creates a rotation matrix rotating around the Y axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationY(T angle) { + T sina = (T)sin(angle); + T cosa = (T)cos(angle); + return Matrix4(cosa, 0, sina, 0, 1, 0, -sina, 0, cosa); + } + + // Creates a rotation matrix rotating around the Z axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationZ(T angle) { + T sina = sin(angle); + T cosa = cos(angle); + return Matrix4(cosa, -sina, 0, sina, cosa, 0, 0, 0, 1); + } + + // LookAtRH creates a View transformation matrix for right-handed coordinate system. + // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' + // specifying the up vector. The resulting matrix should be used with PerspectiveRH + // projection. + static Matrix4 LookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up) { + Vector3 z = (eye - at).Normalized(); // Forward + Vector3 x = up.Cross(z).Normalized(); // Right + Vector3 y = z.Cross(x); + + Matrix4 m( + x.x, + x.y, + x.z, + -(x.Dot(eye)), + y.x, + y.y, + y.z, + -(y.Dot(eye)), + z.x, + z.y, + z.z, + -(z.Dot(eye)), + 0, + 0, + 0, + 1); + return m; + } + + // LookAtLH creates a View transformation matrix for left-handed coordinate system. + // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' + // specifying the up vector. + static Matrix4 LookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up) { + Vector3 z = (at - eye).Normalized(); // Forward + Vector3 x = up.Cross(z).Normalized(); // Right + Vector3 y = z.Cross(x); + + Matrix4 m( + x.x, + x.y, + x.z, + -(x.Dot(eye)), + y.x, + y.y, + y.z, + -(y.Dot(eye)), + z.x, + z.y, + z.z, + -(z.Dot(eye)), + 0, + 0, + 0, + 1); + return m; + } + + // PerspectiveRH creates a right-handed perspective projection matrix that can be + // used with the Oculus sample renderer. + // yfov - Specifies vertical field of view in radians. + // aspect - Screen aspect ration, which is usually width/height for square pixels. + // Note that xfov = yfov * aspect. + // znear - Absolute value of near Z clipping clipping range. + // zfar - Absolute value of far Z clipping clipping range (larger then near). + // Even though RHS usually looks in the direction of negative Z, positive values + // are expected for znear and zfar. + static Matrix4 PerspectiveRH(T yfov, T aspect, T znear, T zfar) { + Matrix4 m; + T tanHalfFov = (T)tan(yfov * T(0.5)); + + m.M[0][0] = T(1) / (aspect * tanHalfFov); + m.M[1][1] = T(1) / tanHalfFov; + m.M[2][2] = zfar / (znear - zfar); + m.M[3][2] = T(-1); + m.M[2][3] = (zfar * znear) / (znear - zfar); + m.M[3][3] = T(0); + + // Note: Post-projection matrix result assumes Left-Handed coordinate system, + // with Y up, X right and Z forward. This supports positive z-buffer values. + // This is the case even for RHS coordinate input. + return m; + } + + // PerspectiveLH creates a left-handed perspective projection matrix that can be + // used with the Oculus sample renderer. + // yfov - Specifies vertical field of view in radians. + // aspect - Screen aspect ration, which is usually width/height for square pixels. + // Note that xfov = yfov * aspect. + // znear - Absolute value of near Z clipping clipping range. + // zfar - Absolute value of far Z clipping clipping range (larger then near). + static Matrix4 PerspectiveLH(T yfov, T aspect, T znear, T zfar) { + Matrix4 m; + T tanHalfFov = (T)tan(yfov * T(0.5)); + + m.M[0][0] = T(1) / (aspect * tanHalfFov); + m.M[1][1] = T(1) / tanHalfFov; + // m.M[2][2] = zfar / (znear - zfar); + m.M[2][2] = zfar / (zfar - znear); + m.M[3][2] = T(-1); + m.M[2][3] = (zfar * znear) / (znear - zfar); + m.M[3][3] = T(0); + + // Note: Post-projection matrix result assumes Left-Handed coordinate system, + // with Y up, X right and Z forward. This supports positive z-buffer values. + // This is the case even for RHS coordinate input. + return m; + } + + static Matrix4 Ortho2D(T w, T h) { + Matrix4 m; + m.M[0][0] = T(2.0) / w; + m.M[1][1] = T(-2.0) / h; + m.M[0][3] = T(-1.0); + m.M[1][3] = T(1.0); + m.M[2][2] = T(0); + return m; + } +}; - // Vector cross product as a premultiply matrix: - // L.Cross(R) = RightCrossAsMatrix(R) * L - static Matrix3 RightCrossAsMatrix(const Vector3& R) - { - return Matrix3( - T(0), +R.z, -R.y, - -R.z, T(0), +R.x, - +R.y, -R.x, T(0)); - } +typedef Matrix4 Matrix4f; +typedef Matrix4 Matrix4d; - // Angle in radians of a rotation matrix - // Uses identity trace(a) = 2*cos(theta) + 1 - T Angle() const - { - return Acos((Trace() - T(1)) * T(0.5)); - } +//------------------------------------------------------------------------------------- +// ***** Matrix3 +// +// Matrix3 is a 3x3 matrix used for representing a rotation matrix. +// The matrix is stored in row-major order in memory, meaning that values +// of the first row are stored before the next one. +// +// The arrangement of the matrix is chosen to be in Right-Handed +// coordinate system and counterclockwise rotations when looking down +// the axis +// +// Transformation Order: +// - Transformations are applied from right to left, so the expression +// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, +// followed by M2 and M1. +// +// Coordinate system: Right Handed +// +// Rotations: Counterclockwise when looking down the axis. All angles are in radians. - // Angle in radians between two rotation matrices - T Angle(const Matrix3& b) const - { - // Compute trace of (this->Transposed() * b) - // This works out to sum of products of elements. - T trace = T(0); - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - trace += M[i][j] * b.M[i][j]; - } +template +class Matrix3 { + public: + typedef T ElementType; + static const size_t Dimension = 3; + + T M[3][3]; + + enum NoInitType { NoInit }; + + // Construct with no memory initialization. + Matrix3(NoInitType) {} + + // By default, we construct identity matrix. + Matrix3() { + M[0][0] = M[1][1] = M[2][2] = T(1); + M[0][1] = M[1][0] = M[2][0] = T(0); + M[0][2] = M[1][2] = M[2][1] = T(0); + } + + Matrix3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33) { + M[0][0] = m11; + M[0][1] = m12; + M[0][2] = m13; + M[1][0] = m21; + M[1][1] = m22; + M[1][2] = m23; + M[2][0] = m31; + M[2][1] = m32; + M[2][2] = m33; + } + + // Construction from X, Y, Z basis vectors + Matrix3(const Vector3& xBasis, const Vector3& yBasis, const Vector3& zBasis) { + M[0][0] = xBasis.x; + M[0][1] = yBasis.x; + M[0][2] = zBasis.x; + M[1][0] = xBasis.y; + M[1][1] = yBasis.y; + M[1][2] = zBasis.y; + M[2][0] = xBasis.z; + M[2][1] = yBasis.z; + M[2][2] = zBasis.z; + } + + explicit Matrix3(const Quat& q) { + OVR_MATH_ASSERT(q.IsNormalized()); // If this fires, caller has a quat math bug + const T tx = q.x + q.x, ty = q.y + q.y, tz = q.z + q.z; + const T twx = q.w * tx, twy = q.w * ty, twz = q.w * tz; + const T txx = q.x * tx, txy = q.x * ty, txz = q.x * tz; + const T tyy = q.y * ty, tyz = q.y * tz, tzz = q.z * tz; + M[0][0] = T(1) - (tyy + tzz); + M[0][1] = txy - twz; + M[0][2] = txz + twy; + M[1][0] = txy + twz; + M[1][1] = T(1) - (txx + tzz); + M[1][2] = tyz - twx; + M[2][0] = txz - twy; + M[2][1] = tyz + twx; + M[2][2] = T(1) - (txx + tyy); + } + + inline explicit Matrix3(T s) { + M[0][0] = M[1][1] = M[2][2] = s; + M[0][1] = M[0][2] = M[1][0] = M[1][2] = M[2][0] = M[2][1] = T(0); + } + + Matrix3(T m11, T m22, T m33) { + M[0][0] = m11; + M[0][1] = T(0); + M[0][2] = T(0); + M[1][0] = T(0); + M[1][1] = m22; + M[1][2] = T(0); + M[2][0] = T(0); + M[2][1] = T(0); + M[2][2] = m33; + } + + explicit Matrix3(const Matrix3::OtherFloatType>& src) { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] = (T)src.M[i][j]; + } + + // C-interop support. + Matrix3(const typename CompatibleTypes>::Type& s) { + OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix3), "sizeof(s) == sizeof(Matrix3)"); + memcpy(M, s.M, sizeof(M)); + } + + operator const typename CompatibleTypes>::Type() const { + typename CompatibleTypes>::Type result; + OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix3), "sizeof(result) == sizeof(Matrix3)"); + memcpy(result.M, M, sizeof(M)); + return result; + } + + T operator()(int i, int j) const { + return M[i][j]; + } + T& operator()(int i, int j) { + return M[i][j]; + } + + void ToString(char* dest, size_t destsize) const { + size_t pos = 0; + for (int r = 0; r < 3; r++) { + for (int c = 0; c < 3; c++) + pos += OVRMath_sprintf(dest + pos, destsize - pos, "%g ", M[r][c]); + } + } + + static Matrix3 FromString(const char* src) { + Matrix3 result; + if (src) { + for (int r = 0; r < 3; r++) { + for (int c = 0; c < 3; c++) { + result.M[r][c] = (T)atof(src); + while (*src && *src != ' ') + src++; + while (*src && *src == ' ') + src++; } - return Acos((trace - T(1)) * T(0.5)); - } + } + } + return result; + } + + static Matrix3 Identity() { + return Matrix3(); + } + + void SetIdentity() { + M[0][0] = M[1][1] = M[2][2] = T(1); + M[0][1] = M[1][0] = M[2][0] = T(0); + M[0][2] = M[1][2] = M[2][1] = T(0); + } + + static Matrix3 Diagonal(T m00, T m11, T m22) { + return Matrix3(m00, 0, 0, 0, m11, 0, 0, 0, m22); + } + static Matrix3 Diagonal(const Vector3& v) { + return Diagonal(v.x, v.y, v.z); + } + + T Trace() const { + return M[0][0] + M[1][1] + M[2][2]; + } + + bool operator==(const Matrix3& b) const { + bool isEqual = true; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + isEqual &= (M[i][j] == b.M[i][j]); + } + + return isEqual; + } + + Matrix3 operator+(const Matrix3& b) const { + Matrix3 result(*this); + result += b; + return result; + } + + Matrix3& operator+=(const Matrix3& b) { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] += b.M[i][j]; + return *this; + } + + void operator=(const Matrix3& b) { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] = b.M[i][j]; + } + + Matrix3 operator-(const Matrix3& b) const { + Matrix3 result(*this); + result -= b; + return result; + } + + Matrix3& operator-=(const Matrix3& b) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + M[i][j] -= b.M[i][j]; + } + + return *this; + } + + // Multiplies two matrices into destination with minimum copying. + static Matrix3& Multiply(Matrix3* d, const Matrix3& a, const Matrix3& b) { + OVR_MATH_ASSERT((d != &a) && (d != &b)); + int i = 0; + do { + d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0]; + d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1]; + d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2]; + } while ((++i) < 3); + + return *d; + } + + Matrix3 operator*(const Matrix3& b) const { + Matrix3 result(Matrix3::NoInit); + Multiply(&result, *this, b); + return result; + } + + Matrix3& operator*=(const Matrix3& b) { + return Multiply(this, Matrix3(*this), b); + } + + Matrix3 operator*(T s) const { + Matrix3 result(*this); + result *= s; + return result; + } + + Matrix3& operator*=(T s) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + M[i][j] *= s; + } + + return *this; + } + + Vector3 operator*(const Vector3& b) const { + Vector3 result; + result.x = M[0][0] * b.x + M[0][1] * b.y + M[0][2] * b.z; + result.y = M[1][0] * b.x + M[1][1] * b.y + M[1][2] * b.z; + result.z = M[2][0] * b.x + M[2][1] * b.y + M[2][2] * b.z; + + return result; + } + + Matrix3 operator/(T s) const { + Matrix3 result(*this); + result /= s; + return result; + } + + Matrix3& operator/=(T s) { + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + M[i][j] /= s; + } + + return *this; + } + + Vector2 Transform(const Vector2& v) const { + const T rcpZ = T(1) / (M[2][0] * v.x + M[2][1] * v.y + M[2][2]); + return Vector2( + (M[0][0] * v.x + M[0][1] * v.y + M[0][2]) * rcpZ, + (M[1][0] * v.x + M[1][1] * v.y + M[1][2]) * rcpZ); + } + + Vector3 Transform(const Vector3& v) const { + return Vector3( + M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z, + M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z, + M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z); + } + + Matrix3 Transposed() const { + return Matrix3(M[0][0], M[1][0], M[2][0], M[0][1], M[1][1], M[2][1], M[0][2], M[1][2], M[2][2]); + } + + void Transpose() { + *this = Transposed(); + } + + T SubDet(const size_t* rows, const size_t* cols) const { + return M[rows[0]][cols[0]] * + (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) - + M[rows[0]][cols[1]] * + (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) + + M[rows[0]][cols[2]] * + (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); + } + + // M += a*b.t() + inline void Rank1Add(const Vector3& a, const Vector3& b) { + M[0][0] += a.x * b.x; + M[0][1] += a.x * b.y; + M[0][2] += a.x * b.z; + M[1][0] += a.y * b.x; + M[1][1] += a.y * b.y; + M[1][2] += a.y * b.z; + M[2][0] += a.z * b.x; + M[2][1] += a.z * b.y; + M[2][2] += a.z * b.z; + } + + // M -= a*b.t() + inline void Rank1Sub(const Vector3& a, const Vector3& b) { + M[0][0] -= a.x * b.x; + M[0][1] -= a.x * b.y; + M[0][2] -= a.x * b.z; + M[1][0] -= a.y * b.x; + M[1][1] -= a.y * b.y; + M[1][2] -= a.y * b.z; + M[2][0] -= a.z * b.x; + M[2][1] -= a.z * b.y; + M[2][2] -= a.z * b.z; + } + + inline Vector3 Col(int c) const { + return Vector3(M[0][c], M[1][c], M[2][c]); + } + + inline Vector3 Row(int r) const { + return Vector3(M[r][0], M[r][1], M[r][2]); + } + + inline Vector3 GetColumn(int c) const { + return Vector3(M[0][c], M[1][c], M[2][c]); + } + + inline Vector3 GetRow(int r) const { + return Vector3(M[r][0], M[r][1], M[r][2]); + } + + inline void SetColumn(int c, const Vector3& v) { + M[0][c] = v.x; + M[1][c] = v.y; + M[2][c] = v.z; + } + + inline void SetRow(int r, const Vector3& v) { + M[r][0] = v.x; + M[r][1] = v.y; + M[r][2] = v.z; + } + + inline T Determinant() const { + const Matrix3& m = *this; + T d; + + d = m.M[0][0] * (m.M[1][1] * m.M[2][2] - m.M[1][2] * m.M[2][1]); + d -= m.M[0][1] * (m.M[1][0] * m.M[2][2] - m.M[1][2] * m.M[2][0]); + d += m.M[0][2] * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]); + + return d; + } + + inline Matrix3 Inverse() const { + Matrix3 a; + const Matrix3& m = *this; + T d = Determinant(); + + OVR_MATH_ASSERT(d != 0); + T s = T(1) / d; + + a.M[0][0] = s * (m.M[1][1] * m.M[2][2] - m.M[1][2] * m.M[2][1]); + a.M[1][0] = s * (m.M[1][2] * m.M[2][0] - m.M[1][0] * m.M[2][2]); + a.M[2][0] = s * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]); + + a.M[0][1] = s * (m.M[0][2] * m.M[2][1] - m.M[0][1] * m.M[2][2]); + a.M[1][1] = s * (m.M[0][0] * m.M[2][2] - m.M[0][2] * m.M[2][0]); + a.M[2][1] = s * (m.M[0][1] * m.M[2][0] - m.M[0][0] * m.M[2][1]); + + a.M[0][2] = s * (m.M[0][1] * m.M[1][2] - m.M[0][2] * m.M[1][1]); + a.M[1][2] = s * (m.M[0][2] * m.M[1][0] - m.M[0][0] * m.M[1][2]); + a.M[2][2] = s * (m.M[0][0] * m.M[1][1] - m.M[0][1] * m.M[1][0]); + + return a; + } + + // Outer Product of two column vectors: a * b.Transpose() + static Matrix3 OuterProduct(const Vector3& a, const Vector3& b) { + return Matrix3( + a.x * b.x, + a.x * b.y, + a.x * b.z, + a.y * b.x, + a.y * b.y, + a.y * b.z, + a.z * b.x, + a.z * b.y, + a.z * b.z); + } + + // Vector cross product as a premultiply matrix: + // L.Cross(R) = LeftCrossAsMatrix(L) * R + static Matrix3 LeftCrossAsMatrix(const Vector3& L) { + return Matrix3(T(0), -L.z, +L.y, +L.z, T(0), -L.x, -L.y, +L.x, T(0)); + } + + // Vector cross product as a premultiply matrix: + // L.Cross(R) = RightCrossAsMatrix(R) * L + static Matrix3 RightCrossAsMatrix(const Vector3& R) { + return Matrix3(T(0), +R.z, -R.y, -R.z, T(0), +R.x, +R.y, -R.x, T(0)); + } + + // Angle in radians of a rotation matrix + // Uses identity trace(a) = 2*cos(theta) + 1 + T Angle() const { + return Acos((Trace() - T(1)) * T(0.5)); + } + + // Angle in radians between two rotation matrices + T Angle(const Matrix3& b) const { + // Compute trace of (this->Transposed() * b) + // This works out to sum of products of elements. + T trace = T(0); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + trace += M[i][j] * b.M[i][j]; + } + } + return Acos((trace - T(1)) * T(0.5)); + } }; -typedef Matrix3 Matrix3f; +typedef Matrix3 Matrix3f; typedef Matrix3 Matrix3d; //------------------------------------------------------------------------------------- // ***** Matrix2 -template -class Matrix2 -{ -public: - typedef T ElementType; - static const size_t Dimension = 2; - - T M[2][2]; - - enum NoInitType { NoInit }; - - // Construct with no memory initialization. - Matrix2(NoInitType) { } - - // By default, we construct identity matrix. - Matrix2() - { - M[0][0] = M[1][1] = T(1); - M[0][1] = M[1][0] = T(0); - } - - Matrix2(T m11, T m12, - T m21, T m22) - { - M[0][0] = m11; M[0][1] = m12; - M[1][0] = m21; M[1][1] = m22; - } - - // Construction from X, Y basis vectors - Matrix2(const Vector2& xBasis, const Vector2& yBasis) - { - M[0][0] = xBasis.x; M[0][1] = yBasis.x; - M[1][0] = xBasis.y; M[1][1] = yBasis.y; - } - - explicit Matrix2(T s) - { - M[0][0] = M[1][1] = s; - M[0][1] = M[1][0] = T(0); - } - - Matrix2(T m11, T m22) - { - M[0][0] = m11; M[0][1] = T(0); - M[1][0] = T(0); M[1][1] = m22; - } - - explicit Matrix2(const Matrix2::OtherFloatType> &src) - { - M[0][0] = T(src.M[0][0]); M[0][1] = T(src.M[0][1]); - M[1][0] = T(src.M[1][0]); M[1][1] = T(src.M[1][1]); - } - - // C-interop support - Matrix2(const typename CompatibleTypes >::Type& s) - { - OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix2), "sizeof(s) == sizeof(Matrix2)"); - memcpy(M, s.M, sizeof(M)); - } - - operator const typename CompatibleTypes >::Type() const - { - typename CompatibleTypes >::Type result; - OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix2), "sizeof(result) == sizeof(Matrix2)"); - memcpy(result.M, M, sizeof(M)); - return result; - } - - T operator()(int i, int j) const { return M[i][j]; } - T& operator()(int i, int j) { return M[i][j]; } - const T* operator[](int i) const { return M[i]; } - T* operator[](int i) { return M[i]; } - - static Matrix2 Identity() { return Matrix2(); } - - void SetIdentity() - { - M[0][0] = M[1][1] = T(1); - M[0][1] = M[1][0] = T(0); - } - - static Matrix2 Diagonal(T m00, T m11) - { - return Matrix2(m00, m11); - } - static Matrix2 Diagonal(const Vector2& v) { return Matrix2(v.x, v.y); } - - T Trace() const { return M[0][0] + M[1][1]; } - - bool operator== (const Matrix2& b) const - { - return M[0][0] == b.M[0][0] && M[0][1] == b.M[0][1] && - M[1][0] == b.M[1][0] && M[1][1] == b.M[1][1]; - } - - Matrix2 operator+ (const Matrix2& b) const - { - return Matrix2(M[0][0] + b.M[0][0], M[0][1] + b.M[0][1], - M[1][0] + b.M[1][0], M[1][1] + b.M[1][1]); - } - - Matrix2& operator+= (const Matrix2& b) - { - M[0][0] += b.M[0][0]; M[0][1] += b.M[0][1]; - M[1][0] += b.M[1][0]; M[1][1] += b.M[1][1]; - return *this; - } - - void operator= (const Matrix2& b) - { - M[0][0] = b.M[0][0]; M[0][1] = b.M[0][1]; - M[1][0] = b.M[1][0]; M[1][1] = b.M[1][1]; - } - - Matrix2 operator- (const Matrix2& b) const - { - return Matrix2(M[0][0] - b.M[0][0], M[0][1] - b.M[0][1], - M[1][0] - b.M[1][0], M[1][1] - b.M[1][1]); - } - - Matrix2& operator-= (const Matrix2& b) - { - M[0][0] -= b.M[0][0]; M[0][1] -= b.M[0][1]; - M[1][0] -= b.M[1][0]; M[1][1] -= b.M[1][1]; - return *this; - } - - Matrix2 operator* (const Matrix2& b) const - { - return Matrix2(M[0][0] * b.M[0][0] + M[0][1] * b.M[1][0], M[0][0] * b.M[0][1] + M[0][1] * b.M[1][1], - M[1][0] * b.M[0][0] + M[1][1] * b.M[1][0], M[1][0] * b.M[0][1] + M[1][1] * b.M[1][1]); - } - - Matrix2& operator*= (const Matrix2& b) - { - *this = *this * b; - return *this; - } - - Matrix2 operator* (T s) const - { - return Matrix2(M[0][0] * s, M[0][1] * s, - M[1][0] * s, M[1][1] * s); - } - - Matrix2& operator*= (T s) - { - M[0][0] *= s; M[0][1] *= s; - M[1][0] *= s; M[1][1] *= s; - return *this; - } - - Matrix2 operator/ (T s) const - { - return *this * (T(1) / s); - } - - Matrix2& operator/= (T s) - { - return *this *= (T(1) / s); - } - - Vector2 operator* (const Vector2 &b) const - { - return Vector2(M[0][0] * b.x + M[0][1] * b.y, - M[1][0] * b.x + M[1][1] * b.y); - } - - Vector2 Transform(const Vector2& v) const - { - return Vector2(M[0][0] * v.x + M[0][1] * v.y, - M[1][0] * v.x + M[1][1] * v.y); - } - - Matrix2 Transposed() const - { - return Matrix2(M[0][0], M[1][0], - M[0][1], M[1][1]); - } - - void Transpose() - { - OVRMath_Swap(M[1][0], M[0][1]); - } - - Vector2 GetColumn(int c) const - { - return Vector2(M[0][c], M[1][c]); - } - - Vector2 GetRow(int r) const - { - return Vector2(M[r][0], M[r][1]); - } - - void SetColumn(int c, const Vector2& v) - { - M[0][c] = v.x; - M[1][c] = v.y; - } - - void SetRow(int r, const Vector2& v) - { - M[r][0] = v.x; - M[r][1] = v.y; - } - - T Determinant() const - { - return M[0][0] * M[1][1] - M[0][1] * M[1][0]; - } - - Matrix2 Inverse() const - { - T rcpDet = T(1) / Determinant(); - return Matrix2( M[1][1] * rcpDet, -M[0][1] * rcpDet, - -M[1][0] * rcpDet, M[0][0] * rcpDet); - } - - // Outer Product of two column vectors: a * b.Transpose() - static Matrix2 OuterProduct(const Vector2& a, const Vector2& b) - { - return Matrix2(a.x*b.x, a.x*b.y, - a.y*b.x, a.y*b.y); - } - - // Angle in radians between two rotation matrices - T Angle(const Matrix2& b) const - { - const Matrix2& a = *this; - return Acos(a(0, 0)*b(0, 0) + a(1, 0)*b(1, 0)); - } +template +class Matrix2 { + public: + typedef T ElementType; + static const size_t Dimension = 2; + + T M[2][2]; + + enum NoInitType { NoInit }; + + // Construct with no memory initialization. + Matrix2(NoInitType) {} + + // By default, we construct identity matrix. + Matrix2() { + M[0][0] = M[1][1] = T(1); + M[0][1] = M[1][0] = T(0); + } + + Matrix2(T m11, T m12, T m21, T m22) { + M[0][0] = m11; + M[0][1] = m12; + M[1][0] = m21; + M[1][1] = m22; + } + + // Construction from X, Y basis vectors + Matrix2(const Vector2& xBasis, const Vector2& yBasis) { + M[0][0] = xBasis.x; + M[0][1] = yBasis.x; + M[1][0] = xBasis.y; + M[1][1] = yBasis.y; + } + + explicit Matrix2(T s) { + M[0][0] = M[1][1] = s; + M[0][1] = M[1][0] = T(0); + } + + Matrix2(T m11, T m22) { + M[0][0] = m11; + M[0][1] = T(0); + M[1][0] = T(0); + M[1][1] = m22; + } + + explicit Matrix2(const Matrix2::OtherFloatType>& src) { + M[0][0] = T(src.M[0][0]); + M[0][1] = T(src.M[0][1]); + M[1][0] = T(src.M[1][0]); + M[1][1] = T(src.M[1][1]); + } + + // C-interop support + Matrix2(const typename CompatibleTypes>::Type& s) { + OVR_MATH_STATIC_ASSERT(sizeof(s) == sizeof(Matrix2), "sizeof(s) == sizeof(Matrix2)"); + memcpy(M, s.M, sizeof(M)); + } + + operator const typename CompatibleTypes>::Type() const { + typename CompatibleTypes>::Type result; + OVR_MATH_STATIC_ASSERT(sizeof(result) == sizeof(Matrix2), "sizeof(result) == sizeof(Matrix2)"); + memcpy(result.M, M, sizeof(M)); + return result; + } + + T operator()(int i, int j) const { + return M[i][j]; + } + T& operator()(int i, int j) { + return M[i][j]; + } + const T* operator[](int i) const { + return M[i]; + } + T* operator[](int i) { + return M[i]; + } + + static Matrix2 Identity() { + return Matrix2(); + } + + void SetIdentity() { + M[0][0] = M[1][1] = T(1); + M[0][1] = M[1][0] = T(0); + } + + static Matrix2 Diagonal(T m00, T m11) { + return Matrix2(m00, m11); + } + static Matrix2 Diagonal(const Vector2& v) { + return Matrix2(v.x, v.y); + } + + T Trace() const { + return M[0][0] + M[1][1]; + } + + bool operator==(const Matrix2& b) const { + return M[0][0] == b.M[0][0] && M[0][1] == b.M[0][1] && M[1][0] == b.M[1][0] && + M[1][1] == b.M[1][1]; + } + + Matrix2 operator+(const Matrix2& b) const { + return Matrix2( + M[0][0] + b.M[0][0], M[0][1] + b.M[0][1], M[1][0] + b.M[1][0], M[1][1] + b.M[1][1]); + } + + Matrix2& operator+=(const Matrix2& b) { + M[0][0] += b.M[0][0]; + M[0][1] += b.M[0][1]; + M[1][0] += b.M[1][0]; + M[1][1] += b.M[1][1]; + return *this; + } + + void operator=(const Matrix2& b) { + M[0][0] = b.M[0][0]; + M[0][1] = b.M[0][1]; + M[1][0] = b.M[1][0]; + M[1][1] = b.M[1][1]; + } + + Matrix2 operator-(const Matrix2& b) const { + return Matrix2( + M[0][0] - b.M[0][0], M[0][1] - b.M[0][1], M[1][0] - b.M[1][0], M[1][1] - b.M[1][1]); + } + + Matrix2& operator-=(const Matrix2& b) { + M[0][0] -= b.M[0][0]; + M[0][1] -= b.M[0][1]; + M[1][0] -= b.M[1][0]; + M[1][1] -= b.M[1][1]; + return *this; + } + + Matrix2 operator*(const Matrix2& b) const { + return Matrix2( + M[0][0] * b.M[0][0] + M[0][1] * b.M[1][0], + M[0][0] * b.M[0][1] + M[0][1] * b.M[1][1], + M[1][0] * b.M[0][0] + M[1][1] * b.M[1][0], + M[1][0] * b.M[0][1] + M[1][1] * b.M[1][1]); + } + + Matrix2& operator*=(const Matrix2& b) { + *this = *this * b; + return *this; + } + + Matrix2 operator*(T s) const { + return Matrix2(M[0][0] * s, M[0][1] * s, M[1][0] * s, M[1][1] * s); + } + + Matrix2& operator*=(T s) { + M[0][0] *= s; + M[0][1] *= s; + M[1][0] *= s; + M[1][1] *= s; + return *this; + } + + Matrix2 operator/(T s) const { + return *this * (T(1) / s); + } + + Matrix2& operator/=(T s) { + return *this *= (T(1) / s); + } + + Vector2 operator*(const Vector2& b) const { + return Vector2(M[0][0] * b.x + M[0][1] * b.y, M[1][0] * b.x + M[1][1] * b.y); + } + + Vector2 Transform(const Vector2& v) const { + return Vector2(M[0][0] * v.x + M[0][1] * v.y, M[1][0] * v.x + M[1][1] * v.y); + } + + Matrix2 Transposed() const { + return Matrix2(M[0][0], M[1][0], M[0][1], M[1][1]); + } + + void Transpose() { + OVRMath_Swap(M[1][0], M[0][1]); + } + + Vector2 GetColumn(int c) const { + return Vector2(M[0][c], M[1][c]); + } + + Vector2 GetRow(int r) const { + return Vector2(M[r][0], M[r][1]); + } + + void SetColumn(int c, const Vector2& v) { + M[0][c] = v.x; + M[1][c] = v.y; + } + + void SetRow(int r, const Vector2& v) { + M[r][0] = v.x; + M[r][1] = v.y; + } + + T Determinant() const { + return M[0][0] * M[1][1] - M[0][1] * M[1][0]; + } + + Matrix2 Inverse() const { + T rcpDet = T(1) / Determinant(); + return Matrix2(M[1][1] * rcpDet, -M[0][1] * rcpDet, -M[1][0] * rcpDet, M[0][0] * rcpDet); + } + + // Outer Product of two column vectors: a * b.Transpose() + static Matrix2 OuterProduct(const Vector2& a, const Vector2& b) { + return Matrix2(a.x * b.x, a.x * b.y, a.y * b.x, a.y * b.y); + } + + // Angle in radians between two rotation matrices + T Angle(const Matrix2& b) const { + const Matrix2& a = *this; + return Acos(a(0, 0) * b(0, 0) + a(1, 0) * b(1, 0)); + } }; -typedef Matrix2 Matrix2f; +typedef Matrix2 Matrix2f; typedef Matrix2 Matrix2d; //------------------------------------------------------------------------------------- -template -class SymMat3 -{ -private: - typedef SymMat3 this_type; - -public: - typedef T Value_t; - // Upper symmetric - T v[6]; // _00 _01 _02 _11 _12 _22 - - inline SymMat3() {} - - inline explicit SymMat3(T s) - { - v[0] = v[3] = v[5] = s; - v[1] = v[2] = v[4] = T(0); - } - - inline explicit SymMat3(T a00, T a01, T a02, T a11, T a12, T a22) - { - v[0] = a00; v[1] = a01; v[2] = a02; - v[3] = a11; v[4] = a12; - v[5] = a22; - } - - // Cast to symmetric Matrix3 - operator Matrix3() const - { - return Matrix3(v[0], v[1], v[2], - v[1], v[3], v[4], - v[2], v[4], v[5]); - } - - static inline int Index(unsigned int i, unsigned int j) - { - return (i <= j) ? (3*i - i*(i+1)/2 + j) : (3*j - j*(j+1)/2 + i); - } - - inline T operator()(int i, int j) const { return v[Index(i,j)]; } - - inline T &operator()(int i, int j) { return v[Index(i,j)]; } - - inline this_type& operator+=(const this_type& b) - { - v[0]+=b.v[0]; - v[1]+=b.v[1]; - v[2]+=b.v[2]; - v[3]+=b.v[3]; - v[4]+=b.v[4]; - v[5]+=b.v[5]; - return *this; - } - - inline this_type& operator-=(const this_type& b) - { - v[0]-=b.v[0]; - v[1]-=b.v[1]; - v[2]-=b.v[2]; - v[3]-=b.v[3]; - v[4]-=b.v[4]; - v[5]-=b.v[5]; - - return *this; - } - - inline this_type& operator*=(T s) - { - v[0]*=s; - v[1]*=s; - v[2]*=s; - v[3]*=s; - v[4]*=s; - v[5]*=s; - - return *this; - } - - inline SymMat3 operator*(T s) const - { - SymMat3 d; - d.v[0] = v[0]*s; - d.v[1] = v[1]*s; - d.v[2] = v[2]*s; - d.v[3] = v[3]*s; - d.v[4] = v[4]*s; - d.v[5] = v[5]*s; - - return d; - } - - // Multiplies two matrices into destination with minimum copying. - static SymMat3& Multiply(SymMat3* d, const SymMat3& a, const SymMat3& b) - { - // _00 _01 _02 _11 _12 _22 - - d->v[0] = a.v[0] * b.v[0]; - d->v[1] = a.v[0] * b.v[1] + a.v[1] * b.v[3]; - d->v[2] = a.v[0] * b.v[2] + a.v[1] * b.v[4]; - - d->v[3] = a.v[3] * b.v[3]; - d->v[4] = a.v[3] * b.v[4] + a.v[4] * b.v[5]; - - d->v[5] = a.v[5] * b.v[5]; - - return *d; - } - - inline T Determinant() const - { - const this_type& m = *this; - T d; - - d = m(0,0) * (m(1,1)*m(2,2) - m(1,2) * m(2,1)); - d -= m(0,1) * (m(1,0)*m(2,2) - m(1,2) * m(2,0)); - d += m(0,2) * (m(1,0)*m(2,1) - m(1,1) * m(2,0)); - - return d; - } - - inline this_type Inverse() const - { - this_type a; - const this_type& m = *this; - T d = Determinant(); - - OVR_MATH_ASSERT(d != 0); - T s = T(1)/d; - - a(0,0) = s * (m(1,1) * m(2,2) - m(1,2) * m(2,1)); - - a(0,1) = s * (m(0,2) * m(2,1) - m(0,1) * m(2,2)); - a(1,1) = s * (m(0,0) * m(2,2) - m(0,2) * m(2,0)); - - a(0,2) = s * (m(0,1) * m(1,2) - m(0,2) * m(1,1)); - a(1,2) = s * (m(0,2) * m(1,0) - m(0,0) * m(1,2)); - a(2,2) = s * (m(0,0) * m(1,1) - m(0,1) * m(1,0)); - - return a; - } - - inline T Trace() const { return v[0] + v[3] + v[5]; } - - // M = a*a.t() - inline void Rank1(const Vector3 &a) - { - v[0] = a.x*a.x; v[1] = a.x*a.y; v[2] = a.x*a.z; - v[3] = a.y*a.y; v[4] = a.y*a.z; - v[5] = a.z*a.z; - } - - // M += a*a.t() - inline void Rank1Add(const Vector3 &a) - { - v[0] += a.x*a.x; v[1] += a.x*a.y; v[2] += a.x*a.z; - v[3] += a.y*a.y; v[4] += a.y*a.z; - v[5] += a.z*a.z; - } - - // M -= a*a.t() - inline void Rank1Sub(const Vector3 &a) - { - v[0] -= a.x*a.x; v[1] -= a.x*a.y; v[2] -= a.x*a.z; - v[3] -= a.y*a.y; v[4] -= a.y*a.z; - v[5] -= a.z*a.z; - } +template +class SymMat3 { + private: + typedef SymMat3 this_type; + + public: + typedef T Value_t; + // Upper symmetric + T v[6]; // _00 _01 _02 _11 _12 _22 + + inline SymMat3() {} + + inline explicit SymMat3(T s) { + v[0] = v[3] = v[5] = s; + v[1] = v[2] = v[4] = T(0); + } + + inline explicit SymMat3(T a00, T a01, T a02, T a11, T a12, T a22) { + v[0] = a00; + v[1] = a01; + v[2] = a02; + v[3] = a11; + v[4] = a12; + v[5] = a22; + } + + // Cast to symmetric Matrix3 + operator Matrix3() const { + return Matrix3(v[0], v[1], v[2], v[1], v[3], v[4], v[2], v[4], v[5]); + } + + static inline int Index(unsigned int i, unsigned int j) { + return (i <= j) ? (3 * i - i * (i + 1) / 2 + j) : (3 * j - j * (j + 1) / 2 + i); + } + + inline T operator()(int i, int j) const { + return v[Index(i, j)]; + } + + inline T& operator()(int i, int j) { + return v[Index(i, j)]; + } + + inline this_type& operator+=(const this_type& b) { + v[0] += b.v[0]; + v[1] += b.v[1]; + v[2] += b.v[2]; + v[3] += b.v[3]; + v[4] += b.v[4]; + v[5] += b.v[5]; + return *this; + } + + inline this_type& operator-=(const this_type& b) { + v[0] -= b.v[0]; + v[1] -= b.v[1]; + v[2] -= b.v[2]; + v[3] -= b.v[3]; + v[4] -= b.v[4]; + v[5] -= b.v[5]; + + return *this; + } + + inline this_type& operator*=(T s) { + v[0] *= s; + v[1] *= s; + v[2] *= s; + v[3] *= s; + v[4] *= s; + v[5] *= s; + + return *this; + } + + inline SymMat3 operator*(T s) const { + SymMat3 d; + d.v[0] = v[0] * s; + d.v[1] = v[1] * s; + d.v[2] = v[2] * s; + d.v[3] = v[3] * s; + d.v[4] = v[4] * s; + d.v[5] = v[5] * s; + + return d; + } + + // Multiplies two matrices into destination with minimum copying. + static SymMat3& Multiply(SymMat3* d, const SymMat3& a, const SymMat3& b) { + // _00 _01 _02 _11 _12 _22 + + d->v[0] = a.v[0] * b.v[0]; + d->v[1] = a.v[0] * b.v[1] + a.v[1] * b.v[3]; + d->v[2] = a.v[0] * b.v[2] + a.v[1] * b.v[4]; + + d->v[3] = a.v[3] * b.v[3]; + d->v[4] = a.v[3] * b.v[4] + a.v[4] * b.v[5]; + + d->v[5] = a.v[5] * b.v[5]; + + return *d; + } + + inline T Determinant() const { + const this_type& m = *this; + T d; + + d = m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)); + d -= m(0, 1) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)); + d += m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0)); + + return d; + } + + inline this_type Inverse() const { + this_type a; + const this_type& m = *this; + T d = Determinant(); + + OVR_MATH_ASSERT(d != 0); + T s = T(1) / d; + + a(0, 0) = s * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)); + + a(0, 1) = s * (m(0, 2) * m(2, 1) - m(0, 1) * m(2, 2)); + a(1, 1) = s * (m(0, 0) * m(2, 2) - m(0, 2) * m(2, 0)); + + a(0, 2) = s * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)); + a(1, 2) = s * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)); + a(2, 2) = s * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)); + + return a; + } + + inline T Trace() const { + return v[0] + v[3] + v[5]; + } + + // M = a*a.t() + inline void Rank1(const Vector3& a) { + v[0] = a.x * a.x; + v[1] = a.x * a.y; + v[2] = a.x * a.z; + v[3] = a.y * a.y; + v[4] = a.y * a.z; + v[5] = a.z * a.z; + } + + // M += a*a.t() + inline void Rank1Add(const Vector3& a) { + v[0] += a.x * a.x; + v[1] += a.x * a.y; + v[2] += a.x * a.z; + v[3] += a.y * a.y; + v[4] += a.y * a.z; + v[5] += a.z * a.z; + } + + // M -= a*a.t() + inline void Rank1Sub(const Vector3& a) { + v[0] -= a.x * a.x; + v[1] -= a.x * a.y; + v[2] -= a.x * a.z; + v[3] -= a.y * a.y; + v[4] -= a.y * a.z; + v[5] -= a.z * a.z; + } }; -typedef SymMat3 SymMat3f; +typedef SymMat3 SymMat3f; typedef SymMat3 SymMat3d; -template -inline Matrix3 operator*(const SymMat3& a, const SymMat3& b) -{ - #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c)) - return Matrix3( - AJB_ARBC(0,0), AJB_ARBC(0,1), AJB_ARBC(0,2), - AJB_ARBC(1,0), AJB_ARBC(1,1), AJB_ARBC(1,2), - AJB_ARBC(2,0), AJB_ARBC(2,1), AJB_ARBC(2,2)); - #undef AJB_ARBC +template +inline Matrix3 operator*(const SymMat3& a, const SymMat3& b) { +#define AJB_ARBC(r, c) (a(r, 0) * b(0, c) + a(r, 1) * b(1, c) + a(r, 2) * b(2, c)) + return Matrix3( + AJB_ARBC(0, 0), + AJB_ARBC(0, 1), + AJB_ARBC(0, 2), + AJB_ARBC(1, 0), + AJB_ARBC(1, 1), + AJB_ARBC(1, 2), + AJB_ARBC(2, 0), + AJB_ARBC(2, 1), + AJB_ARBC(2, 2)); +#undef AJB_ARBC } -template -inline Matrix3 operator*(const Matrix3& a, const SymMat3& b) -{ - #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c)) - return Matrix3( - AJB_ARBC(0,0), AJB_ARBC(0,1), AJB_ARBC(0,2), - AJB_ARBC(1,0), AJB_ARBC(1,1), AJB_ARBC(1,2), - AJB_ARBC(2,0), AJB_ARBC(2,1), AJB_ARBC(2,2)); - #undef AJB_ARBC +template +inline Matrix3 operator*(const Matrix3& a, const SymMat3& b) { +#define AJB_ARBC(r, c) (a(r, 0) * b(0, c) + a(r, 1) * b(1, c) + a(r, 2) * b(2, c)) + return Matrix3( + AJB_ARBC(0, 0), + AJB_ARBC(0, 1), + AJB_ARBC(0, 2), + AJB_ARBC(1, 0), + AJB_ARBC(1, 1), + AJB_ARBC(1, 2), + AJB_ARBC(2, 0), + AJB_ARBC(2, 1), + AJB_ARBC(2, 2)); +#undef AJB_ARBC } //------------------------------------------------------------------------------------- @@ -3519,267 +4109,404 @@ inline Matrix3 operator*(const Matrix3& a, const SymMat3& b) // Cleanly representing the algebra of 2D rotations. // The operations maintain the angle between -Pi and Pi, the same range as atan2. -template -class Angle -{ -public: - enum AngularUnits - { - Radians = 0, - Degrees = 1 - }; - - Angle() : a(0) {} - - // Fix the range to be between -Pi and Pi - Angle(T a_, AngularUnits u = Radians) : a((u == Radians) ? a_ : a_*((T)MATH_DOUBLE_DEGREETORADFACTOR)) { FixRange(); } - - T Get(AngularUnits u = Radians) const { return (u == Radians) ? a : a*((T)MATH_DOUBLE_RADTODEGREEFACTOR); } - void Set(const T& x, AngularUnits u = Radians) { a = (u == Radians) ? x : x*((T)MATH_DOUBLE_DEGREETORADFACTOR); FixRange(); } - int Sign() const { if (a == 0) return 0; else return (a > 0) ? 1 : -1; } - T Abs() const { return (a >= 0) ? a : -a; } - - bool operator== (const Angle& b) const { return a == b.a; } - bool operator!= (const Angle& b) const { return a != b.a; } -// bool operator< (const Angle& b) const { return a < a.b; } -// bool operator> (const Angle& b) const { return a > a.b; } -// bool operator<= (const Angle& b) const { return a <= a.b; } -// bool operator>= (const Angle& b) const { return a >= a.b; } -// bool operator= (const T& x) { a = x; FixRange(); } - - // These operations assume a is already between -Pi and Pi. - Angle& operator+= (const Angle& b) { a = a + b.a; FastFixRange(); return *this; } - Angle& operator+= (const T& x) { a = a + x; FixRange(); return *this; } - Angle operator+ (const Angle& b) const { Angle res = *this; res += b; return res; } - Angle operator+ (const T& x) const { Angle res = *this; res += x; return res; } - Angle& operator-= (const Angle& b) { a = a - b.a; FastFixRange(); return *this; } - Angle& operator-= (const T& x) { a = a - x; FixRange(); return *this; } - Angle operator- (const Angle& b) const { Angle res = *this; res -= b; return res; } - Angle operator- (const T& x) const { Angle res = *this; res -= x; return res; } - - T Distance(const Angle& b) { T c = fabs(a - b.a); return (c <= ((T)MATH_DOUBLE_PI)) ? c : ((T)MATH_DOUBLE_TWOPI) - c; } - -private: - - // The stored angle, which should be maintained between -Pi and Pi - T a; - - // Fixes the angle range to [-Pi,Pi], but assumes no more than 2Pi away on either side - inline void FastFixRange() - { - if (a < -((T)MATH_DOUBLE_PI)) - a += ((T)MATH_DOUBLE_TWOPI); - else if (a > ((T)MATH_DOUBLE_PI)) - a -= ((T)MATH_DOUBLE_TWOPI); - } - - // Fixes the angle range to [-Pi,Pi] for any given range, but slower then the fast method - inline void FixRange() - { - // do nothing if the value is already in the correct range, since fmod call is expensive - if (a >= -((T)MATH_DOUBLE_PI) && a <= ((T)MATH_DOUBLE_PI)) - return; - a = fmod(a,((T)MATH_DOUBLE_TWOPI)); - if (a < -((T)MATH_DOUBLE_PI)) - a += ((T)MATH_DOUBLE_TWOPI); - else if (a > ((T)MATH_DOUBLE_PI)) - a -= ((T)MATH_DOUBLE_TWOPI); - } +template +class Angle { + public: + enum AngularUnits { Radians = 0, Degrees = 1 }; + + Angle() : a(0) {} + + // Fix the range to be between -Pi and Pi + Angle(T a_, AngularUnits u = Radians) + : a((u == Radians) ? a_ : a_ * ((T)MATH_DOUBLE_DEGREETORADFACTOR)) { + FixRange(); + } + + T Get(AngularUnits u = Radians) const { + return (u == Radians) ? a : a * ((T)MATH_DOUBLE_RADTODEGREEFACTOR); + } + void Set(const T& x, AngularUnits u = Radians) { + a = (u == Radians) ? x : x * ((T)MATH_DOUBLE_DEGREETORADFACTOR); + FixRange(); + } + int Sign() const { + if (a == 0) + return 0; + else + return (a > 0) ? 1 : -1; + } + T Abs() const { + return (a >= 0) ? a : -a; + } + + bool operator==(const Angle& b) const { + return a == b.a; + } + bool operator!=(const Angle& b) const { + return a != b.a; + } + // bool operator< (const Angle& b) const { return a < a.b; } + // bool operator> (const Angle& b) const { return a > a.b; } + // bool operator<= (const Angle& b) const { return a <= a.b; } + // bool operator>= (const Angle& b) const { return a >= a.b; } + // bool operator= (const T& x) { a = x; FixRange(); } + + // These operations assume a is already between -Pi and Pi. + Angle& operator+=(const Angle& b) { + a = a + b.a; + FastFixRange(); + return *this; + } + Angle& operator+=(const T& x) { + a = a + x; + FixRange(); + return *this; + } + Angle operator+(const Angle& b) const { + Angle res = *this; + res += b; + return res; + } + Angle operator+(const T& x) const { + Angle res = *this; + res += x; + return res; + } + Angle& operator-=(const Angle& b) { + a = a - b.a; + FastFixRange(); + return *this; + } + Angle& operator-=(const T& x) { + a = a - x; + FixRange(); + return *this; + } + Angle operator-(const Angle& b) const { + Angle res = *this; + res -= b; + return res; + } + Angle operator-(const T& x) const { + Angle res = *this; + res -= x; + return res; + } + + T Distance(const Angle& b) { + T c = fabs(a - b.a); + return (c <= ((T)MATH_DOUBLE_PI)) ? c : ((T)MATH_DOUBLE_TWOPI) - c; + } + + private: + // The stored angle, which should be maintained between -Pi and Pi + T a; + + // Fixes the angle range to [-Pi,Pi], but assumes no more than 2Pi away on either side + inline void FastFixRange() { + if (a < -((T)MATH_DOUBLE_PI)) + a += ((T)MATH_DOUBLE_TWOPI); + else if (a > ((T)MATH_DOUBLE_PI)) + a -= ((T)MATH_DOUBLE_TWOPI); + } + + // Fixes the angle range to [-Pi,Pi] for any given range, but slower then the fast method + inline void FixRange() { + // do nothing if the value is already in the correct range, since fmod call is expensive + if (a >= -((T)MATH_DOUBLE_PI) && a <= ((T)MATH_DOUBLE_PI)) + return; + a = fmod(a, ((T)MATH_DOUBLE_TWOPI)); + if (a < -((T)MATH_DOUBLE_PI)) + a += ((T)MATH_DOUBLE_TWOPI); + else if (a > ((T)MATH_DOUBLE_PI)) + a -= ((T)MATH_DOUBLE_TWOPI); + } }; - -typedef Angle Anglef; +typedef Angle Anglef; typedef Angle Angled; - //------------------------------------------------------------------------------------- // ***** Plane // Consists of a normal vector and distance from the origin where the plane is located. -template -class Plane -{ -public: - Vector3 N; - T D; +template +class Plane { + public: + Vector3 N; + T D; - Plane() : D(0) {} + Plane() : D(0) {} - // Normals must already be normalized - Plane(const Vector3& n, T d) : N(n), D(d) {} - Plane(T x, T y, T z, T d) : N(x,y,z), D(d) {} + // Normals must already be normalized + Plane(const Vector3& n, T d) : N(n), D(d) {} + Plane(T x, T y, T z, T d) : N(x, y, z), D(d) {} - // construct from a point on the plane and the normal - Plane(const Vector3& p, const Vector3& n) : N(n), D(-(p * n)) {} + // construct from a point on the plane and the normal + Plane(const Vector3& p, const Vector3& n) : N(n), D(-(p.Dot(n))) {} - // Find the point to plane distance. The sign indicates what side of the plane the point is on (0 = point on plane). - T TestSide(const Vector3& p) const - { - return (N.Dot(p)) + D; - } + // Find the point to plane distance. The sign indicates what side of the plane the point is on (0 + // = point on plane). + T TestSide(const Vector3& p) const { + return (N.Dot(p)) + D; + } - Plane Flipped() const - { - return Plane(-N, -D); - } + Plane Flipped() const { + return Plane(-N, -D); + } - void Flip() - { - N = -N; - D = -D; - } + void Flip() { + N = -N; + D = -D; + } - bool operator==(const Plane& rhs) const - { - return (this->D == rhs.D && this->N == rhs.N); - } + bool operator==(const Plane& rhs) const { + return (this->D == rhs.D && this->N == rhs.N); + } }; typedef Plane Planef; typedef Plane Planed; - - - //----------------------------------------------------------------------------------- -// ***** ScaleAndOffset2D - -struct ScaleAndOffset2D -{ - Vector2f Scale; - Vector2f Offset; - - ScaleAndOffset2D(float sx = 0.0f, float sy = 0.0f, float ox = 0.0f, float oy = 0.0f) - : Scale(sx, sy), Offset(ox, oy) - { } +// ***** ScaleAndOffset + +template +struct ScaleAndOffset { + T Scale; + T Offset; + + ScaleAndOffset(float sx = 0.0f, float sy = 0.0f, float ox = 0.0f, float oy = 0.0f) + : Scale(sx, sy), Offset(ox, oy) {} + + T ApplyTo(const T& input) const { + return input * Scale + Offset; + } + + ScaleAndOffset Invert() const { + ScaleAndOffset inverted; + inverted.Scale = T(1.0f) / this->Scale; + inverted.Offset = -(this->Offset) * inverted.Scale; + return inverted; + } + + // nextSO is the other scale-offset operation that would have normally followed this scale-offset. + // Result is a single scale-offset operation that can be applied to an input instead of + // two or more separate scale-offset applications on a given Vector2f input. + // + // So this: + // ScaleAndOffset2D so1, so2, so3; // initialized to some values + // Vector2f input = Vector2f(2.0f, -1.0f); + // input = so1.ApplyTo(input); + // input = so2.ApplyTo(input); + // input = so3.ApplyTo(input); + // + // equals this: + // ScaleAndOffset2D so1, so2, so3; // initialized to some values + // so1 = so1.Combine(so2); + // so1 = so1.Combine(so3); + // Vector2f input = Vector2f(2.0f, -1.0f); + // input = so1.ApplyTo(input); + // + ScaleAndOffset Combine(const ScaleAndOffset& nextSO) const { + ScaleAndOffset retValSO; + retValSO.Offset = this->Offset * nextSO.Scale + nextSO.Offset; + retValSO.Scale = nextSO.Scale * this->Scale; + return retValSO; + } }; +typedef ScaleAndOffset ScaleAndOffset2D; +typedef ScaleAndOffset ScaleAndOffset3D; //----------------------------------------------------------------------------------- // ***** FovPort // FovPort describes Field Of View (FOV) of a viewport. -// This class has values for up, down, left and right, stored in +// This class has values for up, down, left and right, stored in // tangent of the angle units to simplify calculations. // -// As an example, for a standard 90 degree vertical FOV, we would +// As an example, for a standard 90 degree vertical FOV, we would // have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }. // // CreateFromRadians/Degrees helper functions can be used to // access FOV in different units. - // ***** FovPort -struct FovPort -{ - float UpTan; - float DownTan; - float LeftTan; - float RightTan; - - FovPort ( float sideTan = 0.0f ) : - UpTan(sideTan), DownTan(sideTan), LeftTan(sideTan), RightTan(sideTan) { } - FovPort ( float u, float d, float l, float r ) : - UpTan(u), DownTan(d), LeftTan(l), RightTan(r) { } - - // C-interop support: FovPort <-> ovrFovPort (implementation in OVR_CAPI.cpp). - FovPort(const ovrFovPort &src) - : UpTan(src.UpTan), DownTan(src.DownTan), LeftTan(src.LeftTan), RightTan(src.RightTan) - { } - - operator ovrFovPort () const - { - ovrFovPort result; - result.LeftTan = LeftTan; - result.RightTan = RightTan; - result.UpTan = UpTan; - result.DownTan = DownTan; - return result; - } - - static FovPort CreateFromRadians(float horizontalFov, float verticalFov) - { - FovPort result; - result.UpTan = tanf ( verticalFov * 0.5f ); - result.DownTan = tanf ( verticalFov * 0.5f ); - result.LeftTan = tanf ( horizontalFov * 0.5f ); - result.RightTan = tanf ( horizontalFov * 0.5f ); - return result; - } - - static FovPort CreateFromDegrees(float horizontalFovDegrees, - float verticalFovDegrees) - { - return CreateFromRadians(DegreeToRad(horizontalFovDegrees), - DegreeToRad(verticalFovDegrees)); - } +struct FovPort { + float UpTan; + float DownTan; + float LeftTan; + float RightTan; - // Get Horizontal/Vertical components of Fov in radians. - float GetVerticalFovRadians() const { return atanf(UpTan) + atanf(DownTan); } - float GetHorizontalFovRadians() const { return atanf(LeftTan) + atanf(RightTan); } - // Get Horizontal/Vertical components of Fov in degrees. - float GetVerticalFovDegrees() const { return RadToDegree(GetVerticalFovRadians()); } - float GetHorizontalFovDegrees() const { return RadToDegree(GetHorizontalFovRadians()); } + FovPort(float sideTan = 0.0f) + : UpTan(sideTan), DownTan(sideTan), LeftTan(sideTan), RightTan(sideTan) {} + FovPort(float u, float d, float l, float r) : UpTan(u), DownTan(d), LeftTan(l), RightTan(r) {} - // Compute maximum tangent value among all four sides. - float GetMaxSideTan() const - { - return OVRMath_Max(OVRMath_Max(UpTan, DownTan), OVRMath_Max(LeftTan, RightTan)); - } +#ifndef OVR_EXCLUDE_CAPI_FROM_MATH + // C-interop support. + typedef CompatibleTypes::Type CompatibleType; - static ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort tanHalfFov ) - { - float projXScale = 2.0f / ( tanHalfFov.LeftTan + tanHalfFov.RightTan ); - float projXOffset = ( tanHalfFov.LeftTan - tanHalfFov.RightTan ) * projXScale * 0.5f; - float projYScale = 2.0f / ( tanHalfFov.UpTan + tanHalfFov.DownTan ); - float projYOffset = ( tanHalfFov.UpTan - tanHalfFov.DownTan ) * projYScale * 0.5f; - - ScaleAndOffset2D result; - result.Scale = Vector2f(projXScale, projYScale); - result.Offset = Vector2f(projXOffset, projYOffset); - // Hey - why is that Y.Offset negated? - // It's because a projection matrix transforms from world coords with Y=up, - // whereas this is from NDC which is Y=down. - - return result; - } + FovPort(const CompatibleType& s) + : UpTan(s.UpTan), DownTan(s.DownTan), LeftTan(s.LeftTan), RightTan(s.RightTan) {} - // Converts Fov Tan angle units to [-1,1] render target NDC space - Vector2f TanAngleToRendertargetNDC(Vector2f const &tanEyeAngle) - { - ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov(*this); - return tanEyeAngle * eyeToSourceNDC.Scale + eyeToSourceNDC.Offset; - } + operator const CompatibleType&() const { + OVR_MATH_STATIC_ASSERT(sizeof(FovPort) == sizeof(CompatibleType), "sizeof(FovPort) failure"); + return reinterpret_cast(*this); + } +#endif - // Compute per-channel minimum and maximum of Fov. - static FovPort Min(const FovPort& a, const FovPort& b) - { - FovPort fov( OVRMath_Min( a.UpTan , b.UpTan ), - OVRMath_Min( a.DownTan , b.DownTan ), - OVRMath_Min( a.LeftTan , b.LeftTan ), - OVRMath_Min( a.RightTan, b.RightTan ) ); - return fov; - } + static FovPort CreateFromRadians(float horizontalFov, float verticalFov) { + FovPort result; + result.UpTan = tanf(verticalFov * 0.5f); + result.DownTan = tanf(verticalFov * 0.5f); + result.LeftTan = tanf(horizontalFov * 0.5f); + result.RightTan = tanf(horizontalFov * 0.5f); + return result; + } + + static FovPort CreateFromDegrees(float horizontalFovDegrees, float verticalFovDegrees) { + return CreateFromRadians(DegreeToRad(horizontalFovDegrees), DegreeToRad(verticalFovDegrees)); + } + + // Get Horizontal/Vertical components of Fov in radians. + float GetVerticalFovRadians() const { + return atanf(UpTan) + atanf(DownTan); + } + float GetHorizontalFovRadians() const { + return atanf(LeftTan) + atanf(RightTan); + } + // Get Horizontal/Vertical components of Fov in degrees. + float GetVerticalFovDegrees() const { + return RadToDegree(GetVerticalFovRadians()); + } + float GetHorizontalFovDegrees() const { + return RadToDegree(GetHorizontalFovRadians()); + } + + // Compute maximum tangent value among all four sides. + float GetMaxSideTan() const { + return OVRMath_Max(OVRMath_Max(UpTan, DownTan), OVRMath_Max(LeftTan, RightTan)); + } + + static ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov(FovPort tanHalfFov) { + float projXScale = 2.0f / (tanHalfFov.LeftTan + tanHalfFov.RightTan); + float projXOffset = (tanHalfFov.LeftTan - tanHalfFov.RightTan) * projXScale * 0.5f; + float projYScale = 2.0f / (tanHalfFov.UpTan + tanHalfFov.DownTan); + float projYOffset = (tanHalfFov.UpTan - tanHalfFov.DownTan) * projYScale * 0.5f; + + ScaleAndOffset2D result; + result.Scale = Vector2f(projXScale, projYScale); + result.Offset = Vector2f(projXOffset, projYOffset); + // Hey - why is that Y.Offset negated? + // It's because a projection matrix transforms from world coords with Y=up, + // whereas this is from NDC which is Y=down. + + return result; + } + + // Converts Fov Tan angle units to [-1,1] render target NDC space + Vector2f TanAngleToRendertargetNDC(Vector2f const& tanEyeAngle) { + ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov(*this); + return tanEyeAngle * eyeToSourceNDC.Scale + eyeToSourceNDC.Offset; + } + + // Compute per-channel minimum and maximum of Fov. + static FovPort Min(const FovPort& a, const FovPort& b) { + FovPort fov( + OVRMath_Min(a.UpTan, b.UpTan), + OVRMath_Min(a.DownTan, b.DownTan), + OVRMath_Min(a.LeftTan, b.LeftTan), + OVRMath_Min(a.RightTan, b.RightTan)); + return fov; + } + + static FovPort Max(const FovPort& a, const FovPort& b) { + FovPort fov( + OVRMath_Max(a.UpTan, b.UpTan), + OVRMath_Max(a.DownTan, b.DownTan), + OVRMath_Max(a.LeftTan, b.LeftTan), + OVRMath_Max(a.RightTan, b.RightTan)); + return fov; + } + + static FovPort Uncant(const FovPort& cantedFov, Quatf canting) { + FovPort uncantedFov = cantedFov; + + // make 3D vectors from the FovPorts projected to z=1 plane + Vector3f leftUp = Vector3f(cantedFov.LeftTan, -cantedFov.UpTan, 1.0f); + Vector3f rightUp = Vector3f(-cantedFov.RightTan, -cantedFov.UpTan, 1.0f); + Vector3f leftDown = Vector3f(cantedFov.LeftTan, cantedFov.DownTan, 1.0f); + Vector3f rightDown = Vector3f(-cantedFov.RightTan, cantedFov.DownTan, 1.0f); + + // rotate these vectors using the canting specified + leftUp = canting.Rotate(leftUp); + rightUp = canting.Rotate(rightUp); + leftDown = canting.Rotate(leftDown); + rightDown = canting.Rotate(rightDown); + + // If the z coordinates of any of the corners end up being really small or negative, then + // projection will generate extremely large or inverted frustums and we don't really want that + const float kMinValidZ = 0.01f; + + // re-project back to z=1 plane while making sure we don't generate gigantic values (hence max) + leftUp /= OVRMath_Max(leftUp.z, kMinValidZ); + rightUp /= OVRMath_Max(rightUp.z, kMinValidZ); + leftDown /= OVRMath_Max(leftDown.z, kMinValidZ); + rightDown /= OVRMath_Max(rightDown.z, kMinValidZ); + + // generate new FovTans as "bounding box" values + uncantedFov.UpTan = OVRMath_Max(-leftUp.y, -rightUp.y); + uncantedFov.DownTan = OVRMath_Max(leftDown.y, rightDown.y); + uncantedFov.LeftTan = OVRMath_Max(leftUp.x, leftDown.x); + uncantedFov.RightTan = OVRMath_Max(-rightDown.x, -rightUp.x); + + return uncantedFov; + } + + // Widens a given FovPort by specified angle in each direction + static FovPort Expand(const FovPort& inFov, float expandAngle) { + auto ClampedExpand = [expandAngle](float t) -> float { + // We don't want gigantic values coming out of this function, so we limit resulting FOV. + // Limit before calling tanf() to avoid wrap around to negative values. + const float limitFov = atanf(10.0f); + return tanf(OVRMath_Min(OVRMath_Max(atanf(t) + expandAngle, -limitFov), limitFov)); + }; - static FovPort Max(const FovPort& a, const FovPort& b) - { - FovPort fov( OVRMath_Max( a.UpTan , b.UpTan ), - OVRMath_Max( a.DownTan , b.DownTan ), - OVRMath_Max( a.LeftTan , b.LeftTan ), - OVRMath_Max( a.RightTan, b.RightTan ) ); - return fov; - } + FovPort modFov = FovPort( + ClampedExpand(inFov.UpTan), + ClampedExpand(inFov.DownTan), + ClampedExpand(inFov.LeftTan), + ClampedExpand(inFov.RightTan)); + + return modFov; + } + + template + static FovPort ScaleFovPort(const FovPort& fov, OVR::Vector2 scaleFactors) { + FovPort retFov = FovPort(fov); + retFov.LeftTan *= ((scaleFactors.x != 0.0) ? scaleFactors.x : 1.0f); + retFov.RightTan *= ((scaleFactors.x != 0.0) ? scaleFactors.x : 1.0f); + retFov.UpTan *= ((scaleFactors.y != 0.0) ? scaleFactors.y : 1.0f); + retFov.DownTan *= ((scaleFactors.y != 0.0) ? scaleFactors.y : 1.0f); + return retFov; + } }; +inline bool isNan(const Vector3d& v) { + return v.IsNan(); +} + +inline bool isNan(const Vector3f& v) { + return v.IsNan(); +} } // Namespace OVR - #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif - #endif diff --git a/ext/LibOVR/Include/Extras/OVR_StereoProjection.h b/ext/LibOVR/Include/Extras/OVR_StereoProjection.h index b4bc3bc..f6e5e45 100644 --- a/ext/LibOVR/Include/Extras/OVR_StereoProjection.h +++ b/ext/LibOVR/Include/Extras/OVR_StereoProjection.h @@ -5,18 +5,18 @@ Content : Stereo projection functions Created : November 30, 2013 Authors : Tom Fosyth -Copyright : Copyright 2014-2016 Oculus VR, LLC All Rights reserved. +Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which +Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which otherwise accompanies this software in either electronic or hard copy form. You may obtain a copy of the License at -http://www.oculusvr.com/licenses/LICENSE-3.3 +http://www.oculusvr.com/licenses/LICENSE-3.3 -Unless required by applicable law or agreed to in writing, the Oculus VR SDK +Unless required by applicable law or agreed to in writing, the Oculus VR SDK distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -27,44 +27,47 @@ limitations under the License. #ifndef OVR_StereoProjection_h #define OVR_StereoProjection_h - #include "Extras/OVR_Math.h" - namespace OVR { - //----------------------------------------------------------------------------------- // ***** Stereo Enumerations // StereoEye specifies which eye we are rendering for; it is used to // retrieve StereoEyeParams. -enum StereoEye -{ - StereoEye_Left, - StereoEye_Right, - StereoEye_Center -}; - - +enum StereoEye { StereoEye_Left, StereoEye_Right, StereoEye_Center }; //----------------------------------------------------------------------------------- // ***** Propjection functions -Matrix4f CreateProjection ( bool rightHanded, bool isOpenGL, FovPort fov, StereoEye eye, - float zNear = 0.01f, float zFar = 10000.0f, - bool flipZ = false, bool farAtInfinity = false); - -Matrix4f CreateOrthoSubProjection ( bool rightHanded, StereoEye eyeType, - float tanHalfFovX, float tanHalfFovY, - float unitsX, float unitsY, float distanceFromCamera, - float interpupillaryDistance, Matrix4f const &projection, - float zNear = 0.0f, float zFar = 0.0f, - bool flipZ = false, bool farAtInfinity = false); - -ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort fov ); - - -} //namespace OVR +Matrix4f CreateProjection( + bool rightHanded, + bool isOpenGL, + FovPort fov, + StereoEye eye, + float zNear = 0.01f, + float zFar = 10000.0f, + bool flipZ = false, + bool farAtInfinity = false); + +Matrix4f CreateOrthoSubProjection( + bool rightHanded, + StereoEye eyeType, + float tanHalfFovX, + float tanHalfFovY, + float unitsX, + float unitsY, + float distanceFromCamera, + float interpupillaryDistance, + Matrix4f const& projection, + float zNear = 0.0f, + float zFar = 0.0f, + bool flipZ = false, + bool farAtInfinity = false); + +ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov(FovPort fov); + +} // namespace OVR #endif // OVR_StereoProjection_h diff --git a/ext/LibOVR/Include/OVR_CAPI.h b/ext/LibOVR/Include/OVR_CAPI.h index b1ec3cc..39d3646 100644 --- a/ext/LibOVR/Include/OVR_CAPI.h +++ b/ext/LibOVR/Include/OVR_CAPI.h @@ -1,57 +1,61 @@ -/********************************************************************************//** -\file OVR_CAPI.h -\brief C Interface to the Oculus PC SDK tracking and rendering library. -\copyright Copyright 2014 Oculus VR, LLC All Rights reserved. -************************************************************************************/ - -#ifndef OVR_CAPI_h // We don't use version numbers within this name, as all versioned variations of this file are currently mutually exclusive. -#define OVR_CAPI_h ///< Header include guard +/************************************************************************************ + \file OVR_CAPI.h + \brief C Interface to the Oculus PC SDK tracking and rendering library. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ +// We don't use version numbers within OVR_CAPI_h, as all versioned variations +// of this file are currently mutually exclusive. +#ifndef OVR_CAPI_h +#define OVR_CAPI_h #include "OVR_CAPI_Keys.h" #include "OVR_Version.h" #include "OVR_ErrorCode.h" +#if !defined(_WIN32) +#include +#endif + + +// Turn on OpenXR support on all builds +// Note: we're not shipping the loader, only exposing xrNegotiateLoaderRuntimeInterface +#define OVR_OPENXR_SUPPORT_ENABLED #include #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable: 4324) // structure was padded due to __declspec(align()) - #pragma warning(disable: 4359) // The alignment specified for a type is less than the alignment of the type of one of its data members +#pragma warning(push) +#pragma warning(disable : 4324) // structure was padded due to __declspec(align()) +#pragma warning(disable : 4359) // The alignment specified for a type is less than the +// alignment of the type of one of its data members #endif - - //----------------------------------------------------------------------------------- // ***** OVR_OS // #if !defined(OVR_OS_WIN32) && defined(_WIN32) - #define OVR_OS_WIN32 +#define OVR_OS_WIN32 #endif #if !defined(OVR_OS_MAC) && defined(__APPLE__) - #define OVR_OS_MAC +#define OVR_OS_MAC #endif #if !defined(OVR_OS_LINUX) && defined(__linux__) - #define OVR_OS_LINUX +#define OVR_OS_LINUX #endif - - //----------------------------------------------------------------------------------- // ***** OVR_CPP // #if !defined(OVR_CPP) - #if defined(__cplusplus) - #define OVR_CPP(x) x - #else - #define OVR_CPP(x) /* Not C++ */ - #endif +#if defined(__cplusplus) +#define OVR_CPP(x) x +#else +#define OVR_CPP(x) /* Not C++ */ +#endif #endif - - //----------------------------------------------------------------------------------- // ***** OVR_CDECL @@ -59,14 +63,12 @@ /// LibOVR calling convention for 32-bit Windows builds. // #if !defined(OVR_CDECL) - #if defined(_WIN32) - #define OVR_CDECL __cdecl - #else - #define OVR_CDECL - #endif +#if defined(_WIN32) +#define OVR_CDECL __cdecl +#else +#define OVR_CDECL +#endif #endif - - //----------------------------------------------------------------------------------- // ***** OVR_EXTERN_C @@ -74,58 +76,62 @@ /// Defined as extern "C" when built from C++ code. // #if !defined(OVR_EXTERN_C) - #ifdef __cplusplus - #define OVR_EXTERN_C extern "C" - #else - #define OVR_EXTERN_C - #endif +#ifdef __cplusplus +#define OVR_EXTERN_C extern "C" +#else +#define OVR_EXTERN_C +#endif #endif - - //----------------------------------------------------------------------------------- // ***** OVR_PUBLIC_FUNCTION / OVR_PRIVATE_FUNCTION // -// OVR_PUBLIC_FUNCTION - Functions that externally visible from a shared library. Corresponds to Microsoft __dllexport. -// OVR_PUBLIC_CLASS - C++ structs and classes that are externally visible from a shared library. Corresponds to Microsoft __dllexport. -// OVR_PRIVATE_FUNCTION - Functions that are not visible outside of a shared library. They are private to the shared library. -// OVR_PRIVATE_CLASS - C++ structs and classes that are not visible outside of a shared library. They are private to the shared library. +// OVR_PUBLIC_FUNCTION - Functions that externally visible from a shared library. +// Corresponds to Microsoft __dllexport. +// OVR_PUBLIC_CLASS - C++ structs and classes that are externally visible from a +// shared library. Corresponds to Microsoft __dllexport. +// OVR_PRIVATE_FUNCTION - Functions that are not visible outside of a shared library. +// They are private to the shared library. +// OVR_PRIVATE_CLASS - C++ structs and classes that are not visible outside of a +// shared library. They are private to the shared library. // // OVR_DLL_BUILD - Used to indicate that the current compilation unit is of a shared library. -// OVR_DLL_IMPORT - Used to indicate that the current compilation unit is a user of the corresponding shared library. -// OVR_STATIC_BUILD - used to indicate that the current compilation unit is not a shared library but rather statically linked code. +// OVR_DLL_IMPORT - Used to indicate that the current compilation unit is a +// user of the corresponding shared library. +// OVR_STATIC_BUILD - used to indicate that the current compilation unit is not a +// shared library but rather statically linked code. // #if !defined(OVR_PUBLIC_FUNCTION) - #if defined(OVR_DLL_BUILD) - #if defined(_WIN32) - #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllexport) rval OVR_CDECL - #define OVR_PUBLIC_CLASS __declspec(dllexport) - #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL - #define OVR_PRIVATE_CLASS - #else - #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __attribute__((visibility("default"))) rval OVR_CDECL /* Requires GCC 4.0+ */ - #define OVR_PUBLIC_CLASS __attribute__((visibility("default"))) /* Requires GCC 4.0+ */ - #define OVR_PRIVATE_FUNCTION(rval) __attribute__((visibility("hidden"))) rval OVR_CDECL - #define OVR_PRIVATE_CLASS __attribute__((visibility("hidden"))) - #endif - #elif defined(OVR_DLL_IMPORT) - #if defined(_WIN32) - #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllimport) rval OVR_CDECL - #define OVR_PUBLIC_CLASS __declspec(dllimport) - #else - #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL - #define OVR_PUBLIC_CLASS - #endif - #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL - #define OVR_PRIVATE_CLASS - #else // OVR_STATIC_BUILD - #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL - #define OVR_PUBLIC_CLASS - #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL - #define OVR_PRIVATE_CLASS - #endif +#if defined(OVR_DLL_BUILD) +#if defined(_WIN32) +#define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllexport) rval OVR_CDECL +#define OVR_PUBLIC_CLASS __declspec(dllexport) +#define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL +#define OVR_PRIVATE_CLASS +#else +#define OVR_PUBLIC_FUNCTION(rval) \ + OVR_EXTERN_C __attribute__((visibility("default"))) rval OVR_CDECL /* Requires GCC 4.0+ */ +#define OVR_PUBLIC_CLASS __attribute__((visibility("default"))) /* Requires GCC 4.0+ */ +#define OVR_PRIVATE_FUNCTION(rval) __attribute__((visibility("hidden"))) rval OVR_CDECL +#define OVR_PRIVATE_CLASS __attribute__((visibility("hidden"))) +#endif +#elif defined(OVR_DLL_IMPORT) +#if defined(_WIN32) +#define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllimport) rval OVR_CDECL +#define OVR_PUBLIC_CLASS __declspec(dllimport) +#else +#define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL +#define OVR_PUBLIC_CLASS +#endif +#define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL +#define OVR_PRIVATE_CLASS +#else // OVR_STATIC_BUILD +#define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL +#define OVR_PUBLIC_CLASS +#define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL +#define OVR_PRIVATE_CLASS +#endif #endif - //----------------------------------------------------------------------------------- // ***** OVR_EXPORT @@ -133,30 +139,27 @@ /// Provided for backward compatibility with older versions of this library. // #if !defined(OVR_EXPORT) - #ifdef OVR_OS_WIN32 - #define OVR_EXPORT __declspec(dllexport) - #else - #define OVR_EXPORT - #endif +#ifdef OVR_OS_WIN32 +#define OVR_EXPORT __declspec(dllexport) +#else +#define OVR_EXPORT +#endif #endif - - //----------------------------------------------------------------------------------- // ***** OVR_ALIGNAS // #if !defined(OVR_ALIGNAS) - #if defined(__GNUC__) || defined(__clang__) - #define OVR_ALIGNAS(n) __attribute__((aligned(n))) - #elif defined(_MSC_VER) || defined(__INTEL_COMPILER) - #define OVR_ALIGNAS(n) __declspec(align(n)) - #elif defined(__CC_ARM) - #define OVR_ALIGNAS(n) __align(n) - #else - #error Need to define OVR_ALIGNAS - #endif +#if defined(__GNUC__) || defined(__clang__) +#define OVR_ALIGNAS(n) __attribute__((aligned(n))) +#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define OVR_ALIGNAS(n) __declspec(align(n)) +#elif defined(__CC_ARM) +#define OVR_ALIGNAS(n) __align(n) +#else +#error Need to define OVR_ALIGNAS +#endif #endif - //----------------------------------------------------------------------------------- // ***** OVR_CC_HAS_FEATURE @@ -172,13 +175,12 @@ // #endif // #if !defined(OVR_CC_HAS_FEATURE) - #if defined(__clang__) // http://clang.llvm.org/docs/LanguageExtensions.html#id2 - #define OVR_CC_HAS_FEATURE(x) __has_feature(x) - #else - #define OVR_CC_HAS_FEATURE(x) 0 - #endif +#if defined(__clang__) // http://clang.llvm.org/docs/LanguageExtensions.html#id2 +#define OVR_CC_HAS_FEATURE(x) __has_feature(x) +#else +#define OVR_CC_HAS_FEATURE(x) 0 +#endif #endif - // ------------------------------------------------------------------------ // ***** OVR_STATIC_ASSERT @@ -191,32 +193,45 @@ // OVR_STATIC_ASSERT(sizeof(int32_t) == 4, "int32_t expected to be 4 bytes."); #if !defined(OVR_STATIC_ASSERT) - #if !(defined(__cplusplus) && (__cplusplus >= 201103L)) /* Other */ && \ - !(defined(__GXX_EXPERIMENTAL_CXX0X__)) /* GCC */ && \ - !(defined(__clang__) && defined(__cplusplus) && OVR_CC_HAS_FEATURE(cxx_static_assert)) /* clang */ && \ - !(defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(__cplusplus)) /* VS2010+ */ - - #if !defined(OVR_SA_UNUSED) - #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) - #define OVR_SA_UNUSED __attribute__((unused)) - #else - #define OVR_SA_UNUSED - #endif - #define OVR_SA_PASTE(a,b) a##b - #define OVR_SA_HELP(a,b) OVR_SA_PASTE(a,b) - #endif - - #if defined(__COUNTER__) - #define OVR_STATIC_ASSERT(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __COUNTER__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED - #else - #define OVR_STATIC_ASSERT(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __LINE__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED - #endif - - #else - #define OVR_STATIC_ASSERT(expression, msg) static_assert(expression, msg) - #endif +#if !(defined(__cplusplus) && (__cplusplus >= 201103L)) /* Other */ && \ + !(defined(__GXX_EXPERIMENTAL_CXX0X__)) /* GCC */ && \ + !(defined(__clang__) && defined(__cplusplus) && \ + OVR_CC_HAS_FEATURE(cxx_static_assert)) /* clang */ \ + && !(defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(__cplusplus)) /* VS2010+ */ + +#if !defined(OVR_SA_UNUSED) +#if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) +#define OVR_SA_UNUSED __attribute__((unused)) +#else +#define OVR_SA_UNUSED +#endif +#define OVR_SA_PASTE(a, b) a##b +#define OVR_SA_HELP(a, b) OVR_SA_PASTE(a, b) +#endif + +#if defined(__COUNTER__) +#define OVR_STATIC_ASSERT(expression, msg) \ + typedef char OVR_SA_HELP(staticAssert, __COUNTER__)[((expression) != 0) ? 1 : -1] OVR_SA_UNUSED +#else +#define OVR_STATIC_ASSERT(expression, msg) \ + typedef char OVR_SA_HELP(staticAssert, __LINE__)[((expression) != 0) ? 1 : -1] OVR_SA_UNUSED +#endif + +#else +#define OVR_STATIC_ASSERT(expression, msg) static_assert(expression, msg) +#endif #endif +// OVR_STATIC_ASSERT_OFFSETOF statically asserts offsetof(Type.member) == expected_offset +#define OVR_STATIC_ASSERT_OFFSETOF(Type, member, expected_offset) \ + OVR_STATIC_ASSERT( \ + offsetof(Type, member) == (expected_offset), \ + "Expected " #Type "." #member " offset == " #expected_offset) + +// OVR_STATIC_ASSERT_SIZEOF statically asserts sizeof(Type) == expected_size +#define OVR_STATIC_ASSERT_SIZEOF(Type, expected_size) \ + OVR_STATIC_ASSERT( \ + sizeof(Type) == (expected_size), "Expected sizeof(" #Type ") == " #expected_size) //----------------------------------------------------------------------------------- // ***** Padding @@ -226,117 +241,124 @@ /// Compile-time and runtime behavior with and without this defined should be identical. /// #if !defined(OVR_UNUSED_STRUCT_PAD) - #define OVR_UNUSED_STRUCT_PAD(padName, size) char padName[size]; +#define OVR_UNUSED_STRUCT_PAD(padName, size) char padName[size]; #endif - //----------------------------------------------------------------------------------- // ***** Word Size // /// Specifies the size of a pointer on the given platform. /// #if !defined(OVR_PTR_SIZE) - #if defined(__WORDSIZE) - #define OVR_PTR_SIZE ((__WORDSIZE) / 8) - #elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || defined(__ia64__) || defined(__arch64__) || defined(__64BIT__) || defined(__Ptr_Is_64) - #define OVR_PTR_SIZE 8 - #elif defined(__CC_ARM) && (__sizeof_ptr == 8) - #define OVR_PTR_SIZE 8 - #else - #define OVR_PTR_SIZE 4 - #endif +#if defined(__WORDSIZE) +#define OVR_PTR_SIZE ((__WORDSIZE) / 8) +#elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || \ + defined(__ia64__) || defined(__arch64__) || defined(__64BIT__) || defined(__Ptr_Is_64) +#define OVR_PTR_SIZE 8 +#elif defined(__CC_ARM) && (__sizeof_ptr == 8) +#define OVR_PTR_SIZE 8 +#else +#define OVR_PTR_SIZE 4 +#endif #endif - //----------------------------------------------------------------------------------- // ***** OVR_ON32 / OVR_ON64 // #if OVR_PTR_SIZE == 8 - #define OVR_ON32(x) - #define OVR_ON64(x) x +#define OVR_ON32(x) +#define OVR_ON64(x) x #else - #define OVR_ON32(x) x - #define OVR_ON64(x) +#define OVR_ON32(x) x +#define OVR_ON64(x) #endif - //----------------------------------------------------------------------------------- // ***** ovrBool -typedef char ovrBool; ///< Boolean type -#define ovrFalse 0 ///< ovrBool value of false. -#define ovrTrue 1 ///< ovrBool value of true. +typedef char ovrBool; ///< Boolean type +#define ovrFalse 0 ///< ovrBool value of false. +#define ovrTrue 1 ///< ovrBool value of true. +//----------------------------------------------------------------------------------- +// ***** PFN_ovrVoidFunction +// +/// Defines a generic function pointer. +/// +/// \see ovr_GetInstanceProcAddr +/// +typedef void (*PFN_ovrVoidFunction)(void); //----------------------------------------------------------------------------------- // ***** Simple Math Structures +/// A RGBA color with normalized float components. +typedef struct OVR_ALIGNAS(4) ovrColorf_ { + float r, g, b, a; +} ovrColorf; + /// A 2D vector with integer components. -typedef struct OVR_ALIGNAS(4) ovrVector2i_ -{ - int x, y; +typedef struct OVR_ALIGNAS(4) ovrVector2i_ { + int x, y; } ovrVector2i; /// A 2D size with integer components. -typedef struct OVR_ALIGNAS(4) ovrSizei_ -{ - int w, h; +typedef struct OVR_ALIGNAS(4) ovrSizei_ { + int w, h; } ovrSizei; /// A 2D rectangle with a position and size. /// All components are integers. -typedef struct OVR_ALIGNAS(4) ovrRecti_ -{ - ovrVector2i Pos; - ovrSizei Size; +typedef struct OVR_ALIGNAS(4) ovrRecti_ { + ovrVector2i Pos; + ovrSizei Size; } ovrRecti; /// A quaternion rotation. -typedef struct OVR_ALIGNAS(4) ovrQuatf_ -{ - float x, y, z, w; +typedef struct OVR_ALIGNAS(4) ovrQuatf_ { + float x, y, z, w; } ovrQuatf; /// A 2D vector with float components. -typedef struct OVR_ALIGNAS(4) ovrVector2f_ -{ - float x, y; +typedef struct OVR_ALIGNAS(4) ovrVector2f_ { + float x, y; } ovrVector2f; /// A 3D vector with float components. -typedef struct OVR_ALIGNAS(4) ovrVector3f_ -{ - float x, y, z; +typedef struct OVR_ALIGNAS(4) ovrVector3f_ { + float x, y, z; } ovrVector3f; +/// A 4D vector with float components. +typedef struct OVR_ALIGNAS(4) ovrVector4f_ { + float x, y, z, w; +} ovrVector4f; + /// A 4x4 matrix with float elements. -typedef struct OVR_ALIGNAS(4) ovrMatrix4f_ -{ - float M[4][4]; +typedef struct OVR_ALIGNAS(4) ovrMatrix4f_ { + float M[4][4]; } ovrMatrix4f; - /// Position and orientation together. -typedef struct OVR_ALIGNAS(4) ovrPosef_ -{ - ovrQuatf Orientation; - ovrVector3f Position; +/// The coordinate system used is right-handed Cartesian. +typedef struct OVR_ALIGNAS(4) ovrPosef_ { + ovrQuatf Orientation; + ovrVector3f Position; } ovrPosef; /// A full pose (rigid body) configuration with first and second derivatives. /// /// Body refers to any object for which ovrPoseStatef is providing data. -/// It can be the HMD, Touch controller, sensor or something else. The context +/// It can be the HMD, Touch controller, sensor or something else. The context /// depends on the usage of the struct. -typedef struct OVR_ALIGNAS(8) ovrPoseStatef_ -{ - ovrPosef ThePose; ///< Position and orientation. - ovrVector3f AngularVelocity; ///< Angular velocity in radians per second. - ovrVector3f LinearVelocity; ///< Velocity in meters per second. - ovrVector3f AngularAcceleration; ///< Angular acceleration in radians per second per second. - ovrVector3f LinearAcceleration; ///< Acceleration in meters per second per second. - OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct pad. - double TimeInSeconds; ///< Absolute time that this pose refers to. \see ovr_GetTimeInSeconds +typedef struct OVR_ALIGNAS(8) ovrPoseStatef_ { + ovrPosef ThePose; ///< Position and orientation. + ovrVector3f AngularVelocity; ///< Angular velocity in radians per second. + ovrVector3f LinearVelocity; ///< Velocity in meters per second. + ovrVector3f AngularAcceleration; ///< Angular acceleration in radians per second per second. + ovrVector3f LinearAcceleration; ///< Acceleration in meters per second per second. + OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct pad. + double TimeInSeconds; ///< Absolute time that this pose refers to. \see ovr_GetTimeInSeconds } ovrPoseStatef; /// Describes the up, down, left, and right angles of the field of view. @@ -344,222 +366,284 @@ typedef struct OVR_ALIGNAS(8) ovrPoseStatef_ /// Field Of View (FOV) tangent of the angle units. /// \note For a standard 90 degree vertical FOV, we would /// have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }. -typedef struct OVR_ALIGNAS(4) ovrFovPort_ -{ - float UpTan; ///< The tangent of the angle between the viewing vector and the top edge of the field of view. - float DownTan; ///< The tangent of the angle between the viewing vector and the bottom edge of the field of view. - float LeftTan; ///< The tangent of the angle between the viewing vector and the left edge of the field of view. - float RightTan; ///< The tangent of the angle between the viewing vector and the right edge of the field of view. +typedef struct OVR_ALIGNAS(4) ovrFovPort_ { + float UpTan; ///< Tangent of the angle between the viewing vector and top edge of the FOV. + float DownTan; ///< Tangent of the angle between the viewing vector and bottom edge of the FOV. + float LeftTan; ///< Tangent of the angle between the viewing vector and left edge of the FOV. + float RightTan; ///< Tangent of the angle between the viewing vector and right edge of the FOV. } ovrFovPort; - //----------------------------------------------------------------------------------- // ***** HMD Types /// Enumerates all HMD types that we support. /// -/// The currently released developer kits are ovrHmd_DK1 and ovrHmd_DK2. The other enumerations are for internal use only. -typedef enum ovrHmdType_ -{ - ovrHmd_None = 0, - ovrHmd_DK1 = 3, - ovrHmd_DKHD = 4, - ovrHmd_DK2 = 6, - ovrHmd_CB = 8, - ovrHmd_Other = 9, - ovrHmd_E3_2015 = 10, - ovrHmd_ES06 = 11, - ovrHmd_ES09 = 12, - ovrHmd_ES11 = 13, - ovrHmd_CV1 = 14, - - ovrHmd_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +/// The currently released developer kits are ovrHmd_DK1 and ovrHmd_DK2. +/// The other enumerations are for internal use only. +typedef enum ovrHmdType_ { + ovrHmd_None = 0, + ovrHmd_DK1 = 3, + ovrHmd_DKHD = 4, + ovrHmd_DK2 = 6, + ovrHmd_CB = 8, + ovrHmd_Other = 9, + ovrHmd_E3_2015 = 10, + ovrHmd_ES06 = 11, + ovrHmd_ES09 = 12, + ovrHmd_ES11 = 13, + ovrHmd_CV1 = 14, + ovrHmd_RiftS = 16, + + ovrHmd_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrHmdType; - /// HMD capability bits reported by device. /// -typedef enum ovrHmdCaps_ -{ - // Read-only flags - ovrHmdCap_DebugDevice = 0x0010, ///< (read only) Specifies that the HMD is a virtual debug device. +typedef enum ovrHmdCaps_ { + // Read-only flags + /// (read only) Specifies that the HMD is a virtual debug device. + ovrHmdCap_DebugDevice = 0x0010, - ovrHmdCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t. -} ovrHmdCaps; + ovrHmdCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrHmdCaps; /// Tracking capability bits reported by the device. /// Used with ovr_GetTrackingCaps. -typedef enum ovrTrackingCaps_ -{ - ovrTrackingCap_Orientation = 0x0010, ///< Supports orientation tracking (IMU). - ovrTrackingCap_MagYawCorrection = 0x0020, ///< Supports yaw drift correction via a magnetometer or other means. - ovrTrackingCap_Position = 0x0040, ///< Supports positional tracking. - ovrTrackingCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrTrackingCaps_ { + ovrTrackingCap_Orientation = 0x0010, ///< Supports orientation tracking (IMU). + ovrTrackingCap_MagYawCorrection = 0x0020, ///< Supports yaw drift correction. + ovrTrackingCap_Position = 0x0040, ///< Supports positional tracking. + ovrTrackingCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTrackingCaps; +/// Defines the largest size for an extension name string, including the '\0' terminator. +/// +/// \see ovrExtensionProperties +/// +#define OVR_MAX_EXTENSION_NAME_SIZE 128 + +/// Describes the properties of an API extension. +/// +/// \see ovr_EnumerateInstanceExtensionProperties +/// +typedef struct ovrExtensionProperties_ { + int extensionId; // One of enum ovrExtensions or a dynamic value. + char extensionName[OVR_MAX_EXTENSION_NAME_SIZE]; + uint32_t extensionVersion; // OpenXR-like version. Version compatibility is identified by the + // extension documentation. +} ovrExtensionProperties; + +/// Optional extensions +typedef enum ovrExtensions_ { + ovrExtension_TextureLayout_Octilinear = 0, ///< Enable before first layer submission. + ovrExtension_Count, ///< \internal Sanity checking + ovrExtension_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrExtensions; /// Specifies which eye is being used for rendering. -/// This type explicitly does not include a third "NoStereo" monoscopic option, as such is -/// not required for an HMD-centered API. -typedef enum ovrEyeType_ -{ - ovrEye_Left = 0, ///< The left eye, from the viewer's perspective. - ovrEye_Right = 1, ///< The right eye, from the viewer's perspective. - ovrEye_Count = 2, ///< \internal Count of enumerated elements. - ovrEye_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +/// This type explicitly does not include a third "NoStereo" monoscopic option, +/// as such is not required for an HMD-centered API. +typedef enum ovrEyeType_ { + ovrEye_Left = 0, ///< The left eye, from the viewer's perspective. + ovrEye_Right = 1, ///< The right eye, from the viewer's perspective. + ovrEye_Count = 2, ///< \internal Count of enumerated elements. + ovrEye_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrEyeType; /// Specifies the coordinate system ovrTrackingState returns tracking poses in. /// Used with ovr_SetTrackingOriginType() -typedef enum ovrTrackingOrigin_ -{ - /// \brief Tracking system origin reported at eye (HMD) height - /// \details Prefer using this origin when your application requires - /// matching user's current physical head pose to a virtual head pose - /// without any regards to a the height of the floor. Cockpit-based, - /// or 3rd-person experiences are ideal candidates. - /// When used, all poses in ovrTrackingState are reported as an offset - /// transform from the profile calibrated or recentered HMD pose. - /// It is recommended that apps using this origin type call ovr_RecenterTrackingOrigin - /// prior to starting the VR experience, but notify the user before doing so - /// to make sure the user is in a comfortable pose, facing a comfortable - /// direction. - ovrTrackingOrigin_EyeLevel = 0, - /// \brief Tracking system origin reported at floor height - /// \details Prefer using this origin when your application requires the - /// physical floor height to match the virtual floor height, such as - /// standing experiences. - /// When used, all poses in ovrTrackingState are reported as an offset - /// transform from the profile calibrated floor pose. Calling ovr_RecenterTrackingOrigin - /// will recenter the X & Z axes as well as yaw, but the Y-axis (i.e. height) will continue - /// to be reported using the floor height as the origin for all poses. - ovrTrackingOrigin_FloorLevel = 1, - ovrTrackingOrigin_Count = 2, ///< \internal Count of enumerated elements. - ovrTrackingOrigin_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrTrackingOrigin_ { + /// \brief Tracking system origin reported at eye (HMD) height + /// \details Prefer using this origin when your application requires + /// matching user's current physical head pose to a virtual head pose + /// without any regards to a the height of the floor. Cockpit-based, + /// or 3rd-person experiences are ideal candidates. + /// When used, all poses in ovrTrackingState are reported as an offset + /// transform from the profile calibrated or recentered HMD pose. + /// It is recommended that apps using this origin type call ovr_RecenterTrackingOrigin + /// prior to starting the VR experience, but notify the user before doing so + /// to make sure the user is in a comfortable pose, facing a comfortable + /// direction. + ovrTrackingOrigin_EyeLevel = 0, + + /// \brief Tracking system origin reported at floor height + /// \details Prefer using this origin when your application requires the + /// physical floor height to match the virtual floor height, such as + /// standing experiences. + /// When used, all poses in ovrTrackingState are reported as an offset + /// transform from the profile calibrated floor pose. Calling ovr_RecenterTrackingOrigin + /// will recenter the X & Z axes as well as yaw, but the Y-axis (i.e. height) will continue + /// to be reported using the floor height as the origin for all poses. + ovrTrackingOrigin_FloorLevel = 1, + + ovrTrackingOrigin_Count = 2, ///< \internal Count of enumerated elements. + ovrTrackingOrigin_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTrackingOrigin; + /// Identifies a graphics device in a platform-specific way. /// For Windows this is a LUID type. -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrGraphicsLuid_ -{ - // Public definition reserves space for graphics API-specific implementation - char Reserved[8]; +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrGraphicsLuid_ { + // Public definition reserves space for graphics API-specific implementation + char Reserved[8]; } ovrGraphicsLuid; - /// This is a complete descriptor of the HMD. -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrHmdDesc_ -{ - ovrHmdType Type; ///< The type of HMD. - OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal struct paddding. - char ProductName[64]; ///< UTF8-encoded product identification string (e.g. "Oculus Rift DK1"). - char Manufacturer[64]; ///< UTF8-encoded HMD manufacturer identification string. - short VendorId; ///< HID (USB) vendor identifier of the device. - short ProductId; ///< HID (USB) product identifier of the device. - char SerialNumber[24]; ///< HMD serial number. - short FirmwareMajor; ///< HMD firmware major version. - short FirmwareMinor; ///< HMD firmware minor version. - unsigned int AvailableHmdCaps; ///< Capability bits described by ovrHmdCaps which the HMD currently supports. - unsigned int DefaultHmdCaps; ///< Capability bits described by ovrHmdCaps which are default for the current Hmd. - unsigned int AvailableTrackingCaps; ///< Capability bits described by ovrTrackingCaps which the system currently supports. - unsigned int DefaultTrackingCaps; ///< Capability bits described by ovrTrackingCaps which are default for the current system. - ovrFovPort DefaultEyeFov[ovrEye_Count]; ///< Defines the recommended FOVs for the HMD. - ovrFovPort MaxEyeFov[ovrEye_Count]; ///< Defines the maximum FOVs for the HMD. - ovrSizei Resolution; ///< Resolution of the full HMD screen (both eyes) in pixels. - float DisplayRefreshRate; ///< Nominal refresh rate of the display in cycles per second at the time of HMD creation. - OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad1, 4)) ///< \internal struct paddding. +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrHmdDesc_ { + ovrHmdType Type; ///< The type of HMD. + OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal struct padding. + char ProductName[64]; ///< UTF8-encoded product identification string (e.g. "Oculus Rift DK1"). + char Manufacturer[64]; ///< UTF8-encoded HMD manufacturer identification string. + short VendorId; ///< HID (USB) vendor identifier of the device. + short ProductId; ///< HID (USB) product identifier of the device. + char SerialNumber[24]; ///< HMD serial number. + short FirmwareMajor; ///< HMD firmware major version. + short FirmwareMinor; ///< HMD firmware minor version. + unsigned int AvailableHmdCaps; ///< Available ovrHmdCaps bits. + unsigned int DefaultHmdCaps; ///< Default ovrHmdCaps bits. + unsigned int AvailableTrackingCaps; ///< Available ovrTrackingCaps bits. + unsigned int DefaultTrackingCaps; ///< Default ovrTrackingCaps bits. + ovrFovPort DefaultEyeFov[ovrEye_Count]; ///< Defines the recommended FOVs for the HMD. + ovrFovPort MaxEyeFov[ovrEye_Count]; ///< Defines the maximum FOVs for the HMD. + ovrSizei Resolution; ///< Resolution of the full HMD screen (both eyes) in pixels. + float DisplayRefreshRate; ///< Refresh rate of the display in cycles per second. + OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad1, 4)) ///< \internal struct padding. } ovrHmdDesc; - /// Used as an opaque pointer to an OVR session. typedef struct ovrHmdStruct* ovrSession; +#ifdef OVR_OS_WIN32 +typedef uint32_t ovrProcessId; +#else +typedef pid_t ovrProcessId; +#endif +/// Fallback definitions for when the vulkan header isn't being included +#if !defined(VK_VERSION_1_0) +// From : +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || \ + defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || \ + defined(__powerpc64__) +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T* object; +#else +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; +#endif +VK_DEFINE_HANDLE(VkInstance) +VK_DEFINE_HANDLE(VkPhysicalDevice) +VK_DEFINE_HANDLE(VkDevice) +VK_DEFINE_HANDLE(VkQueue) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) +#endif /// Bit flags describing the current status of sensor tracking. /// The values must be the same as in enum StatusBits /// /// \see ovrTrackingState /// -typedef enum ovrStatusBits_ -{ - ovrStatus_OrientationTracked = 0x0001, ///< Orientation is currently tracked (connected and in use). - ovrStatus_PositionTracked = 0x0002, ///< Position is currently tracked (false if out of range). - ovrStatus_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrStatusBits_ { + // Device orientation is currently tracked. It's possible that the device orientation is not + // tracked, + // but its reported orientation is nevertheless valid (e.g. due to estimation) + ovrStatus_OrientationTracked = 0x0001, + + // Device position is currently tracked. It's possible that the device position is not tracked, + // but its reported position is nevertheless valid (e.g. due to estimation). + ovrStatus_PositionTracked = 0x0002, + + // The reported device orientation is valid for application use. In the case that OrientationValid + // is true and + // OrientationTracked is false, the runtime may be estimating the orientation of the device. + // In the case that OrientationValid is false, the application should not use the returned + // orientation value. + ovrStatus_OrientationValid = 0x0004, + + // The reported device orientation is valid for application use. In the case that PositionValid is + // true and + // PositionTracked is false, the runtime may be estimating the position of the device. + // In the case that PositionValid is false, the application should not use the returned position + // value. + ovrStatus_PositionValid = 0x0008 } ovrStatusBits; - /// Specifies the description of a single sensor. /// -/// \see ovrGetTrackerDesc +/// \see ovr_GetTrackerDesc /// -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrTrackerDesc_ -{ - float FrustumHFovInRadians; ///< Sensor frustum horizontal field-of-view (if present). - float FrustumVFovInRadians; ///< Sensor frustum vertical field-of-view (if present). - float FrustumNearZInMeters; ///< Sensor frustum near Z (if present). - float FrustumFarZInMeters; ///< Sensor frustum far Z (if present). +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrTrackerDesc_ { + float FrustumHFovInRadians; ///< Sensor frustum horizontal field-of-view (if present). + float FrustumVFovInRadians; ///< Sensor frustum vertical field-of-view (if present). + float FrustumNearZInMeters; ///< Sensor frustum near Z (if present). + float FrustumFarZInMeters; ///< Sensor frustum far Z (if present). } ovrTrackerDesc; - /// Specifies sensor flags. /// /// /see ovrTrackerPose /// -typedef enum ovrTrackerFlags_ -{ - ovrTracker_Connected = 0x0020, ///< The sensor is present, else the sensor is absent or offline. - ovrTracker_PoseTracked = 0x0004 ///< The sensor has a valid pose, else the pose is unavailable. This will only be set if ovrTracker_Connected is set. -} ovrTrackerFlags; +typedef enum ovrTrackerFlags_ { + /// The sensor is present, else the sensor is absent or offline. + ovrTracker_Connected = 0x0020, + /// The sensor has a valid pose, else the pose is unavailable. + /// This will only be set if ovrTracker_Connected is set. + ovrTracker_PoseTracked = 0x0004 +} ovrTrackerFlags; /// Specifies the pose for a single sensor. /// -typedef struct OVR_ALIGNAS(8) _ovrTrackerPose -{ - unsigned int TrackerFlags; ///< ovrTrackerFlags. - ovrPosef Pose; ///< The sensor's pose. This pose includes sensor tilt (roll and pitch). For a leveled coordinate system use LeveledPose. - ovrPosef LeveledPose; ///< The sensor's leveled pose, aligned with gravity. This value includes position and yaw of the sensor, but not roll and pitch. It can be used as a reference point to render real-world objects in the correct location. - OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct pad. -} ovrTrackerPose; +typedef struct OVR_ALIGNAS(8) _ovrTrackerPose { + /// ovrTrackerFlags. + unsigned int TrackerFlags; + + /// The sensor's pose. This pose includes sensor tilt (roll and pitch). + /// For a leveled coordinate system use LeveledPose. + ovrPosef Pose; + + /// The sensor's leveled pose, aligned with gravity. This value includes pos and yaw of the + /// sensor, but not roll and pitch. It can be used as a reference point to render real-world + /// objects in the correct location. + ovrPosef LeveledPose; + OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct pad. +} ovrTrackerPose; /// Tracking state at a given absolute time (describes predicted HMD pose, etc.). /// Returned by ovr_GetTrackingState. /// /// \see ovr_GetTrackingState /// -typedef struct OVR_ALIGNAS(8) ovrTrackingState_ -{ - /// Predicted head pose (and derivatives) at the requested absolute time. - ovrPoseStatef HeadPose; +typedef struct OVR_ALIGNAS(8) ovrTrackingState_ { + /// Predicted head pose (and derivatives) at the requested absolute time. + ovrPoseStatef HeadPose; - /// HeadPose tracking status described by ovrStatusBits. - unsigned int StatusFlags; + /// HeadPose tracking status described by ovrStatusBits. + unsigned int StatusFlags; - /// The most recent calculated pose for each hand when hand controller tracking is present. - /// HandPoses[ovrHand_Left] refers to the left hand and HandPoses[ovrHand_Right] to the right hand. - /// These values can be combined with ovrInputState for complete hand controller information. - ovrPoseStatef HandPoses[2]; + /// The most recent calculated pose for each hand when hand controller tracking is present. + /// HandPoses[ovrHand_Left] refers to the left hand and HandPoses[ovrHand_Right] to the right. + /// These values can be combined with ovrInputState for complete hand controller information. + ovrPoseStatef HandPoses[2]; - /// HandPoses status flags described by ovrStatusBits. - /// Only ovrStatus_OrientationTracked and ovrStatus_PositionTracked are reported. - unsigned int HandStatusFlags[2]; + /// HandPoses status flags described by ovrStatusBits. + unsigned int HandStatusFlags[2]; - /// The pose of the origin captured during calibration. - /// Like all other poses here, this is expressed in the space set by ovr_RecenterTrackingOrigin, - /// and so will change every time that is called. This pose can be used to calculate - /// where the calibrated origin lands in the new recentered space. - /// If an application never calls ovr_RecenterTrackingOrigin, expect this value to be the identity - /// pose and as such will point respective origin based on ovrTrackingOrigin requested when - /// calling ovr_GetTrackingState. - ovrPosef CalibratedOrigin; + /// The pose of the origin captured during calibration. + /// Like all other poses here, this is expressed in the space set by ovr_RecenterTrackingOrigin, + /// or ovr_SpecifyTrackingOrigin and so will change every time either of those functions are + /// called. This pose can be used to calculate where the calibrated origin lands in the new + /// recentered space. If an application never calls ovr_RecenterTrackingOrigin or + /// ovr_SpecifyTrackingOrigin, expect this value to be the identity pose and as such will point + /// respective origin based on ovrTrackingOrigin requested when calling ovr_GetTrackingState. + ovrPosef CalibratedOrigin; } ovrTrackingState; + /// Rendering information for each eye. Computed by ovr_GetRenderDesc() based on the /// specified FOV. Note that the rendering viewport is not included /// here as it can be specified separately and modified per frame by @@ -567,16 +651,14 @@ typedef struct OVR_ALIGNAS(8) ovrTrackingState_ /// /// \see ovr_GetRenderDesc /// -typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_ -{ - ovrEyeType Eye; ///< The eye index to which this instance corresponds. - ovrFovPort Fov; ///< The field of view. - ovrRecti DistortedViewport; ///< Distortion viewport. - ovrVector2f PixelsPerTanAngleAtCenter; ///< How many display pixels will fit in tan(angle) = 1. - ovrVector3f HmdToEyeOffset; ///< Translation of each eye, in meters. +typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_ { + ovrEyeType Eye; ///< The eye index to which this instance corresponds. + ovrFovPort Fov; ///< The field of view. + ovrRecti DistortedViewport; ///< Distortion viewport. + ovrVector2f PixelsPerTanAngleAtCenter; ///< How many display pixels will fit in tan(angle) = 1. + ovrPosef HmdToEyePose; ///< Transform of eye from the HMD center, in meters. } ovrEyeRenderDesc; - /// Projection information for ovrLayerEyeFovDepth. /// /// Use the utility function ovrTimewarpProjectionDesc_FromProjection to @@ -584,32 +666,32 @@ typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_ /// /// \see ovrLayerEyeFovDepth, ovrTimewarpProjectionDesc_FromProjection /// -typedef struct OVR_ALIGNAS(4) ovrTimewarpProjectionDesc_ -{ - float Projection22; ///< Projection matrix element [2][2]. - float Projection23; ///< Projection matrix element [2][3]. - float Projection32; ///< Projection matrix element [3][2]. +typedef struct OVR_ALIGNAS(4) ovrTimewarpProjectionDesc_ { + float Projection22; ///< Projection matrix element [2][2]. + float Projection23; ///< Projection matrix element [2][3]. + float Projection32; ///< Projection matrix element [3][2]. } ovrTimewarpProjectionDesc; /// Contains the data necessary to properly calculate position info for various layer types. -/// - HmdToEyeOffset is the same value pair provided in ovrEyeRenderDesc. +/// - HmdToEyePose is the same value-pair provided in ovrEyeRenderDesc. Modifying this value is +/// suggested only if the app is forcing monoscopic rendering and requires that all layers +/// including quad layers show up in a monoscopic fashion. /// - HmdSpaceToWorldScaleInMeters is used to scale player motion into in-application units. /// In other words, it is how big an in-application unit is in the player's physical meters. -/// For example, if the application uses inches as its units then HmdSpaceToWorldScaleInMeters would be 0.0254. +/// For example, if the application uses inches as its units then HmdSpaceToWorldScaleInMeters +/// would be 0.0254. /// Note that if you are scaling the player in size, this must also scale. So if your application /// units are inches, but you're shrinking the player to half their normal size, then /// HmdSpaceToWorldScaleInMeters would be 0.0254*2.0. /// /// \see ovrEyeRenderDesc, ovr_SubmitFrame /// -typedef struct OVR_ALIGNAS(4) ovrViewScaleDesc_ -{ - ovrVector3f HmdToEyeOffset[ovrEye_Count]; ///< Translation of each eye. - float HmdSpaceToWorldScaleInMeters; ///< Ratio of viewer units to meter units. +typedef struct OVR_ALIGNAS(4) ovrViewScaleDesc_ { + ovrPosef HmdToEyePose[ovrEye_Count]; ///< Transform of each eye from the HMD center, in meters. + float HmdSpaceToWorldScaleInMeters; ///< Ratio of viewer units to meter units. } ovrViewScaleDesc; - //----------------------------------------------------------------------------------- // ***** Platform-independent Rendering Configuration @@ -617,13 +699,12 @@ typedef struct OVR_ALIGNAS(4) ovrViewScaleDesc_ /// /// \see ovrTextureSwapChainDesc /// -typedef enum ovrTextureType_ -{ - ovrTexture_2D, ///< 2D textures. - ovrTexture_2D_External, ///< External 2D texture. Not used on PC - ovrTexture_Cube, ///< Cube maps. Not currently supported on PC. - ovrTexture_Count, - ovrTexture_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrTextureType_ { + ovrTexture_2D, ///< 2D textures. + ovrTexture_2D_External, ///< Application-provided 2D texture. Not supported on PC. + ovrTexture_Cube, ///< Cube maps. ovrTextureSwapChainDesc::ArraySize must be 6 for this type. + ovrTexture_Count, + ovrTexture_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTextureType; /// The bindings required for texture swap chain. @@ -633,39 +714,63 @@ typedef enum ovrTextureType_ /// /// \see ovrTextureSwapChainDesc /// -typedef enum ovrTextureBindFlags_ -{ - ovrTextureBind_None, - ovrTextureBind_DX_RenderTarget = 0x0001, ///< The application can write into the chain with pixel shader - ovrTextureBind_DX_UnorderedAccess = 0x0002, ///< The application can write to the chain with compute shader - ovrTextureBind_DX_DepthStencil = 0x0004, ///< The chain buffers can be bound as depth and/or stencil buffers +typedef enum ovrTextureBindFlags_ { + ovrTextureBind_None, - ovrTextureBind_EnumSize = 0x7fffffff ///< \internal Force type int32_t. + /// The application can write into the chain with pixel shader. + ovrTextureBind_DX_RenderTarget = 0x0001, + + /// The application can write to the chain with compute shader. + ovrTextureBind_DX_UnorderedAccess = 0x0002, + + /// The chain buffers can be bound as depth and/or stencil buffers. + /// This flag cannot be combined with ovrTextureBind_DX_RenderTarget. + ovrTextureBind_DX_DepthStencil = 0x0004, + + + ovrTextureBind_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTextureBindFlags; /// The format of a texture. /// /// \see ovrTextureSwapChainDesc /// -typedef enum ovrTextureFormat_ -{ - OVR_FORMAT_UNKNOWN, - OVR_FORMAT_B5G6R5_UNORM, ///< Not currently supported on PC. Would require a DirectX 11.1 device. - OVR_FORMAT_B5G5R5A1_UNORM, ///< Not currently supported on PC. Would require a DirectX 11.1 device. - OVR_FORMAT_B4G4R4A4_UNORM, ///< Not currently supported on PC. Would require a DirectX 11.1 device. - OVR_FORMAT_R8G8B8A8_UNORM, - OVR_FORMAT_R8G8B8A8_UNORM_SRGB, - OVR_FORMAT_B8G8R8A8_UNORM, - OVR_FORMAT_B8G8R8A8_UNORM_SRGB, ///< Not supported for OpenGL applications - OVR_FORMAT_B8G8R8X8_UNORM, ///< Not supported for OpenGL applications - OVR_FORMAT_B8G8R8X8_UNORM_SRGB, ///< Not supported for OpenGL applications - OVR_FORMAT_R16G16B16A16_FLOAT, - OVR_FORMAT_D16_UNORM, - OVR_FORMAT_D24_UNORM_S8_UINT, - OVR_FORMAT_D32_FLOAT, - OVR_FORMAT_D32_FLOAT_S8X24_UINT, - - OVR_FORMAT_ENUMSIZE = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrTextureFormat_ { + OVR_FORMAT_UNKNOWN = 0, + OVR_FORMAT_B5G6R5_UNORM = 1, ///< Not currently supported on PC. Requires a DirectX 11.1 device. + OVR_FORMAT_B5G5R5A1_UNORM = 2, ///< Not currently supported on PC. Requires a DirectX 11.1 device. + OVR_FORMAT_B4G4R4A4_UNORM = 3, ///< Not currently supported on PC. Requires a DirectX 11.1 device. + OVR_FORMAT_R8G8B8A8_UNORM = 4, + OVR_FORMAT_R8G8B8A8_UNORM_SRGB = 5, + OVR_FORMAT_B8G8R8A8_UNORM = 6, + OVR_FORMAT_B8G8R8_UNORM = 27, + OVR_FORMAT_B8G8R8A8_UNORM_SRGB = 7, ///< Not supported for OpenGL applications + OVR_FORMAT_B8G8R8X8_UNORM = 8, ///< Not supported for OpenGL applications + OVR_FORMAT_B8G8R8X8_UNORM_SRGB = 9, ///< Not supported for OpenGL applications + OVR_FORMAT_R16G16B16A16_FLOAT = 10, + OVR_FORMAT_R11G11B10_FLOAT = 25, ///< Not supported for D3D12 applications. Introduced in v1.10 + + // Depth formats + OVR_FORMAT_D16_UNORM = 11, + OVR_FORMAT_D24_UNORM_S8_UINT = 12, + OVR_FORMAT_D32_FLOAT = 13, + OVR_FORMAT_D32_FLOAT_S8X24_UINT = 14, + + // Added in 1.5 compressed formats can be used for static layers + OVR_FORMAT_BC1_UNORM = 15, + OVR_FORMAT_BC1_UNORM_SRGB = 16, + OVR_FORMAT_BC2_UNORM = 17, + OVR_FORMAT_BC2_UNORM_SRGB = 18, + OVR_FORMAT_BC3_UNORM = 19, + OVR_FORMAT_BC3_UNORM_SRGB = 20, + OVR_FORMAT_BC6H_UF16 = 21, + OVR_FORMAT_BC6H_SF16 = 22, + OVR_FORMAT_BC7_UNORM = 23, + OVR_FORMAT_BC7_UNORM_SRGB = 24, + + + OVR_FORMAT_LAST, + OVR_FORMAT_ENUMSIZE = 0x7fffffff ///< \internal Force type int32_t. } ovrTextureFormat; /// Misc flags overriding particular @@ -673,26 +778,31 @@ typedef enum ovrTextureFormat_ /// /// \see ovrTextureSwapChainDesc /// -typedef enum ovrTextureMiscFlags_ -{ - ovrTextureMisc_None, +typedef enum ovrTextureMiscFlags_ { + ovrTextureMisc_None, - /// DX only: The underlying texture is created with a TYPELESS equivalent of the - /// format specified in the texture desc. The SDK will still access the - /// texture using the format specified in the texture desc, but the app can - /// create views with different formats if this is specified. - ovrTextureMisc_DX_Typeless = 0x0001, + /// Vulkan and DX only: The underlying texture is created with a TYPELESS equivalent + /// of the format specified in the texture desc. The SDK will still access the + /// texture using the format specified in the texture desc, but the app can + /// create views with different formats if this is specified. + ovrTextureMisc_DX_Typeless = 0x0001, - /// DX only: Allow generation of the mip chain on the GPU via the GenerateMips - /// call. This flag requires that RenderTarget binding also be specified. - ovrTextureMisc_AllowGenerateMips = 0x0002, + /// DX only: Allow generation of the mip chain on the GPU via the GenerateMips + /// call. This flag requires that RenderTarget binding also be specified. + ovrTextureMisc_AllowGenerateMips = 0x0002, - /// Texture swap chain contains protected content, and requires - /// HDCP connection in order to display to HMD. Also prevents - /// mirroring or other redirection of any frame containing this contents - ovrTextureMisc_ProtectedContent = 0x0004, + /// Texture swap chain contains protected content, and requires + /// HDCP connection in order to display to HMD. Also prevents + /// mirroring or other redirection of any frame containing this contents + ovrTextureMisc_ProtectedContent = 0x0004, - ovrTextureMisc_EnumSize = 0x7fffffff ///< \internal Force type int32_t. + /// Automatically generate and use the mip chain in composition on each submission. + /// Mips are regenerated from highest quality level, ignoring other pre-existing mip levels. + /// Not supported for depth or compressed (BC) formats. + ovrTextureMisc_AutoGenerateMips = 0x0008, + + + ovrTextureMisc_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTextureFlags; /// Description used to create a texture swap chain. @@ -700,31 +810,71 @@ typedef enum ovrTextureMiscFlags_ /// \see ovr_CreateTextureSwapChainDX /// \see ovr_CreateTextureSwapChainGL /// -typedef struct ovrTextureSwapChainDesc_ -{ - ovrTextureType Type; - ovrTextureFormat Format; - int ArraySize; ///< Only supported with ovrTexture_2D. Not supported on PC at this time. - int Width; - int Height; - int MipLevels; - int SampleCount; ///< Current only supported on depth textures - ovrBool StaticImage; ///< Not buffered in a chain. For images that don't change - unsigned int MiscFlags; ///< ovrTextureFlags - unsigned int BindFlags; ///< ovrTextureBindFlags. Not used for GL. +typedef struct ovrTextureSwapChainDesc_ { + ovrTextureType Type; ///< Must be ovrTexture_2D + ovrTextureFormat Format; + int ArraySize; ///< Must be 6 for ovrTexture_Cube, 1 for other types. + int Width; + int Height; + int MipLevels; + int SampleCount; + ovrBool StaticImage; ///< Not buffered in a chain. For images that don't change + OVR_ALIGNAS(4) unsigned int MiscFlags; ///< ovrTextureFlags + OVR_ALIGNAS(4) unsigned int BindFlags; ///< ovrTextureBindFlags. Not used for GL. } ovrTextureSwapChainDesc; +/// Bit flags used as part of ovrMirrorTextureDesc's MirrorOptions field. +/// +/// \see ovr_CreateMirrorTextureWithOptionsDX +/// \see ovr_CreateMirrorTextureWithOptionsGL +/// \see ovr_CreateMirrorTextureWithOptionsVk +/// +typedef enum ovrMirrorOptions_ { + /// By default the mirror texture will be: + /// * Pre-distortion (i.e. rectilinear) + /// * Contain both eye textures + /// * Exclude Guardian, Notifications, System Menu GUI + ovrMirrorOption_Default = 0x0000, + + /// Retrieves the barrel distorted texture contents instead of the rectilinear one + /// This is only recommended for debugging purposes, and not for final desktop presentation + ovrMirrorOption_PostDistortion = 0x0001, + + /// Since ovrMirrorOption_Default renders both eyes into the mirror texture, + /// these two flags are exclusive (i.e. cannot use them simultaneously) + ovrMirrorOption_LeftEyeOnly = 0x0002, + ovrMirrorOption_RightEyeOnly = 0x0004, + + /// Shows the boundary system aka Guardian on the mirror texture + ovrMirrorOption_IncludeGuardian = 0x0008, + + /// Shows system notifications the user receives on the mirror texture + ovrMirrorOption_IncludeNotifications = 0x0010, + + /// Shows the system menu (triggered by hitting the Home button) on the mirror texture + ovrMirrorOption_IncludeSystemGui = 0x0020, + + /// Forces mirror output to use max symmetric FOV instead of asymmetric full FOV used by HMD. + /// Only valid for rectilinear mirrors i.e. using ovrMirrorOption_PostDistortion with + /// ovrMirrorOption_ForceSymmetricFov will result in ovrError_InvalidParameter error. + ovrMirrorOption_ForceSymmetricFov = 0x0040, + + + ovrMirrorOption_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrMirrorOptions; + /// Description used to create a mirror texture. /// -/// \see ovr_CreateMirrorTextureDX -/// \see ovr_CreateMirrorTextureGL +/// \see ovr_CreateMirrorTextureWithOptionsDX +/// \see ovr_CreateMirrorTextureWithOptionsGL +/// \see ovr_CreateMirrorTextureWithOptionsVk /// -typedef struct ovrMirrorTextureDesc_ -{ - ovrTextureFormat Format; - int Width; - int Height; - unsigned int MiscFlags; ///< ovrTextureFlags +typedef struct ovrMirrorTextureDesc_ { + ovrTextureFormat Format; + int Width; + int Height; + unsigned int MiscFlags; ///< ovrTextureFlags + unsigned int MirrorOptions; ///< ovrMirrorOptions } ovrMirrorTextureDesc; typedef struct ovrTextureSwapChainData* ovrTextureSwapChain; @@ -732,142 +882,507 @@ typedef struct ovrMirrorTextureData* ovrMirrorTexture; //----------------------------------------------------------------------------------- +/// Fov-stencil mesh for assisting in rendering efficiency for clients using EyeFov layers + +/// A fov-stencil mesh is used to cull out the parts of the eye render target used in +/// ovrLayerType_EyeFov & ovrLayerType_EyeFovDepth layers that would not normally be visible to +/// the user wearing the HMD. +/// +/// A rasterized eye render target is rectangular, but the parts of the render target visible to the +/// user do not necessarily follow a rectangular region. This is where the fov-stencil mesh +/// helps designate the boundaries of the visible parts for a given eye render target. +/// +/// To make effective use of this mesh, the client should render the mesh before kicking off any +/// other rendering work. Ideally the mesh would be rendered at the near-depth plane distance, or +/// into the stencil buffer right after clearing the depth-stencil buffer. The choice of using +/// depth vs. stencil is left up to the client, but the client should make sure that the mesh is +/// rendered in a way that it can make use of Hierarchical-Z or Hierarchical-Stencil for better +/// performance on rejected geometry post-vertex shading. + +/// Viewport stencil types provided by the ovr_GetFovStencil call. +/// \see ovr_GetFovStencil +typedef enum ovrFovStencilType_ { + ovrFovStencil_HiddenArea = 0, ///< Triangle list covering parts that are hidden to users + ovrFovStencil_VisibleArea = 1, ///< Triangle list covering parts that are visible to users + ovrFovStencil_BorderLine = 2, ///< Line list that draws the boundary visible to users + ovrFovStencil_VisibleRectangle = 3, ///< Axis-aligned rectangle fit in visible region + ///< 4x vertices: TopLeft, TopRight, BottomRight, BottomLeft + + ovrFovStencilType_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrFovStencilType; + +/// Identifies flags used by ovrFovStencilDesc and which are passed to ovr_GetFovStencil. +/// \see ovrFovStencilDesc +typedef enum ovrFovStencilFlags_ { + + /// When used, flips the Y component of the provided 2D mesh coordinates, such that Y increases + /// upwards. When not used, places mesh origin at top-left where Y increases downwards. + ovrFovStencilFlag_MeshOriginAtBottomLeft = 0x01, + + ovrFovStencilFlag_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrFovStencilFlags; + +/// Fov-stencil mesh descriptor passed into the function ovr_GetFovStencil +/// \see ovr_GetFovStencil +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrFovStencilDesc_ { + ovrFovStencilType StencilType; + uint32_t StencilFlags; ///< Bit flag combination of ovrFovStencilFlags + ovrEyeType Eye; + ovrFovPort FovPort; ///< Typically FOV obtained from ovrEyeRenderDesc + ovrQuatf HmdToEyeRotation; ///< Typically HmdToEyePose.Orientation obtained from ovrEyeRenderDesc + ///< Note: Currently unsupported, always treated as identity +} ovrFovStencilDesc; + +/// Contains the data for the fov-stencil mesh. Parts of the struct are filled by the caller +/// while some parts are filled by the SDK. +/// \see ovr_GetFovStencil +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrFovStencilMeshBuffer_ { + /// Vertex info + int AllocVertexCount; ///< To be filled in by caller of ovr_GetFovStencil + int UsedVertexCount; ///< To be filled in by SDK and returned to caller + ovrVector2f* VertexBuffer; ///< To be allocated by caller and filled in by SDK + + /// Index info + int AllocIndexCount; ///< To be filled in by caller of ovr_GetFovStencil + int UsedIndexCount; ///< To be filled in by SDK and returned to caller + uint16_t* IndexBuffer; ///< To be allocated by caller and filled in by SDK +} ovrFovStencilMeshBuffer; + +/// Returns a viewport stencil mesh to be used for defining the area or outline the user +/// can see through the lens on an area defined by a given ovrFovPort. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] fovStencilDesc Info provided by caller necessary to generate a stencil mesh. +/// \param[in] meshBuffer Mesh buffer to be partially filled in and returned by the SDK. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of +/// failure, use ovr_GetLastErrorInfo to get more information. +/// Return values include but aren't limited to: +/// - ovrSuccess: Completed successfully. +/// - ovrError_ServiceConnection: The service connection was lost and the application +/// must destroy the session. +/// - ovrError_InvalidParameter: One or more of the parameters +/// +/// To find out how big the vertex and index buffers in meshBuffer buffer should be, first call +/// this function setting AllocVertexCount & AllocIndexCount to 0 while also sending in nullptr +/// for VertexBuffer & IndexBuffer. The SDK will populate UsedVertexCount & UsedIndexCount values. +/// +/// If Alloc*Count fields in meshBuffer are smaller than the expected Used*Count fields, +/// (except when they are 0) then the SDK will return ovrError_InvalidParameter and leave +/// VertexBuffer and IndexBuffer untouched. +/// +/// 2D positions provided in the buffer will be in the [0,1] range where Y increases downward, +/// similar to texture-UV space. If Y coordinates need to be flipped upside down, use the +/// ovrFovStencilFlag_MeshOriginAtBottomLeft. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetFovStencil( + ovrSession session, + const ovrFovStencilDesc* fovStencilDesc, + ovrFovStencilMeshBuffer* meshBuffer); + +//----------------------------------------------------------------------------------- + /// Describes button input types. -/// Button inputs are combined; that is they will be reported as pressed if they are +/// Button inputs are combined; that is they will be reported as pressed if they are /// pressed on either one of the two devices. /// The ovrButton_Up/Down/Left/Right map to both XBox D-Pad and directional buttons. /// The ovrButton_Enter and ovrButton_Return map to Start and Back controller buttons, respectively. -typedef enum ovrButton_ -{ - ovrButton_A = 0x00000001, - ovrButton_B = 0x00000002, - ovrButton_RThumb = 0x00000004, - ovrButton_RShoulder = 0x00000008, - - // Bit mask of all buttons on the right Touch controller - ovrButton_RMask = ovrButton_A | ovrButton_B | ovrButton_RThumb | ovrButton_RShoulder, - - ovrButton_X = 0x00000100, - ovrButton_Y = 0x00000200, - ovrButton_LThumb = 0x00000400, - ovrButton_LShoulder = 0x00000800, - - // Bit mask of all buttons on the left Touch controller - ovrButton_LMask = ovrButton_X | ovrButton_Y | ovrButton_LThumb | ovrButton_LShoulder, - - // Navigation through DPad. - ovrButton_Up = 0x00010000, - ovrButton_Down = 0x00020000, - ovrButton_Left = 0x00040000, - ovrButton_Right = 0x00080000, - ovrButton_Enter = 0x00100000, // Start on XBox controller. - ovrButton_Back = 0x00200000, // Back on Xbox controller. - ovrButton_VolUp = 0x00400000, // only supported by Remote. - ovrButton_VolDown = 0x00800000, // only supported by Remote. - ovrButton_Home = 0x01000000, - ovrButton_Private = ovrButton_VolUp | ovrButton_VolDown | ovrButton_Home, - - - ovrButton_EnumSize = 0x7fffffff ///< \internal Force type int32_t. -} ovrButton; +typedef enum ovrButton_ { + /// A button on XBox controllers and right Touch controller. Not present on Oculus Remote. + ovrButton_A = 0x00000001, -/// Describes touch input types. -/// These values map to capacitive touch values reported ovrInputState::Touch. -/// Some of these values are mapped to button bits for consistency. -typedef enum ovrTouch_ -{ - ovrTouch_A = ovrButton_A, - ovrTouch_B = ovrButton_B, - ovrTouch_RThumb = ovrButton_RThumb, - ovrTouch_RIndexTrigger = 0x00000010, + /// B button on XBox controllers and right Touch controller. Not present on Oculus Remote. + ovrButton_B = 0x00000002, + + /// Right thumbstick on XBox controllers and Touch controllers. Not present on Oculus Remote. + ovrButton_RThumb = 0x00000004, + + /// Right shoulder button on XBox controllers. Not present on Touch controllers or Oculus Remote. + ovrButton_RShoulder = 0x00000008, + + + /// X button on XBox controllers and left Touch controller. Not present on Oculus Remote. + ovrButton_X = 0x00000100, + + /// Y button on XBox controllers and left Touch controller. Not present on Oculus Remote. + ovrButton_Y = 0x00000200, - // Bit mask of all the button touches on the right controller - ovrTouch_RButtonMask = ovrTouch_A | ovrTouch_B | ovrTouch_RThumb | ovrTouch_RIndexTrigger, + /// Left thumbstick on XBox controllers and Touch controllers. Not present on Oculus Remote. + ovrButton_LThumb = 0x00000400, - ovrTouch_X = ovrButton_X, - ovrTouch_Y = ovrButton_Y, - ovrTouch_LThumb = ovrButton_LThumb, - ovrTouch_LIndexTrigger = 0x00001000, + /// Left shoulder button on XBox controllers. Not present on Touch controllers or Oculus Remote. + ovrButton_LShoulder = 0x00000800, - // Bit mask of all the button touches on the left controller - ovrTouch_LButtonMask = ovrTouch_X | ovrTouch_Y | ovrTouch_LThumb | ovrTouch_LIndexTrigger, + /// Up button on XBox controllers and Oculus Remote. Not present on Touch controllers. + ovrButton_Up = 0x00010000, - // Finger pose state - // Derived internally based on distance, proximity to sensors and filtering. - ovrTouch_RIndexPointing = 0x00000020, - ovrTouch_RThumbUp = 0x00000040, + /// Down button on XBox controllers and Oculus Remote. Not present on Touch controllers. + ovrButton_Down = 0x00020000, - // Bit mask of all right controller poses - ovrTouch_RPoseMask = ovrTouch_RIndexPointing | ovrTouch_RThumbUp, + /// Left button on XBox controllers and Oculus Remote. Not present on Touch controllers. + ovrButton_Left = 0x00040000, - ovrTouch_LIndexPointing = 0x00002000, - ovrTouch_LThumbUp = 0x00004000, + /// Right button on XBox controllers and Oculus Remote. Not present on Touch controllers. + ovrButton_Right = 0x00080000, - // Bit mask of all left controller poses - ovrTouch_LPoseMask = ovrTouch_LIndexPointing | ovrTouch_LThumbUp, + /// Start on XBox 360 controller. Menu on XBox One controller and Left Touch controller. + /// Select button on Oculus Remote. + /// Should be referred to as the Menu button in user-facing documentation. + ovrButton_Enter = 0x00100000, - ovrTouch_EnumSize = 0x7fffffff ///< \internal Force type int32_t. + /// Back on Xbox 360 controller and Oculus Remote. View button on XBox One controller. + /// Not present on Touch controllers. + ovrButton_Back = 0x00200000, + + /// Volume button on Oculus Remote. Not present on XBox or Touch controllers. + ovrButton_VolUp = 0x00400000, + + /// Volume button on Oculus Remote. Not present on XBox or Touch controllers. + ovrButton_VolDown = 0x00800000, + + /// Home button on XBox controllers. Oculus button on Touch controllers and Oculus Remote. + ovrButton_Home = 0x01000000, + + // Bit mask of all buttons that are for private usage by Oculus + ovrButton_Private = ovrButton_VolUp | ovrButton_VolDown | ovrButton_Home, + + // Bit mask of all buttons on the right Touch controller + ovrButton_RMask = ovrButton_A | ovrButton_B | ovrButton_RThumb | ovrButton_RShoulder, + + // Bit mask of all buttons on the left Touch controller + ovrButton_LMask = + ovrButton_X | ovrButton_Y | ovrButton_LThumb | ovrButton_LShoulder | ovrButton_Enter, + + ovrButton_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrButton; + +/// Describes touch input types. +/// These values map to capacitive touch values reported ovrInputState::Touch. +/// Some of these values are mapped to button bits for consistency. +typedef enum ovrTouch_ { + ovrTouch_A = ovrButton_A, + ovrTouch_B = ovrButton_B, + ovrTouch_RThumb = ovrButton_RThumb, + ovrTouch_RThumbRest = 0x00000008, + ovrTouch_RIndexTrigger = 0x00000010, + + // Bit mask of all the button touches on the right controller + ovrTouch_RButtonMask = + ovrTouch_A | ovrTouch_B | ovrTouch_RThumb | ovrTouch_RThumbRest | ovrTouch_RIndexTrigger, + + ovrTouch_X = ovrButton_X, + ovrTouch_Y = ovrButton_Y, + ovrTouch_LThumb = ovrButton_LThumb, + ovrTouch_LThumbRest = 0x00000800, + ovrTouch_LIndexTrigger = 0x00001000, + + // Bit mask of all the button touches on the left controller + ovrTouch_LButtonMask = + ovrTouch_X | ovrTouch_Y | ovrTouch_LThumb | ovrTouch_LThumbRest | ovrTouch_LIndexTrigger, + + // Finger pose state + // Derived internally based on distance, proximity to sensors and filtering. + ovrTouch_RIndexPointing = 0x00000020, + ovrTouch_RThumbUp = 0x00000040, + ovrTouch_LIndexPointing = 0x00002000, + ovrTouch_LThumbUp = 0x00004000, + + // Bit mask of all right controller poses + ovrTouch_RPoseMask = ovrTouch_RIndexPointing | ovrTouch_RThumbUp, + + // Bit mask of all left controller poses + ovrTouch_LPoseMask = ovrTouch_LIndexPointing | ovrTouch_LThumbUp, + + ovrTouch_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrTouch; +/// Describes the Touch Haptics engine. +/// Currently, those values will NOT change during a session. +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrTouchHapticsDesc_ { + // Haptics engine frequency/sample-rate, sample time in seconds equals 1.0/sampleRateHz + int SampleRateHz; + // Size of each Haptics sample, sample value range is [0, 2^(Bytes*8)-1] + int SampleSizeInBytes; + + // Queue size that would guarantee Haptics engine would not starve for data + // Make sure size doesn't drop below it for best results + int QueueMinSizeToAvoidStarvation; + + // Minimum, Maximum and Optimal number of samples that can be sent to Haptics through + // ovr_SubmitControllerVibration + int SubmitMinSamples; + int SubmitMaxSamples; + int SubmitOptimalSamples; +} ovrTouchHapticsDesc; + /// Specifies which controller is connected; multiple can be connected at once. -typedef enum ovrControllerType_ -{ - ovrControllerType_None = 0x00, - ovrControllerType_LTouch = 0x01, - ovrControllerType_RTouch = 0x02, - ovrControllerType_Touch = 0x03, - ovrControllerType_Remote = 0x04, - ovrControllerType_XBox = 0x10, - - ovrControllerType_Active = 0xff, ///< Operate on or query whichever controller is active. - - ovrControllerType_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrControllerType_ { + ovrControllerType_None = 0x0000, + ovrControllerType_LTouch = 0x0001, + ovrControllerType_RTouch = 0x0002, + ovrControllerType_Touch = (ovrControllerType_LTouch | ovrControllerType_RTouch), + ovrControllerType_Remote = 0x0004, + + ovrControllerType_XBox = 0x0010, + + ovrControllerType_Object0 = 0x0100, + ovrControllerType_Object1 = 0x0200, + ovrControllerType_Object2 = 0x0400, + ovrControllerType_Object3 = 0x0800, + + ovrControllerType_Active = 0xffffffff, ///< Operate on or query whichever controller is active. + + ovrControllerType_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrControllerType; +/// Haptics buffer submit mode +typedef enum ovrHapticsBufferSubmitMode_ { + /// Enqueue buffer for later playback + ovrHapticsBufferSubmit_Enqueue +} ovrHapticsBufferSubmitMode; + +/// Maximum number of samples in ovrHapticsBuffer +#define OVR_HAPTICS_BUFFER_SAMPLES_MAX 256 + +/// Haptics buffer descriptor, contains amplitude samples used for Touch vibration +typedef struct ovrHapticsBuffer_ { + /// Samples stored in opaque format + const void* Samples; + /// Number of samples (up to OVR_HAPTICS_BUFFER_SAMPLES_MAX) + int SamplesCount; + /// How samples are submitted to the hardware + ovrHapticsBufferSubmitMode SubmitMode; +} ovrHapticsBuffer; + +/// State of the Haptics playback for Touch vibration +typedef struct ovrHapticsPlaybackState_ { + // Remaining space available to queue more samples + int RemainingQueueSpace; + + // Number of samples currently queued + int SamplesQueued; +} ovrHapticsPlaybackState; + +/// Position tracked devices +typedef enum ovrTrackedDeviceType_ { + ovrTrackedDevice_None = 0x0000, + ovrTrackedDevice_HMD = 0x0001, + ovrTrackedDevice_LTouch = 0x0002, + ovrTrackedDevice_RTouch = 0x0004, + ovrTrackedDevice_Touch = (ovrTrackedDevice_LTouch | ovrTrackedDevice_RTouch), + + ovrTrackedDevice_Object0 = 0x0010, + ovrTrackedDevice_Object1 = 0x0020, + ovrTrackedDevice_Object2 = 0x0040, + ovrTrackedDevice_Object3 = 0x0080, + + ovrTrackedDevice_All = 0xFFFF, +} ovrTrackedDeviceType; + +/// Boundary types that specified while using the boundary system +typedef enum ovrBoundaryType_ { + /// Outer boundary - closely represents user setup walls + ovrBoundary_Outer = 0x0001, + + /// Play area - safe rectangular area inside outer boundary which can optionally be used to + /// restrict user interactions and motion. + ovrBoundary_PlayArea = 0x0100, +} ovrBoundaryType; + +/// Boundary system look and feel +typedef struct ovrBoundaryLookAndFeel_ { + /// Boundary color (alpha channel is ignored) + ovrColorf Color; +} ovrBoundaryLookAndFeel; + +/// Provides boundary test information +typedef struct ovrBoundaryTestResult_ { + /// True if the boundary system is being triggered. Note that due to fade in/out effects this may + /// not exactly match visibility. + ovrBool IsTriggering; + + /// Distance to the closest play area or outer boundary surface. + float ClosestDistance; + + /// Closest point on the boundary surface. + ovrVector3f ClosestPoint; + + /// Unit surface normal of the closest boundary surface. + ovrVector3f ClosestPointNormal; +} ovrBoundaryTestResult; /// Provides names for the left and right hand array indexes. /// /// \see ovrInputState, ovrTrackingState -/// -typedef enum ovrHandType_ -{ - ovrHand_Left = 0, - ovrHand_Right = 1, - ovrHand_Count = 2, - ovrHand_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +/// +typedef enum ovrHandType_ { + ovrHand_Left = 0, + ovrHand_Right = 1, + ovrHand_Count = 2, + ovrHand_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrHandType; - - /// ovrInputState describes the complete controller input state, including Oculus Touch, /// and XBox gamepad. If multiple inputs are connected and used at the same time, /// their inputs are combined. -typedef struct ovrInputState_ -{ - // System type when the controller state was last updated. - double TimeInSeconds; - - // Values for buttons described by ovrButton. - unsigned int Buttons; - - // Touch values for buttons and sensors as described by ovrTouch. - unsigned int Touches; - - // Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. - float IndexTrigger[ovrHand_Count]; - - // Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. - float HandTrigger[ovrHand_Count]; - - // Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f. - ovrVector2f Thumbstick[ovrHand_Count]; - - // The type of the controller this state is for. - ovrControllerType ControllerType; - +typedef struct ovrInputState_ { + /// System type when the controller state was last updated. + double TimeInSeconds; + + /// Values for buttons described by ovrButton. + unsigned int Buttons; + + /// Touch values for buttons and sensors as described by ovrTouch. + unsigned int Touches; + + /// Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in range 0.0 to 1.0f. + /// Returns 0 if the value would otherwise be less than 0.1176, for ovrControllerType_XBox. + /// This has been formally named simply "Trigger". We retain the name IndexTrigger for backwards + /// code compatibility. + /// User-facing documentation should refer to it as the Trigger. + float IndexTrigger[ovrHand_Count]; + + /// Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. + /// This has been formally named "Grip Button". We retain the name HandTrigger for backwards code + /// compatibility. + /// User-facing documentation should refer to it as the Grip Button or simply Grip. + float HandTrigger[ovrHand_Count]; + + /// Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range + /// of -1.0f to 1.0f. + /// Returns a deadzone (value 0) per each axis if the value on that axis would otherwise have been + /// between -.2746 to +.2746, for ovrControllerType_XBox + ovrVector2f Thumbstick[ovrHand_Count]; + + /// The type of the controller this state is for. + ovrControllerType ControllerType; + + /// Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in range 0.0 to 1.0f. + /// Does not apply a deadzone. Only touch applies a filter. + /// This has been formally named simply "Trigger". We retain the name IndexTrigger for backwards + /// code compatibility. + /// User-facing documentation should refer to it as the Trigger. + float IndexTriggerNoDeadzone[ovrHand_Count]; + + /// Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. + /// Does not apply a deadzone. Only touch applies a filter. + /// This has been formally named "Grip Button". We retain the name HandTrigger for backwards code + /// compatibility. + /// User-facing documentation should refer to it as the Grip Button or simply Grip. + float HandTriggerNoDeadzone[ovrHand_Count]; + + /// Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range + /// -1.0f to 1.0f + /// Does not apply a deadzone or filter. + ovrVector2f ThumbstickNoDeadzone[ovrHand_Count]; + + /// Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in range 0.0 to 1.0f. + /// No deadzone or filter + /// This has been formally named "Grip Button". We retain the name HandTrigger for backwards code + /// compatibility. + /// User-facing documentation should refer to it as the Grip Button or simply Grip. + float IndexTriggerRaw[ovrHand_Count]; + + /// Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f. + /// No deadzone or filter + /// This has been formally named "Grip Button". We retain the name HandTrigger for backwards code + /// compatibility. + /// User-facing documentation should refer to it as the Grip Button or simply Grip. + float HandTriggerRaw[ovrHand_Count]; + + /// Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range + /// -1.0f to 1.0f + /// No deadzone or filter + ovrVector2f ThumbstickRaw[ovrHand_Count]; + } ovrInputState; +typedef struct ovrCameraIntrinsics_ { + /// Time in seconds from last change to the parameters + double LastChangedTime; + + /// Angles of all 4 sides of viewport + ovrFovPort FOVPort; + + /// Near plane of the virtual camera used to match the external camera + float VirtualNearPlaneDistanceMeters; + + /// Far plane of the virtual camera used to match the external camera + float VirtualFarPlaneDistanceMeters; + + /// Height in pixels of image sensor + ovrSizei ImageSensorPixelResolution; + + /// The lens distortion matrix of camera + ovrMatrix4f LensDistortionMatrix; + + /// How often, in seconds, the exposure is taken + double ExposurePeriodSeconds; + + /// length of the exposure time + double ExposureDurationSeconds; + +} ovrCameraIntrinsics; + +typedef enum ovrCameraStatusFlags_ { + /// Initial state of camera + ovrCameraStatus_None = 0x0, + + /// Bit set when the camera is connected to the system + ovrCameraStatus_Connected = 0x1, + + /// Bit set when the camera is undergoing calibration + ovrCameraStatus_Calibrating = 0x2, + /// Bit set when the camera has tried & failed calibration + ovrCameraStatus_CalibrationFailed = 0x4, + + /// Bit set when the camera has tried & passed calibration + ovrCameraStatus_Calibrated = 0x8, + + /// Bit set when the camera is capturing + ovrCameraStatus_Capturing = 0x10, + + ovrCameraStatus_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrCameraStatusFlags; + +typedef struct ovrCameraExtrinsics_ { + /// Time in seconds from last change to the parameters. + /// For instance, if the pose changes, or a camera exposure happens, this struct will be updated. + double LastChangedTimeSeconds; + + /// Current Status of the camera, a mix of bits from ovrCameraStatusFlags + unsigned int CameraStatusFlags; + + /// Which Tracked device, if any, is the camera rigidly attached to + /// If set to ovrTrackedDevice_None, then the camera is not attached to a tracked object. + /// If the external camera moves while unattached (i.e. set to ovrTrackedDevice_None), its Pose + /// won't be updated + ovrTrackedDeviceType AttachedToDevice; + + /// The relative Pose of the External Camera. + /// If AttachedToDevice is ovrTrackedDevice_None, then this is a absolute pose in tracking space + ovrPosef RelativePose; + + /// The time, in seconds, when the last successful exposure was taken + double LastExposureTimeSeconds; + + /// Estimated exposure latency to get from the exposure time to the system + double ExposureLatencySeconds; + + /// Additional latency to get from the exposure time of the real camera to match the render time + /// of the virtual camera + double AdditionalLatencySeconds; + +} ovrCameraExtrinsics; +#define OVR_MAX_EXTERNAL_CAMERA_COUNT 16 +#define OVR_EXTERNAL_CAMERA_NAME_SIZE 32 +typedef struct ovrExternalCamera_ { + char Name[OVR_EXTERNAL_CAMERA_NAME_SIZE]; // camera identifier: vid + pid + serial number etc. + ovrCameraIntrinsics Intrinsics; + ovrCameraExtrinsics Extrinsics; +} ovrExternalCamera; //----------------------------------------------------------------------------------- // ***** Initialize structures @@ -876,37 +1391,55 @@ typedef struct ovrInputState_ /// /// \see ovrInitParams, ovr_Initialize /// -typedef enum ovrInitFlags_ -{ - /// When a debug library is requested, a slower debugging version of the library will - /// run which can be used to help solve problems in the library and debug application code. - ovrInit_Debug = 0x00000001, +typedef enum ovrInitFlags_ { + /// When a debug library is requested, a slower debugging version of the library will + /// run which can be used to help solve problems in the library and debug application code. + ovrInit_Debug = 0x00000001, - /// When a version is requested, the LibOVR runtime respects the RequestedMinorVersion - /// field and verifies that the RequestedMinorVersion is supported. - ovrInit_RequestVersion = 0x00000004, - // These bits are writable by user code. - ovrinit_WritableBits = 0x00ffffff, + /// When a version is requested, the LibOVR runtime respects the RequestedMinorVersion + /// field and verifies that the RequestedMinorVersion is supported. Normally when you + /// specify this flag you simply use OVR_MINOR_VERSION for ovrInitParams::RequestedMinorVersion, + /// though you could use a lower version than OVR_MINOR_VERSION to specify previous + /// version behavior. + ovrInit_RequestVersion = 0x00000004, + + + /// This client will not be visible in the HMD. + /// Typically set by diagnostic or debugging utilities. + ovrInit_Invisible = 0x00000010, + + /// This client will alternate between VR and 2D rendering. + /// Typically set by game engine editors and VR-enabled web browsers. + ovrInit_MixedRendering = 0x00000020, + + /// This client is aware of ovrSessionStatus focus states (e.g. ovrSessionStatus::HasInputFocus), + /// and responds to them appropriately (e.g. pauses and stops drawing hands when lacking focus). + ovrInit_FocusAware = 0x00000040, - ovrInit_EnumSize = 0x7fffffff ///< \internal Force type int32_t. -} ovrInitFlags; + + + + /// These bits are writable by user code. + ovrinit_WritableBits = 0x00ffffff, + + ovrInit_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrInitFlags; + /// Logging levels /// /// \see ovrInitParams, ovrLogCallback /// -typedef enum ovrLogLevel_ -{ - ovrLogLevel_Debug = 0, ///< Debug-level log event. - ovrLogLevel_Info = 1, ///< Info-level log event. - ovrLogLevel_Error = 2, ///< Error-level log event. +typedef enum ovrLogLevel_ { + ovrLogLevel_Debug = 0, ///< Debug-level log event. + ovrLogLevel_Info = 1, ///< Info-level log event. + ovrLogLevel_Error = 2, ///< Error-level log event. - ovrLogLevel_EnumSize = 0x7fffffff ///< \internal Force type int32_t. + ovrLogLevel_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrLogLevel; - /// Signature of the logging callback function pointer type. /// /// \param[in] userData is an arbitrary value specified by the user of ovrInitParams. @@ -914,39 +1447,38 @@ typedef enum ovrLogLevel_ /// \param[in] message is a UTF8-encoded null-terminated string. /// \see ovrInitParams, ovrLogLevel, ovr_Initialize /// -typedef void (OVR_CDECL* ovrLogCallback)(uintptr_t userData, int level, const char* message); - +typedef void(OVR_CDECL* ovrLogCallback)(uintptr_t userData, int level, const char* message); /// Parameters for ovr_Initialize. /// /// \see ovr_Initialize /// -typedef struct OVR_ALIGNAS(8) ovrInitParams_ -{ - /// Flags from ovrInitFlags to override default behavior. - /// Use 0 for the defaults. - uint32_t Flags; +typedef struct OVR_ALIGNAS(8) ovrInitParams_ { + /// Flags from ovrInitFlags to override default behavior. + /// Use 0 for the defaults. + uint32_t Flags; - /// Requests a specific minimum minor version of the LibOVR runtime. - /// Flags must include ovrInit_RequestVersion or this will be ignored - /// and OVR_MINOR_VERSION will be used. - uint32_t RequestedMinorVersion; + /// Requests a specific minor version of the LibOVR runtime. + /// Flags must include ovrInit_RequestVersion or this will be ignored and OVR_MINOR_VERSION + /// will be used. If you are directly calling the LibOVRRT version of ovr_Initialize + /// in the LibOVRRT DLL then this must be valid and include ovrInit_RequestVersion. + uint32_t RequestedMinorVersion; - /// User-supplied log callback function, which may be called at any time - /// asynchronously from multiple threads until ovr_Shutdown completes. - /// Use NULL to specify no log callback. - ovrLogCallback LogCallback; + /// User-supplied log callback function, which may be called at any time + /// asynchronously from multiple threads until ovr_Shutdown completes. + /// Use NULL to specify no log callback. + ovrLogCallback LogCallback; - /// User-supplied data which is passed as-is to LogCallback. Typically this - /// is used to store an application-specific pointer which is read in the - /// callback function. - uintptr_t UserData; + /// User-supplied data which is passed as-is to LogCallback. Typically this + /// is used to store an application-specific pointer which is read in the + /// callback function. + uintptr_t UserData; - /// Relative number of milliseconds to wait for a connection to the server - /// before failing. Use 0 for the default timeout. - uint32_t ConnectionTimeoutMS; + /// Relative number of milliseconds to wait for a connection to the server + /// before failing. Use 0 for the default timeout. + uint32_t ConnectionTimeoutMS; - OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal + OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal } ovrInitParams; @@ -956,39 +1488,11 @@ extern "C" { #endif +#if !defined(OVR_EXPORTING_CAPI) + // ----------------------------------------------------------------------------------- // ***** API Interfaces -// Overview of the API -// -// Setup: -// - ovr_Initialize(). -// - ovr_Create(&hmd, &graphicsId). -// - Use hmd members and ovr_GetFovTextureSize() to determine graphics configuration -// and ovr_GetRenderDesc() to get per-eye rendering parameters. -// - Allocate texture swap chains with ovr_CreateTextureSwapChainDX() or -// ovr_CreateTextureSwapChainGL(). Create any associated render target views or -// frame buffer objects. -// -// Application Loop: -// - Call ovr_GetPredictedDisplayTime() to get the current frame timing information. -// - Call ovr_GetTrackingState() and ovr_CalcEyePoses() to obtain the predicted -// rendering pose for each eye based on timing. -// - Render the scene content into the current buffer of the texture swapchains -// for each eye and layer you plan to update this frame. If you render into a -// texture swap chain, you must call ovr_CommitTextureSwapChain() on it to commit -// the changes before you reference the chain this frame (otherwise, your latest -// changes won't be picked up). -// - Call ovr_SubmitFrame() to render the distorted layers to and present them on the HMD. -// If ovr_SubmitFrame returns ovrSuccess_NotVisible, there is no need to render the scene -// for the next loop iteration. Instead, just call ovr_SubmitFrame again until it returns -// ovrSuccess. -// -// Shutdown: -// - ovr_Destroy(). -// - ovr_Shutdown(). - - /// Initializes LibOVR /// /// Initialize LibOVR for application usage. This includes finding and loading the LibOVRRT @@ -997,17 +1501,18 @@ extern "C" { /// followed by a call to ovr_Shutdown. ovr_Initialize calls are idempotent. /// Calling ovr_Initialize twice does not require two matching calls to ovr_Shutdown. /// If already initialized, the return value is ovr_Success. -/// +/// /// LibOVRRT shared library search order: /// -# Current working directory (often the same as the application directory). /// -# Module directory (usually the same as the application directory, /// but not if the module is a separate shared library). /// -# Application directory -/// -# Development directory (only if OVR_ENABLE_DEVELOPER_SEARCH is enabled, -/// which is off by default). /// -# Standard OS shared library search location(s) (OS-specific). /// -/// \param params Specifies custom initialization options. May be NULL to indicate default options. +/// \param params Specifies custom initialization options. May be NULL to indicate default options +/// when using the CAPI shim. If you are directly calling the LibOVRRT version of +/// ovr_Initialize in the LibOVRRT DLL then this must be valid and +/// include ovrInit_RequestVersion. /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. Example failed results include: /// - ovrError_Initialize: Generic initialization error. @@ -1022,7 +1527,8 @@ extern "C" { /// /// Example code /// \code{.cpp} -/// ovrResult result = ovr_Initialize(NULL); +/// ovrInitParams initParams = { ovrInit_RequestVersion, OVR_MINOR_VERSION, NULL, 0, 0 }; +/// ovrResult result = ovr_Initialize(&initParams); /// if(OVR_FAILURE(result)) { /// ovrErrorInfo errorInfo; /// ovr_GetLastErrorInfo(&errorInfo); @@ -1036,12 +1542,12 @@ extern "C" { /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* params); - /// Shuts down LibOVR /// /// A successful call to ovr_Initialize must be eventually matched by a call to ovr_Shutdown. /// After calling ovr_Shutdown, no LibOVR functions can be called except ovr_GetLastErrorInfo -/// or another ovr_Initialize. ovr_Shutdown invalidates all pointers, references, and created objects +/// or another ovr_Initialize. ovr_Shutdown invalidates all pointers, references, and created +/// objects /// previously returned by LibOVR functions. The LibOVRRT shared library can be unloaded by /// ovr_Shutdown. /// @@ -1066,7 +1572,6 @@ OVR_PUBLIC_FUNCTION(void) ovr_Shutdown(); /// OVR_PUBLIC_FUNCTION(void) ovr_GetLastErrorInfo(ovrErrorInfo* errorInfo); - /// Returns the version string representing the LibOVRRT version. /// /// The returned string pointer is valid until the next call to ovr_Shutdown. @@ -1082,7 +1587,6 @@ OVR_PUBLIC_FUNCTION(void) ovr_GetLastErrorInfo(ovrErrorInfo* errorInfo); /// OVR_PUBLIC_FUNCTION(const char*) ovr_GetVersionString(); - /// Writes a message string to the LibOVR tracing mechanism (if enabled). /// /// This message will be passed back to the application via the ovrLogCallback if @@ -1096,6 +1600,33 @@ OVR_PUBLIC_FUNCTION(const char*) ovr_GetVersionString(); /// OVR_PUBLIC_FUNCTION(int) ovr_TraceMessage(int level, const char* message); +/// Identify client application info. +/// +/// The string is one or more newline-delimited lines of optional info +/// indicating engine name, engine version, engine plugin name, engine plugin +/// version, engine editor. The order of the lines is not relevant. Individual +/// lines are optional. A newline is not necessary at the end of the last line. +/// Call after ovr_Initialize and before the first call to ovr_Create. +/// Each value is limited to 20 characters. Key names such as 'EngineName:' +/// 'EngineVersion:' do not count towards this limit. +/// +/// \param[in] identity Specifies one or more newline-delimited lines of optional info: +/// EngineName: %s\n +/// EngineVersion: %s\n +/// EnginePluginName: %s\n +/// EnginePluginVersion: %s\n +/// EngineEditor: ('true' or 'false')\n +/// +/// Example code +/// \code{.cpp} +/// ovr_IdentifyClient("EngineName: Unity\n" +/// "EngineVersion: 5.3.3\n" +/// "EnginePluginName: OVRPlugin\n" +/// "EnginePluginVersion: 1.2.0\n" +/// "EngineEditor: true"); +/// \endcode +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_IdentifyClient(const char* identity); //------------------------------------------------------------------------------------- /// @name HMD Management @@ -1103,65 +1634,74 @@ OVR_PUBLIC_FUNCTION(int) ovr_TraceMessage(int level, const char* message); /// Handles the enumeration, creation, destruction, and properties of an HMD (head-mounted display). ///@{ - /// Returns information about the current HMD. /// -/// ovr_Initialize must have first been called in order for this to succeed, otherwise ovrHmdDesc::Type -/// will be reported as ovrHmd_None. -/// -/// \param[in] session Specifies an ovrSession previously returned by ovr_Create, else NULL in which -/// case this function detects whether an HMD is present and returns its info if so. +/// ovr_Initialize must be called prior to calling this function, +/// otherwise ovrHmdDesc::Type will be set to ovrHmd_None without +/// checking for the HMD presence. +/// +/// For newer headsets being used on a game built against an old SDK version, +/// we may return the ovrHmdType as ovrHmd_CV1 for backwards compatibility. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create() or NULL. /// -/// \return Returns an ovrHmdDesc. If the hmd is NULL and ovrHmdDesc::Type is ovrHmd_None then -/// no HMD is present. +/// \return Returns an ovrHmdDesc. If invoked with NULL session argument, ovrHmdDesc::Type +/// set to ovrHmd_None indicates that the HMD is not connected. /// OVR_PUBLIC_FUNCTION(ovrHmdDesc) ovr_GetHmdDesc(ovrSession session); - -/// Returns the number of sensors. +/// Returns the number of attached trackers. /// -/// The number of sensors may change at any time, so this function should be called before use +/// The number of trackers may change at any time, so this function should be called before use /// as opposed to once on startup. -/// +/// +/// For newer headsets being used on a game built against an old SDK version, +/// we may simulate three CV1 trackers to maintain backwards compatibility. +/// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// /// \return Returns unsigned int count. /// OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackerCount(ovrSession session); - -/// Returns a given sensor description. -/// -/// It's possible that sensor desc [0] may indicate a unconnnected or non-pose tracked sensor, but -/// sensor desc [1] may be connected. +/// Returns a given attached tracker description. /// /// ovr_Initialize must have first been called in order for this to succeed, otherwise the returned -/// trackerDescArray will be zero-initialized. The data returned by this function can change at runtime. -/// +/// trackerDescArray will be zero-initialized. The data returned by this function can change at +/// runtime. +/// +/// For newer headsets being used on a game built against an old SDK version, +/// we may simulate three CV1 trackers to maintain backwards compatibility. +/// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// -/// \param[in] trackerDescIndex Specifies a sensor index. The valid indexes are in the range of 0 to -/// the sensor count returned by ovr_GetTrackerCount. /// -/// \return Returns ovrTrackerDesc. An empty ovrTrackerDesc will be returned if trackerDescIndex is out of range. +/// \param[in] trackerDescIndex Specifies a tracker index. The valid indexes are in the +/// range of 0 to the tracker count returned by ovr_GetTrackerCount. +/// +/// \return Returns ovrTrackerDesc. An empty ovrTrackerDesc will be returned if +/// trackerDescIndex is out of range. /// /// \see ovrTrackerDesc, ovr_GetTrackerCount /// -OVR_PUBLIC_FUNCTION(ovrTrackerDesc) ovr_GetTrackerDesc(ovrSession session, unsigned int trackerDescIndex); - +OVR_PUBLIC_FUNCTION(ovrTrackerDesc) +ovr_GetTrackerDesc(ovrSession session, unsigned int trackerDescIndex); /// Creates a handle to a VR session. /// -/// Upon success the returned ovrSession must be eventually freed with ovr_Destroy when it is no longer needed. -/// A second call to ovr_Create will result in an error return value if the previous Hmd has not been destroyed. +/// Upon success the returned ovrSession must be eventually freed with ovr_Destroy when it is no +/// longer needed. +/// A second call to ovr_Create will result in an error return value if the previous session has not +/// been destroyed. /// /// \param[out] pSession Provides a pointer to an ovrSession which will be written to upon success. -/// \param[out] luid Provides a system specific graphics adapter identifier that locates which +/// \param[out] pLuid Provides a system specific graphics adapter identifier that locates which /// graphics adapter has the HMD attached. This must match the adapter used by the application -/// or no rendering output will be possible. This is important for stability on multi-adapter systems. An -/// application that simply chooses the default adapter will not run reliably on multi-adapter systems. +/// or no rendering output will be possible. This is important for stability on multi-adapter +/// systems. An +/// application that simply chooses the default adapter will not run reliably on multi-adapter +/// systems. /// \return Returns an ovrResult indicating success or failure. Upon failure -/// the returned pHmd will be NULL. +/// the returned ovrSession will be NULL. /// /// Example code /// \code{.cpp} @@ -1176,8 +1716,7 @@ OVR_PUBLIC_FUNCTION(ovrTrackerDesc) ovr_GetTrackerDesc(ovrSession session, unsig /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid); - -/// Destroys the HMD. +/// Destroys the session. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \see ovr_Create @@ -1185,20 +1724,50 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* OVR_PUBLIC_FUNCTION(void) ovr_Destroy(ovrSession session); +#endif // !defined(OVR_EXPORTING_CAPI) + /// Specifies status information for the current session. /// /// \see ovr_GetSessionStatus /// -typedef struct ovrSessionStatus_ -{ - ovrBool IsVisible; ///< True if the process has VR focus and thus is visible in the HMD. - ovrBool HmdPresent; ///< True if an HMD is present. - ovrBool HmdMounted; ///< True if the HMD is on the user's head. - ovrBool DisplayLost; ///< True if the session is in a display-lost state. See ovr_SubmitFrame. - ovrBool ShouldQuit; ///< True if the application should initiate shutdown. - ovrBool ShouldRecenter; ///< True if UX has requested re-centering. Must call ovr_ClearShouldRecenterFlag or ovr_RecenterTrackingOrigin. -}ovrSessionStatus; +typedef struct ovrSessionStatus_ { + /// True if the process has VR focus and thus is visible in the HMD. + ovrBool IsVisible; + + /// True if an HMD is present. + ovrBool HmdPresent; + + /// True if the HMD is on the user's head. + ovrBool HmdMounted; + + /// True if the session is in a display-lost state. See ovr_SubmitFrame. + ovrBool DisplayLost; + + /// True if the application should initiate shutdown. + ovrBool ShouldQuit; + + /// True if UX has requested re-centering. Must call ovr_ClearShouldRecenterFlag, + /// ovr_RecenterTrackingOrigin or ovr_SpecifyTrackingOrigin. + ovrBool ShouldRecenter; + + /// True if the application is the foreground application and receives input (e.g. Touch + /// controller state). If this is false then the application is in the background (but possibly + /// still visible) should hide any input representations such as hands. + ovrBool HasInputFocus; + + /// True if a system overlay is present, such as a dashboard. In this case the application + /// (if visible) should pause while still drawing, avoid drawing near-field graphics so they + /// don't visually fight with the system overlay, and consume fewer CPU and GPU resources. + /// \deprecated Do not use. + ovrBool OverlayPresent; + + /// True if runtime is requesting that the application provide depth buffers with projection + /// layers. + ovrBool DepthRequested; + +} ovrSessionStatus; +#if !defined(OVR_EXPORTING_CAPI) /// Returns status information for the application. /// @@ -1207,17 +1776,48 @@ typedef struct ovrSessionStatus_ /// /// \return Returns an ovrResult indicating success or failure. In the case of /// failure, use ovr_GetLastErrorInfo to get more information. -// Return values include but aren't limited to: +/// Return values include but aren't limited to: /// - ovrSuccess: Completed successfully. /// - ovrError_ServiceConnection: The service connection was lost and the application -// must destroy the session. +/// must destroy the session. /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessionStatus* sessionStatus); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetSessionStatus(ovrSession session, ovrSessionStatus* sessionStatus); -//@} +/// Query extension support status. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] extension Extension to query. +/// \param[out] outExtensionSupported Set to extension support status. ovrTrue if supported. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of +/// failure use ovr_GetLastErrorInfo to get more information. +/// +/// \see ovrExtensions +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_IsExtensionSupported( + ovrSession session, + ovrExtensions extension, + ovrBool* outExtensionSupported); + +/// Enable extension. Extensions must be enabled after ovr_Create is called. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] extension Extension to enable. +/// +/// \return Returns an ovrResult indicating success or failure. Extension is only +/// enabled if successful. In the case of failure use ovr_GetLastErrorInfo +/// to get more information. +/// +/// \see ovrExtensions +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_EnableExtension(ovrSession session, ovrExtensions extension); +//@} //------------------------------------------------------------------------------------- /// @name Tracking @@ -1230,12 +1830,11 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessi ///@{ - /// Sets the tracking origin type /// /// When the tracking origin is changed, all of the calls that either provide /// or accept ovrPosef will use the new tracking origin provided. -/// +/// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] origin Specifies an ovrTrackingOrigin to be used for all ovrPosef /// @@ -1243,27 +1842,31 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessi /// ovr_GetLastErrorInfo to get more information. /// /// \see ovrTrackingOrigin, ovr_GetTrackingOriginType -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetTrackingOriginType(ovrSession session, ovrTrackingOrigin origin); - +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetTrackingOriginType(ovrSession session, ovrTrackingOrigin origin); /// Gets the tracking origin state -/// +/// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// -/// \return Returns the ovrTrackingOrigin that was either set by default, or previous set by the application. +/// \return Returns the ovrTrackingOrigin that was either set by default, or previous set by the +/// application. /// /// \see ovrTrackingOrigin, ovr_SetTrackingOriginType OVR_PUBLIC_FUNCTION(ovrTrackingOrigin) ovr_GetTrackingOriginType(ovrSession session); - /// Re-centers the sensor position and orientation. /// -/// This resets the (x,y,z) positional components and the yaw orientation component. -/// The Roll and pitch orientation components are always determined by gravity and cannot +/// This resets the (x,y,z) positional components and the yaw orientation component of the +/// tracking space for the HMD and controllers using the HMD's current tracking pose. +/// If the caller requires some tweaks on top of the HMD's current tracking pose, consider using +/// ovr_SpecifyTrackingOrigin instead. +/// +/// The roll and pitch orientation components are always determined by gravity and cannot /// be redefined. All future tracking will report values relative to this new reference position. -/// If you are using ovrTrackerPoses then you will need to call ovr_GetTrackerPose after +/// If you are using ovrTrackerPoses then you will need to call ovr_GetTrackerPose after /// this, because the sensor position(s) will change as a result of this. -/// +/// /// The headset cannot be facing vertically upward or downward but rather must be roughly /// level otherwise this function will fail with ovrError_InvalidHeadsetOrientation. /// @@ -1273,69 +1876,141 @@ OVR_PUBLIC_FUNCTION(ovrTrackingOrigin) ovr_GetTrackingOriginType(ovrSession sess /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// /// \return Returns an ovrResult indicating success or failure. In the case of failure, use -/// ovr_GetLastErrorInfo to get more information. Return values include but aren't limited to: +/// ovr_GetLastErrorInfo to get more information. Return values include but aren't limited +/// to: /// - ovrSuccess: Completed successfully. /// - ovrError_InvalidHeadsetOrientation: The headset was facing an invalid direction when /// attempting recentering, such as facing vertically. /// -/// \see ovrTrackingOrigin, ovr_GetTrackerPose +/// \see ovrTrackingOrigin, ovr_GetTrackerPose, ovr_SpecifyTrackingOrigin /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_RecenterTrackingOrigin(ovrSession session); - -/// Clears the ShouldRecenter status bit in ovrSessionStatus. +/// Allows manually tweaking the sensor position and orientation. /// -/// Clears the ShouldRecenter status bit in ovrSessionStatus, allowing further recenter -/// requests to be detected. Since this is automatically done by ovr_RecenterTrackingOrigin, -/// this is only needs to be called when application is doing its own re-centering. -OVR_PUBLIC_FUNCTION(void) ovr_ClearShouldRecenterFlag(ovrSession session); - - -/// Returns tracking state reading based on the specified absolute system time. +/// This function is similar to ovr_RecenterTrackingOrigin in that it modifies the +/// (x,y,z) positional components and the yaw orientation component of the tracking space for +/// the HMD and controllers. /// -/// Pass an absTime value of 0.0 to request the most recent sensor reading. In this case -/// both PredictedPose and SamplePose will have the same value. +/// While ovr_RecenterTrackingOrigin resets the tracking origin in reference to the HMD's +/// current pose, ovr_SpecifyTrackingOrigin allows the caller to explicitly specify a transform +/// for the tracking origin. This transform is expected to be an offset to the most recent +/// recentered origin, so calling this function repeatedly with the same originPose will keep +/// nudging the recentered origin in that direction. /// -/// This may also be used for more refined timing of front buffer rendering logic, and so on. -/// This may be called by multiple threads. +/// There are several use cases for this function. For example, if the application decides to +/// limit the yaw, or translation of the recentered pose instead of directly using the HMD pose +/// the application can query the current tracking state via ovr_GetTrackingState, and apply +/// some limitations to the HMD pose because feeding this pose back into this function. +/// Similarly, this can be used to "adjust the seating position" incrementally in apps that +/// feature seated experiences such as cockpit-based games. /// -/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// This function can emulate ovr_RecenterTrackingOrigin as such: +/// ovrTrackingState ts = ovr_GetTrackingState(session, 0.0, ovrFalse); +/// ovr_SpecifyTrackingOrigin(session, ts.HeadPose.ThePose); +/// +/// The roll and pitch orientation components are determined by gravity and cannot be redefined. +/// If you are using ovrTrackerPoses then you will need to call ovr_GetTrackerPose after +/// this, because the sensor position(s) will change as a result of this. +/// +/// For more info, see the notes on each ovrTrackingOrigin enumeration to understand how +/// recenter will vary slightly in its behavior based on the current ovrTrackingOrigin setting. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] originPose Specifies a pose that will be used to transform the current tracking +/// origin. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. Return values include but aren't limited +/// to: +/// - ovrSuccess: Completed successfully. +/// - ovrError_InvalidParameter: The heading direction in originPose was invalid, +/// such as facing vertically. This can happen if the caller is directly feeding the pose +/// of a position-tracked device such as an HMD or controller into this function. +/// +/// \see ovrTrackingOrigin, ovr_GetTrackerPose, ovr_RecenterTrackingOrigin +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_SpecifyTrackingOrigin(ovrSession session, ovrPosef originPose); + +/// Clears the ShouldRecenter status bit in ovrSessionStatus. +/// +/// Clears the ShouldRecenter status bit in ovrSessionStatus, allowing further recenter requests to +/// be detected. Since this is automatically done by ovr_RecenterTrackingOrigin and +/// ovr_SpecifyTrackingOrigin, this function only needs to be called when application is doing +/// its own re-centering logic. +OVR_PUBLIC_FUNCTION(void) ovr_ClearShouldRecenterFlag(ovrSession session); + +/// Returns tracking state reading based on the specified absolute system time. +/// +/// Pass an absTime value of 0.0 to request the most recent sensor reading. In this case +/// both PredictedPose and SamplePose will have the same value. +/// +/// This may also be used for more refined timing of front buffer rendering logic, and so on. +/// This may be called by multiple threads. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] absTime Specifies the absolute future time to predict the return /// ovrTrackingState value. Use 0 to request the most recent tracking state. /// \param[in] latencyMarker Specifies that this call is the point in time where /// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer -/// provides "SensorSampleTimestamp", that will override the value stored here. +/// provides "SensorSampleTime", that will override the value stored here. /// \return Returns the ovrTrackingState that is predicted for the given absTime. /// /// \see ovrTrackingState, ovr_GetEyePoses, ovr_GetTimeInSeconds /// -OVR_PUBLIC_FUNCTION(ovrTrackingState) ovr_GetTrackingState(ovrSession session, double absTime, ovrBool latencyMarker); +OVR_PUBLIC_FUNCTION(ovrTrackingState) +ovr_GetTrackingState(ovrSession session, double absTime, ovrBool latencyMarker); +/// Returns an array of poses, where each pose matches a device type provided by the deviceTypes +/// array parameter. If any pose cannot be retrieved, it will return a reason for the missing +/// pose and the device pose will be zeroed out with a pose quaternion [x=0, y=0, z=0, w=1]. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] deviceTypes Array of device types to query for their poses. +/// \param[in] deviceCount Number of queried poses. This number must match the length of the +/// outDevicePoses and deviceTypes array. +/// \param[in] absTime Specifies the absolute future time to predict the return +/// ovrTrackingState value. Use 0 to request the most recent tracking state. +/// \param[out] outDevicePoses Array of poses, one for each device type in deviceTypes arrays. +/// +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and +/// true upon success. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetDevicePoses( + ovrSession session, + ovrTrackedDeviceType* deviceTypes, + int deviceCount, + double absTime, + ovrPoseStatef* outDevicePoses); -/// Returns the ovrTrackerPose for the given sensor. +/// Returns the ovrTrackerPose for the given attached tracker. +/// +/// For newer headsets being used on a game built against an old SDK version, +/// we may simulate three CV1 trackers to maintain backwards compatibility. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] trackerPoseIndex Index of the sensor being requested. +/// \param[in] trackerPoseIndex Index of the tracker being requested. /// -/// \return Returns the requested ovrTrackerPose. An empty ovrTrackerPose will be returned if trackerPoseIndex is out of range. +/// \return Returns the requested ovrTrackerPose. An empty ovrTrackerPose will be returned if +/// trackerPoseIndex is out of range. /// /// \see ovr_GetTrackerCount /// -OVR_PUBLIC_FUNCTION(ovrTrackerPose) ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex); - - +OVR_PUBLIC_FUNCTION(ovrTrackerPose) +ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex); /// Returns the most recent input state for controllers, without positional tracking info. /// /// \param[out] inputState Input state that will be filled in. -/// \param[in] ovrControllerType Specifies which controller the input will be returned for. +/// \param[in] controllerType Specifies which controller the input will be returned for. /// \return Returns ovrSuccess if the new state was successfully obtained. /// /// \see ovrControllerType /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetInputState(ovrSession session, ovrControllerType controllerType, ovrInputState* inputState); - +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetInputState(ovrSession session, ovrControllerType controllerType, ovrInputState* inputState); /// Returns controller types connected to the system OR'ed together. /// @@ -1345,87 +2020,334 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetInputState(ovrSession session, ovrControll /// OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetConnectedControllerTypes(ovrSession session); +/// Gets information about Haptics engine for the specified Touch controller. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] controllerType The controller to retrieve the information from. +/// +/// \return Returns an ovrTouchHapticsDesc. +/// +OVR_PUBLIC_FUNCTION(ovrTouchHapticsDesc) +ovr_GetTouchHapticsDesc(ovrSession session, ovrControllerType controllerType); + +/// Sets constant vibration (with specified frequency and amplitude) to a controller. +/// Note: ovr_SetControllerVibration cannot be used interchangeably with +/// ovr_SubmitControllerVibration. +/// +/// This method should be called periodically, vibration lasts for a maximum of 2.5 seconds. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] controllerType The controller to set the vibration to. +/// \param[in] frequency Vibration frequency. Supported values are: 0.0 (disabled), 0.5 and 1.0. Non +/// valid values will be clamped. +/// \param[in] amplitude Vibration amplitude in the [0.0, 1.0] range. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_DeviceUnavailable: The call succeeded but the device referred to by +/// controllerType is not available. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetControllerVibration( + ovrSession session, + ovrControllerType controllerType, + float frequency, + float amplitude); + +/// Submits a Haptics buffer (used for vibration) to Touch (only) controllers. +/// Note: ovr_SubmitControllerVibration cannot be used interchangeably with +/// ovr_SetControllerVibration. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] controllerType Controller where the Haptics buffer will be played. +/// \param[in] buffer Haptics buffer containing amplitude samples to be played. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_DeviceUnavailable: The call succeeded but the device referred to by +/// controllerType is not available. +/// +/// \see ovrHapticsBuffer +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SubmitControllerVibration( + ovrSession session, + ovrControllerType controllerType, + const ovrHapticsBuffer* buffer); + +/// Gets the Haptics engine playback state of a specific Touch controller. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] controllerType Controller where the Haptics buffer wil be played. +/// \param[in] outState State of the haptics engine. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_DeviceUnavailable: The call succeeded but the device referred to by +/// controllerType is not available. +/// +/// \see ovrHapticsPlaybackState +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetControllerVibrationState( + ovrSession session, + ovrControllerType controllerType, + ovrHapticsPlaybackState* outState); -/// Turns on vibration of the given controller. +/// Tests collision/proximity of position tracked devices (e.g. HMD and/or Touch) against the +/// Boundary System. +/// Note: this method is similar to ovr_BoundaryTestPoint but can be more precise as it may take +/// into account device acceleration/momentum. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] deviceBitmask Bitmask of one or more tracked devices to test. +/// \param[in] boundaryType Must be either ovrBoundary_Outer or ovrBoundary_PlayArea. +/// \param[out] outTestResult Result of collision/proximity test, contains information such as +/// distance and closest point. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_BoundaryInvalid: The call succeeded but the result is not a valid boundary due +/// to not being set up. +/// - ovrSuccess_DeviceUnavailable: The call succeeded but the device referred to by +/// deviceBitmask is not available. +/// +/// \see ovrBoundaryTestResult /// -/// To disable vibration, call ovr_SetControllerVibration with an amplitude of 0. -/// Vibration automatically stops after a nominal amount of time, so if you want vibration -/// to be continuous over multiple seconds then you need to call this function periodically. +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_TestBoundary( + ovrSession session, + ovrTrackedDeviceType deviceBitmask, + ovrBoundaryType boundaryType, + ovrBoundaryTestResult* outTestResult); + +/// Tests collision/proximity of a 3D point against the Boundary System. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] controllerType Specifies the controller to apply the vibration to. -/// \param[in] frequency Specifies a vibration frequency in the range of 0.0 to 1.0. -/// Currently the only valid values are 0.0, 0.5, and 1.0 and other values will -/// be clamped to one of these. -/// \param[in] amplitude Specifies a vibration amplitude in the range of 0.0 to 1.0. +/// \param[in] point 3D point to test. +/// \param[in] singleBoundaryType Must be either ovrBoundary_Outer or ovrBoundary_PlayArea to test +/// against +/// \param[out] outTestResult Result of collision/proximity test, contains information such as +/// distance and closest point. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_BoundaryInvalid: The call succeeded but the result is not a valid boundary due +/// to not being set up. +/// +/// \see ovrBoundaryTestResult +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_TestBoundaryPoint( + ovrSession session, + const ovrVector3f* point, + ovrBoundaryType singleBoundaryType, + ovrBoundaryTestResult* outTestResult); + +/// Compatibility stub. +/// +/// \deprecated Previously set the look and feel of the Boundary System - this functionality has +/// been removed. /// +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] lookAndFeel Look and feel parameters. /// \return Returns ovrSuccess upon success. +/// \see ovrBoundaryLookAndFeel /// -/// \see ovrControllerType -/// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetControllerVibration(ovrSession session, ovrControllerType controllerType, - float frequency, float amplitude); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetBoundaryLookAndFeel(ovrSession session, const ovrBoundaryLookAndFeel* lookAndFeel); + +/// Resets the look and feel of the Boundary System to its default state. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \return Returns ovrSuccess upon success. +/// \see ovrBoundaryLookAndFeel +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_ResetBoundaryLookAndFeel(ovrSession session); + +/// Gets the geometry of the Boundary System's "play area" or "outer boundary" as 3D floor points. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] boundaryType Must be either ovrBoundary_Outer or ovrBoundary_PlayArea. +/// \param[out] outFloorPoints Array of 3D points (in clockwise order) defining the boundary at +/// floor height (can be NULL to retrieve only the number of points). +/// \param[out] outFloorPointsCount Number of 3D points returned in the array. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_BoundaryInvalid: The call succeeded but the result is not a valid boundary due +/// to not being set up. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetBoundaryGeometry( + ovrSession session, + ovrBoundaryType boundaryType, + ovrVector3f* outFloorPoints, + int* outFloorPointsCount); + +/// Gets the dimension of the Boundary System's "play area" or "outer boundary". +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] boundaryType Must be either ovrBoundary_Outer or ovrBoundary_PlayArea. +/// \param[out] outDimensions Dimensions of the axis aligned bounding box that encloses the area in +/// meters (width, height and length). +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: The call succeeded and a result was returned. +/// - ovrSuccess_BoundaryInvalid: The call succeeded but the result is not a valid boundary due +/// to not being set up. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetBoundaryDimensions( + ovrSession session, + ovrBoundaryType boundaryType, + ovrVector3f* outDimensions); + +/// Returns if the boundary is currently visible. +/// Note: visibility is false if the user has turned off boundaries, otherwise, it's true if +/// the app has requested boundaries to be visible or if any tracked device is currently +/// triggering it. This may not exactly match rendering due to fade-in and fade-out effects. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[out] outIsVisible ovrTrue, if the boundary is visible. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: Result was successful and a result was returned. +/// - ovrSuccess_BoundaryInvalid: The call succeeded but the result is not a valid boundary due +/// to not being set up. +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetBoundaryVisible(ovrSession session, ovrBool* outIsVisible); + +/// Requests boundary to be visible. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] visible forces the outer boundary to be visible. An application can't force it +/// to be invisible, but can cancel its request by passing false. +/// \return Returns ovrSuccess upon success. +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_RequestBoundaryVisible(ovrSession session, ovrBool visible); + +// ----------------------------------------------------------------------------------- +/// @name Mixed reality capture support +/// +/// Defines functions used for mixed reality capture / third person cameras. +/// + +/// Returns the number of camera properties of all cameras +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in, out] cameras Pointer to the array. If null and the provided array capacity is +/// sufficient, will return ovrError_NullArrayPointer. +/// \param[in, out] inoutCameraCount Supply the +/// array capacity, will return the actual # of cameras defined. If *inoutCameraCount is too small, +/// will return ovrError_InsufficientArraySize. +/// \return Returns the list of external cameras the system knows about. +/// Returns ovrError_NoExternalCameraInfo if there is not any eternal camera information. +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetExternalCameras( + ovrSession session, + ovrExternalCamera* cameras, + unsigned int* inoutCameraCount); + +/// Sets the camera intrinsics and/or extrinsics stored for the cameraName camera +/// Names must be < 32 characters and null-terminated. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] name Specifies which camera to set the intrinsics or extrinsics for. +/// The name must be at most OVR_EXTERNAL_CAMERA_NAME_SIZE - 1 +/// characters. Otherwise, ovrError_ExternalCameraNameWrongSize is returned. +/// \param[in] intrinsics Contains the intrinsic parameters to set, can be null +/// \param[in] extrinsics Contains the extrinsic parameters to set, can be null +/// \return Returns ovrSuccess or an ovrError code +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetExternalCameraProperties( + ovrSession session, + const char* name, + const ovrCameraIntrinsics* const intrinsics, + const ovrCameraExtrinsics* const extrinsics); ///@} +#endif // !defined(OVR_EXPORTING_CAPI) //------------------------------------------------------------------------------------- // @name Layers // ///@{ - /// Specifies the maximum number of layers supported by ovr_SubmitFrame. /// /// /see ovr_SubmitFrame /// -enum { - ovrMaxLayerCount = 16 -}; +enum { ovrMaxLayerCount = 16 }; /// Describes layer types that can be passed to ovr_SubmitFrame. /// Each layer type has an associated struct, such as ovrLayerEyeFov. /// /// \see ovrLayerHeader /// -typedef enum ovrLayerType_ -{ - ovrLayerType_Disabled = 0, ///< Layer is disabled. - ovrLayerType_EyeFov = 1, ///< Described by ovrLayerEyeFov. - ovrLayerType_Quad = 3, ///< Described by ovrLayerQuad. Previously called ovrLayerType_QuadInWorld. - /// enum 4 used to be ovrLayerType_QuadHeadLocked. Instead, use ovrLayerType_Quad with ovrLayerFlag_HeadLocked. - ovrLayerType_EyeMatrix = 5, ///< Described by ovrLayerEyeMatrix. - ovrLayerType_EnumSize = 0x7fffffff ///< Force type int32_t. -} ovrLayerType; +typedef enum ovrLayerType_ { + /// Layer is disabled. + ovrLayerType_Disabled = 0, + + /// Described by ovrLayerEyeFov. + ovrLayerType_EyeFov = 1, + + /// Described by ovrLayerEyeFovDepth. + ovrLayerType_EyeFovDepth = 2, + + /// Described by ovrLayerQuad. Previously called ovrLayerType_QuadInWorld. + ovrLayerType_Quad = 3, + // enum 4 used to be ovrLayerType_QuadHeadLocked. Instead, use ovrLayerType_Quad with + // ovrLayerFlag_HeadLocked. + + /// Described by ovrLayerEyeMatrix. + ovrLayerType_EyeMatrix = 5, + + + /// Described by ovrLayerEyeFovMultires. + ovrLayerType_EyeFovMultires = 7, + + /// Described by ovrLayerCylinder. + ovrLayerType_Cylinder = 8, + + /// Described by ovrLayerCube + ovrLayerType_Cube = 10, + + + + ovrLayerType_EnumSize = 0x7fffffff ///< Force type int32_t. + +} ovrLayerType; /// Identifies flags used by ovrLayerHeader and which are passed to ovr_SubmitFrame. /// /// \see ovrLayerHeader /// -typedef enum ovrLayerFlags_ -{ - /// ovrLayerFlag_HighQuality enables 4x anisotropic sampling during the composition of the layer. - /// The benefits are mostly visible at the periphery for high-frequency & high-contrast visuals. - /// For best results consider combining this flag with an ovrTextureSwapChain that has mipmaps and - /// instead of using arbitrary sized textures, prefer texture sizes that are powers-of-two. - /// Actual rendered viewport and doesn't necessarily have to fill the whole texture. - ovrLayerFlag_HighQuality = 0x01, - - /// ovrLayerFlag_TextureOriginAtBottomLeft: the opposite is TopLeft. - /// Generally this is false for D3D, true for OpenGL. - ovrLayerFlag_TextureOriginAtBottomLeft = 0x02, - - /// Mark this surface as "headlocked", which means it is specified - /// relative to the HMD and moves with it, rather than being specified - /// relative to sensor/torso space and remaining still while the head moves. - /// What used to be ovrLayerType_QuadHeadLocked is now ovrLayerType_Quad plus this flag. - /// However the flag can be applied to any layer type to achieve a similar effect. - ovrLayerFlag_HeadLocked = 0x04 +typedef enum ovrLayerFlags_ { + /// ovrLayerFlag_HighQuality enables 4x anisotropic sampling during the composition of the layer. + /// The benefits are mostly visible at the periphery for high-frequency & high-contrast visuals. + /// For best results consider combining this flag with an ovrTextureSwapChain that has mipmaps and + /// instead of using arbitrary sized textures, prefer texture sizes that are powers-of-two. + /// Actual rendered viewport and doesn't necessarily have to fill the whole texture. + ovrLayerFlag_HighQuality = 0x01, -} ovrLayerFlags; + /// ovrLayerFlag_TextureOriginAtBottomLeft: the opposite is TopLeft. + /// Generally this is false for D3D, true for OpenGL. + ovrLayerFlag_TextureOriginAtBottomLeft = 0x02, + + /// Mark this surface as "headlocked", which means it is specified + /// relative to the HMD and moves with it, rather than being specified + /// relative to sensor/torso space and remaining still while the head moves. + /// What used to be ovrLayerType_QuadHeadLocked is now ovrLayerType_Quad plus this flag. + /// However the flag can be applied to any layer type to achieve a similar effect. + ovrLayerFlag_HeadLocked = 0x04, + ovrLayerFlags_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrLayerFlags; + /// Defines properties shared by all ovrLayer structs, such as ovrLayerEyeFov. /// /// ovrLayerHeader is used as a base member in these larger structs. @@ -1433,19 +2355,21 @@ typedef enum ovrLayerFlags_ /// /// \see ovrLayerType, ovrLayerFlags /// -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerHeader_ -{ - ovrLayerType Type; ///< Described by ovrLayerType. - unsigned Flags; ///< Described by ovrLayerFlags. -} ovrLayerHeader; +typedef struct ovrLayerHeader_ ovrLayerHeader; +struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerHeader_ { + ovrLayerType Type; ///< Described by ovrLayerType. + unsigned Flags; ///< Described by ovrLayerFlags. + char Reserved[128]; +}; /// Describes a layer that specifies a monoscopic or stereoscopic view. /// This is the kind of layer that's typically used as layer 0 to ovr_SubmitFrame, /// as it is the kind of layer used to render a 3D stereoscopic view. /// /// Three options exist with respect to mono/stereo texture usage: -/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively. +/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, +/// respectively. /// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively. /// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL, /// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0]. @@ -1454,37 +2378,211 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerHeader_ /// /// \see ovrTextureSwapChain, ovr_SubmitFrame /// -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFov_ -{ - /// Header.Type must be ovrLayerType_EyeFov. - ovrLayerHeader Header; - - /// ovrTextureSwapChains for the left and right eye respectively. - /// The second one of which can be NULL for cases described above. - ovrTextureSwapChain ColorTexture[ovrEye_Count]; +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFov_ { + /// Header.Type must be ovrLayerType_EyeFov. + ovrLayerHeader Header; - /// Specifies the ColorTexture sub-rect UV coordinates. - /// Both Viewport[0] and Viewport[1] must be valid. - ovrRecti Viewport[ovrEye_Count]; + /// ovrTextureSwapChains for the left and right eye respectively. + /// The second one of which can be NULL for cases described above. + ovrTextureSwapChain ColorTexture[ovrEye_Count]; - /// The viewport field of view. - ovrFovPort Fov[ovrEye_Count]; + /// Specifies the ColorTexture sub-rect UV coordinates. + /// Both Viewport[0] and Viewport[1] must be valid. + ovrRecti Viewport[ovrEye_Count]; - /// Specifies the position and orientation of each eye view, with the position specified in meters. - /// RenderPose will typically be the value returned from ovr_CalcEyePoses, - /// but can be different in special cases if a different head pose is used for rendering. - ovrPosef RenderPose[ovrEye_Count]; + /// The viewport field of view. + ovrFovPort Fov[ovrEye_Count]; - /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) - /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds - /// around the instant the application calls ovr_GetTrackingState - /// The main purpose for this is to accurately track app tracking latency. - double SensorSampleTime; + /// Specifies the position and orientation of each eye view, with position specified in meters. + /// RenderPose will typically be the value returned from ovr_CalcEyePoses, + /// but can be different in special cases if a different head pose is used for rendering. + ovrPosef RenderPose[ovrEye_Count]; + /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) + /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds + /// around the instant the application calls ovr_GetTrackingState + /// The main purpose for this is to accurately track app tracking latency. + double SensorSampleTime; } ovrLayerEyeFov; +/// Describes a layer that specifies a monoscopic or stereoscopic view, +/// with depth textures in addition to color textures. This is typically used to support +/// positional time warp. This struct is the same as ovrLayerEyeFov, but with the addition +/// of DepthTexture and ProjectionDesc. +/// +/// ProjectionDesc can be created using ovrTimewarpProjectionDesc_FromProjection. +/// +/// Three options exist with respect to mono/stereo texture usage: +/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, +/// respectively. +/// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively. +/// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL, +/// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0]. +/// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and +/// Viewport[1] both refer to that rendering. +/// +/// \see ovrTextureSwapChain, ovr_SubmitFrame +/// +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFovDepth_ { + /// Header.Type must be ovrLayerType_EyeFovDepth. + ovrLayerHeader Header; + + /// ovrTextureSwapChains for the left and right eye respectively. + /// The second one of which can be NULL for cases described above. + ovrTextureSwapChain ColorTexture[ovrEye_Count]; + + /// Specifies the ColorTexture sub-rect UV coordinates. + /// Both Viewport[0] and Viewport[1] must be valid. + ovrRecti Viewport[ovrEye_Count]; + + /// The viewport field of view. + ovrFovPort Fov[ovrEye_Count]; + + /// Specifies the position and orientation of each eye view, with position specified in meters. + /// RenderPose will typically be the value returned from ovr_CalcEyePoses, + /// but can be different in special cases if a different head pose is used for rendering. + ovrPosef RenderPose[ovrEye_Count]; + + /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) + /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds + /// around the instant the application calls ovr_GetTrackingState + /// The main purpose for this is to accurately track app tracking latency. + double SensorSampleTime; + + /// Depth texture for depth composition with overlays + /// Must map 1:1 to the ColorTexture. + ovrTextureSwapChain DepthTexture[ovrEye_Count]; + + /// Specifies how to convert DepthTexture information into meters. + /// \see ovrTimewarpProjectionDesc_FromProjection + ovrTimewarpProjectionDesc ProjectionDesc; +} ovrLayerEyeFovDepth; + + +/// Describes eye texture layouts. Used with ovrLayerEyeFovMultires. +/// +typedef enum ovrTextureLayout_ { + ovrTextureLayout_Rectilinear = 0, ///< Regular eyeFov layer. + ovrTextureLayout_Octilinear = 1, ///< Octilinear extension must be enabled. + ovrTextureLayout_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +} ovrTextureLayout; + +/// Multiresolution descriptor for Octilinear. +/// +/// Usage of this layer must be successfully enabled via ovr_EnableExtension +/// before it can be used. +/// +/// \see ovrLayerEyeFovMultres +/// +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrTextureLayoutOctilinear_ { + // W warping + float WarpLeft; + float WarpRight; + float WarpUp; + float WarpDown; + + // Size of W quadrants. + // + // SizeLeft + SizeRight <= Viewport.Size.w + // SizeUp + sizeDown <= Viewport.Size.h + // + // Clip space (0,0) is located at Viewport.Pos + (SizeLeft,SizeUp) where + // Viewport is given in the layer description. + // + // Viewport Top left + // +-----------------------------------------------------+ + // | ^ | | + // | | | | + // | 0 SizeUp 1 | | + // | | |<--Portion of viewport + // | | | determined by sizes + // | | | | + // |<--------SizeLeft-------+-------SizeRight------>| | + // | | | | + // | | | | + // | 2 SizeDown 3 | | + // | | | | + // | | | | + // | v | | + // +------------------------------------------------+ | + // | | + // +-----------------------------------------------------+ + // Viewport bottom right + // + // For example, when rendering quadrant 0 its scissor rectangle will be + // + // Top = 0 + // Left = 0 + // Right = SizeLeft + // Bottom = SizeUp + // + // and the scissor rectangle for quadrant 1 will be: + // + // Top = 0 + // Left = SizeLeft + // Right = SizeLeft + SizeRight + // Bottom = SizeUp + // + float SizeLeft; + float SizeRight; + float SizeUp; + float SizeDown; + +} ovrTextureLayoutOctilinear; + +/// Combines texture layout descriptors. +/// +typedef union OVR_ALIGNAS(OVR_PTR_SIZE) ovrTextureLayoutDesc_Union_ { + ovrTextureLayoutOctilinear Octilinear[ovrEye_Count]; +} ovrTextureLayoutDesc_Union; + +/// Describes a layer that specifies a monoscopic or stereoscopic view with +/// support for optional multiresolution textures. This struct is the same as +/// ovrLayerEyeFov plus texture layout parameters. +/// +/// Three options exist with respect to mono/stereo texture usage: +/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, +/// respectively. +/// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively. +/// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL, +/// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0]. +/// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and +/// Viewport[1] both refer to that rendering. +/// +/// \see ovrTextureSwapChain, ovr_SubmitFrame +/// +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFovMultires_ { + /// Header.Type must be ovrLayerType_EyeFovMultires. + ovrLayerHeader Header; + + /// ovrTextureSwapChains for the left and right eye respectively. + /// The second one of which can be NULL for cases described above. + ovrTextureSwapChain ColorTexture[ovrEye_Count]; + + /// Specifies the ColorTexture sub-rect UV coordinates. + /// Both Viewport[0] and Viewport[1] must be valid. + ovrRecti Viewport[ovrEye_Count]; + + /// The viewport field of view. + ovrFovPort Fov[ovrEye_Count]; + /// Specifies the position and orientation of each eye view, with position specified in meters. + /// RenderPose will typically be the value returned from ovr_CalcEyePoses, + /// but can be different in special cases if a different head pose is used for rendering. + ovrPosef RenderPose[ovrEye_Count]; + /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) + /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds + /// around the instant the application calls ovr_GetTrackingState + /// The main purpose for this is to accurately track app tracking latency. + double SensorSampleTime; + + /// Specifies layout type of textures. + ovrTextureLayout TextureLayout; + + /// Specifies texture layout parameters. + ovrTextureLayoutDesc_Union TextureLayoutDesc; +} ovrLayerEyeFovMultires; /// Describes a layer that specifies a monoscopic or stereoscopic view. /// This uses a direct 3x4 matrix to map from view space to the UV coordinates. @@ -1494,7 +2592,8 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFov_ /// to use ovrLayerEyeFov. /// /// Three options exist with respect to mono/stereo texture usage: -/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively. +/// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, +/// respectively. /// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively. /// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL, /// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0]. @@ -1503,43 +2602,37 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFov_ /// /// \see ovrTextureSwapChain, ovr_SubmitFrame /// -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeMatrix_ -{ - /// Header.Type must be ovrLayerType_EyeMatrix. - ovrLayerHeader Header; - - /// ovrTextureSwapChains for the left and right eye respectively. - /// The second one of which can be NULL for cases described above. - ovrTextureSwapChain ColorTexture[ovrEye_Count]; - - /// Specifies the ColorTexture sub-rect UV coordinates. - /// Both Viewport[0] and Viewport[1] must be valid. - ovrRecti Viewport[ovrEye_Count]; - - /// Specifies the position and orientation of each eye view, with the position specified in meters. - /// RenderPose will typically be the value returned from ovr_CalcEyePoses, - /// but can be different in special cases if a different head pose is used for rendering. - ovrPosef RenderPose[ovrEye_Count]; - - /// Specifies the mapping from a view-space vector - /// to a UV coordinate on the textures given above. - /// P = (x,y,z,1)*Matrix - /// TexU = P.x/P.z - /// TexV = P.y/P.z - ovrMatrix4f Matrix[ovrEye_Count]; - - /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) - /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds - /// around the instant the application calls ovr_GetTrackingState - /// The main purpose for this is to accurately track app tracking latency. - double SensorSampleTime; - +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeMatrix_ { + /// Header.Type must be ovrLayerType_EyeMatrix. + ovrLayerHeader Header; + + /// ovrTextureSwapChains for the left and right eye respectively. + /// The second one of which can be NULL for cases described above. + ovrTextureSwapChain ColorTexture[ovrEye_Count]; + + /// Specifies the ColorTexture sub-rect UV coordinates. + /// Both Viewport[0] and Viewport[1] must be valid. + ovrRecti Viewport[ovrEye_Count]; + + /// Specifies the position and orientation of each eye view, with position specified in meters. + /// RenderPose will typically be the value returned from ovr_CalcEyePoses, + /// but can be different in special cases if a different head pose is used for rendering. + ovrPosef RenderPose[ovrEye_Count]; + + /// Specifies the mapping from a view-space vector + /// to a UV coordinate on the textures given above. + /// P = (x,y,z,1)*Matrix + /// TexU = P.x/P.z + /// TexV = P.y/P.z + ovrMatrix4f Matrix[ovrEye_Count]; + + /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose) + /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds + /// around the instant the application calls ovr_GetTrackingState + /// The main purpose for this is to accurately track app tracking latency. + double SensorSampleTime; } ovrLayerEyeMatrix; - - - - /// Describes a layer of Quad type, which is a single quad in world or viewer space. /// It is used for ovrLayerType_Quad. This type of layer represents a single /// object placed in the world and not a stereo view of the world itself. @@ -1553,45 +2646,132 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeMatrix_ /// /// \see ovrTextureSwapChain, ovr_SubmitFrame /// -typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerQuad_ -{ - /// Header.Type must be ovrLayerType_Quad. - ovrLayerHeader Header; +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerQuad_ { + /// Header.Type must be ovrLayerType_Quad. + ovrLayerHeader Header; - /// Contains a single image, never with any stereo view. - ovrTextureSwapChain ColorTexture; + /// Contains a single image, never with any stereo view. + ovrTextureSwapChain ColorTexture; - /// Specifies the ColorTexture sub-rect UV coordinates. - ovrRecti Viewport; + /// Specifies the ColorTexture sub-rect UV coordinates. + ovrRecti Viewport; - /// Specifies the orientation and position of the center point of a Quad layer type. - /// The supplied direction is the vector perpendicular to the quad. - /// The position is in real-world meters (not the application's virtual world, - /// the physical world the user is in) and is relative to the "zero" position - /// set by ovr_RecenterTrackingOrigin unless the ovrLayerFlag_HeadLocked flag is used. - ovrPosef QuadPoseCenter; - - /// Width and height (respectively) of the quad in meters. - ovrVector2f QuadSize; + /// Specifies the orientation and position of the center point of a Quad layer type. + /// The supplied direction is the vector perpendicular to the quad. + /// The position is in real-world meters (not the application's virtual world, + /// the physical world the user is in) and is relative to the "zero" position + /// set by ovr_RecenterTrackingOrigin unless the ovrLayerFlag_HeadLocked flag is used. + ovrPosef QuadPoseCenter; + /// Width and height (respectively) of the quad in meters. + ovrVector2f QuadSize; } ovrLayerQuad; +/// Describes a layer of type ovrLayerType_Cylinder which is a single cylinder +/// relative to the recentered origin. This type of layer represents a single +/// object placed in the world and not a stereo view of the world itself. +/// +/// -Z +Y +/// U=0 +--+--+ U=1 +/// +---+ | +---+ +-----------------+ - V=0 +/// +--+ \ | / +--+ | | | +/// +-+ \ / +-+ | | | +/// ++ \ A / ++ | | | +/// ++ \---/ ++ | | | +/// | \ / | | +X | | +/// +-------------C------R------+ +X +--------C--------+ | <--- Height +/// (+Y is out of screen) | | | +/// | | | +/// R = Radius | | | +/// A = Angle (0,2*Pi) | | | +/// C = CylinderPoseCenter | | | +/// U/V = UV Coordinates +-----------------+ - V=1 +/// +/// An identity CylinderPoseCenter places the center of the cylinder +/// at the recentered origin unless the headlocked flag is set. +/// +/// Does not utilize HmdSpaceToWorldScaleInMeters. If necessary, adjust +/// translation and radius. +/// +/// \note Only the interior surface of the cylinder is visible. Use cylinder +/// layers when the user cannot leave the extents of the cylinder. Artifacts may +/// appear when viewing the cylinder's exterior surface. Additionally, while the +/// interface supports an Angle that ranges from [0,2*Pi] the angle should +/// remain less than 1.9*PI to avoid artifacts where the cylinder edges +/// converge. +/// +/// \see ovrTextureSwapChain, ovr_SubmitFrame +/// +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerCylinder_ { + /// Header.Type must be ovrLayerType_Cylinder. + ovrLayerHeader Header; + + /// Contains a single image, never with any stereo view. + ovrTextureSwapChain ColorTexture; + + /// Specifies the ColorTexture sub-rect UV coordinates. + ovrRecti Viewport; + + /// Specifies the orientation and position of the center point of a cylinder layer type. + /// The position is in real-world meters not the application's virtual world, + /// but the physical world the user is in. It is relative to the "zero" position + /// set by ovr_RecenterTrackingOrigin unless the ovrLayerFlag_HeadLocked flag is used. + ovrPosef CylinderPoseCenter; + + /// Radius of the cylinder in meters. + float CylinderRadius; + + /// Angle in radians. Range is from 0 to 2*Pi exclusive covering the entire + /// cylinder (see diagram and note above). + float CylinderAngle; + + /// Custom aspect ratio presumably set based on 'Viewport'. Used to + /// calculate the height of the cylinder based on the arc-length (CylinderAngle) + /// and radius (CylinderRadius) given above. The height of the cylinder is + /// given by: height = (CylinderRadius * CylinderAngle) / CylinderAspectRatio. + /// Aspect ratio is width / height. + float CylinderAspectRatio; +} ovrLayerCylinder; + +/// Describes a layer of type ovrLayerType_Cube which is a single timewarped +/// cubemap at infinity. When looking down the recentered origin's -Z axis, +X +/// face is left and +Y face is up. Similarly, if headlocked the +X face is +/// left, +Y face is up and -Z face is forward. Note that the coordinate system +/// is left-handed. +/// +/// ovrLayerFlag_TextureOriginAtBottomLeft flag is not supported by ovrLayerCube. +/// +/// \see ovrTextureSwapChain, ovr_SubmitFrame +/// +typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerCube_ { + /// Header.Type must be ovrLayerType_Cube. + ovrLayerHeader Header; + + /// Orientation of the cube. + ovrQuatf Orientation; + + /// Contains a single cubemap swapchain (not a stereo pair of swapchains). + ovrTextureSwapChain CubeMapTexture; +} ovrLayerCube; /// Union that combines ovrLayer types in a way that allows them /// to be used in a polymorphic way. -typedef union ovrLayer_Union_ -{ - ovrLayerHeader Header; - ovrLayerEyeFov EyeFov; - ovrLayerQuad Quad; +typedef union ovrLayer_Union_ { + ovrLayerHeader Header; + ovrLayerEyeFov EyeFov; + ovrLayerEyeFovDepth EyeFovDepth; + ovrLayerQuad Quad; + ovrLayerEyeMatrix EyeMatrix; + ovrLayerEyeFovMultires Multires; + ovrLayerCylinder Cylinder; + ovrLayerCube Cube; } ovrLayer_Union; - //@} - +#if !defined(OVR_EXPORTING_CAPI) /// @name SDK Distortion Rendering /// @@ -1614,11 +2794,12 @@ typedef union ovrLayer_Union_ /// \param[in] chain Specifies the ovrTextureSwapChain for which the length should be retrieved. /// \param[out] out_Length Returns the number of buffers in the specified chain. /// -/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. /// /// \see ovr_CreateTextureSwapChainDX, ovr_CreateTextureSwapChainGL /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainLength(ovrSession session, ovrTextureSwapChain chain, int* out_Length); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainLength(ovrSession session, ovrTextureSwapChain chain, int* out_Length); /// Gets the current index in an ovrTextureSwapChain. /// @@ -1626,23 +2807,29 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainLength(ovrSession session, /// \param[in] chain Specifies the ovrTextureSwapChain for which the index should be retrieved. /// \param[out] out_Index Returns the current (free) index in specified chain. /// -/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. /// /// \see ovr_CreateTextureSwapChainDX, ovr_CreateTextureSwapChainGL /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainCurrentIndex(ovrSession session, ovrTextureSwapChain chain, int* out_Index); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainCurrentIndex(ovrSession session, ovrTextureSwapChain chain, int* out_Index); /// Gets the description of the buffers in an ovrTextureSwapChain /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] chain Specifies the ovrTextureSwapChain for which the description should be retrieved. +/// \param[in] chain Specifies the ovrTextureSwapChain for which the description +/// should be retrieved. /// \param[out] out_Desc Returns the description of the specified chain. /// -/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. /// /// \see ovr_CreateTextureSwapChainDX, ovr_CreateTextureSwapChainGL /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainDesc(ovrSession session, ovrTextureSwapChain chain, ovrTextureSwapChainDesc* out_Desc); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainDesc( + ovrSession session, + ovrTextureSwapChain chain, + ovrTextureSwapChainDesc* out_Desc); /// Commits any pending changes to an ovrTextureSwapChain, and advances its current index /// @@ -1655,37 +2842,41 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainDesc(ovrSession session, o /// it will synchronize with the app's graphics context and pick up the submitted index, opening up /// room in the swap chain for further commits. /// -/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error. /// Failures include but aren't limited to: -/// - ovrError_TextureSwapChainFull: ovr_CommitTextureSwapChain was called too many times on a texture swapchain without calling submit to use the chain. +/// - ovrError_TextureSwapChainFull: ovr_CommitTextureSwapChain was called too many times on a +/// texture swapchain without calling submit to use the chain. /// /// \see ovr_CreateTextureSwapChainDX, ovr_CreateTextureSwapChainGL /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CommitTextureSwapChain(ovrSession session, ovrTextureSwapChain chain); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CommitTextureSwapChain(ovrSession session, ovrTextureSwapChain chain); /// Destroys an ovrTextureSwapChain and frees all the resources associated with it. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] chain Specifies the ovrTextureSwapChain to destroy. If it is NULL then this function has no effect. +/// \param[in] chain Specifies the ovrTextureSwapChain to destroy. If it is NULL then +/// this function has no effect. /// /// \see ovr_CreateTextureSwapChainDX, ovr_CreateTextureSwapChainGL /// -OVR_PUBLIC_FUNCTION(void) ovr_DestroyTextureSwapChain(ovrSession session, ovrTextureSwapChain chain); - +OVR_PUBLIC_FUNCTION(void) +ovr_DestroyTextureSwapChain(ovrSession session, ovrTextureSwapChain chain); /// MirrorTexture creation is rendering API-specific. -/// ovr_CreateMirrorTextureDX and ovr_CreateMirrorTextureGL can be found in the +/// ovr_CreateMirrorTextureWithOptionsDX and ovr_CreateMirrorTextureWithOptionsGL can be found in /// rendering API-specific headers, such as OVR_CAPI_D3D.h and OVR_CAPI_GL.h /// Destroys a mirror texture previously created by one of the mirror texture creation functions. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] mirrorTexture Specifies the ovrTexture to destroy. If it is NULL then this function has no effect. +/// \param[in] mirrorTexture Specifies the ovrTexture to destroy. If it is NULL then +/// this function has no effect. /// -/// \see ovr_CreateMirrorTextureDX, ovr_CreateMirrorTextureGL +/// \see ovr_CreateMirrorTextureWithOptionsDX, ovr_CreateMirrorTextureWithOptionsGL /// -OVR_PUBLIC_FUNCTION(void) ovr_DestroyMirrorTexture(ovrSession session, ovrMirrorTexture mirrorTexture); - +OVR_PUBLIC_FUNCTION(void) +ovr_DestroyMirrorTexture(ovrSession session, ovrMirrorTexture mirrorTexture); /// Calculates the recommended viewport size for rendering a given eye within the HMD /// with a given FOV cone. @@ -1705,14 +2896,20 @@ OVR_PUBLIC_FUNCTION(void) ovr_DestroyMirrorTexture(ovrSession session, ovrMirror /// Example code /// \code{.cpp} /// ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session); -/// ovrSizei eyeSizeLeft = ovr_GetFovTextureSize(session, ovrEye_Left, hmdDesc.DefaultEyeFov[ovrEye_Left], 1.0f); -/// ovrSizei eyeSizeRight = ovr_GetFovTextureSize(session, ovrEye_Right, hmdDesc.DefaultEyeFov[ovrEye_Right], 1.0f); +/// ovrSizei eyeSizeLeft = ovr_GetFovTextureSize(session, ovrEye_Left, +/// hmdDesc.DefaultEyeFov[ovrEye_Left], 1.0f); +/// ovrSizei eyeSizeRight = ovr_GetFovTextureSize(session, ovrEye_Right, +/// hmdDesc.DefaultEyeFov[ovrEye_Right], 1.0f); /// \endcode /// /// \return Returns the texture width and height size. /// -OVR_PUBLIC_FUNCTION(ovrSizei) ovr_GetFovTextureSize(ovrSession session, ovrEyeType eye, ovrFovPort fov, - float pixelsPerDisplayPixel); +OVR_PUBLIC_FUNCTION(ovrSizei) +ovr_GetFovTextureSize( + ovrSession session, + ovrEyeType eye, + ovrFovPort fov, + float pixelsPerDisplayPixel); /// Computes the distortion viewport, view adjust, and other rendering parameters for /// the specified eye. @@ -1725,11 +2922,128 @@ OVR_PUBLIC_FUNCTION(ovrSizei) ovr_GetFovTextureSize(ovrSession session, ovrEyeTy /// /// \see ovrEyeRenderDesc /// -OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session, - ovrEyeType eyeType, ovrFovPort fov); +OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) +ovr_GetRenderDesc(ovrSession session, ovrEyeType eyeType, ovrFovPort fov); + +/// Waits until surfaces are available and it is time to begin rendering the frame. Must be +/// called before ovr_BeginFrame, but not necessarily from the same thread. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// +/// \param[in] frameIndex Specifies the targeted application frame index. +/// +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: command completed successfully. +/// - ovrSuccess_NotVisible: rendering of a previous frame completed successfully but was not +/// displayed on the HMD, usually because another application currently has ownership of the +/// HMD. Applications receiving this result should stop rendering new content and call +/// ovr_GetSessionStatus to detect visibility. +/// - ovrError_DisplayLost: The session has become invalid (such as due to a device removal) +/// and the shared resources need to be released (ovr_DestroyTextureSwapChain), the session +/// needs to destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be +/// created (ovr_CreateTextureSwapChainXXX). The application's existing private graphics +/// resources do not need to be recreated unless the new ovr_Create call returns a different +/// GraphicsLuid. +/// +/// \see ovr_BeginFrame, ovr_EndFrame, ovr_GetSessionStatus +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_WaitToBeginFrame(ovrSession session, long long frameIndex); + +/// Called from render thread before application begins rendering. Must be called after +/// ovr_WaitToBeginFrame and before ovr_EndFrame, but not necessarily from the same threads. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// +/// \param[in] frameIndex Specifies the targeted application frame index. It must match what was +/// passed to ovr_WaitToBeginFrame. +/// +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: command completed successfully. +/// - ovrError_DisplayLost: The session has become invalid (such as due to a device removal) +/// and the shared resources need to be released (ovr_DestroyTextureSwapChain), the session +/// needs to destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be +/// created (ovr_CreateTextureSwapChainXXX). The application's existing private graphics +/// resources do not need to be recreated unless the new ovr_Create call returns a different +/// GraphicsLuid. +/// +/// \see ovr_WaitToBeginFrame, ovr_EndFrame +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_BeginFrame(ovrSession session, long long frameIndex); + +/// Called from render thread after application has finished rendering. Must be called after +/// ovr_BeginFrame, but not necessarily from the same thread. Submits layers for distortion and +/// display, which will happen asynchronously. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// +/// \param[in] frameIndex Specifies the targeted application frame index. It must match what was +/// passed to ovr_BeginFrame. +/// +/// \param[in] viewScaleDesc Provides additional information needed only if layerPtrList contains +/// an ovrLayerType_Quad. If NULL, a default version is used based on the current +/// configuration and a 1.0 world scale. +/// +/// \param[in] layerPtrList Specifies a list of ovrLayer pointers, which can include NULL entries to +/// indicate that any previously shown layer at that index is to not be displayed. +/// Each layer header must be a part of a layer structure such as ovrLayerEyeFov or +/// ovrLayerQuad, with Header.Type identifying its type. A NULL layerPtrList entry in the +/// array indicates the absence of the given layer. +/// +/// \param[in] layerCount Indicates the number of valid elements in layerPtrList. The maximum +/// supported layerCount is not currently specified, but may be specified in a future +/// version. +/// +/// - Layers are drawn in the order they are specified in the array, regardless of the layer type. +/// +/// - Layers are not remembered between successive calls to ovr_SubmitFrame. A layer must be +/// specified in every call to ovr_SubmitFrame or it won't be displayed. +/// +/// - If a layerPtrList entry that was specified in a previous call to ovr_SubmitFrame is +/// passed as NULL or is of type ovrLayerType_Disabled, that layer is no longer displayed. +/// +/// - A layerPtrList entry can be of any layer type and multiple entries of the same layer type +/// are allowed. No layerPtrList entry may be duplicated (i.e. the same pointer as an earlier +/// entry). +/// +/// Example code +/// \code{.cpp} +/// ovrLayerEyeFov layer0; +/// ovrLayerQuad layer1; +/// ... +/// ovrLayerHeader* layers[2] = { &layer0.Header, &layer1.Header }; +/// ovrResult result = ovr_EndFrame(session, frameIndex, nullptr, layers, 2); +/// \endcode +/// +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. Return values include but aren't limited to: +/// - ovrSuccess: rendering completed successfully. +/// - ovrError_DisplayLost: The session has become invalid (such as due to a device removal) +/// and the shared resources need to be released (ovr_DestroyTextureSwapChain), the session +/// needs to destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be +/// created (ovr_CreateTextureSwapChainXXX). The application's existing private graphics +/// resources do not need to be recreated unless the new ovr_Create call returns a different +/// GraphicsLuid. +/// - ovrError_TextureSwapChainInvalid: The ovrTextureSwapChain is in an incomplete or +/// inconsistent state. Ensure ovr_CommitTextureSwapChain was called at least once first. +/// +/// \see ovr_WaitToBeginFrame, ovr_BeginFrame, ovrViewScaleDesc, ovrLayerHeader +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_EndFrame( + ovrSession session, + long long frameIndex, + const ovrViewScaleDesc* viewScaleDesc, + ovrLayerHeader const* const* layerPtrList, + unsigned int layerCount); /// Submits layers for distortion and display. /// +/// \deprecated Use ovr_WaitToBeginFrame, ovr_BeginFrame, and ovr_EndFrame instead. +/// /// ovr_SubmitFrame triggers distortion and processing which might happen asynchronously. /// The function will return when there is room in the submission queue and surfaces /// are available. Distortion might or might not have completed. @@ -1740,16 +3054,18 @@ OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session, /// after the last time ovr_SubmitFrame was called. /// /// \param[in] viewScaleDesc Provides additional information needed only if layerPtrList contains -/// an ovrLayerType_Quad. If NULL, a default version is used based on the current configuration and a 1.0 world scale. +/// an ovrLayerType_Quad. If NULL, a default version is used based on the current +/// configuration and a 1.0 world scale. /// /// \param[in] layerPtrList Specifies a list of ovrLayer pointers, which can include NULL entries to /// indicate that any previously shown layer at that index is to not be displayed. -/// Each layer header must be a part of a layer structure such as ovrLayerEyeFov or ovrLayerQuad, -/// with Header.Type identifying its type. A NULL layerPtrList entry in the array indicates the -// absence of the given layer. +/// Each layer header must be a part of a layer structure such as ovrLayerEyeFov or +/// ovrLayerQuad, with Header.Type identifying its type. A NULL layerPtrList entry in the +/// array indicates the absence of the given layer. /// /// \param[in] layerCount Indicates the number of valid elements in layerPtrList. The maximum -/// supported layerCount is not currently specified, but may be specified in a future version. +/// supported layerCount is not currently specified, but may be specified in a future +/// version. /// /// - Layers are drawn in the order they are specified in the array, regardless of the layer type. /// @@ -1760,7 +3076,8 @@ OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session, /// passed as NULL or is of type ovrLayerType_Disabled, that layer is no longer displayed. /// /// - A layerPtrList entry can be of any layer type and multiple entries of the same layer type -/// are allowed. No layerPtrList entry may be duplicated (i.e. the same pointer as an earlier entry). +/// are allowed. No layerPtrList entry may be duplicated (i.e. the same pointer as an earlier +/// entry). /// /// Example code /// \code{.cpp} @@ -1768,64 +3085,271 @@ OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session, /// ovrLayerQuad layer1; /// ... /// ovrLayerHeader* layers[2] = { &layer0.Header, &layer1.Header }; -/// ovrResult result = ovr_SubmitFrame(hmd, frameIndex, nullptr, layers, 2); +/// ovrResult result = ovr_SubmitFrame(session, frameIndex, nullptr, layers, 2); /// \endcode /// /// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true /// upon success. Return values include but aren't limited to: /// - ovrSuccess: rendering completed successfully. /// - ovrSuccess_NotVisible: rendering completed successfully but was not displayed on the HMD, -/// usually because another application currently has ownership of the HMD. Applications receiving -/// this result should stop rendering new content, but continue to call ovr_SubmitFrame periodically -/// until it returns a value other than ovrSuccess_NotVisible. +/// usually because another application currently has ownership of the HMD. Applications +/// receiving this result should stop rendering new content, call ovr_GetSessionStatus +/// to detect visibility. /// - ovrError_DisplayLost: The session has become invalid (such as due to a device removal) -/// and the shared resources need to be released (ovr_DestroyTextureSwapChain), the session needs to -/// destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be created -/// (ovr_CreateTextureSwapChainXXX). The application's existing private graphics resources do not -/// need to be recreated unless the new ovr_Create call returns a different GraphicsLuid. -/// - ovrError_TextureSwapChainInvalid: The ovrTextureSwapChain is in an incomplete or inconsistent state. -/// Ensure ovr_CommitTextureSwapChain was called at least once first. -/// -/// \see ovr_GetPredictedDisplayTime, ovrViewScaleDesc, ovrLayerHeader -/// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SubmitFrame(ovrSession session, long long frameIndex, - const ovrViewScaleDesc* viewScaleDesc, - ovrLayerHeader const * const * layerPtrList, unsigned int layerCount); -///@} +/// and the shared resources need to be released (ovr_DestroyTextureSwapChain), the session +/// needs to destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be +/// created (ovr_CreateTextureSwapChainXXX). The application's existing private graphics +/// resources do not need to be recreated unless the new ovr_Create call returns a different +/// GraphicsLuid. +/// - ovrError_TextureSwapChainInvalid: The ovrTextureSwapChain is in an incomplete or +/// inconsistent state. Ensure ovr_CommitTextureSwapChain was called at least once first. +/// +/// \see ovr_GetPredictedDisplayTime, ovrViewScaleDesc, ovrLayerHeader, ovr_GetSessionStatus +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SubmitFrame( + ovrSession session, + long long frameIndex, + const ovrViewScaleDesc* viewScaleDesc, + ovrLayerHeader const* const* layerPtrList, + unsigned int layerCount); +///@} +#endif // !defined(OVR_EXPORTING_CAPI) //------------------------------------------------------------------------------------- /// @name Frame Timing /// //@{ +/// +/// Contains the performance stats for a given SDK compositor frame +/// +/// All of the 'int' typed fields can be reset via the ovr_ResetPerfStats call. +/// +typedef struct OVR_ALIGNAS(4) ovrPerfStatsPerCompositorFrame_ { + /// Vsync Frame Index - increments with each HMD vertical synchronization signal (i.e. vsync or + /// refresh rate) + /// If the compositor drops a frame, expect this value to increment more than 1 at a time. + int HmdVsyncIndex; + + /// + /// Application stats + /// + + /// Index that increments with each successive ovr_SubmitFrame call + int AppFrameIndex; + + /// If the app fails to call ovr_SubmitFrame on time, then expect this value to increment with + /// each missed frame + int AppDroppedFrameCount; + + /// Motion-to-photon latency for the application + /// This value is calculated by either using the SensorSampleTime provided for the ovrLayerEyeFov + /// or if that + /// is not available, then the call to ovr_GetTrackingState which has latencyMarker set to ovrTrue + float AppMotionToPhotonLatency; + + /// Amount of queue-ahead in seconds provided to the app based on performance and overlap of + /// CPU and GPU utilization. A value of 0.0 would mean the CPU & GPU workload is being completed + /// in 1 frame's worth of time, while 11 ms (on the CV1) of queue ahead would indicate that the + /// app's CPU workload for the next frame is overlapping the GPU workload for the current frame. + float AppQueueAheadTime; + + /// Amount of time in seconds spent on the CPU by the app's render-thread that calls + /// ovr_SubmitFram. Measured as elapsed time between from when app regains control from + /// ovr_SubmitFrame to the next time the app calls ovr_SubmitFrame. + float AppCpuElapsedTime; + + /// Amount of time in seconds spent on the GPU by the app. + /// Measured as elapsed time between each ovr_SubmitFrame call using GPU timing queries. + float AppGpuElapsedTime; + + /// + /// SDK Compositor stats + /// + + /// Index that increments each time the SDK compositor completes a distortion and timewarp pass + /// Since the compositor operates asynchronously, even if the app calls ovr_SubmitFrame too late, + /// the compositor will kick off for each vsync. + int CompositorFrameIndex; + + /// Increments each time the SDK compositor fails to complete in time + /// This is not tied to the app's performance, but failure to complete can be related to other + /// factors such as OS capabilities, overall available hardware cycles to execute the compositor + /// in time and other factors outside of the app's control. + int CompositorDroppedFrameCount; + + /// Motion-to-photon latency of the SDK compositor in seconds. + /// This is the latency of timewarp which corrects the higher app latency as well as dropped app + /// frames. + float CompositorLatency; + + /// The amount of time in seconds spent on the CPU by the SDK compositor. Unless the + /// VR app is utilizing all of the CPU cores at their peak performance, there is a good chance the + /// compositor CPU times will not affect the app's CPU performance in a major way. + float CompositorCpuElapsedTime; + + /// The amount of time in seconds spent on the GPU by the SDK compositor. Any time spent on the + /// compositor will eat away from the available GPU time for the app. + float CompositorGpuElapsedTime; + + /// The amount of time in seconds spent from the point the CPU kicks off the compositor to the + /// point in time the compositor completes the distortion & timewarp on the GPU. In the event the + /// GPU time is not available, expect this value to be -1.0f. + float CompositorCpuStartToGpuEndElapsedTime; + + /// The amount of time in seconds left after the compositor is done on the GPU to the associated + /// V-Sync time. In the event the GPU time is not available, expect this value to be -1.0f. + float CompositorGpuEndToVsyncElapsedTime; + + /// + /// Async Spacewarp stats (ASW) + /// + + /// Will be true if ASW is active for the given frame such that the application is being forced + /// into half the frame-rate while the compositor continues to run at full frame-rate. + ovrBool AswIsActive; + + /// Increments each time ASW it activated where the app was forced in and out of + /// half-rate rendering. + int AswActivatedToggleCount; + + /// Accumulates the number of frames presented by the compositor which had extrapolated + /// ASW frames presented. + int AswPresentedFrameCount; + + /// Accumulates the number of frames that the compositor tried to present when ASW is + /// active but failed. + int AswFailedFrameCount; + +} ovrPerfStatsPerCompositorFrame; + +/// +/// Maximum number of frames of performance stats provided back to the caller of ovr_GetPerfStats +/// +enum { ovrMaxProvidedFrameStats = 5 }; + +/// +/// This is a complete descriptor of the performance stats provided by the SDK +/// +/// \see ovr_GetPerfStats, ovrPerfStatsPerCompositorFrame +typedef struct OVR_ALIGNAS(4) ovrPerfStats_ { + /// FrameStatsCount will have a maximum value set by ovrMaxProvidedFrameStats + /// If the application calls ovr_GetPerfStats at the native refresh rate of the HMD + /// then FrameStatsCount will be 1. If the app's workload happens to force + /// ovr_GetPerfStats to be called at a lower rate, then FrameStatsCount will be 2 or more. + /// If the app does not want to miss any performance data for any frame, it needs to + /// ensure that it is calling ovr_SubmitFrame and ovr_GetPerfStats at a rate that is at least: + /// "HMD_refresh_rate / ovrMaxProvidedFrameStats". On the Oculus Rift CV1 HMD, this will + /// be equal to 18 times per second. + /// + /// The performance entries will be ordered in reverse chronological order such that the + /// first entry will be the most recent one. + ovrPerfStatsPerCompositorFrame FrameStats[ovrMaxProvidedFrameStats]; + int FrameStatsCount; + + /// If the app calls ovr_GetPerfStats at less than 18 fps for CV1, then AnyFrameStatsDropped + /// will be ovrTrue and FrameStatsCount will be equal to ovrMaxProvidedFrameStats. + ovrBool AnyFrameStatsDropped; + + /// AdaptiveGpuPerformanceScale is an edge-filtered value that a caller can use to adjust + /// the graphics quality of the application to keep the GPU utilization in check. The value + /// is calculated as: (desired_GPU_utilization / current_GPU_utilization) + /// As such, when this value is 1.0, the GPU is doing the right amount of work for the app. + /// Lower values mean the app needs to pull back on the GPU utilization. + /// If the app is going to directly drive render-target resolution using this value, then + /// be sure to take the square-root of the value before scaling the resolution with it. + /// Changing render target resolutions however is one of the many things an app can do + /// increase or decrease the amount of GPU utilization. + /// Since AdaptiveGpuPerformanceScale is edge-filtered and does not change rapidly + /// (i.e. reports non-1.0 values once every couple of seconds) the app can make the + /// necessary adjustments and then keep watching the value to see if it has been satisfied. + float AdaptiveGpuPerformanceScale; + + /// Will be true if Async Spacewarp (ASW) is available for this system which is dependent on + /// several factors such as choice of GPU, OS and debug overrides + ovrBool AswIsAvailable; + + /// Contains the Process ID of the VR application the stats are being polled for + /// If an app continues to grab perf stats even when it is not visible, then expect this + /// value to point to the other VR app that has grabbed focus (i.e. became visible) + ovrProcessId VisibleProcessId; +} ovrPerfStats; + +#if !defined(OVR_EXPORTING_CAPI) + +/// Retrieves performance stats for the VR app as well as the SDK compositor. +/// +/// This function will return stats for the VR app that is currently visible in the HMD +/// regardless of what VR app is actually calling this function. +/// +/// If the VR app is trying to make sure the stats returned belong to the same application, +/// the caller can compare the VisibleProcessId with their own process ID. Normally this will +/// be the case if the caller is only calling ovr_GetPerfStats when ovr_GetSessionStatus has +/// IsVisible flag set to be true. +/// +/// If the VR app calling ovr_GetPerfStats is actually the one visible in the HMD, +/// then new perf stats will only be populated after a new call to ovr_SubmitFrame. +/// That means subsequent calls to ovr_GetPerfStats after the first one without calling +/// ovr_SubmitFrame will receive a FrameStatsCount of zero. +/// +/// If the VR app is not visible, or was initially marked as ovrInit_Invisible, then each call +/// to ovr_GetPerfStats will immediately fetch new perf stats from the compositor without +/// a need for the ovr_SubmitFrame call. +/// +/// Even though invisible VR apps do not require ovr_SubmitFrame to be called to gather new +/// perf stats, since stats are generated at the native refresh rate of the HMD (i.e. 90 Hz +/// for CV1), calling it at a higher rate than that would be unnecessary. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[out] outStats Contains the performance stats for the application and SDK compositor +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. +/// +/// \see ovrPerfStats, ovrPerfStatsPerCompositorFrame, ovr_ResetPerfStats +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetPerfStats(ovrSession session, ovrPerfStats* outStats); + +/// Resets the accumulated stats reported in each ovrPerfStatsPerCompositorFrame back to zero. +/// +/// Only the integer values such as HmdVsyncIndex, AppDroppedFrameCount etc. will be reset +/// as the other fields such as AppMotionToPhotonLatency are independent timing values updated +/// per-frame. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true +/// upon success. +/// +/// \see ovrPerfStats, ovrPerfStatsPerCompositorFrame, ovr_GetPerfStats +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_ResetPerfStats(ovrSession session); /// Gets the time of the specified frame midpoint. /// -/// Predicts the time at which the given frame will be displayed. The predicted time -/// is the middle of the time period during which the corresponding eye images will -/// be displayed. +/// Predicts the time at which the given frame will be displayed. The predicted time +/// is the middle of the time period during which the corresponding eye images will +/// be displayed. /// /// The application should increment frameIndex for each successively targeted frame, -/// and pass that index to any relevent OVR functions that need to apply to the frame +/// and pass that index to any relevant OVR functions that need to apply to the frame /// identified by that index. /// /// This function is thread-safe and allows for multiple application threads to target /// their processing to the same displayed frame. -/// +/// /// In the even that prediction fails due to various reasons (e.g. the display being off /// or app has yet to present any frames), the return value will be current CPU time. -/// +/// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] frameIndex Identifies the frame the caller wishes to target. /// A value of zero returns the next frame index. -/// \return Returns the absolute frame midpoint time for the given frameIndex. +/// \return Returns the absolute frame midpoint time for the given frameIndex. /// \see ovr_GetTimeInSeconds /// OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long long frameIndex); - /// Returns global, absolute high-resolution time in seconds. /// /// The time frame of reference for this function is not specified and should not be @@ -1836,6 +3360,7 @@ OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long /// OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds(); +#endif // !defined(OVR_EXPORTING_CAPI) /// Performance HUD enables the HMD user to see information critical to /// the real-time operation of the VR application such as latency timing, @@ -1844,19 +3369,19 @@ OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds(); /// App can toggle performance HUD modes as such: /// \code{.cpp} /// ovrPerfHudMode PerfHudMode = ovrPerfHud_LatencyTiming; -/// ovr_SetInt(Hmd, OVR_PERF_HUD_MODE, (int)PerfHudMode); +/// ovr_SetInt(session, OVR_PERF_HUD_MODE, (int)PerfHudMode); /// \endcode /// -typedef enum ovrPerfHudMode_ -{ - ovrPerfHud_Off = 0, ///< Turns off the performance HUD - ovrPerfHud_PerfSummary = 1, ///< Shows performance summary and headroom - ovrPerfHud_LatencyTiming = 2, ///< Shows latency related timing info - ovrPerfHud_AppRenderTiming = 3, ///< Shows render timing info for application - ovrPerfHud_CompRenderTiming = 4, ///< Shows render timing info for OVR compositor - ovrPerfHud_VersionInfo = 5, ///< Shows SDK & HMD version Info - ovrPerfHud_Count = 6, ///< \internal Count of enumerated elements. - ovrPerfHud_EnumSize = 0x7fffffff ///< \internal Force type int32_t. +typedef enum ovrPerfHudMode_ { + ovrPerfHud_Off = 0, ///< Turns off the performance HUD + ovrPerfHud_PerfSummary = 1, ///< Shows performance summary and headroom + ovrPerfHud_LatencyTiming = 2, ///< Shows latency related timing info + ovrPerfHud_AppRenderTiming = 3, ///< Shows render timing info for application + ovrPerfHud_CompRenderTiming = 4, ///< Shows render timing info for OVR compositor + ovrPerfHud_AswStats = 6, ///< Shows Async Spacewarp-specific info + ovrPerfHud_VersionInfo = 5, ///< Shows SDK & HMD version Info + ovrPerfHud_Count = 7, ///< \internal Count of enumerated elements. + ovrPerfHud_EnumSize = 0x7fffffff ///< \internal Force type int32_t. } ovrPerfHudMode; /// Layer HUD enables the HMD user to see information about a layer @@ -1864,20 +3389,19 @@ typedef enum ovrPerfHudMode_ /// App can toggle layer HUD modes as such: /// \code{.cpp} /// ovrLayerHudMode LayerHudMode = ovrLayerHud_Info; -/// ovr_SetInt(Hmd, OVR_LAYER_HUD_MODE, (int)LayerHudMode); +/// ovr_SetInt(session, OVR_LAYER_HUD_MODE, (int)LayerHudMode); /// \endcode /// -typedef enum ovrLayerHudMode_ -{ - ovrLayerHud_Off = 0, ///< Turns off the layer HUD - ovrLayerHud_Info = 1, ///< Shows info about a specific layer - ovrLayerHud_EnumSize = 0x7fffffff +typedef enum ovrLayerHudMode_ { + ovrLayerHud_Off = 0, ///< Turns off the layer HUD + ovrLayerHud_Info = 1, ///< Shows info about a specific layer + ovrLayerHud_EnumSize = 0x7fffffff } ovrLayerHudMode; ///@} /// Debug HUD is provided to help developers gauge and debug the fidelity of their app's -/// stereo rendering characteristics. Using the provided quad and crosshair guides, +/// stereo rendering characteristics. Using the provided quad and crosshair guides, /// the developer can verify various aspects such as VR tracking units (e.g. meters), /// stereo camera-parallax properties (e.g. making sure objects at infinity are rendered /// with the proper separation), measuring VR geometry sizes and distances and more. @@ -1885,25 +3409,32 @@ typedef enum ovrLayerHudMode_ /// App can toggle the debug HUD modes as such: /// \code{.cpp} /// ovrDebugHudStereoMode DebugHudMode = ovrDebugHudStereo_QuadWithCrosshair; -/// ovr_SetInt(Hmd, OVR_DEBUG_HUD_STEREO_MODE, (int)DebugHudMode); +/// ovr_SetInt(session, OVR_DEBUG_HUD_STEREO_MODE, (int)DebugHudMode); /// \endcode /// /// The app can modify the visual properties of the stereo guide (i.e. quad, crosshair) /// using the ovr_SetFloatArray function. For a list of tweakable properties, /// see the OVR_DEBUG_HUD_STEREO_GUIDE_* keys in the OVR_CAPI_Keys.h header file. -typedef enum ovrDebugHudStereoMode_ -{ - ovrDebugHudStereo_Off = 0, ///< Turns off the Stereo Debug HUD - ovrDebugHudStereo_Quad = 1, ///< Renders Quad in world for Stereo Debugging - ovrDebugHudStereo_QuadWithCrosshair = 2, ///< Renders Quad+crosshair in world for Stereo Debugging - ovrDebugHudStereo_CrosshairAtInfinity = 3, ///< Renders screen-space crosshair at infinity for Stereo Debugging - ovrDebugHudStereo_Count, ///< \internal Count of enumerated elements - - ovrDebugHudStereo_EnumSize = 0x7fffffff ///< \internal Force type int32_t -} ovrDebugHudStereoMode; +typedef enum ovrDebugHudStereoMode_ { + /// Turns off the Stereo Debug HUD. + ovrDebugHudStereo_Off = 0, + /// Renders Quad in world for Stereo Debugging. + ovrDebugHudStereo_Quad = 1, + /// Renders Quad+crosshair in world for Stereo Debugging + ovrDebugHudStereo_QuadWithCrosshair = 2, + /// Renders screen-space crosshair at infinity for Stereo Debugging + ovrDebugHudStereo_CrosshairAtInfinity = 3, + + /// \internal Count of enumerated elements + ovrDebugHudStereo_Count, + + ovrDebugHudStereo_EnumSize = 0x7fffffff ///< \internal Force type int32_t +} ovrDebugHudStereoMode; + +#if !defined(OVR_EXPORTING_CAPI) // ----------------------------------------------------------------------------------- /// @name Property Access @@ -1920,7 +3451,8 @@ typedef enum ovrDebugHudStereoMode_ /// \param[in] defaultVal specifes the value to return if the property couldn't be read. /// \return Returns the property interpreted as a boolean value. Returns defaultVal if /// the property doesn't exist. -OVR_PUBLIC_FUNCTION(ovrBool) ovr_GetBool(ovrSession session, const char* propertyName, ovrBool defaultVal); +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_GetBool(ovrSession session, const char* propertyName, ovrBool defaultVal); /// Writes or creates a boolean property. /// If the property wasn't previously a boolean property, it is changed to a boolean property. @@ -1928,10 +3460,11 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovr_GetBool(ovrSession session, const char* propert /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] value The value to write. -/// \return Returns true if successful, otherwise false. A false result should only occur if the property +/// \return Returns true if successful, otherwise false. A false result should only occur if the +/// property /// name is empty or if the property is read-only. -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetBool(ovrSession session, const char* propertyName, ovrBool value); - +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetBool(ovrSession session, const char* propertyName, ovrBool value); /// Reads an integer property. /// @@ -1949,11 +3482,10 @@ OVR_PUBLIC_FUNCTION(int) ovr_GetInt(ovrSession session, const char* propertyName /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] value The value to write. -/// \return Returns true if successful, otherwise false. A false result should only occur if the property -/// name is empty or if the property is read-only. +/// \return Returns true if successful, otherwise false. A false result should only occur if the +/// property name is empty or if the property is read-only. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetInt(ovrSession session, const char* propertyName, int value); - /// Reads a float property. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. @@ -1961,7 +3493,8 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetInt(ovrSession session, const char* property /// \param[in] defaultVal specifes the value to return if the property couldn't be read. /// \return Returns the property interpreted as an float value. Returns defaultVal if /// the property doesn't exist. -OVR_PUBLIC_FUNCTION(float) ovr_GetFloat(ovrSession session, const char* propertyName, float defaultVal); +OVR_PUBLIC_FUNCTION(float) +ovr_GetFloat(ovrSession session, const char* propertyName, float defaultVal); /// Writes or creates a float property. /// If the property wasn't previously a float property, it's changed to a float property. @@ -1969,10 +3502,10 @@ OVR_PUBLIC_FUNCTION(float) ovr_GetFloat(ovrSession session, const char* property /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] value The value to write. -/// \return Returns true if successful, otherwise false. A false result should only occur if the property -/// name is empty or if the property is read-only. -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloat(ovrSession session, const char* propertyName, float value); - +/// \return Returns true if successful, otherwise false. A false result should only occur if the +/// property name is empty or if the property is read-only. +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetFloat(ovrSession session, const char* propertyName, float value); /// Reads a float array property. /// @@ -1981,8 +3514,12 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloat(ovrSession session, const char* proper /// \param[in] values An array of float to write to. /// \param[in] valuesCapacity Specifies the maximum number of elements to write to the values array. /// \return Returns the number of elements read, or 0 if property doesn't exist or is empty. -OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetFloatArray(ovrSession session, const char* propertyName, - float values[], unsigned int valuesCapacity); +OVR_PUBLIC_FUNCTION(unsigned int) +ovr_GetFloatArray( + ovrSession session, + const char* propertyName, + float values[], + unsigned int valuesCapacity); /// Writes or creates a float array property. /// @@ -1990,11 +3527,14 @@ OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetFloatArray(ovrSession session, const ch /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] values An array of float to write from. /// \param[in] valuesSize Specifies the number of elements to write. -/// \return Returns true if successful, otherwise false. A false result should only occur if the property -/// name is empty or if the property is read-only. -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloatArray(ovrSession session, const char* propertyName, - const float values[], unsigned int valuesSize); - +/// \return Returns true if successful, otherwise false. A false result should only occur if the +/// property name is empty or if the property is read-only. +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetFloatArray( + ovrSession session, + const char* propertyName, + const float values[], + unsigned int valuesSize); /// Reads a string property. /// Strings are UTF8-encoded and null-terminated. @@ -2002,11 +3542,11 @@ OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloatArray(ovrSession session, const char* p /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] defaultVal Specifes the value to return if the property couldn't be read. -/// \return Returns the string property if it exists. Otherwise returns defaultVal, which can be specified as NULL. -/// The return memory is guaranteed to be valid until next call to ovr_GetString or -/// until the HMD is destroyed, whichever occurs first. -OVR_PUBLIC_FUNCTION(const char*) ovr_GetString(ovrSession session, const char* propertyName, - const char* defaultVal); +/// \return Returns the string property if it exists. Otherwise returns defaultVal, which can be +/// specified as NULL. The return memory is guaranteed to be valid until next call to +/// ovr_GetString or until the session is destroyed, whichever occurs first. +OVR_PUBLIC_FUNCTION(const char*) +ovr_GetString(ovrSession session, const char* propertyName, const char* defaultVal); /// Writes or creates a string property. /// Strings are UTF8-encoded and null-terminated. @@ -2014,93 +3554,30 @@ OVR_PUBLIC_FUNCTION(const char*) ovr_GetString(ovrSession session, const char* p /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] propertyName The name of the property, which needs to be valid only for the call. /// \param[in] value The string property, which only needs to be valid for the duration of the call. -/// \return Returns true if successful, otherwise false. A false result should only occur if the property -/// name is empty or if the property is read-only. -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetString(ovrSession session, const char* propertyName, - const char* value); +/// \return Returns true if successful, otherwise false. A false result should only occur if the +/// property name is empty or if the property is read-only. +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetString(ovrSession session, const char* propertyName, const char* value); ///@} - +#endif // !defined(OVR_EXPORTING_CAPI) #ifdef __cplusplus } // extern "C" #endif - #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif /// @cond DoxygenIgnore -//----------------------------------------------------------------------------- -// ***** Compiler packing validation -// -// These checks ensure that the compiler settings being used will be compatible -// with with pre-built dynamic library provided with the runtime. - -OVR_STATIC_ASSERT(sizeof(ovrBool) == 1, "ovrBool size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrVector2i) == 4 * 2, "ovrVector2i size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrSizei) == 4 * 2, "ovrSizei size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrRecti) == sizeof(ovrVector2i) + sizeof(ovrSizei), "ovrRecti size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrQuatf) == 4 * 4, "ovrQuatf size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrVector2f) == 4 * 2, "ovrVector2f size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrVector3f) == 4 * 3, "ovrVector3f size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrMatrix4f) == 4 * 16, "ovrMatrix4f size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrPosef) == (7 * 4), "ovrPosef size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrPoseStatef) == (22 * 4), "ovrPoseStatef size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrFovPort) == (4 * 4), "ovrFovPort size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrHmdCaps) == 4, "ovrHmdCaps size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrTrackingCaps) == 4, "ovrTrackingCaps size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrEyeType) == 4, "ovrEyeType size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrHmdType) == 4, "ovrHmdType size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrTrackerDesc) == 4 + 4 + 4 + 4, "ovrTrackerDesc size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrTrackerPose) == 4 + 4 + sizeof(ovrPosef) + sizeof(ovrPosef), "ovrTrackerPose size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrTrackingState) == sizeof(ovrPoseStatef) + 4 + 4 + (sizeof(ovrPoseStatef) * 2) + (sizeof(unsigned int) * 2) + sizeof(ovrPosef) + 4, "ovrTrackingState size mismatch"); - - -//OVR_STATIC_ASSERT(sizeof(ovrTextureHeader) == sizeof(ovrRenderAPIType) + sizeof(ovrSizei), -// "ovrTextureHeader size mismatch"); -//OVR_STATIC_ASSERT(sizeof(ovrTexture) == sizeof(ovrTextureHeader) OVR_ON64(+4) + sizeof(uintptr_t) * 8, -// "ovrTexture size mismatch"); -// -OVR_STATIC_ASSERT(sizeof(ovrStatusBits) == 4, "ovrStatusBits size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrSessionStatus) == 6, "ovrSessionStatus size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrEyeRenderDesc) == sizeof(ovrEyeType) + sizeof(ovrFovPort) + sizeof(ovrRecti) + - sizeof(ovrVector2f) + sizeof(ovrVector3f), - "ovrEyeRenderDesc size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrTimewarpProjectionDesc) == 4 * 3, "ovrTimewarpProjectionDesc size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrInitFlags) == 4, "ovrInitFlags size mismatch"); -OVR_STATIC_ASSERT(sizeof(ovrLogLevel) == 4, "ovrLogLevel size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrInitParams) == 4 + 4 + sizeof(ovrLogCallback) + sizeof(uintptr_t) + 4 + 4, - "ovrInitParams size mismatch"); - -OVR_STATIC_ASSERT(sizeof(ovrHmdDesc) == - + sizeof(ovrHmdType) // Type - OVR_ON64(+ 4) // pad0 - + 64 // ProductName - + 64 // Manufacturer - + 2 // VendorId - + 2 // ProductId - + 24 // SerialNumber - + 2 // FirmwareMajor - + 2 // FirmwareMinor - + 4 * 4 // AvailableHmdCaps - DefaultTrackingCaps - + sizeof(ovrFovPort) * 2 // DefaultEyeFov - + sizeof(ovrFovPort) * 2 // MaxEyeFov - + sizeof(ovrSizei) // Resolution - + 4 // DisplayRefreshRate - OVR_ON64(+ 4) // pad1 - , "ovrHmdDesc size mismatch"); +OVR_STATIC_ASSERT( + sizeof(ovrTextureSwapChainDesc) == 10 * 4, + "ovrTextureSwapChainDesc size mismatch"); + // ----------------------------------------------------------------------------------- // ***** Backward compatibility #includes // @@ -2108,7 +3585,7 @@ OVR_STATIC_ASSERT(sizeof(ovrHmdDesc) == // declarations above. #if !defined(OVR_CAPI_NO_UTILS) - #include "Extras/OVR_CAPI_Util.h" +#include "Extras/OVR_CAPI_Util.h" #endif /// @endcond diff --git a/ext/LibOVR/Include/OVR_CAPI_Audio.h b/ext/LibOVR/Include/OVR_CAPI_Audio.h index c534481..8650208 100644 --- a/ext/LibOVR/Include/OVR_CAPI_Audio.h +++ b/ext/LibOVR/Include/OVR_CAPI_Audio.h @@ -1,21 +1,27 @@ -/********************************************************************************//** -\file OVR_CAPI_Audio.h -\brief CAPI audio functions. -\copyright Copyright 2015 Oculus VR, LLC. All Rights reserved. -************************************************************************************/ - +/********************************************************************************/ /** + \file OVR_CAPI_Audio.h + \brief CAPI audio functions. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ #ifndef OVR_CAPI_Audio_h #define OVR_CAPI_Audio_h #ifdef _WIN32 +// Prevents from defining min() and max() macro symbols. +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #include "OVR_CAPI.h" #define OVR_AUDIO_MAX_DEVICE_STR_SIZE 128 +#if !defined(OVR_EXPORTING_CAPI) + /// Gets the ID of the preferred VR audio output device. /// -/// \param[out] deviceOutId The ID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be WAVE_MAPPER. +/// \param[out] deviceOutId The ID of the user's preferred VR audio device to use, +/// which will be valid upon a successful return value, else it will be WAVE_MAPPER. /// /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. @@ -24,14 +30,14 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutWaveId(UINT* deviceOutId); /// Gets the ID of the preferred VR audio input device. /// -/// \param[out] deviceInId The ID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be WAVE_MAPPER. +/// \param[out] deviceInId The ID of the user's preferred VR audio device to use, +/// which will be valid upon a successful return value, else it will be WAVE_MAPPER. /// /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInWaveId(UINT* deviceInId); - /// Gets the GUID of the preferred VR audio device as a string. /// /// \param[out] deviceOutStrBuffer A buffer where the GUID string for the device will copied to. @@ -39,19 +45,19 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInWaveId(UINT* deviceInId); /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuidStr(WCHAR deviceOutStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE]); - +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetAudioDeviceOutGuidStr(WCHAR deviceOutStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE]); /// Gets the GUID of the preferred VR audio device. /// -/// \param[out] deviceOutGuid The GUID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be NULL. +/// \param[out] deviceOutGuid The GUID of the user's preferred VR audio device to use, +/// which will be valid upon a successful return value, else it will be NULL. /// /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid); - /// Gets the GUID of the preferred VR microphone device as a string. /// /// \param[out] deviceInStrBuffer A buffer where the GUID string for the device will copied to. @@ -59,18 +65,21 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid); /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuidStr(WCHAR deviceInStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE]); - +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetAudioDeviceInGuidStr(WCHAR deviceInStrBuffer[OVR_AUDIO_MAX_DEVICE_STR_SIZE]); /// Gets the GUID of the preferred VR microphone device. /// -/// \param[out] deviceInGuid The GUID of the user's preferred VR audio device to use, which will be valid upon a successful return value, else it will be NULL. +/// \param[out] deviceInGuid The GUID of the user's preferred VR audio device to use, +/// which will be valid upon a successful return value, else it will be NULL. /// /// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuid(GUID* deviceInGuid); -#endif //OVR_OS_MS +#endif // !defined(OVR_EXPORTING_CAPI) + +#endif // OVR_OS_MS -#endif // OVR_CAPI_Audio_h +#endif // OVR_CAPI_Audio_h diff --git a/ext/LibOVR/Include/OVR_CAPI_D3D.h b/ext/LibOVR/Include/OVR_CAPI_D3D.h index 50806bc..c8bbc91 100644 --- a/ext/LibOVR/Include/OVR_CAPI_D3D.h +++ b/ext/LibOVR/Include/OVR_CAPI_D3D.h @@ -1,8 +1,8 @@ -/********************************************************************************//** -\file OVR_CAPI_D3D.h -\brief D3D specific structures used by the CAPI interface. -\copyright Copyright 2014-2016 Oculus VR, LLC All Rights reserved. -************************************************************************************/ +/********************************************************************************/ /** + \file OVR_CAPI_D3D.h + \brief D3D specific structures used by the CAPI interface. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ #ifndef OVR_CAPI_D3D_h #define OVR_CAPI_D3D_h @@ -10,9 +10,11 @@ #include "OVR_CAPI.h" #include "OVR_Version.h" - -#if defined (_WIN32) +#if defined(_WIN32) #include +#include + +#if !defined(OVR_EXPORTING_CAPI) //----------------------------------------------------------------------------------- // ***** Direct3D Specific @@ -20,26 +22,36 @@ /// Create Texture Swap Chain suitable for use with Direct3D 11 and 12. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] d3dPtr Specifies the application's D3D11Device to create resources with or the D3D12CommandQueue -/// which must be the same one the application renders to the eye textures with. -/// \param[in] desc Specifies requested texture properties. See notes for more info about texture format. -/// \param[in] bindFlags Specifies what ovrTextureBindFlags the application requires for this texture chain. -/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain, which will be valid upon a successful return value, else it will be NULL. -/// This texture chain must be eventually destroyed via ovr_DestroyTextureSwapChain before destroying the HMD with ovr_Destroy. -/// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \param[in] d3dPtr Specifies the application's D3D11Device to create resources with +/// or the D3D12CommandQueue which must be the same one the application renders +/// to the eye textures with. +/// \param[in] desc Specifies requested texture properties. See notes for more info +/// about texture format. +/// \param[in] bindFlags Specifies what ovrTextureBindFlags the application requires +/// for this texture chain. +/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain, which will +/// be valid upon a successful return value, else it will be NULL. +/// This texture chain must be eventually destroyed via ovr_DestroyTextureSwapChain +/// before destroying the session with ovr_Destroy. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -/// \note The texture format provided in \a desc should be thought of as the format the distortion-compositor will use for the -/// ShaderResourceView when reading the contents of the texture. To that end, it is highly recommended that the application -/// requests texture swapchain formats that are in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor -/// does sRGB-correct rendering. As such, the compositor relies on the GPU's hardware sampler to do the sRGB-to-linear -/// conversion. If the application still prefers to render to a linear format (e.g. OVR_FORMAT_R8G8B8A8_UNORM) while handling the -/// linear-to-gamma conversion via HLSL code, then the application must still request the corresponding sRGB format and also use -/// the \a ovrTextureMisc_DX_Typeless flag in the ovrTextureSwapChainDesc's Flag field. This will allow the application to create -/// a RenderTargetView that is the desired linear format while the compositor continues to treat it as sRGB. Failure to do so -/// will cause the compositor to apply unexpected gamma conversions leading to gamma-curve artifacts. The \a ovrTextureMisc_DX_Typeless -/// flag for depth buffer formats (e.g. OVR_FORMAT_D32_FLOAT) is ignored as they are always converted to be typeless. +/// \note The texture format provided in \a desc should be thought of as the format the +/// distortion-compositor will use for the ShaderResourceView when reading the contents of +/// the texture. To that end, it is highly recommended that the application requests texture +// swapchain formats that are in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) +/// as the compositor does sRGB-correct rendering. As such, the compositor relies on the +/// GPU's hardware sampler to do the sRGB-to-linear conversion. If the application still +/// prefers to render to a linear format (e.g. OVR_FORMAT_R8G8B8A8_UNORM) while handling the +/// linear-to-gamma conversion via HLSL code, then the application must still request the +/// corresponding sRGB format and also use the \a ovrTextureMisc_DX_Typeless flag in the +/// ovrTextureSwapChainDesc's Flag field. This will allow the application to create +/// a RenderTargetView that is the desired linear format while the compositor continues to +/// treat it as sRGB. Failure to do so will cause the compositor to apply unexpected gamma +/// conversions leading to gamma-curve artifacts. The \a ovrTextureMisc_DX_Typeless +/// flag for depth buffer formats (e.g. OVR_FORMAT_D32_FLOAT) is ignored as they are always +/// converted to be typeless. /// /// \see ovr_GetTextureSwapChainLength /// \see ovr_GetTextureSwapChainCurrentIndex @@ -47,60 +59,75 @@ /// \see ovr_GetTextureSwapChainBufferDX /// \see ovr_DestroyTextureSwapChain /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateTextureSwapChainDX(ovrSession session, - IUnknown* d3dPtr, - const ovrTextureSwapChainDesc* desc, - ovrTextureSwapChain* out_TextureSwapChain); - +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* out_TextureSwapChain); -/// Get a specific buffer within the chain as any compatible COM interface (similar to QueryInterface) +/// Get a specific buffer within the chain as any compatible COM interface (similar to +/// QueryInterface) /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] chain Specifies an ovrTextureSwapChain previously returned by ovr_CreateTextureSwapChainDX -/// \param[in] index Specifies the index within the chain to retrieve. Must be between 0 and length (see ovr_GetTextureSwapChainLength), -/// or may pass -1 to get the buffer at the CurrentIndex location. (Saving a call to GetTextureSwapChainCurrentIndex) +/// \param[in] chain Specifies an ovrTextureSwapChain previously returned +/// by ovr_CreateTextureSwapChainDX +/// \param[in] index Specifies the index within the chain to retrieve. +/// Must be between 0 and length (see ovr_GetTextureSwapChainLength), +/// or may pass -1 to get the buffer at the CurrentIndex location. (Saving a call to +/// GetTextureSwapChainCurrentIndex) /// \param[in] iid Specifies the interface ID of the interface pointer to query the buffer for. /// \param[out] out_Buffer Returns the COM interface pointer retrieved. /// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// /// Example code /// \code{.cpp} -/// ovr_GetTextureSwapChainBufferDX(session, chain, 0, IID_ID3D11Texture2D, &d3d11Texture); -/// ovr_GetTextureSwapChainBufferDX(session, chain, 1, IID_PPV_ARGS(&dxgiResource)); +/// ovr_GetTextureSwapChainBufferDX(s, d3d11Chain, 0, IID_ID3D11Texture2D, &d3d11Texture); +/// ovr_GetTextureSwapChainBufferDX(s, d3d11Chain, 1, IID_PPV_ARGS(&dxgiResource)); +/// ovr_GetTextureSwapChainBufferDX(s, d3d12Chain, 0, IID_ID3D12Resource, &d3d12Texture); /// \endcode /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferDX(ovrSession session, - ovrTextureSwapChain chain, - int index, - IID iid, - void** out_Buffer); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferDX( + ovrSession session, + ovrTextureSwapChain chain, + int index, + IID iid, + void** out_Buffer); - -/// Create Mirror Texture which is auto-refreshed to mirror Rift contents produced by this application. +/// Create Mirror Texture which is auto-refreshed to mirror Rift contents produced by this +/// application. /// -/// A second call to ovr_CreateMirrorTextureDX for a given ovrSession before destroying the first one -/// is not supported and will result in an error return. +/// A second call to ovr_CreateMirrorTextureWithOptionsDX for a given ovrSession before destroying +/// the first one is not supported and will result in an error return. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] d3dPtr Specifies the application's D3D11Device to create resources with or the D3D12CommandQueue -/// which must be the same one the application renders to the textures with. -/// \param[in] desc Specifies requested texture properties. See notes for more info about texture format. -/// \param[out] out_MirrorTexture Returns the created ovrMirrorTexture, which will be valid upon a successful return value, else it will be NULL. -/// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before destroying the HMD with ovr_Destroy. -/// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \param[in] d3dPtr Specifies the application's D3D11Device to create resources with +/// or the D3D12CommandQueue which must be the same one the application renders to +/// the textures with. +/// \param[in] desc Specifies requested texture properties. +/// See notes for more info about texture format. +/// \param[out] out_MirrorTexture Returns the created ovrMirrorTexture, which will be valid upon a +/// successful return value, else it will be NULL. +/// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before +/// destroying the session with ovr_Destroy. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -/// \note The texture format provided in \a desc should be thought of as the format the compositor will use for the RenderTargetView when -/// writing into mirror texture. To that end, it is highly recommended that the application requests a mirror texture format that is -/// in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor does sRGB-correct rendering. If however the application wants -/// to still read the mirror texture as a linear format (e.g. OVR_FORMAT_R8G8B8A8_UNORM) and handle the sRGB-to-linear conversion in -/// HLSL code, then it is recommended the application still requests an sRGB format and also use the \a ovrTextureMisc_DX_Typeless flag in the -/// ovrMirrorTextureDesc's Flags field. This will allow the application to bind a ShaderResourceView that is a linear format while the -/// compositor continues to treat is as sRGB. Failure to do so will cause the compositor to apply unexpected gamma conversions leading to -/// gamma-curve artifacts. +/// \note The texture format provided in \a desc should be thought of as the format the compositor +/// will use for the RenderTargetView when writing into mirror texture. To that end, it is +/// highly recommended that the application requests a mirror texture format that is +/// in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor does sRGB-correct +/// rendering. If however the application wants to still read the mirror texture as a linear +/// format (e.g. OVR_FORMAT_R8G8B8A8_UNORM) and handle the sRGB-to-linear conversion in +/// HLSL code, then it is recommended the application still requests an sRGB format and also +/// use the \a ovrTextureMisc_DX_Typeless flag in the ovrMirrorTextureDesc's Flags field. +/// This will allow the application to bind a ShaderResourceView that is a linear format +/// while the compositor continues to treat is as sRGB. Failure to do so will cause the +/// compositor to apply unexpected gamma conversions leading to gamma-curve artifacts. /// /// /// Example code @@ -110,7 +137,8 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferDX(ovrSession sessio /// mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; /// mirrorDesc.Width = mirrorWindowWidth; /// mirrorDesc.Height = mirrorWindowHeight; -/// ovrResult result = ovr_CreateMirrorTextureDX(session, d3d11Device, &mirrorDesc, &mirrorTexture); +/// ovrResult result = ovr_CreateMirrorTextureWithOptionsDX(session, d3d11Device, +/// &mirrorDesc, &mirrorTexture); /// [...] /// // Destroy the texture when done with it. /// ovr_DestroyMirrorTexture(session, mirrorTexture); @@ -120,19 +148,36 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferDX(ovrSession sessio /// \see ovr_GetMirrorTextureBufferDX /// \see ovr_DestroyMirrorTexture /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureDX(ovrSession session, - IUnknown* d3dPtr, - const ovrMirrorTextureDesc* desc, - ovrMirrorTexture* out_MirrorTexture); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture); + +/// Deprecated. Use ovr_CreateMirrorTextureWithOptionsDX instead +/// +/// Same as ovr_CreateMirrorTextureWithOptionsDX except doesn't use ovrMirrorOptions flags as part +/// of ovrMirrorTextureDesc's MirrorOptions field, and defaults to ovrMirrorOption_PostDistortion +/// +/// \see ovrMirrorOptions, ovr_CreateMirrorTextureWithOptionsDX +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture); -/// Get a the underlying buffer as any compatible COM interface (similar to QueryInterface) +/// Get a the underlying buffer as any compatible COM interface (similar to QueryInterface) /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] mirrorTexture Specifies an ovrMirrorTexture previously returned by ovr_CreateMirrorTextureDX +/// \param[in] mirrorTexture Specifies an ovrMirrorTexture previously returned +/// by ovr_CreateMirrorTextureWithOptionsDX /// \param[in] iid Specifies the interface ID of the interface pointer to query the buffer for. /// \param[out] out_Buffer Returns the COM interface pointer retrieved. /// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// /// Example code @@ -144,12 +189,15 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureDX(ovrSession session, /// dxgiSwapChain->Present(0, 0); /// \endcode /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetMirrorTextureBufferDX(ovrSession session, - ovrMirrorTexture mirrorTexture, - IID iid, - void** out_Buffer); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferDX( + ovrSession session, + ovrMirrorTexture mirrorTexture, + IID iid, + void** out_Buffer); +#endif // !defined(OVR_EXPORTING_CAPI) #endif // _WIN32 -#endif // OVR_CAPI_D3D_h +#endif // OVR_CAPI_D3D_h diff --git a/ext/LibOVR/Include/OVR_CAPI_GL.h b/ext/LibOVR/Include/OVR_CAPI_GL.h index 1658ca5..6c1b9bf 100644 --- a/ext/LibOVR/Include/OVR_CAPI_GL.h +++ b/ext/LibOVR/Include/OVR_CAPI_GL.h @@ -1,33 +1,40 @@ -/********************************************************************************//** -\file OVR_CAPI_GL.h -\brief OpenGL-specific structures used by the CAPI interface. -\copyright Copyright 2015 Oculus VR, LLC. All Rights reserved. -************************************************************************************/ +/********************************************************************************/ /** + \file OVR_CAPI_GL.h + \brief OpenGL-specific structures used by the CAPI interface. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ #ifndef OVR_CAPI_GL_h #define OVR_CAPI_GL_h #include "OVR_CAPI.h" +#if !defined(OVR_EXPORTING_CAPI) + /// Creates a TextureSwapChain suitable for use with OpenGL. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] desc Specifies the requested texture properties. See notes for more info about texture format. -/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain, which will be valid upon -/// a successful return value, else it will be NULL. This texture swap chain must be eventually -/// destroyed via ovr_DestroyTextureSwapChain before destroying the HMD with ovr_Destroy. -/// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \param[in] desc Specifies the requested texture properties. +/// See notes for more info about texture format. +/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain, +/// which will be valid upon a successful return value, else it will be NULL. +/// This texture swap chain must be eventually destroyed via +// ovr_DestroyTextureSwapChain before destroying the session with ovr_Destroy. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -/// \note The \a format provided should be thought of as the format the distortion compositor will use when reading -/// the contents of the texture. To that end, it is highly recommended that the application requests texture swap chain -/// formats that are in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the distortion compositor does sRGB-correct -/// rendering. Furthermore, the app should then make sure "glEnable(GL_FRAMEBUFFER_SRGB);" is called before rendering -/// into these textures. Even though it is not recommended, if the application would like to treat the texture as a linear -/// format and do linear-to-gamma conversion in GLSL, then the application can avoid calling "glEnable(GL_FRAMEBUFFER_SRGB);", -/// but should still pass in an sRGB variant for the \a format. Failure to do so will cause the distortion compositor -/// to apply incorrect gamma conversions leading to gamma-curve artifacts. +/// \note The \a format provided should be thought of as the format the distortion compositor will +/// use when reading the contents of the texture. To that end, it is highly recommended +/// that the application requests texture swap chain formats that are in sRGB-space +/// (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the distortion compositor does sRGB-correct +/// rendering. Furthermore, the app should then make sure "glEnable(GL_FRAMEBUFFER_SRGB);" +/// is called before rendering into these textures. Even though it is not recommended, +/// if the application would like to treat the texture as a linear format and do +/// linear-to-gamma conversion in GLSL, then the application can avoid +/// calling "glEnable(GL_FRAMEBUFFER_SRGB);", but should still pass in an sRGB variant for +/// the \a format. Failure to do so will cause the distortion compositor to apply incorrect +/// gamma conversions leading to gamma-curve artifacts. /// /// \see ovr_GetTextureSwapChainLength /// \see ovr_GetTextureSwapChainCurrentIndex @@ -35,65 +42,96 @@ /// \see ovr_GetTextureSwapChainBufferGL /// \see ovr_DestroyTextureSwapChain /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateTextureSwapChainGL(ovrSession session, - const ovrTextureSwapChainDesc* desc, - ovrTextureSwapChain* out_TextureSwapChain); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainGL( + ovrSession session, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* out_TextureSwapChain); /// Get a specific buffer within the chain as a GL texture name /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] chain Specifies an ovrTextureSwapChain previously returned by ovr_CreateTextureSwapChainGL -/// \param[in] index Specifies the index within the chain to retrieve. Must be between 0 and length (see ovr_GetTextureSwapChainLength) -/// or may pass -1 to get the buffer at the CurrentIndex location. (Saving a call to GetTextureSwapChainCurrentIndex) -/// \param[out] out_TexId Returns the GL texture object name associated with the specific index requested -/// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use -/// ovr_GetLastErrorInfo to get more information. -/// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferGL(ovrSession session, - ovrTextureSwapChain chain, - int index, - unsigned int* out_TexId); +/// \param[in] chain Specifies an ovrTextureSwapChain previously returned +/// by ovr_CreateTextureSwapChainGL +/// \param[in] index Specifies the index within the chain to retrieve. +/// Must be between 0 and length (see ovr_GetTextureSwapChainLength) +/// or may pass -1 to get the buffer at the CurrentIndex location. +/// (Saving a call to GetTextureSwapChainCurrentIndex) +/// \param[out] out_TexId Returns the GL texture object name associated with +/// the specific index requested +/// +/// \return Returns an ovrResult indicating success or failure. +/// In the case of failure, use ovr_GetLastErrorInfo to get more information. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferGL( + ovrSession session, + ovrTextureSwapChain chain, + int index, + unsigned int* out_TexId); - -/// Creates a Mirror Texture which is auto-refreshed to mirror Rift contents produced by this application. +/// Creates a Mirror Texture which is auto-refreshed to mirror Rift contents produced by this +/// application. /// -/// A second call to ovr_CreateMirrorTextureGL for a given ovrSession before destroying the first one -/// is not supported and will result in an error return. +/// A second call to ovr_CreateMirrorTextureWithOptionsGL for a given ovrSession before destroying +/// the first one is not supported and will result in an error return. /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. /// \param[in] desc Specifies the requested mirror texture description. -/// \param[out] out_MirrorTexture Specifies the created ovrMirrorTexture, which will be valid upon a successful return value, else it will be NULL. -/// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before destroying the HMD with ovr_Destroy. +/// \param[out] out_MirrorTexture Specifies the created ovrMirrorTexture, which will be +/// valid upon a successful return value, else it will be NULL. +/// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before +/// destroying the session with ovr_Destroy. /// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -/// \note The \a format provided should be thought of as the format the distortion compositor will use when writing into the mirror -/// texture. It is highly recommended that mirror textures are requested as sRGB formats because the distortion compositor -/// does sRGB-correct rendering. If the application requests a non-sRGB format (e.g. R8G8B8A8_UNORM) as the mirror texture, -/// then the application might have to apply a manual linear-to-gamma conversion when reading from the mirror texture. -/// Failure to do so can result in incorrect gamma conversions leading to gamma-curve artifacts and color banding. +/// \note The \a format provided should be thought of as the format the distortion compositor will +/// use when writing into the mirror texture. It is highly recommended that mirror textures +// are requested as sRGB formats because the distortion compositor does sRGB-correct +/// rendering. If the application requests a non-sRGB format (e.g. R8G8B8A8_UNORM) as the +/// mirror texture, then the application might have to apply a manual linear-to-gamma +/// conversion when reading from the mirror texture. Failure to do so can result in +// incorrect gamma conversions leading to gamma-curve artifacts and color banding. /// /// \see ovr_GetMirrorTextureBufferGL /// \see ovr_DestroyMirrorTexture /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureGL(ovrSession session, - const ovrMirrorTextureDesc* desc, - ovrMirrorTexture* out_MirrorTexture); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsGL( + ovrSession session, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture); + +/// Deprecated. Use ovr_CreateMirrorTextureWithOptionsGL instead +/// +/// Same as ovr_CreateMirrorTextureWithOptionsGL except doesn't use ovrMirrorOptions flags as part +/// of ovrMirrorTextureDesc's MirrorOptions field, and defaults to ovrMirrorOption_PostDistortion +/// +/// \see ovrMirrorOptions, ovr_CreateMirrorTextureWithOptionsGL +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureGL( + ovrSession session, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture); /// Get a the underlying buffer as a GL texture name /// /// \param[in] session Specifies an ovrSession previously returned by ovr_Create. -/// \param[in] mirrorTexture Specifies an ovrMirrorTexture previously returned by ovr_CreateMirrorTextureGL +/// \param[in] mirrorTexture Specifies an ovrMirrorTexture previously returned +// by ovr_CreateMirrorTextureWithOptionsGL /// \param[out] out_TexId Specifies the GL texture object name associated with the mirror texture /// -/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use /// ovr_GetLastErrorInfo to get more information. /// -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetMirrorTextureBufferGL(ovrSession session, - ovrMirrorTexture mirrorTexture, - unsigned int* out_TexId); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferGL( + ovrSession session, + ovrMirrorTexture mirrorTexture, + unsigned int* out_TexId); +#endif // !defined(OVR_EXPORTING_CAPI) -#endif // OVR_CAPI_GL_h +#endif // OVR_CAPI_GL_h diff --git a/ext/LibOVR/Include/OVR_CAPI_Keys.h b/ext/LibOVR/Include/OVR_CAPI_Keys.h index e3e9d68..7c37357 100644 --- a/ext/LibOVR/Include/OVR_CAPI_Keys.h +++ b/ext/LibOVR/Include/OVR_CAPI_Keys.h @@ -1,8 +1,8 @@ -/********************************************************************************//** -\file OVR_CAPI.h -\brief Keys for CAPI proprty function calls -\copyright Copyright 2015 Oculus VR, LLC All Rights reserved. -************************************************************************************/ +/********************************************************************************/ /** + \file OVR_CAPI.h + \brief Keys for CAPI property function calls + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ #ifndef OVR_CAPI_Keys_h #define OVR_CAPI_Keys_h @@ -11,43 +11,39 @@ -#define OVR_KEY_USER "User" // string +#define OVR_KEY_USER "User" // string -#define OVR_KEY_NAME "Name" // string +#define OVR_KEY_NAME "Name" // string -#define OVR_KEY_GENDER "Gender" // string "Male", "Female", or "Unknown" -#define OVR_DEFAULT_GENDER "Unknown" +#define OVR_KEY_GENDER "Gender" // string "Male", "Female", or "Unknown" +#define OVR_DEFAULT_GENDER "Unknown" -#define OVR_KEY_PLAYER_HEIGHT "PlayerHeight" // float meters -#define OVR_DEFAULT_PLAYER_HEIGHT 1.778f +#define OVR_KEY_PLAYER_HEIGHT "PlayerHeight" // float meters +#define OVR_DEFAULT_PLAYER_HEIGHT 1.778f -#define OVR_KEY_EYE_HEIGHT "EyeHeight" // float meters -#define OVR_DEFAULT_EYE_HEIGHT 1.675f +#define OVR_KEY_EYE_HEIGHT "EyeHeight" // float meters +#define OVR_DEFAULT_EYE_HEIGHT 1.675f -#define OVR_KEY_NECK_TO_EYE_DISTANCE "NeckEyeDistance" // float[2] meters -#define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.0805f -#define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.075f +#define OVR_KEY_NECK_TO_EYE_DISTANCE "NeckEyeDistance" // float[2] meters +#define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.0805f +#define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.075f +#define OVR_KEY_EYE_TO_NOSE_DISTANCE "EyeToNoseDist" // float[2] meters -#define OVR_KEY_EYE_TO_NOSE_DISTANCE "EyeToNoseDist" // float[2] meters +#define OVR_PERF_HUD_MODE "PerfHudMode" // int, allowed values are defined in enum ovrPerfHudMode +#define OVR_LAYER_HUD_MODE "LayerHudMode" // int, allowed values are defined in enum ovrLayerHudMode +#define OVR_LAYER_HUD_CURRENT_LAYER "LayerHudCurrentLayer" // int, The layer to show +#define OVR_LAYER_HUD_SHOW_ALL_LAYERS "LayerHudShowAll" // bool, Hide other layers when hud enabled - -#define OVR_PERF_HUD_MODE "PerfHudMode" // int, allowed values are defined in enum ovrPerfHudMode - -#define OVR_LAYER_HUD_MODE "LayerHudMode" // int, allowed values are defined in enum ovrLayerHudMode -#define OVR_LAYER_HUD_CURRENT_LAYER "LayerHudCurrentLayer" // int, The layer to show -#define OVR_LAYER_HUD_SHOW_ALL_LAYERS "LayerHudShowAll" // bool, Hide other layers when the hud is enabled - -#define OVR_DEBUG_HUD_STEREO_MODE "DebugHudStereoMode" // int, allowed values are defined in enum ovrDebugHudStereoMode -#define OVR_DEBUG_HUD_STEREO_GUIDE_INFO_ENABLE "DebugHudStereoGuideInfoEnable" // bool -#define OVR_DEBUG_HUD_STEREO_GUIDE_SIZE "DebugHudStereoGuideSize2f" // float[2] -#define OVR_DEBUG_HUD_STEREO_GUIDE_POSITION "DebugHudStereoGuidePosition3f" // float[3] +#define OVR_DEBUG_HUD_STEREO_MODE "DebugHudStereoMode" // int, see enum ovrDebugHudStereoMode +#define OVR_DEBUG_HUD_STEREO_GUIDE_INFO_ENABLE "DebugHudStereoGuideInfoEnable" // bool +#define OVR_DEBUG_HUD_STEREO_GUIDE_SIZE "DebugHudStereoGuideSize2f" // float[2] +#define OVR_DEBUG_HUD_STEREO_GUIDE_POSITION "DebugHudStereoGuidePosition3f" // float[3] #define OVR_DEBUG_HUD_STEREO_GUIDE_YAWPITCHROLL "DebugHudStereoGuideYawPitchRoll3f" // float[3] -#define OVR_DEBUG_HUD_STEREO_GUIDE_COLOR "DebugHudStereoGuideColor4f" // float[4] - +#define OVR_DEBUG_HUD_STEREO_GUIDE_COLOR "DebugHudStereoGuideColor4f" // float[4] #endif // OVR_CAPI_Keys_h diff --git a/ext/LibOVR/Include/OVR_CAPI_Vk.h b/ext/LibOVR/Include/OVR_CAPI_Vk.h new file mode 100644 index 0000000..feae83f --- /dev/null +++ b/ext/LibOVR/Include/OVR_CAPI_Vk.h @@ -0,0 +1,285 @@ +/********************************************************************************/ /** + \file OVR_CAPI_Vk.h + \brief Vulkan specific structures used by the CAPI interface. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ + +#ifndef OVR_CAPI_Vk_h +#define OVR_CAPI_Vk_h + +#include "OVR_CAPI.h" +#include "OVR_Version.h" + +#if !defined(OVR_EXPORTING_CAPI) + +//----------------------------------------------------------------------------------- +// ***** Vulkan Specific + +/// Get a list of Vulkan vkInstance extensions required for VR. +/// +/// Returns a list of strings delimited by a single space identifying Vulkan extensions that must +/// be enabled in order for the VR runtime to support Vulkan-based applications. The returned +/// list reflects the current runtime version and the GPU the VR system is currently connected to. +/// +/// \param[in] luid Specifies the luid for the relevant GPU, which is returned from ovr_Create. +/// \param[in] extensionNames is a character buffer which will receive a list of extension name +/// strings, separated by a single space char between each extension. +/// \param[in] inoutExtensionNamesSize indicates on input the capacity of extensionNames in chars. +/// On output it returns the number of characters written to extensionNames, +/// including the terminating 0 char. In the case of this function returning +/// ovrError_InsufficientArraySize, the required inoutExtensionNamesSize is returned. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. Returns ovrError_InsufficientArraySize in +/// the case that inoutExtensionNameSize didn't have enough space, in which case +/// inoutExtensionNameSize will return the required inoutExtensionNamesSize. +/// +/// Example code +/// \code{.cpp} +/// char extensionNames[4096]; +/// uint32_t extensionNamesSize = sizeof(extensionNames); +/// ovr_GetInstanceExtensionsVk(luid, extensionsnames, &extensionNamesSize); +/// +/// uint32_t extensionCount = 0; +/// const char* extensionNamePtrs[256]; +/// for(const char* p = extensionNames; *p; ++p) { +/// if((p == extensionNames) || (p[-1] == ' ')) { +/// extensionNamePtrs[extensionCount++] = p; +/// if (p[-1] == ' ') +/// p[-1] = '\0'; +/// } +/// } +/// +/// VkInstanceCreateInfo info = { ... }; +/// info.enabledExtensionCount = extensionCount; +/// info.ppEnabledExtensionNames = extensionNamePtrs; +/// [...] +/// \endcode +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetInstanceExtensionsVk( + ovrGraphicsLuid luid, + char* extensionNames, + uint32_t* inoutExtensionNamesSize); + +/// Get a list of Vulkan vkDevice extensions required for VR. +/// +/// Returns a list of strings delimited by a single space identifying Vulkan extensions that must +/// be enabled in order for the VR runtime to support Vulkan-based applications. The returned +/// list reflects the current runtime version and the GPU the VR system is currently connected to. +/// +/// \param[in] luid Specifies the luid for the relevant GPU, which is returned from ovr_Create. +/// \param[in] extensionNames is a character buffer which will receive a list of extension name +/// strings, separated by a single space char between each extension. +/// \param[in] inoutExtensionNamesSize indicates on input the capacity of extensionNames in chars. +/// On output it returns the number of characters written to extensionNames, +/// including the terminating 0 char. In the case of this function returning +/// ovrError_InsufficientArraySize, the required inoutExtensionNamesSize is returned. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. Returns ovrError_InsufficientArraySize in +/// the case that inoutExtensionNameSize didn't have enough space, in which case +/// inoutExtensionNameSize will return the required inoutExtensionNamesSize. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetDeviceExtensionsVk( + ovrGraphicsLuid luid, + char* extensionNames, + uint32_t* inoutExtensionNamesSize); + +/// Find VkPhysicalDevice matching ovrGraphicsLuid +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] luid Specifies the luid returned from ovr_Create. +/// \param[in] instance Specifies a VkInstance to search for matching luids in. +/// \param[out] out_physicalDevice Returns the VkPhysicalDevice matching the instance and luid. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +/// \note This function enumerates the current physical devices and returns the one matching the +/// luid. It must be called at least once prior to any ovr_CreateTextureSwapChainVk or +/// ovr_CreateMirrorTextureWithOptionsVk calls, and the instance must remain valid for the lifetime +/// of the returned objects. It is assumed the VkDevice created by the application will be for the +/// returned physical device. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetSessionPhysicalDeviceVk( + ovrSession session, + ovrGraphicsLuid luid, + VkInstance instance, + VkPhysicalDevice* out_physicalDevice); + +/// Select VkQueue to block on till rendering is complete +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] queue Specifies a VkQueue to add a VkFence operation to and wait on. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +/// \note The queue may be changed at any time but only the value at the time ovr_SubmitFrame +/// is called will be used. ovr_SetSynchronizationQueueVk must be called with a valid VkQueue +/// created on the same VkDevice the texture sets were created on prior to the first call to +/// ovr_SubmitFrame. An internally created VkFence object will be signalled by the completion +/// of operations on queue and waited on to synchronize the VR compositor. +/// +OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetSynchronizationQueueVk(ovrSession session, VkQueue queue); +// Backwards compatibility for the original typoed version +#define ovr_SetSynchonizationQueueVk ovr_SetSynchronizationQueueVk +// Define OVR_PREVIEW_DEPRECATION to generate warnings for upcoming API deprecations +#if defined(OVR_PREVIEW_DEPRECATION) +#pragma deprecated("ovr_SetSynchonizationQueueVk") +#endif + +/// Create Texture Swap Chain suitable for use with Vulkan +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] device Specifies the application's VkDevice to create resources with. +/// \param[in] desc Specifies requested texture properties. See notes for more info +/// about texture format. +/// \param[out] out_TextureSwapChain Returns the created ovrTextureSwapChain, which will be valid +/// upon a successful return value, else it will be NULL. +/// This texture chain must be eventually destroyed via ovr_DestroyTextureSwapChain +/// before destroying the session with ovr_Destroy. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +/// \note The texture format provided in \a desc should be thought of as the format the +/// distortion-compositor will use for the ShaderResourceView when reading the contents +/// of the texture. To that end, it is highly recommended that the application +/// requests texture swapchain formats that are in sRGB-space +/// (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor does sRGB-correct rendering. +/// As such, the compositor relies on the GPU's hardware sampler to do the sRGB-to-linear +/// conversion. If the application still prefers to render to a linear format (e.g. +/// OVR_FORMAT_R8G8B8A8_UNORM) while handling the linear-to-gamma conversion via +/// SPIRV code, then the application must still request the corresponding sRGB format and +/// also use the \a ovrTextureMisc_DX_Typeless flag in the ovrTextureSwapChainDesc's +/// Flag field. This will allow the application to create a RenderTargetView that is the +/// desired linear format while the compositor continues to treat it as sRGB. Failure to +/// do so will cause the compositor to apply unexpected gamma conversions leading to +/// gamma-curve artifacts. The \a ovrTextureMisc_DX_Typeless flag for depth buffer formats +/// (e.g. OVR_FORMAT_D32_FLOAT) is ignored as they are always +/// converted to be typeless. +/// +/// \see ovr_GetTextureSwapChainLength +/// \see ovr_GetTextureSwapChainCurrentIndex +/// \see ovr_GetTextureSwapChainDesc +/// \see ovr_GetTextureSwapChainBufferVk +/// \see ovr_DestroyTextureSwapChain +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainVk( + ovrSession session, + VkDevice device, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* out_TextureSwapChain); + +/// Get a specific VkImage within the chain +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] chain Specifies an ovrTextureSwapChain previously returned by +/// ovr_CreateTextureSwapChainVk +/// \param[in] index Specifies the index within the chain to retrieve. +/// Must be between 0 and length (see ovr_GetTextureSwapChainLength), +/// or may pass -1 to get the buffer at the CurrentIndex location (saving a +/// call to GetTextureSwapChainCurrentIndex). +/// \param[out] out_Image Returns the VkImage retrieved. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferVk( + ovrSession session, + ovrTextureSwapChain chain, + int index, + VkImage* out_Image); + +/// Create Mirror Texture which is auto-refreshed to mirror Rift contents produced by this +/// application. +/// +/// A second call to ovr_CreateMirrorTextureWithOptionsVk for a given ovrSession before destroying +/// the first one is not supported and will result in an error return. +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] device Specifies the VkDevice to create resources with. +/// \param[in] desc Specifies requested texture properties. See notes for more info +/// about texture format. +/// \param[out] out_MirrorTexture Returns the created ovrMirrorTexture, which will be +/// valid upon a successful return value, else it will be NULL. +/// This texture must be eventually destroyed via ovr_DestroyMirrorTexture before +/// destroying the session with ovr_Destroy. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +/// \note The texture format provided in \a desc should be thought of as the format the +/// compositor will use for the VkImageView when writing into mirror texture. To that end, +/// it is highly recommended that the application requests a mirror texture format that is +/// in sRGB-space (e.g. OVR_FORMAT_R8G8B8A8_UNORM_SRGB) as the compositor does sRGB-correct +/// rendering. If however the application wants to still read the mirror texture as a +/// linear format (e.g. OVR_FORMAT_R8G8B8A8_UNORM) and handle the sRGB-to-linear conversion +/// in SPIRV code, then it is recommended the application still requests an sRGB format and +/// also use the \a ovrTextureMisc_DX_Typeless flag in the ovrMirrorTextureDesc's +/// Flags field. This will allow the application to bind a ShaderResourceView that is a +/// linear format while the compositor continues to treat is as sRGB. Failure to do so will +/// cause the compositor to apply unexpected gamma conversions leading to +/// gamma-curve artifacts. +/// +/// Example code +/// \code{.cpp} +/// ovrMirrorTexture mirrorTexture = nullptr; +/// ovrMirrorTextureDesc mirrorDesc = {}; +/// mirrorDesc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB; +/// mirrorDesc.Width = mirrorWindowWidth; +/// mirrorDesc.Height = mirrorWindowHeight; +/// ovrResult result = ovr_CreateMirrorTextureWithOptionsVk(session, vkDevice, &mirrorDesc, +/// &mirrorTexture); +/// [...] +/// // Destroy the texture when done with it. +/// ovr_DestroyMirrorTexture(session, mirrorTexture); +/// mirrorTexture = nullptr; +/// \endcode +/// +/// \see ovr_GetMirrorTextureBufferVk +/// \see ovr_DestroyMirrorTexture +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsVk( + ovrSession session, + VkDevice device, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture); + +/// Get a the underlying mirror VkImage +/// +/// \param[in] session Specifies an ovrSession previously returned by ovr_Create. +/// \param[in] mirrorTexture Specifies an ovrMirrorTexture previously returned by +/// ovr_CreateMirrorTextureWithOptionsVk +/// \param[out] out_Image Returns the VkImage pointer retrieved. +/// +/// \return Returns an ovrResult indicating success or failure. In the case of failure, use +/// ovr_GetLastErrorInfo to get more information. +/// +/// Example code +/// \code{.cpp} +/// VkImage mirrorImage = VK_NULL_HANDLE; +/// ovr_GetMirrorTextureBufferVk(session, mirrorTexture, &mirrorImage); +/// ... +/// vkCmdBlitImage(commandBuffer, mirrorImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, +/// presentImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion, VK_FILTER_LINEAR); +/// ... +/// vkQueuePresentKHR(queue, &presentInfo); +/// \endcode +/// +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferVk( + ovrSession session, + ovrMirrorTexture mirrorTexture, + VkImage* out_Image); + +#endif // !defined(OVR_EXPORTING_CAPI) + +#endif // OVR_CAPI_Vk_h diff --git a/ext/LibOVR/Include/OVR_ErrorCode.h b/ext/LibOVR/Include/OVR_ErrorCode.h index ed0be0e..4f20715 100644 --- a/ext/LibOVR/Include/OVR_ErrorCode.h +++ b/ext/LibOVR/Include/OVR_ErrorCode.h @@ -1,39 +1,32 @@ -/********************************************************************************//** -\file OVR_ErrorCode.h -\brief This header provides LibOVR error code declarations. -\copyright Copyright 2015-2016 Oculus VR, LLC All Rights reserved. -*************************************************************************************/ +/********************************************************************************/ /** + \file OVR_ErrorCode.h + \brief This header provides LibOVR error code declarations. + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + *************************************************************************************/ #ifndef OVR_ErrorCode_h #define OVR_ErrorCode_h - #include "OVR_Version.h" #include - - - - #ifndef OVR_RESULT_DEFINED #define OVR_RESULT_DEFINED ///< Allows ovrResult to be independently defined. /// API call results are represented at the highest level by a single ovrResult. typedef int32_t ovrResult; #endif - /// \brief Indicates if an ovrResult indicates success. /// /// Some functions return additional successful values other than ovrSucces and /// require usage of this macro to indicate successs. /// #if !defined(OVR_SUCCESS) - #define OVR_SUCCESS(result) (result >= 0) +#define OVR_SUCCESS(result) (result >= 0) #endif - /// \brief Indicates if an ovrResult indicates an unqualified success. /// /// This is useful for indicating that the code intentionally wants to @@ -41,169 +34,291 @@ typedef int32_t ovrResult; /// checks for result >= ovrSuccess. /// #if !defined(OVR_UNQUALIFIED_SUCCESS) - #define OVR_UNQUALIFIED_SUCCESS(result) (result == ovrSuccess) +#define OVR_UNQUALIFIED_SUCCESS(result) (result == ovrSuccess) #endif - /// \brief Indicates if an ovrResult indicates failure. /// #if !defined(OVR_FAILURE) - #define OVR_FAILURE(result) (!OVR_SUCCESS(result)) +#define OVR_FAILURE(result) (!OVR_SUCCESS(result)) #endif - // Success is a value greater or equal to 0, while all error types are negative values. #ifndef OVR_SUCCESS_DEFINED #define OVR_SUCCESS_DEFINED ///< Allows ovrResult to be independently defined. -typedef enum ovrSuccessType_ -{ - /// This is a general success result. Use OVR_SUCCESS to test for success. - ovrSuccess = 0, - - /// Returned from a call to SubmitFrame. The call succeeded, but what the app - /// rendered will not be visible on the HMD. Ideally the app should continue - /// calling SubmitFrame, but not do any rendering. When the result becomes - /// ovrSuccess, rendering should continue as usual. - ovrSuccess_NotVisible = 1000, - - ovrSuccess_HMDFirmwareMismatch = 4100, ///< The HMD Firmware is out of date but is acceptable. - ovrSuccess_TrackerFirmwareMismatch = 4101, ///< The Tracker Firmware is out of date but is acceptable. - ovrSuccess_ControllerFirmwareMismatch = 4104, ///< The controller firmware is out of date but is acceptable. - ovrSuccess_TrackerDriverNotFound = 4105, ///< The tracker driver interface was not found. Can be a temporary error - +typedef enum ovrSuccessType_ { + /// This is a general success result. Use OVR_SUCCESS to test for success. + ovrSuccess = 0, } ovrSuccessType; #endif +// Public success types +// Success is a value greater or equal to 0, while all error types are negative values. +typedef enum ovrSuccessTypes_ { + /// Returned from a call to SubmitFrame. The call succeeded, but what the app + /// rendered will not be visible on the HMD. Ideally the app should continue + /// calling SubmitFrame, but not do any rendering. When the result becomes + /// ovrSuccess, rendering should continue as usual. + ovrSuccess_NotVisible = 1000, + + /// Boundary is invalid due to sensor change or was not setup. + ovrSuccess_BoundaryInvalid = 1001, -typedef enum ovrErrorType_ -{ - /* General errors */ - ovrError_MemoryAllocationFailure = -1000, ///< Failure to allocate memory. - ovrError_SocketCreationFailure = -1001, ///< Failure to create a socket. - ovrError_InvalidSession = -1002, ///< Invalid ovrSession parameter provided. - ovrError_Timeout = -1003, ///< The operation timed out. - ovrError_NotInitialized = -1004, ///< The system or component has not been initialized. - ovrError_InvalidParameter = -1005, ///< Invalid parameter provided. See error info or log for details. - ovrError_ServiceError = -1006, ///< Generic service error. See error info or log for details. - ovrError_NoHmd = -1007, ///< The given HMD doesn't exist. - ovrError_Unsupported = -1009, ///< Function call is not supported on this hardware/software - ovrError_DeviceUnavailable = -1010, ///< Specified device type isn't available. - ovrError_InvalidHeadsetOrientation = -1011, ///< The headset was in an invalid orientation for the requested operation (e.g. vertically oriented during ovr_RecenterPose). - ovrError_ClientSkippedDestroy = -1012, ///< The client failed to call ovr_Destroy on an active session before calling ovr_Shutdown. Or the client crashed. - ovrError_ClientSkippedShutdown = -1013, ///< The client failed to call ovr_Shutdown or the client crashed. - ovrError_ServiceDeadlockDetected = -1014, ///< The service watchdog discovered a deadlock. - - /* Audio error range, reserved for Audio errors. */ - ovrError_AudioReservedBegin = -2000, ///< First Audio error. - ovrError_AudioDeviceNotFound = -2001, ///< Failure to find the specified audio device. - ovrError_AudioComError = -2002, ///< Generic COM error. - ovrError_AudioReservedEnd = -2999, ///< Last Audio error. - - /* Initialization errors. */ - ovrError_Initialize = -3000, ///< Generic initialization error. - ovrError_LibLoad = -3001, ///< Couldn't load LibOVRRT. - ovrError_LibVersion = -3002, ///< LibOVRRT version incompatibility. - ovrError_ServiceConnection = -3003, ///< Couldn't connect to the OVR Service. - ovrError_ServiceVersion = -3004, ///< OVR Service version incompatibility. - ovrError_IncompatibleOS = -3005, ///< The operating system version is incompatible. - ovrError_DisplayInit = -3006, ///< Unable to initialize the HMD display. - ovrError_ServerStart = -3007, ///< Unable to start the server. Is it already running? - ovrError_Reinitialization = -3008, ///< Attempting to re-initialize with a different version. - ovrError_MismatchedAdapters = -3009, ///< Chosen rendering adapters between client and service do not match - ovrError_LeakingResources = -3010, ///< Calling application has leaked resources - ovrError_ClientVersion = -3011, ///< Client version too old to connect to service - ovrError_OutOfDateOS = -3012, ///< The operating system is out of date. - ovrError_OutOfDateGfxDriver = -3013, ///< The graphics driver is out of date. - ovrError_IncompatibleGPU = -3014, ///< The graphics hardware is not supported - ovrError_NoValidVRDisplaySystem = -3015, ///< No valid VR display system found. - ovrError_Obsolete = -3016, ///< Feature or API is obsolete and no longer supported. - ovrError_DisabledOrDefaultAdapter = -3017, ///< No supported VR display system found, but disabled or driverless adapter found. - ovrError_HybridGraphicsNotSupported = -3018, ///< The system is using hybrid graphics (Optimus, etc...), which is not support. - ovrError_DisplayManagerInit = -3019, ///< Initialization of the DisplayManager failed. - ovrError_TrackerDriverInit = -3020, ///< Failed to get the interface for an attached tracker - - /* Hardware errors */ - ovrError_InvalidBundleAdjustment = -4000, ///< Headset has no bundle adjustment data. - ovrError_USBBandwidth = -4001, ///< The USB hub cannot handle the camera frame bandwidth. - ovrError_USBEnumeratedSpeed = -4002, ///< The USB camera is not enumerating at the correct device speed. - ovrError_ImageSensorCommError = -4003, ///< Unable to communicate with the image sensor. - ovrError_GeneralTrackerFailure = -4004, ///< We use this to report various sensor issues that don't fit in an easily classifiable bucket. - ovrError_ExcessiveFrameTruncation = -4005, ///< A more than acceptable number of frames are coming back truncated. - ovrError_ExcessiveFrameSkipping = -4006, ///< A more than acceptable number of frames have been skipped. - ovrError_SyncDisconnected = -4007, ///< The sensor is not receiving the sync signal (cable disconnected?). - ovrError_TrackerMemoryReadFailure = -4008, ///< Failed to read memory from the sensor. - ovrError_TrackerMemoryWriteFailure = -4009, ///< Failed to write memory from the sensor. - ovrError_TrackerFrameTimeout = -4010, ///< Timed out waiting for a camera frame. - ovrError_TrackerTruncatedFrame = -4011, ///< Truncated frame returned from sensor. - ovrError_TrackerDriverFailure = -4012, ///< The sensor driver has encountered a problem. - ovrError_TrackerNRFFailure = -4013, ///< The sensor wireless subsystem has encountered a problem. - ovrError_HardwareGone = -4014, ///< The hardware has been unplugged - ovrError_NordicEnabledNoSync = -4015, ///< The nordic indicates that sync is enabled but it is not sending sync pulses - ovrError_NordicSyncNoFrames = -4016, ///< It looks like we're getting a sync signal, but no camera frames have been received - ovrError_CatastrophicFailure = -4017, ///< A catastrophic failure has occurred. We will attempt to recover by resetting the device - ovrError_CatastrophicTimeout = -4018, ///< The catastrophic recovery has timed out. - ovrError_RepeatCatastrophicFail = -4019, ///< Catastrophic failure has repeated too many times. - ovrError_USBOpenDeviceFailure = -4020, ///< Could not open handle for Rift device (likely already in use by another process). - ovrError_HMDGeneralFailure = -4021, ///< Unexpected HMD issues that don't fit a specific bucket. - - ovrError_HMDFirmwareMismatch = -4100, ///< The HMD Firmware is out of date and is unacceptable. - ovrError_TrackerFirmwareMismatch = -4101, ///< The sensor Firmware is out of date and is unacceptable. - ovrError_BootloaderDeviceDetected = -4102, ///< A bootloader HMD is detected by the service. - ovrError_TrackerCalibrationError = -4103, ///< The sensor calibration is missing or incorrect. - ovrError_ControllerFirmwareMismatch = -4104, ///< The controller firmware is out of date and is unacceptable. - ovrError_DevManDeviceDetected = -4105, ///< A DeviceManagement mode HMD is detected by the service. - ovrError_RebootedBootloaderDevice = -4106, ///< Had to reboot bootloader device, which succeeded. - ovrError_FailedRebootBootloaderDev = -4107, ///< Had to reboot bootloader device, which failed. Device is stuck in bootloader mode. - - ovrError_IMUTooManyLostSamples = -4200, ///< Too many lost IMU samples. - ovrError_IMURateError = -4201, ///< IMU rate is outside of the expected range. - ovrError_FeatureReportFailure = -4202, ///< A feature report has failed. - ovrError_HMDWirelessTimeout = -4203, ///< HMD wireless interface never returned from busy state. - - ovrError_BootloaderAssertLog = -4300, ///< HMD Bootloader Assert Log was not empty. - ovrError_AppAssertLog = -4301, ///< HMD App Assert Log was not empty. - - /* Synchronization errors */ - ovrError_Incomplete = -5000, ///< Requested async work not yet complete. - ovrError_Abandoned = -5001, ///< Requested async work was abandoned and result is incomplete. - - /* Rendering errors */ - ovrError_DisplayLost = -6000, ///< In the event of a system-wide graphics reset or cable unplug this is returned to the app. - ovrError_TextureSwapChainFull = -6001, ///< ovr_CommitTextureSwapChain was called too many times on a texture swapchain without calling submit to use the chain. - ovrError_TextureSwapChainInvalid = -6002, ///< The ovrTextureSwapChain is in an incomplete or inconsistent state. Ensure ovr_CommitTextureSwapChain was called at least once first. - ovrError_GraphicsDeviceReset = -6003, ///< Graphics device has been reset (TDR, etc...) - ovrError_DisplayRemoved = -6004, ///< HMD removed from the display adapter - ovrError_ContentProtectionNotAvailable = -6005,/// #include #include @@ -35,54 +35,46 @@ limitations under the License. #include #if defined(_WIN32) - #if defined(_MSC_VER) - #pragma warning(push, 0) - #endif - #include - #if defined(_MSC_VER) - #pragma warning(pop) - #endif - - #include "../Include/OVR_CAPI_D3D.h" +#if defined(_MSC_VER) +#pragma warning(push, 0) +#endif +#include +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +#include "OVR_CAPI_D3D.h" #else - #if defined(__APPLE__) - #include - #include - #include - #include - #include - #endif - #include - #include - #include +#if defined(__APPLE__) +#include +#include +#include +#include +#include +#endif +#include +#include +#include #endif -#include "../Include/OVR_CAPI_GL.h" +#include "OVR_CAPI_GL.h" +#include "OVR_CAPI_Vk.h" #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable: 4996) // 'getenv': This function or variable may be unsafe. +#pragma warning(push) +#pragma warning(disable : 4996) // 'getenv': This function or variable may be unsafe. #endif -static const uint8_t OculusSDKUniqueIdentifier[] = -{ - 0x9E, 0xB2, 0x0B, 0x1A, 0xB7, 0x97, 0x09, 0x20, 0xE0, 0xFB, 0x83, 0xED, 0xF8, 0x33, 0x5A, 0xEB, - 0x80, 0x4D, 0x8E, 0x92, 0x20, 0x69, 0x13, 0x56, 0xB4, 0xBB, 0xC4, 0x85, 0xA7, 0x9E, 0xA4, 0xFE, - OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_PATCH_VERSION +// clang-format off +static const uint8_t OculusSDKUniqueIdentifier[] = { + 0x9E, 0xB2, 0x0B, 0x1A, 0xB7, 0x97, 0x09, 0x20, 0xE0, 0xFB, 0x83, 0xED, 0xF8, 0x33, 0x5A, 0xEB, + 0x80, 0x4D, 0x8E, 0x92, 0x20, 0x69, 0x13, 0x56, 0xB4, 0xBB, 0xC4, 0x85, 0xA7, 0x9E, 0xA4, 0xFE, + OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_PATCH_VERSION }; -static const uint8_t OculusSDKUniqueIdentifierXORResult = 0xcb; - - -// ----------------------------------------------------------------------------------- -// ***** OVR_ENABLE_DEVELOPER_SEARCH -// -// If defined then our shared library loading code searches for developer build -// directories. -// -#if !defined(OVR_ENABLE_DEVELOPER_SEARCH) -#endif +// clang-format on +static const uint8_t OculusSDKUniqueIdentifierXORResult = 0xcb; // ----------------------------------------------------------------------------------- // ***** OVR_BUILD_DEBUG @@ -93,949 +85,791 @@ static const uint8_t OculusSDKUniqueIdentifierXORResult = 0xcb; // either -DOVR_BUILD_RELEASE or -DOVR_BUILD_DEBUG in the compiler arguments. #if !defined(OVR_BUILD_DEBUG) && !defined(OVR_BUILD_RELEASE) - #if defined(_MSC_VER) - #if defined(_DEBUG) - #define OVR_BUILD_DEBUG - #endif - #else - #if defined(DEBUG) - #define OVR_BUILD_DEBUG - #endif - #endif +#if defined(_MSC_VER) +#if defined(_DEBUG) +#define OVR_BUILD_DEBUG +#endif +#else +#if defined(DEBUG) +#define OVR_BUILD_DEBUG +#endif +#endif #endif - //----------------------------------------------------------------------------------- // ***** FilePathCharType, ModuleHandleType, ModuleFunctionType // -#if defined(_WIN32) // We need to use wchar_t on Microsoft platforms, as that's the native file system character type. - #define FilePathCharType wchar_t // #define instead of typedef because debuggers (VC++, XCode) don't recognize typedef'd types as a string type. - typedef HMODULE ModuleHandleType; - typedef FARPROC ModuleFunctionType; +#if defined(_WIN32) // We need to use wchar_t on Microsoft platforms, as that's the native file +// system character type. +#define FilePathCharType \ + wchar_t // #define instead of typedef because debuggers (VC++, XCode) don't recognize typedef'd +// types as a string type. +typedef HMODULE ModuleHandleType; +typedef FARPROC ModuleFunctionType; #else - #define FilePathCharType char - typedef void* ModuleHandleType; - typedef void* ModuleFunctionType; +#define FilePathCharType char +typedef void* ModuleHandleType; +typedef void* ModuleFunctionType; #endif -#define ModuleHandleTypeNull ((ModuleHandleType)NULL) +#define ModuleHandleTypeNull ((ModuleHandleType)NULL) #define ModuleFunctionTypeNull ((ModuleFunctionType)NULL) - //----------------------------------------------------------------------------------- // ***** OVR_MAX_PATH // #if !defined(OVR_MAX_PATH) - #if defined(_WIN32) - #define OVR_MAX_PATH _MAX_PATH - #elif defined(__APPLE__) - #define OVR_MAX_PATH PATH_MAX - #else - #define OVR_MAX_PATH 1024 - #endif +#if defined(_WIN32) +#define OVR_MAX_PATH _MAX_PATH +#elif defined(__APPLE__) +#define OVR_MAX_PATH PATH_MAX +#else +#define OVR_MAX_PATH 1024 +#endif #endif - - - -//----------------------------------------------------------------------------------- -// ***** OVR_DECLARE_IMPORT -// -// Creates typedef and pointer declaration for a function of a given signature. -// The typedef is Type, and the pointer is Ptr. -// -// Example usage: -// int MultiplyValues(float x, float y); // Assume this function exists in an external shared library. We don't actually need to redeclare it. -// OVR_DECLARE_IMPORT(int, MultiplyValues, (float x, float y)) // This creates a local typedef and pointer for it. - -#define OVR_DECLARE_IMPORT(ReturnValue, FunctionName, Arguments) \ - typedef ReturnValue (OVR_CDECL *FunctionName##Type)Arguments; \ - FunctionName##Type FunctionName##Ptr = NULL; - - - -//----------------------------------------------------------------------------------- -// ***** OVR_GETFUNCTION -// -// Loads Ptr from hLibOVR if not already loaded. -// Assumes a variable named Ptr of type Type exists which is called in LibOVR. -// -// Example usage: -// OVR_GETFUNCTION(MultiplyValues) // Normally this would be done on library init and not before every usage. -// int result = MultiplyValuesPtr(3.f, 4.f); #if !defined(OVR_DLSYM) - #if defined(_WIN32) - #define OVR_DLSYM(dlImage, name) GetProcAddress(dlImage, name) - #else - #define OVR_DLSYM(dlImage, name) dlsym(dlImage, name) - #endif +#if defined(_WIN32) +#define OVR_DLSYM(dlImage, name) GetProcAddress(dlImage, name) +#else +#define OVR_DLSYM(dlImage, name) dlsym(dlImage, name) +#endif #endif -#define OVR_GETFUNCTION(f) \ - if(!f##Ptr) \ - { \ - union \ - { \ - f##Type p1; \ - ModuleFunctionType p2; \ - } u; \ - u.p2 = OVR_DLSYM(hLibOVR, #f); \ - f##Ptr = u.p1; \ - } - - -static size_t OVR_strlcpy(char* dest, const char* src, size_t destsize) -{ - const char* s = src; - size_t n = destsize; - - if(n && --n) - { - do{ - if((*dest++ = *s++) == 0) - break; - } while(--n); - } - - if(!n) - { - if(destsize) - *dest = 0; - while(*s++) - { } +static size_t OVR_strlcpy(char* dest, const char* src, size_t destsize) { + const char* s = src; + size_t n = destsize; + + if (n && --n) { + do { + if ((*dest++ = *s++) == 0) + break; + } while (--n); + } + + if (!n) { + if (destsize) + *dest = 0; + while (*s++) { } + } - return (size_t)((s - src) - 1); + return (size_t)((s - src) - 1); } +static size_t OVR_strlcat(char* dest, const char* src, size_t destsize) { + const size_t d = destsize ? strlen(dest) : 0; + const size_t s = strlen(src); + const size_t t = s + d; -static size_t OVR_strlcat(char* dest, const char* src, size_t destsize) -{ - const size_t d = destsize ? strlen(dest) : 0; - const size_t s = strlen(src); - const size_t t = s + d; - - if(t < destsize) - memcpy(dest + d, src, (s + 1) * sizeof(*src)); - else - { - if(destsize) - { - memcpy(dest + d, src, ((destsize - d) - 1) * sizeof(*src)); - dest[destsize - 1] = 0; - } + if (t < destsize) + memcpy(dest + d, src, (s + 1) * sizeof(*src)); + else { + if (destsize) { + memcpy(dest + d, src, ((destsize - d) - 1) * sizeof(*src)); + dest[destsize - 1] = 0; } + } - return t; + return t; } - #if defined(__APPLE__) - static ovrBool OVR_strend(const char* pStr, const char* pFind, size_t strLength, size_t findLength) - { - if(strLength == (size_t)-1) - strLength = strlen(pStr); - if(findLength == (size_t)-1) - findLength = strlen(pFind); - if(strLength >= findLength) - return (strcmp(pStr + strLength - findLength, pFind) == 0); - return ovrFalse; - } +static ovrBool +OVR_strend(const char* pStr, const char* pFind, size_t strLength, size_t findLength) { + if (strLength == (size_t)-1) + strLength = strlen(pStr); + if (findLength == (size_t)-1) + findLength = strlen(pFind); + if (strLength >= findLength) + return (strcmp(pStr + strLength - findLength, pFind) == 0); + return ovrFalse; +} - static ovrBool OVR_isBundleFolder(const char* filePath) - { - static const char* extensionArray[] = { ".app", ".bundle", ".framework", ".plugin", ".kext" }; - size_t i; +static ovrBool OVR_isBundleFolder(const char* filePath) { + static const char* extensionArray[] = {".app", ".bundle", ".framework", ".plugin", ".kext"}; + size_t i; - for(i = 0; i < sizeof(extensionArray)/sizeof(extensionArray[0]); i++) - { - if(OVR_strend(filePath, extensionArray[i], (size_t)-1, (size_t)-1)) - return ovrTrue; - } + for (i = 0; i < sizeof(extensionArray) / sizeof(extensionArray[0]); i++) { + if (OVR_strend(filePath, extensionArray[i], (size_t)-1, (size_t)-1)) + return ovrTrue; + } - return ovrFalse; - } + return ovrFalse; +} #endif +#if !defined(_WIN32) +static ovrBool OVR_GetCurrentWorkingDirectory( + FilePathCharType* directoryPath, + size_t directoryPathCapacity) { +#if defined(_WIN32) + DWORD dwSize = GetCurrentDirectoryW((DWORD)directoryPathCapacity, directoryPath); -#if defined(OVR_ENABLE_DEVELOPER_SEARCH) + if ((dwSize > 0) && + (directoryPathCapacity > 1)) // Test > 1 so we have room to possibly append a \ char. + { + size_t length = wcslen(directoryPath); -// Returns true if the path begins with the given prefix. -// Doesn't support non-ASCII paths, else the return value may be incorrect. -static int OVR_PathStartsWith(const FilePathCharType* path, const char* prefix) -{ - while(*prefix) - { - if(tolower((unsigned char)*path++) != tolower((unsigned char)*prefix++)) - return ovrFalse; + if ((length == 0) || + ((directoryPath[length - 1] != L'\\') && (directoryPath[length - 1] != L'/'))) { + directoryPath[length++] = L'\\'; + directoryPath[length] = L'\0'; } return ovrTrue; -} - -#endif - - -static ovrBool OVR_GetCurrentWorkingDirectory(FilePathCharType* directoryPath, size_t directoryPathCapacity) -{ - #if defined(_WIN32) - DWORD dwSize = GetCurrentDirectoryW((DWORD)directoryPathCapacity, directoryPath); + } - if((dwSize > 0) && (directoryPathCapacity > 1)) // Test > 1 so we have room to possibly append a \ char. - { - size_t length = wcslen(directoryPath); - - if((length == 0) || ((directoryPath[length - 1] != L'\\') && (directoryPath[length - 1] != L'/'))) - { - directoryPath[length++] = L'\\'; - directoryPath[length] = L'\0'; - } - - return ovrTrue; - } - - #else - char* cwd = getcwd(directoryPath, directoryPathCapacity); +#else + char* cwd = getcwd(directoryPath, directoryPathCapacity); - if(cwd && directoryPath[0] && (directoryPathCapacity > 1)) // Test > 1 so we have room to possibly append a / char. - { - size_t length = strlen(directoryPath); + if (cwd && directoryPath[0] && + (directoryPathCapacity > 1)) // Test > 1 so we have room to possibly append a / char. + { + size_t length = strlen(directoryPath); - if((length == 0) || (directoryPath[length - 1] != '/')) - { - directoryPath[length++] = '/'; - directoryPath[length] = '\0'; - } + if ((length == 0) || (directoryPath[length - 1] != '/')) { + directoryPath[length++] = '/'; + directoryPath[length] = '\0'; + } - return ovrTrue; - } - #endif + return ovrTrue; + } +#endif - if(directoryPathCapacity > 0) - directoryPath[0] = '\0'; + if (directoryPathCapacity > 0) + directoryPath[0] = '\0'; + + return ovrFalse; +} + +// The appContainer argument is specific currently to only Macintosh. If true and the application is +// a .app bundle then it returns the +// location of the bundle and not the path to the executable within the bundle. Else return the path +// to the executable binary itself. +// The moduleHandle refers to the relevant dynamic (a.k.a. shared) library. The main executable is +// the main module, and each of the shared +// libraries is a module. This way you can specify that you want to know the directory of the given +// shared library, which may be different +// from the main executable. If the moduleHandle is NULL then the current application module is +// used. +static ovrBool OVR_GetCurrentApplicationDirectory( + FilePathCharType* directoryPath, + size_t directoryPathCapacity, + ovrBool appContainer, + ModuleHandleType moduleHandle) { +#if defined(_WIN32) + DWORD length = GetModuleFileNameW(moduleHandle, directoryPath, (DWORD)directoryPathCapacity); + DWORD pos; + + if ((length != 0) && + (length < + (DWORD)directoryPathCapacity)) // If there wasn't an error and there was enough capacity... + { + for (pos = length; (pos > 0) && (directoryPath[pos] != '\\') && (directoryPath[pos] != '/'); + --pos) { + if ((directoryPath[pos - 1] != '\\') && (directoryPath[pos - 1] != '/')) + directoryPath[pos - 1] = 0; + } - return ovrFalse; -} + return ovrTrue; + } + (void)appContainer; // Not used on this platform. -// The appContainer argument is specific currently to only Macintosh. If true and the application is a .app bundle then it returns the -// location of the bundle and not the path to the executable within the bundle. Else return the path to the executable binary itself. -// The moduleHandle refers to the relevant dynamic (a.k.a. shared) library. The main executable is the main module, and each of the shared -// libraries is a module. This way you can specify that you want to know the directory of the given shared library, which may be different -// from the main executable. If the moduleHandle is NULL then the current application module is used. -static ovrBool OVR_GetCurrentApplicationDirectory(FilePathCharType* directoryPath, size_t directoryPathCapacity, ovrBool appContainer, ModuleHandleType moduleHandle) -{ - #if defined(_WIN32) - DWORD length = GetModuleFileNameW(moduleHandle, directoryPath, (DWORD)directoryPathCapacity); - DWORD pos; +#elif defined(__APPLE__) + uint32_t directoryPathCapacity32 = (uint32_t)directoryPathCapacity; + int result = _NSGetExecutablePath(directoryPath, &directoryPathCapacity32); - if((length != 0) && (length < (DWORD)directoryPathCapacity)) // If there wasn't an error and there was enough capacity... - { - for(pos = length; (pos > 0) && (directoryPath[pos] != '\\') && (directoryPath[pos] != '/'); --pos) - { - if((directoryPath[pos - 1] != '\\') && (directoryPath[pos - 1] != '/')) - directoryPath[pos - 1] = 0; - } + if (result == 0) // If success... + { + char realPath[OVR_MAX_PATH]; - return ovrTrue; - } + if (realpath(directoryPath, realPath)) // realpath returns the canonicalized absolute file path. + { + size_t length = 0; - (void)appContainer; // Not used on this platform. + if (appContainer) // If the caller wants the path to the containing bundle... + { + char containerPath[OVR_MAX_PATH]; + ovrBool pathIsContainer; - #elif defined(__APPLE__) - uint32_t directoryPathCapacity32 = (uint32_t)directoryPathCapacity; - int result = _NSGetExecutablePath(directoryPath, &directoryPathCapacity32); + OVR_strlcpy(containerPath, realPath, sizeof(containerPath)); + pathIsContainer = OVR_isBundleFolder(containerPath); - if(result == 0) // If success... + while (!pathIsContainer && strncmp(containerPath, ".", OVR_MAX_PATH) && + strncmp(containerPath, "/", OVR_MAX_PATH)) // While the container we're looking for + // is not found and while the path doesn't + // start with a . or / { - char realPath[OVR_MAX_PATH]; - - if(realpath(directoryPath, realPath)) // realpath returns the canonicalized absolute file path. - { - size_t length = 0; - - if(appContainer) // If the caller wants the path to the containing bundle... - { - char containerPath[OVR_MAX_PATH]; - ovrBool pathIsContainer; - - OVR_strlcpy(containerPath, realPath, sizeof(containerPath)); - pathIsContainer = OVR_isBundleFolder(containerPath); - - while(!pathIsContainer && strncmp(containerPath, ".", OVR_MAX_PATH) && strncmp(containerPath, "/", OVR_MAX_PATH)) // While the container we're looking for is not found and while the path doesn't start with a . or / - { - OVR_strlcpy(containerPath, dirname(containerPath), sizeof(containerPath)); - pathIsContainer = OVR_isBundleFolder(containerPath); - } - - if(pathIsContainer) - length = OVR_strlcpy(directoryPath, containerPath, directoryPathCapacity); - } - - if(length == 0) // If not set above in the appContainer block... - length = OVR_strlcpy(directoryPath, realPath, directoryPathCapacity); - - while(length-- && (directoryPath[length] != '/')) - directoryPath[length] = '\0'; // Strip the file name from the file path, leaving a trailing / char. - - return ovrTrue; - } + OVR_strlcpy(containerPath, dirname(containerPath), sizeof(containerPath)); + pathIsContainer = OVR_isBundleFolder(containerPath); } - (void)moduleHandle; // Not used on this platform. - - #else - ssize_t length = readlink("/proc/self/exe", directoryPath, directoryPathCapacity); - ssize_t pos; + if (pathIsContainer) + length = OVR_strlcpy(directoryPath, containerPath, directoryPathCapacity); + } - if(length > 0) - { - for(pos = length; (pos > 0) && (directoryPath[pos] != '/'); --pos) - { - if(directoryPath[pos - 1] != '/') - directoryPath[pos - 1] = '\0'; - } + if (length == 0) // If not set above in the appContainer block... + length = OVR_strlcpy(directoryPath, realPath, directoryPathCapacity); - return ovrTrue; - } + while (length-- && (directoryPath[length] != '/')) + directoryPath[length] = + '\0'; // Strip the file name from the file path, leaving a trailing / char. - (void)appContainer; // Not used on this platform. - (void)moduleHandle; - #endif + return ovrTrue; + } + } - if(directoryPathCapacity > 0) - directoryPath[0] = '\0'; + (void)moduleHandle; // Not used on this platform. - return ovrFalse; -} +#else + ssize_t length = readlink("/proc/self/exe", directoryPath, directoryPathCapacity); + ssize_t pos; + if (length > 0) { + for (pos = length; (pos > 0) && (directoryPath[pos] != '/'); --pos) { + if (directoryPath[pos - 1] != '/') + directoryPath[pos - 1] = '\0'; + } -#if defined(_WIN32) || defined(OVR_ENABLE_DEVELOPER_SEARCH) // Used only in these cases + return ovrTrue; + } -// Get the file path to the current module's (DLL or EXE) directory within the current process. -// Will be different from the process module handle if the current module is a DLL and is in a different directory than the EXE module. -// If successful then directoryPath will be valid and ovrTrue is returned, else directoryPath will be empty and ovrFalse is returned. -static ovrBool OVR_GetCurrentModuleDirectory(FilePathCharType* directoryPath, size_t directoryPathCapacity, ovrBool appContainer) -{ - #if defined(_WIN32) - HMODULE hModule; - BOOL result = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCWSTR)(uintptr_t)OVR_GetCurrentModuleDirectory, &hModule); - if(result) - OVR_GetCurrentApplicationDirectory(directoryPath, directoryPathCapacity, ovrTrue, hModule); - else - directoryPath[0] = 0; + (void)appContainer; // Not used on this platform. + (void)moduleHandle; +#endif - (void)appContainer; + if (directoryPathCapacity > 0) + directoryPath[0] = '\0'; - return directoryPath[0] ? ovrTrue : ovrFalse; - #else - return OVR_GetCurrentApplicationDirectory(directoryPath, directoryPathCapacity, appContainer, NULL); - #endif + return ovrFalse; } - -#endif +#endif // !defined(_WIN32) #if defined(_WIN32) #ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable: 4201) +#pragma warning(push) +#pragma warning(disable : 4201) #endif #include #include #ifdef _MSC_VER - #pragma warning(pop) +#pragma warning(pop) #endif // Expected certificates: #define ExpectedNumCertificates 3 typedef struct CertificateEntry_t { - const wchar_t* Issuer; - const wchar_t* Subject; + const wchar_t* Issuer; + const wchar_t* Subject; } CertificateEntry; CertificateEntry NewCertificateChain[ExpectedNumCertificates] = { - { L"DigiCert SHA2 Assured ID Code Signing CA", L"Oculus VR, LLC" }, - { L"DigiCert Assured ID Root CA", L"DigiCert SHA2 Assured ID Code Signing CA" }, - { L"DigiCert Assured ID Root CA", L"DigiCert Assured ID Root CA" }, + {L"DigiCert SHA2 Assured ID Code Signing CA", L"Oculus VR, LLC"}, + {L"DigiCert Assured ID Root CA", L"DigiCert SHA2 Assured ID Code Signing CA"}, + {L"DigiCert Assured ID Root CA", L"DigiCert Assured ID Root CA"}, }; #define CertificateChainCount 1 -CertificateEntry* AllowedCertificateChains[CertificateChainCount] = { - NewCertificateChain -}; +CertificateEntry* AllowedCertificateChains[CertificateChainCount] = {NewCertificateChain}; -typedef WINCRYPT32API -DWORD -(WINAPI *PtrCertGetNameStringW)( +typedef DWORD(WINAPI* PtrCertGetNameStringW)( PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, - void *pvTypePara, + void* pvTypePara, LPWSTR pszNameString, - DWORD cchNameString - ); -typedef LONG (WINAPI *PtrWinVerifyTrust)(HWND hwnd, GUID *pgActionID, - LPVOID pWVTData); -typedef CRYPT_PROVIDER_DATA * (WINAPI *PtrWTHelperProvDataFromStateData)(HANDLE hStateData); -typedef CRYPT_PROVIDER_SGNR * (WINAPI *PtrWTHelperGetProvSignerFromChain)( - CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSigner, DWORD idxCounterSigner); + DWORD cchNameString); +typedef LONG(WINAPI* PtrWinVerifyTrust)(HWND hwnd, GUID* pgActionID, LPVOID pWVTData); +typedef CRYPT_PROVIDER_DATA*(WINAPI* PtrWTHelperProvDataFromStateData)(HANDLE hStateData); +typedef CRYPT_PROVIDER_SGNR*(WINAPI* PtrWTHelperGetProvSignerFromChain)( + CRYPT_PROVIDER_DATA* pProvData, + DWORD idxSigner, + BOOL fCounterSigner, + DWORD idxCounterSigner); PtrCertGetNameStringW m_PtrCertGetNameStringW = 0; PtrWinVerifyTrust m_PtrWinVerifyTrust = 0; PtrWTHelperProvDataFromStateData m_PtrWTHelperProvDataFromStateData = 0; PtrWTHelperGetProvSignerFromChain m_PtrWTHelperGetProvSignerFromChain = 0; -typedef enum ValidateCertificateContentsResult_ -{ - VCCRSuccess = 0, - VCCRErrorCertCount = -1, - VCCRErrorTrust = -2, - VCCRErrorValidation = -3 +typedef enum ValidateCertificateContentsResult_ { + VCCRSuccess = 0, + VCCRErrorCertCount = -1, + VCCRErrorTrust = -2, + VCCRErrorValidation = -3 } ValidateCertificateContentsResult; -static ValidateCertificateContentsResult ValidateCertificateContents(CertificateEntry* chain, CRYPT_PROVIDER_SGNR* cps) -{ - int certIndex; - - if (!cps || - !cps->pasCertChain || - cps->csCertChain != ExpectedNumCertificates) - { - return VCCRErrorCertCount; - } +static ValidateCertificateContentsResult ValidateCertificateContents( + CertificateEntry* chain, + CRYPT_PROVIDER_SGNR* cps) { + int certIndex; - for (certIndex = 0; certIndex < ExpectedNumCertificates; ++certIndex) - { - CRYPT_PROVIDER_CERT* pCertData = &cps->pasCertChain[certIndex]; - wchar_t subjectStr[400] = { 0 }; - wchar_t issuerStr[400] = { 0 }; + if (!cps || !cps->pasCertChain || cps->csCertChain != ExpectedNumCertificates) { + return VCCRErrorCertCount; + } - if ((pCertData->fSelfSigned && !pCertData->fTrustedRoot) || - pCertData->fTestCert) - { - return VCCRErrorTrust; - } + for (certIndex = 0; certIndex < ExpectedNumCertificates; ++certIndex) { + CRYPT_PROVIDER_CERT* pCertData = &cps->pasCertChain[certIndex]; + wchar_t subjectStr[400] = {0}; + wchar_t issuerStr[400] = {0}; - m_PtrCertGetNameStringW( - pCertData->pCert, - CERT_NAME_ATTR_TYPE, - 0, - szOID_COMMON_NAME, - subjectStr, - ARRAYSIZE(subjectStr)); - - m_PtrCertGetNameStringW( - pCertData->pCert, - CERT_NAME_ATTR_TYPE, - CERT_NAME_ISSUER_FLAG, - 0, - issuerStr, - ARRAYSIZE(issuerStr)); - - if (wcscmp(subjectStr, chain[certIndex].Subject) != 0 || - wcscmp(issuerStr, chain[certIndex].Issuer) != 0) - { - return VCCRErrorValidation; - } + if ((pCertData->fSelfSigned && !pCertData->fTrustedRoot) || pCertData->fTestCert) { + return VCCRErrorTrust; } - return VCCRSuccess; -} - -#define OVR_SIGNING_CONVERT_PTR(ftype, fptr, procaddr) { \ - union { ftype p1; ModuleFunctionType p2; } u; \ - u.p2 = procaddr; \ - fptr = u.p1; } - -static HANDLE OVR_Win32_SignCheck(FilePathCharType* fullPath) -{ - HANDLE hFile = INVALID_HANDLE_VALUE; - WINTRUST_FILE_INFO fileData; - WINTRUST_DATA wintrustData; - GUID actionGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; - LONG resultStatus; - int verified = 0; - HMODULE libWinTrust = LoadLibraryW(L"wintrust"); - HMODULE libCrypt32 = LoadLibraryW(L"crypt32"); - if (libWinTrust == NULL || libCrypt32 == NULL) - { - return INVALID_HANDLE_VALUE; + m_PtrCertGetNameStringW( + pCertData->pCert, + CERT_NAME_ATTR_TYPE, + 0, + szOID_COMMON_NAME, + subjectStr, + ARRAYSIZE(subjectStr)); + + m_PtrCertGetNameStringW( + pCertData->pCert, + CERT_NAME_ATTR_TYPE, + CERT_NAME_ISSUER_FLAG, + 0, + issuerStr, + ARRAYSIZE(issuerStr)); + + if (wcscmp(subjectStr, chain[certIndex].Subject) != 0 || + wcscmp(issuerStr, chain[certIndex].Issuer) != 0) { + return VCCRErrorValidation; } - - OVR_SIGNING_CONVERT_PTR(PtrCertGetNameStringW, m_PtrCertGetNameStringW, GetProcAddress(libCrypt32, "CertGetNameStringW")); - OVR_SIGNING_CONVERT_PTR(PtrWinVerifyTrust, m_PtrWinVerifyTrust, GetProcAddress(libWinTrust, "WinVerifyTrust")); - OVR_SIGNING_CONVERT_PTR(PtrWTHelperProvDataFromStateData, m_PtrWTHelperProvDataFromStateData, GetProcAddress(libWinTrust, "WTHelperProvDataFromStateData")); - OVR_SIGNING_CONVERT_PTR(PtrWTHelperGetProvSignerFromChain, m_PtrWTHelperGetProvSignerFromChain, GetProcAddress(libWinTrust, "WTHelperGetProvSignerFromChain")); - - if (m_PtrCertGetNameStringW == NULL || m_PtrWinVerifyTrust == NULL || - m_PtrWTHelperProvDataFromStateData == NULL || m_PtrWTHelperGetProvSignerFromChain == NULL) - { - return INVALID_HANDLE_VALUE; + } + + return VCCRSuccess; +} + +#define OVR_SIGNING_CONVERT_PTR(ftype, fptr, procaddr) \ + { \ + union { \ + ftype p1; \ + ModuleFunctionType p2; \ + } u; \ + u.p2 = procaddr; \ + fptr = u.p1; \ + } + +static BOOL OVR_Win32_SignCheck(FilePathCharType* fullPath, HANDLE hFile) { + WINTRUST_FILE_INFO fileData; + WINTRUST_DATA wintrustData; + GUID actionGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2; + LONG resultStatus; + BOOL verified = FALSE; + HMODULE libWinTrust = LoadLibraryW(L"wintrust"); + HMODULE libCrypt32 = LoadLibraryW(L"crypt32"); + if (libWinTrust == NULL || libCrypt32 == NULL) { + return FALSE; + } + + OVR_SIGNING_CONVERT_PTR( + PtrCertGetNameStringW, + m_PtrCertGetNameStringW, + GetProcAddress(libCrypt32, "CertGetNameStringW")); + OVR_SIGNING_CONVERT_PTR( + PtrWinVerifyTrust, m_PtrWinVerifyTrust, GetProcAddress(libWinTrust, "WinVerifyTrust")); + OVR_SIGNING_CONVERT_PTR( + PtrWTHelperProvDataFromStateData, + m_PtrWTHelperProvDataFromStateData, + GetProcAddress(libWinTrust, "WTHelperProvDataFromStateData")); + OVR_SIGNING_CONVERT_PTR( + PtrWTHelperGetProvSignerFromChain, + m_PtrWTHelperGetProvSignerFromChain, + GetProcAddress(libWinTrust, "WTHelperGetProvSignerFromChain")); + + if (m_PtrCertGetNameStringW == NULL || m_PtrWinVerifyTrust == NULL || + m_PtrWTHelperProvDataFromStateData == NULL || m_PtrWTHelperGetProvSignerFromChain == NULL) { + return FALSE; + } + + if (hFile == INVALID_HANDLE_VALUE || fullPath == NULL) { + return FALSE; + } + + ZeroMemory(&fileData, sizeof(fileData)); + fileData.cbStruct = sizeof(fileData); + fileData.pcwszFilePath = fullPath; + fileData.hFile = hFile; + + ZeroMemory(&wintrustData, sizeof(wintrustData)); + wintrustData.cbStruct = sizeof(wintrustData); + wintrustData.pFile = &fileData; + wintrustData.dwUnionChoice = WTD_CHOICE_FILE; // Specify WINTRUST_FILE_INFO. + wintrustData.dwUIChoice = WTD_UI_NONE; // Do not display any UI. + wintrustData.dwUIContext = WTD_UICONTEXT_EXECUTE; // Hint that this is about app execution. + wintrustData.fdwRevocationChecks = WTD_REVOKE_NONE; + wintrustData.dwProvFlags = WTD_REVOCATION_CHECK_NONE; + wintrustData.dwStateAction = WTD_STATEACTION_VERIFY; + wintrustData.hWVTStateData = 0; + + resultStatus = m_PtrWinVerifyTrust( + (HWND)INVALID_HANDLE_VALUE, // Do not display any UI. + &actionGUID, // V2 verification + &wintrustData); + + if (resultStatus == ERROR_SUCCESS && wintrustData.hWVTStateData != 0 && + wintrustData.hWVTStateData != INVALID_HANDLE_VALUE) { + CRYPT_PROVIDER_DATA* cpd = m_PtrWTHelperProvDataFromStateData(wintrustData.hWVTStateData); + if (cpd && cpd->csSigners == 1) { + CRYPT_PROVIDER_SGNR* cps = m_PtrWTHelperGetProvSignerFromChain(cpd, 0, FALSE, 0); + int chainIndex; + for (chainIndex = 0; chainIndex < CertificateChainCount; ++chainIndex) { + CertificateEntry* chain = AllowedCertificateChains[chainIndex]; + if (VCCRSuccess == ValidateCertificateContents(chain, cps)) { + verified = TRUE; + break; + } + } } + } - if (!fullPath) - { - return INVALID_HANDLE_VALUE; - } + wintrustData.dwStateAction = WTD_STATEACTION_CLOSE; - hFile = CreateFileW(fullPath, GENERIC_READ, FILE_SHARE_READ, - 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0); + m_PtrWinVerifyTrust( + (HWND)INVALID_HANDLE_VALUE, // Do not display any UI. + &actionGUID, // V2 verification + &wintrustData); - if (hFile == INVALID_HANDLE_VALUE) - { - return INVALID_HANDLE_VALUE; - } + return verified; +} - ZeroMemory(&fileData, sizeof(fileData)); - fileData.cbStruct = sizeof(fileData); - fileData.pcwszFilePath = fullPath; - fileData.hFile = hFile; - - ZeroMemory(&wintrustData, sizeof(wintrustData)); - wintrustData.cbStruct = sizeof(wintrustData); - wintrustData.pFile = &fileData; - wintrustData.dwUnionChoice = WTD_CHOICE_FILE; // Specify WINTRUST_FILE_INFO. - wintrustData.dwUIChoice = WTD_UI_NONE; // Do not display any UI. - wintrustData.dwUIContext = WTD_UICONTEXT_EXECUTE; // Hint that this is about app execution. - wintrustData.fdwRevocationChecks = WTD_REVOKE_NONE; - wintrustData.dwProvFlags = WTD_REVOCATION_CHECK_NONE; - wintrustData.dwStateAction = WTD_STATEACTION_VERIFY; - wintrustData.hWVTStateData = 0; - - resultStatus = m_PtrWinVerifyTrust( - (HWND)INVALID_HANDLE_VALUE, // Do not display any UI. - &actionGUID, // V2 verification - &wintrustData); - - if (resultStatus == ERROR_SUCCESS && - wintrustData.hWVTStateData != 0 && - wintrustData.hWVTStateData != INVALID_HANDLE_VALUE) - { - CRYPT_PROVIDER_DATA* cpd = m_PtrWTHelperProvDataFromStateData(wintrustData.hWVTStateData); - if (cpd && cpd->csSigners == 1) - { - CRYPT_PROVIDER_SGNR* cps = m_PtrWTHelperGetProvSignerFromChain(cpd, 0, FALSE, 0); - int chainIndex; - for (chainIndex = 0; chainIndex < CertificateChainCount; ++chainIndex) - { - CertificateEntry* chain = AllowedCertificateChains[chainIndex]; - if (0 == ValidateCertificateContents(chain, cps)) - { - verified = 1; - break; - } - } - } - } +#endif // #if defined(_WIN32) - wintrustData.dwStateAction = WTD_STATEACTION_CLOSE; +static ModuleHandleType OVR_OpenLibrary(const FilePathCharType* libraryPath, ovrResult* result) { +#if defined(_WIN32) + DWORD fullPathNameLen = 0; + FilePathCharType fullPath[MAX_PATH] = {0}; + HANDLE hFilePinned = INVALID_HANDLE_VALUE; + ModuleHandleType hModule = 0; - m_PtrWinVerifyTrust( - (HWND)INVALID_HANDLE_VALUE, // Do not display any UI. - &actionGUID, // V2 verification - &wintrustData); + *result = ovrSuccess; - if (verified != 1) - { - CloseHandle(hFile); - return INVALID_HANDLE_VALUE; - } + fullPathNameLen = GetFullPathNameW(libraryPath, MAX_PATH, fullPath, 0); + if (fullPathNameLen <= 0 || fullPathNameLen >= MAX_PATH) { + *result = ovrError_LibPath; + return NULL; + } - return hFile; -} + hFilePinned = CreateFileW( + fullPath, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0); -#endif // #if defined(_WIN32) + if (hFilePinned == INVALID_HANDLE_VALUE) { + *result = ovrError_LibPath; + return NULL; + } -static ModuleHandleType OVR_OpenLibrary(const FilePathCharType* libraryPath) -{ - #if defined(_WIN32) - DWORD fullPathNameLen = 0; - FilePathCharType fullPath[MAX_PATH] = { 0 }; - HANDLE hFilePinned = INVALID_HANDLE_VALUE; - ModuleHandleType hModule = 0; - fullPathNameLen = GetFullPathNameW(libraryPath, MAX_PATH, fullPath, 0); - if (fullPathNameLen <= 0 || fullPathNameLen >= MAX_PATH) - { - return 0; - } - fullPath[MAX_PATH - 1] = 0; + if (!OVR_Win32_SignCheck(fullPath, hFilePinned)) { + *result = ovrError_LibSignCheck; + CloseHandle(hFilePinned); + return NULL; + } - hFilePinned = OVR_Win32_SignCheck(fullPath); - if (hFilePinned == INVALID_HANDLE_VALUE) - { - return 0; - } - - hModule = LoadLibraryW(fullPath); + hModule = LoadLibraryW(fullPath); - if (hFilePinned != INVALID_HANDLE_VALUE) - { - CloseHandle(hFilePinned); - } + CloseHandle(hFilePinned); - return hModule; - #else - // Don't bother trying to dlopen() a file that is not even there. - if (access(libraryPath, X_OK | R_OK ) != 0) - { - return NULL; - } + if (hModule == NULL) { + *result = ovrError_LibLoad; + } - dlerror(); // Clear any previous dlopen() errors + return hModule; +#else + *result = ovrSuccess; - // Use RTLD_NOW because we don't want unexpected stalls at runtime, and the library isn't very large. - // Use RTLD_LOCAL to avoid unilaterally exporting resolved symbols to the rest of this process. - void *lib = dlopen(libraryPath, RTLD_NOW | RTLD_LOCAL); + // Don't bother trying to dlopen() a file that is not even there. + if (access(libraryPath, X_OK | R_OK) != 0) { + *result = ovrError_LibPath; + return NULL; + } - if (!lib) - { - #if defined(__APPLE__) - // TODO: Output the error in whatever logging system OSX uses (jhughes) - #else // __APPLE__ - fprintf(stderr, "ERROR: Can't load '%s':\n%s\n", libraryPath, dlerror()); - #endif // __APPLE__ - } + dlerror(); // Clear any previous dlopen() errors - return lib; - #endif -} + // Use RTLD_NOW because we don't want unexpected stalls at runtime, and the library isn't very + // large. + // Use RTLD_LOCAL to avoid unilaterally exporting resolved symbols to the rest of this process. + void* lib = dlopen(libraryPath, RTLD_NOW | RTLD_LOCAL); + if (!lib) { + fprintf(stderr, "ERROR: Can't load '%s':\n%s\n", libraryPath, dlerror()); + } -static void OVR_CloseLibrary(ModuleHandleType hLibrary) -{ - if (hLibrary) - { - #if defined(_WIN32) - // We may need to consider what to do in the case that the library is in an exception state. - // In a Windows C++ DLL, all global objects (including static members of classes) will be constructed just - // before the calling of the DllMain with DLL_PROCESS_ATTACH and they will be destroyed just after - // the call of the DllMain with DLL_PROCESS_DETACH. We may need to intercept DLL_PROCESS_DETACH and - // have special handling for the case that the DLL is broken. - FreeLibrary(hLibrary); - #else - dlclose(hLibrary); - #endif - } + return lib; +#endif } +static void OVR_CloseLibrary(ModuleHandleType hLibrary) { + if (hLibrary) { +#if defined(_WIN32) + // We may need to consider what to do in the case that the library is in an exception state. + // In a Windows C++ DLL, all global objects (including static members of classes) will be + // constructed just + // before the calling of the DllMain with DLL_PROCESS_ATTACH and they will be destroyed just + // after + // the call of the DllMain with DLL_PROCESS_DETACH. We may need to intercept DLL_PROCESS_DETACH + // and + // have special handling for the case that the DLL is broken. + FreeLibrary(hLibrary); +#else + dlclose(hLibrary); +#endif + } +} -// Returns a valid ModuleHandleType (e.g. Windows HMODULE) or returns ModuleHandleTypeNull (e.g. NULL). +// Returns a valid ModuleHandleType (e.g. Windows HMODULE) or returns ModuleHandleTypeNull (e.g. +// NULL). // The caller is required to eventually call OVR_CloseLibrary on a valid return handle. // -static ModuleHandleType OVR_FindLibraryPath(int requestedProductVersion, int requestedMajorVersion, - FilePathCharType* libraryPath, size_t libraryPathCapacity) -{ - ModuleHandleType moduleHandle; - int printfResult; - FilePathCharType developerDir[OVR_MAX_PATH] = { '\0' }; - - #if defined(_MSC_VER) - #if defined(_WIN64) - const char* pBitDepth = "64"; - #else - const char* pBitDepth = "32"; - #endif - #elif defined(__APPLE__) - // For Apple platforms we are using a Universal Binary LibOVRRT dylib which has both 32 and 64 in it. - #else // Other Unix. - #if defined(__x86_64__) - const char* pBitDepth = "64"; - #else - const char* pBitDepth = "32"; - #endif - #endif - - (void)requestedProductVersion; - - moduleHandle = ModuleHandleTypeNull; - if(libraryPathCapacity) - libraryPath[0] = '\0'; - - // Note: OVR_ENABLE_DEVELOPER_SEARCH is deprecated in favor of the simpler LIBOVR_DLL_DIR, as the edge - // case uses of the former created some complications that may be best solved by simply using a LIBOVR_DLL_DIR - // environment variable which the user can set in their debugger or system environment variables. - #if (defined(_MSC_VER) || defined(_WIN32)) && !defined(OVR_FILE_PATH_SEPARATOR) - #define OVR_FILE_PATH_SEPARATOR "\\" - #else - #define OVR_FILE_PATH_SEPARATOR "/" - #endif +static ModuleHandleType OVR_FindLibraryPath( + int requestedProductVersion, + int requestedMajorVersion, + FilePathCharType* libraryPath, + size_t libraryPathCapacity, + ovrResult* result) { + ModuleHandleType moduleHandle; + FilePathCharType developerDir[OVR_MAX_PATH] = {'\0'}; - { - const char* pLibOvrDllDir = getenv("LIBOVR_DLL_DIR"); // Example value: /dev/OculusSDK/Main/LibOVR/Mac/Debug/ +#if defined(_MSC_VER) +#if defined(_WIN64) + const char* pBitDepth = "64"; +#else + const char* pBitDepth = "32"; +#endif +#elif defined(__APPLE__) +// For Apple platforms we are using a Universal Binary LibOVRRT dylib which has both 32 and 64 in +// it. +#else // Other Unix. +#if defined(__x86_64__) + const char* pBitDepth = "64"; +#else + const char* pBitDepth = "32"; +#endif +#endif - if(pLibOvrDllDir) - { - char developerDir8[OVR_MAX_PATH]; - size_t length = OVR_strlcpy(developerDir8, pLibOvrDllDir, sizeof(developerDir8)); // If missing a trailing path separator then append one. - - if((length > 0) && (length < sizeof(developerDir8)) && (developerDir8[length - 1] != OVR_FILE_PATH_SEPARATOR[0])) - { - length = OVR_strlcat(developerDir8, OVR_FILE_PATH_SEPARATOR, sizeof(developerDir8)); - - if(length < sizeof(developerDir8)) - { - #if defined(_WIN32) - size_t i; - for(i = 0; i <= length; ++i) // ASCII conversion of 8 to 16 bit text. - developerDir[i] = (FilePathCharType)(uint8_t)developerDir8[i]; - #else - OVR_strlcpy(developerDir, developerDir8, sizeof(developerDir)); - #endif - } - } - } - } + (void)requestedProductVersion; - // Support checking for a developer library location override via the OVR_SDK_ROOT environment variable. - // This pathway is deprecated in favor of using LIBOVR_DLL_DIR instead. - #if defined(OVR_ENABLE_DEVELOPER_SEARCH) - if (!developerDir[0]) // If not already set by LIBOVR_DLL_PATH... - { - // __FILE__ maps to /LibOVR/Src/OVR_CAPIShim.c - char sdkRoot[OVR_MAX_PATH]; - char* pLibOVR; + *result = ovrError_LibLoad; + moduleHandle = ModuleHandleTypeNull; + if (libraryPathCapacity) { + libraryPath[0] = '\0'; + } + +#if (defined(_MSC_VER) || defined(_WIN32)) && !defined(OVR_FILE_PATH_SEPARATOR) +#define OVR_FILE_PATH_SEPARATOR "\\" +#else +#define OVR_FILE_PATH_SEPARATOR "/" +#endif + + { + const char* pLibOvrDllDir = + getenv("LIBOVR_DLL_DIR"); // Example value: /dev/OculusSDK/Main/LibOVR/Mac/Debug/ + + if (pLibOvrDllDir) { + char developerDir8[OVR_MAX_PATH]; + size_t length = OVR_strlcpy(developerDir8, pLibOvrDllDir, sizeof(developerDir8)); + + // If missing a trailing path separator then append one. + if ((length > 0) && (length < sizeof(developerDir8)) && + (developerDir8[length - 1] != OVR_FILE_PATH_SEPARATOR[0])) { + length = OVR_strlcat(developerDir8, OVR_FILE_PATH_SEPARATOR, sizeof(developerDir8)); + } + + if (length < sizeof(developerDir8)) { +#if defined(_WIN32) size_t i; + for (i = 0; i <= length; ++i) // ASCII conversion of 8 to 16 bit text. + developerDir[i] = (FilePathCharType)(uint8_t)developerDir8[i]; +#else + OVR_strlcpy(developerDir, developerDir8, sizeof(developerDir)); +#endif + } + } + } - // We assume that __FILE__ returns a full path, which isn't the case for some compilers. - // Need to compile with /FC under VC++ for __FILE__ to expand to the full file path. - // clang expands __FILE__ to a full path by default. - OVR_strlcpy(sdkRoot, __FILE__, sizeof(sdkRoot)); - for(i = 0; sdkRoot[i]; ++i) - sdkRoot[i] = (char)tolower(sdkRoot[i]); // Microsoft doesn't maintain case. - pLibOVR = strstr(sdkRoot, "libovr"); - if(pLibOVR && (pLibOVR > sdkRoot)) - pLibOVR[-1] = '\0'; - else - sdkRoot[0] = '\0'; - - if(sdkRoot[0]) - { - // We want to use a developer version of the library only if the application is also being executed from - // a developer location. Ideally we would do this by checking that the relative path from the executable to - // the shared library is the same at runtime as it was when the executable was first built, but we don't have - // an easy way to do that from here and it would require some runtime help from the application code. - // Instead we verify that the application is simply in the same developer tree that was was when built. - // We could put in some additional logic to make it very likely to know if the EXE is in its original location. - FilePathCharType modulePath[OVR_MAX_PATH]; - const ovrBool pathMatch = OVR_GetCurrentModuleDirectory(modulePath, OVR_MAX_PATH, ovrTrue) && - (OVR_PathStartsWith(modulePath, sdkRoot) == ovrTrue); - if(pathMatch == ovrFalse) - { - sdkRoot[0] = '\0'; // The application module is not in the developer tree, so don't try to use the developer shared library. - } - } + { + size_t i; - if(sdkRoot[0]) - { - #if defined(OVR_BUILD_DEBUG) - const char* pConfigDirName = "Debug"; - #else - const char* pConfigDirName = "Release"; - #endif - - #if defined(_MSC_VER) - #if defined(_WIN64) - const char* pArchDirName = "x64"; - #else - const char* pArchDirName = "Win32"; - #endif - #else - #if defined(__x86_64__) - const char* pArchDirName = "x86_64"; - #else - const char* pArchDirName = "i386"; - #endif - #endif - - #if defined(_MSC_VER) && (_MSC_VER == 1600) - const char* pCompilerVersion = "VS2010"; - #elif defined(_MSC_VER) && (_MSC_VER == 1700) - const char* pCompilerVersion = "VS2012"; - #elif defined(_MSC_VER) && (_MSC_VER == 1800) - const char* pCompilerVersion = "VS2013"; - #elif defined(_MSC_VER) && (_MSC_VER == 1900) - const char* pCompilerVersion = "VS2014"; - #endif - - #if defined(_WIN32) - int count = swprintf_s(developerDir, OVR_MAX_PATH, L"%hs\\LibOVR\\Lib\\Windows\\%hs\\%hs\\%hs\\", - sdkRoot, pArchDirName, pConfigDirName, pCompilerVersion); - #elif defined(__APPLE__) - // Apple/XCode doesn't let you specify an arch in build paths, which is OK if we build a universal binary. - (void)pArchDirName; - int count = snprintf(developerDir, OVR_MAX_PATH, "%s/LibOVR/Lib/Mac/%s/", - sdkRoot, pConfigDirName); - #else - int count = snprintf(developerDir, OVR_MAX_PATH, "%s/LibOVR/Lib/Linux/%s/%s/", - sdkRoot, pArchDirName, pConfigDirName); - #endif - - if((count < 0) || (count >= (int)OVR_MAX_PATH)) // If there was an error or capacity overflow... clear the string. - { - developerDir[0] = '\0'; - } - } +#if !defined(_WIN32) + FilePathCharType cwDir[OVR_MAX_PATH]; // Will be filled in below. + FilePathCharType appDir[OVR_MAX_PATH]; + OVR_GetCurrentWorkingDirectory(cwDir, sizeof(cwDir) / sizeof(cwDir[0])); + OVR_GetCurrentApplicationDirectory(appDir, sizeof(appDir) / sizeof(appDir[0]), ovrTrue, NULL); +#endif + +#if defined(_WIN32) + // On Windows, only search the developer directory and the usual path + const FilePathCharType* directoryArray[2]; + directoryArray[0] = developerDir; // Developer directory. + directoryArray[1] = L""; // No directory, which causes Windows to use the standard search + // strategy to find the DLL. + +#elif defined(__APPLE__) + // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html + + FilePathCharType homeDir[OVR_MAX_PATH]; + FilePathCharType homeFrameworkDir[OVR_MAX_PATH]; + const FilePathCharType* directoryArray[5]; + size_t homeDirLength = 0; + + const char* pHome = getenv("HOME"); // Try getting the HOME environment variable. + + if (pHome) { + homeDirLength = OVR_strlcpy(homeDir, pHome, sizeof(homeDir)); + } else { + // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/getpwuid_r.3.html + const long pwBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX); + + if (pwBufferSize != -1) { + char pwBuffer[pwBufferSize]; + struct passwd pw; + struct passwd* pwResult = NULL; + + if ((getpwuid_r(getuid(), &pw, pwBuffer, pwBufferSize, &pwResult) == 0) && pwResult) + homeDirLength = OVR_strlcpy(homeDir, pw.pw_dir, sizeof(homeDir)); + } } - #endif // OVR_ENABLE_DEVELOPER_SEARCH - { - #if !defined(_WIN32) - FilePathCharType cwDir[OVR_MAX_PATH]; // Will be filled in below. - FilePathCharType appDir[OVR_MAX_PATH]; - #endif - size_t i; + if (homeDirLength) { + if (homeDir[homeDirLength - 1] == '/') + homeDir[homeDirLength - 1] = '\0'; + OVR_strlcpy(homeFrameworkDir, homeDir, sizeof(homeFrameworkDir)); + OVR_strlcat(homeFrameworkDir, "/Library/Frameworks/", sizeof(homeFrameworkDir)); + } else { + homeFrameworkDir[0] = '\0'; + } - #if defined(_WIN32) - // On Windows, only search the developer directory and the usual path - const FilePathCharType* directoryArray[2]; - directoryArray[0] = developerDir; // Developer directory. - directoryArray[1] = L""; // No directory, which causes Windows to use the standard search strategy to find the DLL. - - #elif defined(__APPLE__) - // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html - - FilePathCharType homeDir[OVR_MAX_PATH]; - FilePathCharType homeFrameworkDir[OVR_MAX_PATH]; - const FilePathCharType* directoryArray[5]; - size_t homeDirLength = 0; - - const char* pHome = getenv("HOME"); // Try getting the HOME environment variable. - - if (pHome) - { - homeDirLength = OVR_strlcpy(homeDir, pHome, sizeof(homeDir)); - } - else - { - // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/getpwuid_r.3.html - const long pwBufferSize = sysconf(_SC_GETPW_R_SIZE_MAX); - - if (pwBufferSize != -1) - { - char pwBuffer[pwBufferSize]; - struct passwd pw; - struct passwd* pwResult = NULL; - - if ((getpwuid_r(getuid(), &pw, pwBuffer, pwBufferSize, &pwResult) == 0) && pwResult) - homeDirLength = OVR_strlcpy(homeDir, pw.pw_dir, sizeof(homeDir)); - } - } - - if (homeDirLength) - { - if (homeDir[homeDirLength - 1] == '/') - homeDir[homeDirLength - 1] = '\0'; - OVR_strlcpy(homeFrameworkDir, homeDir, sizeof(homeFrameworkDir)); - OVR_strlcat(homeFrameworkDir, "/Library/Frameworks/", sizeof(homeFrameworkDir)); - } - else - { - homeFrameworkDir[0] = '\0'; - } - - directoryArray[0] = cwDir; - directoryArray[1] = appDir; - directoryArray[2] = homeFrameworkDir; // ~/Library/Frameworks/ - directoryArray[3] = "/Library/Frameworks/"; // DYLD_FALLBACK_FRAMEWORK_PATH - directoryArray[4] = developerDir; // Developer directory. - - #else - #define STR1(x) #x - #define STR(x) STR1(x) - #ifdef LIBDIR - #define TEST_LIB_DIR STR(LIBDIR) "/" - #else - #define TEST_LIB_DIR appDir - #endif - - const FilePathCharType* directoryArray[5]; - directoryArray[0] = cwDir; - directoryArray[1] = TEST_LIB_DIR; // Directory specified by LIBDIR if defined. - directoryArray[2] = developerDir; // Developer directory. - directoryArray[3] = "/usr/local/lib/"; - directoryArray[4] = "/usr/lib/"; - #endif - - #if !defined(_WIN32) - OVR_GetCurrentWorkingDirectory(cwDir, sizeof(cwDir) / sizeof(cwDir[0])); - OVR_GetCurrentApplicationDirectory(appDir, sizeof(appDir) / sizeof(appDir[0]), ovrTrue, NULL); - #endif - - // Versioned file expectations. - // Windows: LibOVRRT__.dll // Example: LibOVRRT64_1_1.dll -- LibOVRRT 64 bit, product 1, major version 1, minor/patch/build numbers unspecified in the name. - // Mac: LibOVRRT_.framework/Versions//LibOVRRT_ // We are not presently using the .framework bundle's Current directory to hold the version number. This may change. - // Linux: libOVRRT_.so. // The file on disk may contain a minor version number, but a symlink is used to map this major-only version to it. - - // Since we are manually loading the LibOVR dynamic library, we need to look in various locations for a file - // that matches our requirements. The functionality required is somewhat similar to the operating system's - // dynamic loader functionality. Each OS has some differences in how this is handled. - // Future versions of this may iterate over all libOVRRT.so.* files in the directory and use the one that matches our requirements. - // - // We need to look for a library that matches the product version and major version of the caller's request, - // and that library needs to support a minor version that is >= the requested minor version. Currently we - // don't test the minor version here, as the library is named based only on the product and major version. - // Currently the minor version test is handled via the initialization of the library and the initialization - // fails if minor version cannot be supported by the library. The reason this is done during initialization - // is that the library can at runtime support multiple minor versions based on the user's request. To the - // external user, all that matters it that they call ovr_Initialize with a requested version and it succeeds - // or fails. - // - // The product version is something that is at a higher level than the major version, and is not something that's - // always seen in libraries (an example is the well-known LibXml2 library, in which the 2 is essentially the product version). - - for(i = 0; i < sizeof(directoryArray)/sizeof(directoryArray[0]); ++i) - { - #if defined(_WIN32) - printfResult = swprintf(libraryPath, libraryPathCapacity, L"%lsLibOVRRT%hs_%d.dll", directoryArray[i], pBitDepth, requestedMajorVersion); - - if (*directoryArray[i] == 0) - { - int k; - FilePathCharType foundPath[MAX_PATH] = { 0 }; - DWORD searchResult = SearchPathW(NULL, libraryPath, NULL, MAX_PATH, foundPath, NULL); - if (searchResult <= 0 || searchResult >= libraryPathCapacity) - { - continue; - } - foundPath[MAX_PATH - 1] = 0; - for (k = 0; k < MAX_PATH; ++k) - { - libraryPath[k] = foundPath[k]; - } - } - - #elif defined(__APPLE__) - // https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/VersionInformation.html - // Macintosh application bundles have the option of embedding dependent frameworks within the application - // bundle itself. A problem with that is that it doesn't support vendor-supplied updates to the framework. - printfResult = snprintf(libraryPath, libraryPathCapacity, "%sLibOVRRT.framework/Versions/%d/LibOVRRT", directoryArray[i], requestedMajorVersion); - - #else // Unix - // Applications that depend on the OS (e.g. ld-linux / ldd) can rely on the library being in a common location - // such as /usr/lib or can rely on the -rpath linker option to embed a path for the OS to check for the library, - // or can rely on the LD_LIBRARY_PATH environment variable being set. It's generally not recommended that applications - // depend on LD_LIBRARY_PATH be globally modified, partly due to potentialy security issues. - // Currently we check the current application directory, current working directory, and then /usr/lib and possibly others. - printfResult = snprintf(libraryPath, libraryPathCapacity, "%slibOVRRT%s.so.%d", directoryArray[i], pBitDepth, requestedMajorVersion); - #endif - - if((printfResult >= 0) && (printfResult < (int)libraryPathCapacity)) - { - moduleHandle = OVR_OpenLibrary(libraryPath); - if(moduleHandle != ModuleHandleTypeNull) - return moduleHandle; - } + directoryArray[0] = cwDir; + directoryArray[1] = appDir; + directoryArray[2] = homeFrameworkDir; // ~/Library/Frameworks/ + directoryArray[3] = "/Library/Frameworks/"; // DYLD_FALLBACK_FRAMEWORK_PATH + directoryArray[4] = developerDir; // Developer directory. + +#else +#define STR1(x) #x +#define STR(x) STR1(x) +#ifdef LIBDIR +#define TEST_LIB_DIR STR(LIBDIR) "/" +#else +#define TEST_LIB_DIR appDir +#endif + + const FilePathCharType* directoryArray[5]; + directoryArray[0] = cwDir; + directoryArray[1] = TEST_LIB_DIR; // Directory specified by LIBDIR if defined. + directoryArray[2] = developerDir; // Developer directory. + directoryArray[3] = "/usr/local/lib/"; + directoryArray[4] = "/usr/lib/"; +#endif + + // Versioned file expectations. + // Windows: LibOVRRT__.dll + // // Example: LibOVRRT64_1_1.dll -- LibOVRRT 64 bit, product 1, major version 1, + // minor/patch/build numbers unspecified in the name. + // Mac: + // LibOVRRT_.framework/Versions//LibOVRRT_ + // // We are not presently using the .framework bundle's Current directory to hold the + // version number. This may change. + // Linux: libOVRRT_.so. + // // The file on disk may contain a minor version number, but a symlink is used to map this + // major-only version to it. + + // Since we are manually loading the LibOVR dynamic library, we need to look in various + // locations for a file + // that matches our requirements. The functionality required is somewhat similar to the + // operating system's + // dynamic loader functionality. Each OS has some differences in how this is handled. + // Future versions of this may iterate over all libOVRRT.so.* files in the directory and use the + // one that matches our requirements. + // + // We need to look for a library that matches the product version and major version of the + // caller's request, + // and that library needs to support a minor version that is >= the requested minor version. + // Currently we + // don't test the minor version here, as the library is named based only on the product and + // major version. + // Currently the minor version test is handled via the initialization of the library and the + // initialization + // fails if minor version cannot be supported by the library. The reason this is done during + // initialization + // is that the library can at runtime support multiple minor versions based on the user's + // request. To the + // external user, all that matters it that they call ovr_Initialize with a requested version and + // it succeeds + // or fails. + // + // The product version is something that is at a higher level than the major version, and is not + // something that's + // always seen in libraries (an example is the well-known LibXml2 library, in which the 2 is + // essentially the product version). + + for (i = 0; i < sizeof(directoryArray) / sizeof(directoryArray[0]); ++i) { +#if defined(_WIN32) + int printfResult = swprintf( + libraryPath, + libraryPathCapacity, + L"%lsLibOVRRT%hs_%d.dll", + directoryArray[i], + pBitDepth, + requestedMajorVersion); + + if (*directoryArray[i] == 0) { + int k; + FilePathCharType foundPath[MAX_PATH] = {0}; + DWORD searchResult = SearchPathW(NULL, libraryPath, NULL, MAX_PATH, foundPath, NULL); + if (searchResult <= 0 || searchResult >= libraryPathCapacity) { + continue; } + foundPath[MAX_PATH - 1] = 0; + for (k = 0; k < MAX_PATH; ++k) { + libraryPath[k] = foundPath[k]; + } + } + +#elif defined(__APPLE__) + // https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/VersionInformation.html + // Macintosh application bundles have the option of embedding dependent frameworks within the + // application + // bundle itself. A problem with that is that it doesn't support vendor-supplied updates to + // the framework. + int printfResult = + snprintf(libraryPath, libraryPathCapacity, "%sLibOVRRT.dylib", directoryArray[i]); + +#else // Unix + // Applications that depend on the OS (e.g. ld-linux / ldd) can rely on the library being in a + // common location + // such as /usr/lib or can rely on the -rpath linker option to embed a path for the OS to + // check for the library, + // or can rely on the LD_LIBRARY_PATH environment variable being set. It's generally not + // recommended that applications + // depend on LD_LIBRARY_PATH be globally modified, partly due to potentialy security issues. + // Currently we check the current application directory, current working directory, and then + // /usr/lib and possibly others. + int printfResult = snprintf( + libraryPath, + libraryPathCapacity, + "%slibOVRRT%s.so.%d", + directoryArray[i], + pBitDepth, + requestedMajorVersion); +#endif + + if ((printfResult >= 0) && (printfResult < (int)libraryPathCapacity)) { + moduleHandle = OVR_OpenLibrary(libraryPath, result); + if (moduleHandle != ModuleHandleTypeNull) + return moduleHandle; + } } + } - return moduleHandle; + return moduleHandle; } - - //----------------------------------------------------------------------------------- // ***** hLibOVR // @@ -1044,871 +878,1057 @@ static ModuleHandleType OVR_FindLibraryPath(int requestedProductVersion, int req static ModuleHandleType hLibOVR = NULL; // This function is currently unsupported. -ModuleHandleType ovr_GetLibOVRRTHandle() -{ - return hLibOVR; +ModuleHandleType ovr_GetLibOVRRTHandle() { + return hLibOVR; } - - //----------------------------------------------------------------------------------- // ***** Function declarations // -// To consider: Move OVR_DECLARE_IMPORT and the declarations below to OVR_CAPI.h + +//----------------------------------------------------------------------------------- +// ***** OVR_DECLARE_IMPORT +// +// Creates a pointer and loader value union for each entry in OVR_LIST_APIS() // -OVR_DECLARE_IMPORT(ovrBool, ovr_InitializeRenderingShimVersion, (int requestedMinorVersion)) -OVR_DECLARE_IMPORT(ovrResult, ovr_Initialize, (const ovrInitParams* params)) -OVR_DECLARE_IMPORT(ovrBool, ovr_Shutdown, ()) -OVR_DECLARE_IMPORT(const char*, ovr_GetVersionString, ()) -OVR_DECLARE_IMPORT(void, ovr_GetLastErrorInfo, (ovrErrorInfo* errorInfo)) -OVR_DECLARE_IMPORT(ovrHmdDesc, ovr_GetHmdDesc, (ovrSession session)) -OVR_DECLARE_IMPORT(unsigned int, ovr_GetTrackerCount, (ovrSession session)) -OVR_DECLARE_IMPORT(ovrTrackerDesc, ovr_GetTrackerDesc, (ovrSession session, unsigned int trackerDescIndex)) -OVR_DECLARE_IMPORT(ovrResult, ovr_Create, (ovrSession* pSession, ovrGraphicsLuid* pLuid)) -OVR_DECLARE_IMPORT(void, ovr_Destroy, (ovrSession session)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetSessionStatus, (ovrSession session, ovrSessionStatus* sessionStatus)) -OVR_DECLARE_IMPORT(ovrResult, ovr_SetTrackingOriginType, (ovrSession session, ovrTrackingOrigin origin)) -OVR_DECLARE_IMPORT(ovrTrackingOrigin, ovr_GetTrackingOriginType, (ovrSession session)) - -OVR_DECLARE_IMPORT(ovrResult, ovr_RecenterTrackingOrigin, (ovrSession session)) -OVR_DECLARE_IMPORT(void, ovr_ClearShouldRecenterFlag, (ovrSession session)) -OVR_DECLARE_IMPORT(ovrTrackingState, ovr_GetTrackingState, (ovrSession session, double absTime, ovrBool latencyMarker)) -OVR_DECLARE_IMPORT(ovrTrackerPose, ovr_GetTrackerPose, (ovrSession session, unsigned int index)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetInputState, (ovrSession session, ovrControllerType controllerType, ovrInputState*)) -OVR_DECLARE_IMPORT(unsigned int, ovr_GetConnectedControllerTypes, (ovrSession session)) -OVR_DECLARE_IMPORT(ovrResult, ovr_SetControllerVibration, (ovrSession session, ovrControllerType controllerType, float frequency, float amplitude)) -OVR_DECLARE_IMPORT(ovrSizei, ovr_GetFovTextureSize, (ovrSession session, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel)) -OVR_DECLARE_IMPORT(ovrResult, ovr_SubmitFrame, (ovrSession session, long long frameIndex, const ovrViewScaleDesc* viewScaleDesc, ovrLayerHeader const * const * layerPtrList, unsigned int layerCount)) -OVR_DECLARE_IMPORT(ovrEyeRenderDesc, ovr_GetRenderDesc, (ovrSession session, ovrEyeType eyeType, ovrFovPort fov)) -OVR_DECLARE_IMPORT(double, ovr_GetPredictedDisplayTime, (ovrSession session, long long frameIndex)) -OVR_DECLARE_IMPORT(double, ovr_GetTimeInSeconds, ()) -OVR_DECLARE_IMPORT(ovrBool, ovr_GetBool, (ovrSession session, const char* propertyName, ovrBool defaultVal)) -OVR_DECLARE_IMPORT(ovrBool, ovr_SetBool, (ovrSession session, const char* propertyName, ovrBool value)) -OVR_DECLARE_IMPORT(int, ovr_GetInt, (ovrSession session, const char* propertyName, int defaultVal)) -OVR_DECLARE_IMPORT(ovrBool, ovr_SetInt, (ovrSession session, const char* propertyName, int value)) -OVR_DECLARE_IMPORT(float, ovr_GetFloat, (ovrSession session, const char* propertyName, float defaultVal)) -OVR_DECLARE_IMPORT(ovrBool, ovr_SetFloat, (ovrSession session, const char* propertyName, float value)) -OVR_DECLARE_IMPORT(unsigned int, ovr_GetFloatArray, (ovrSession session, const char* propertyName, float values[], unsigned int arraySize)) -OVR_DECLARE_IMPORT(ovrBool, ovr_SetFloatArray, (ovrSession session, const char* propertyName, const float values[], unsigned int arraySize)) -OVR_DECLARE_IMPORT(const char*, ovr_GetString, (ovrSession session, const char* propertyName, const char* defaultVal)) -OVR_DECLARE_IMPORT(ovrBool, ovr_SetString, (ovrSession session, const char* propertyName, const char* value)) -OVR_DECLARE_IMPORT(int, ovr_TraceMessage, (int level, const char* message)) - -#if defined (_WIN32) -OVR_DECLARE_IMPORT(ovrResult, ovr_CreateTextureSwapChainDX, (ovrSession session, IUnknown* d3dPtr, const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* outTextureChain)) -OVR_DECLARE_IMPORT(ovrResult, ovr_CreateMirrorTextureDX, (ovrSession session, IUnknown* d3dPtr, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetTextureSwapChainBufferDX, (ovrSession session, ovrTextureSwapChain chain, int index, IID iid, void** ppObject)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetMirrorTextureBufferDX, (ovrSession session, ovrMirrorTexture mirror, IID iid, void** ppObject)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceOutWaveId, (UINT* deviceOutId)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceInWaveId, (UINT* deviceInId)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceOutGuidStr, (WCHAR* deviceOutStrBuffer)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceOutGuid, (GUID* deviceOutGuid)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceInGuidStr, (WCHAR* deviceInStrBuffer)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetAudioDeviceInGuid, (GUID* deviceInGuid)) -#endif -OVR_DECLARE_IMPORT(ovrResult, ovr_CreateTextureSwapChainGL, (ovrSession session, const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* outTextureChain)) -OVR_DECLARE_IMPORT(ovrResult, ovr_CreateMirrorTextureGL, (ovrSession session, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetTextureSwapChainBufferGL, (ovrSession session, ovrTextureSwapChain chain, int index, unsigned int* texId)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetMirrorTextureBufferGL, (ovrSession session, ovrMirrorTexture mirror, unsigned int* texId)) - -OVR_DECLARE_IMPORT(ovrResult, ovr_GetTextureSwapChainLength, (ovrSession session, ovrTextureSwapChain chain, int* length)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetTextureSwapChainCurrentIndex, (ovrSession session, ovrTextureSwapChain chain, int* currentIndex)) -OVR_DECLARE_IMPORT(ovrResult, ovr_GetTextureSwapChainDesc, (ovrSession session, ovrTextureSwapChain chain, ovrTextureSwapChainDesc* desc)) -OVR_DECLARE_IMPORT(ovrResult, ovr_CommitTextureSwapChain, (ovrSession session, ovrTextureSwapChain chain)) -OVR_DECLARE_IMPORT(void, ovr_DestroyTextureSwapChain, (ovrSession session, ovrTextureSwapChain chain)) -OVR_DECLARE_IMPORT(void, ovr_DestroyMirrorTexture, (ovrSession session, ovrMirrorTexture texture)) -OVR_DECLARE_IMPORT(ovrResult, ovr_SetQueueAheadFraction, (ovrSession session, float queueAheadFraction)) - -OVR_DECLARE_IMPORT(ovrResult, ovr_Lookup, (const char* name, void** data)); - -static ovrResult OVR_LoadSharedLibrary(int requestedProductVersion, int requestedMajorVersion) -{ - FilePathCharType filePath[OVR_MAX_PATH]; - - if(hLibOVR) - return ovrSuccess; - - hLibOVR = OVR_FindLibraryPath(requestedProductVersion, requestedMajorVersion, - filePath, sizeof(filePath) / sizeof(filePath[0])); - if(!hLibOVR) - return ovrError_LibLoad; - - OVR_GETFUNCTION(ovr_InitializeRenderingShimVersion) - OVR_GETFUNCTION(ovr_Initialize) - OVR_GETFUNCTION(ovr_Shutdown) - OVR_GETFUNCTION(ovr_GetVersionString) - OVR_GETFUNCTION(ovr_GetLastErrorInfo) - OVR_GETFUNCTION(ovr_GetHmdDesc) - OVR_GETFUNCTION(ovr_GetTrackerCount) - OVR_GETFUNCTION(ovr_GetTrackerDesc) - OVR_GETFUNCTION(ovr_Create) - OVR_GETFUNCTION(ovr_Destroy) - OVR_GETFUNCTION(ovr_GetSessionStatus) - OVR_GETFUNCTION(ovr_SetTrackingOriginType) - OVR_GETFUNCTION(ovr_GetTrackingOriginType) - OVR_GETFUNCTION(ovr_RecenterTrackingOrigin) - OVR_GETFUNCTION(ovr_ClearShouldRecenterFlag) - OVR_GETFUNCTION(ovr_GetTrackingState) - OVR_GETFUNCTION(ovr_GetTrackerPose) - OVR_GETFUNCTION(ovr_GetInputState) - OVR_GETFUNCTION(ovr_GetConnectedControllerTypes) - OVR_GETFUNCTION(ovr_SetControllerVibration) - OVR_GETFUNCTION(ovr_GetFovTextureSize) - OVR_GETFUNCTION(ovr_SubmitFrame) - OVR_GETFUNCTION(ovr_GetRenderDesc) - OVR_GETFUNCTION(ovr_GetPredictedDisplayTime) - OVR_GETFUNCTION(ovr_GetTimeInSeconds) - OVR_GETFUNCTION(ovr_GetBool) - OVR_GETFUNCTION(ovr_SetBool) - OVR_GETFUNCTION(ovr_GetInt) - OVR_GETFUNCTION(ovr_SetInt) - OVR_GETFUNCTION(ovr_GetFloat) - OVR_GETFUNCTION(ovr_SetFloat) - OVR_GETFUNCTION(ovr_GetFloatArray) - OVR_GETFUNCTION(ovr_SetFloatArray) - OVR_GETFUNCTION(ovr_GetString) - OVR_GETFUNCTION(ovr_SetString) - OVR_GETFUNCTION(ovr_TraceMessage) -#if defined (_WIN32) - OVR_GETFUNCTION(ovr_CreateTextureSwapChainDX) - OVR_GETFUNCTION(ovr_CreateMirrorTextureDX) - OVR_GETFUNCTION(ovr_GetTextureSwapChainBufferDX) - OVR_GETFUNCTION(ovr_GetMirrorTextureBufferDX) - OVR_GETFUNCTION(ovr_GetAudioDeviceOutWaveId) - OVR_GETFUNCTION(ovr_GetAudioDeviceInWaveId) - OVR_GETFUNCTION(ovr_GetAudioDeviceOutGuidStr) - OVR_GETFUNCTION(ovr_GetAudioDeviceOutGuid) - OVR_GETFUNCTION(ovr_GetAudioDeviceInGuidStr) - OVR_GETFUNCTION(ovr_GetAudioDeviceInGuid) -#endif - OVR_GETFUNCTION(ovr_CreateTextureSwapChainGL) - OVR_GETFUNCTION(ovr_CreateMirrorTextureGL) - OVR_GETFUNCTION(ovr_GetTextureSwapChainBufferGL) - OVR_GETFUNCTION(ovr_GetMirrorTextureBufferGL) - - OVR_GETFUNCTION(ovr_GetTextureSwapChainLength) - OVR_GETFUNCTION(ovr_GetTextureSwapChainCurrentIndex) - OVR_GETFUNCTION(ovr_GetTextureSwapChainDesc) - OVR_GETFUNCTION(ovr_CommitTextureSwapChain) - OVR_GETFUNCTION(ovr_DestroyTextureSwapChain) - OVR_GETFUNCTION(ovr_DestroyMirrorTexture) - OVR_GETFUNCTION(ovr_SetQueueAheadFraction) - OVR_GETFUNCTION(ovr_Lookup) - - return ovrSuccess; -} - -static void OVR_UnloadSharedLibrary() -{ - // To consider: Make all pointers be part of a struct and memset the struct to 0 here. - ovr_InitializeRenderingShimVersionPtr = NULL; - ovr_InitializePtr = NULL; - ovr_ShutdownPtr = NULL; - ovr_GetVersionStringPtr = NULL; - ovr_GetLastErrorInfoPtr = NULL; - ovr_GetHmdDescPtr = NULL; - ovr_GetTrackerCountPtr = NULL; - ovr_GetTrackerDescPtr = NULL; - ovr_CreatePtr = NULL; - ovr_DestroyPtr = NULL; - ovr_GetSessionStatusPtr = NULL; - ovr_SetTrackingOriginTypePtr = NULL; - ovr_GetTrackingOriginTypePtr = NULL; - ovr_RecenterTrackingOriginPtr = NULL; - ovr_GetTrackingStatePtr = NULL; - ovr_GetTrackerPosePtr = NULL; - ovr_GetInputStatePtr = NULL; - ovr_GetConnectedControllerTypesPtr = NULL; - ovr_SetControllerVibrationPtr = NULL; - ovr_GetFovTextureSizePtr = NULL; - ovr_SubmitFramePtr = NULL; - ovr_GetRenderDescPtr = NULL; - ovr_GetPredictedDisplayTimePtr = NULL; - ovr_GetTimeInSecondsPtr = NULL; - ovr_GetBoolPtr = NULL; - ovr_SetBoolPtr = NULL; - ovr_GetIntPtr = NULL; - ovr_SetIntPtr = NULL; - ovr_GetFloatPtr = NULL; - ovr_SetFloatPtr = NULL; - ovr_GetFloatArrayPtr = NULL; - ovr_SetFloatArrayPtr = NULL; - ovr_GetStringPtr = NULL; - ovr_SetStringPtr = NULL; - ovr_TraceMessagePtr = NULL; -#if defined (_WIN32) - ovr_CreateTextureSwapChainDXPtr = NULL; - ovr_CreateMirrorTextureDXPtr = NULL; - ovr_GetTextureSwapChainBufferDXPtr = NULL; - ovr_GetMirrorTextureBufferDXPtr = NULL; - ovr_GetAudioDeviceInWaveIdPtr = NULL; - ovr_GetAudioDeviceOutWaveIdPtr = NULL; - ovr_GetAudioDeviceInGuidStrPtr = NULL; - ovr_GetAudioDeviceOutGuidStrPtr = NULL; - ovr_GetAudioDeviceInGuidPtr = NULL; - ovr_GetAudioDeviceOutGuidPtr = NULL; -#endif - ovr_CreateTextureSwapChainGLPtr = NULL; - ovr_CreateMirrorTextureGLPtr = NULL; - ovr_GetTextureSwapChainBufferGLPtr = NULL; - ovr_GetMirrorTextureBufferGLPtr = NULL; - - ovr_GetTextureSwapChainLengthPtr = NULL; - ovr_GetTextureSwapChainCurrentIndexPtr = NULL; - ovr_GetTextureSwapChainDescPtr = NULL; - ovr_CommitTextureSwapChainPtr = NULL; - ovr_DestroyTextureSwapChainPtr = NULL; - ovr_DestroyMirrorTexturePtr = NULL; - ovr_SetQueueAheadFractionPtr = NULL; - ovr_LookupPtr = NULL; +#define OVR_DECLARE_IMPORT(ReturnValue, FunctionName, OptionalVersion, Arguments) \ + union { \ + ReturnValue(OVR_CDECL* Ptr) Arguments; \ + ModuleFunctionType Symbol; \ + } FunctionName; + +#define OVR_IGNORE_IMPORT(ReturnValue, FunctionName, OptionalVersion, Arguments) + +//----------------------------------------------------------------------------------- +// ***** API - a structure with each API entrypoint as a FunctionName.Ptr and FunctionName.Symbol +// union +// +static struct { OVR_LIST_APIS(OVR_DECLARE_IMPORT, OVR_IGNORE_IMPORT) } API = {{NULL}}; + +static void OVR_UnloadSharedLibrary() { + memset(&API, 0, sizeof(API)); + if (hLibOVR) OVR_CloseLibrary(hLibOVR); - hLibOVR = NULL; + hLibOVR = NULL; } +// Don't put this on the heap +static ovrErrorInfo LastInitializeErrorInfo = {ovrError_NotInitialized, + "ovr_Initialize never called"}; -OVR_PUBLIC_FUNCTION(ovrBool) ovr_InitializeRenderingShim() -{ -#if 1 - return ovrTrue; -#else - return ovr_InitializeRenderingShimVersion(OVR_MINOR_VERSION); -#endif -} +static ovrResult OVR_LoadSharedLibrary(int requestedProductVersion, int requestedMajorVersion) { + FilePathCharType filePath[OVR_MAX_PATH]; + const char* SymbolName = NULL; + ovrResult result = ovrSuccess; + + if (hLibOVR) + return result; + hLibOVR = OVR_FindLibraryPath( + requestedProductVersion, + requestedMajorVersion, + filePath, + sizeof(filePath) / sizeof(filePath[0]), + &result); + + if (!hLibOVR) { + LastInitializeErrorInfo.Result = result; + OVR_strlcpy( + LastInitializeErrorInfo.ErrorString, + "Unable to load LibOVRRT DLL", + sizeof(LastInitializeErrorInfo.ErrorString)); + return result; + } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_InitializeRenderingShimVersion(int requestedMinorVersion) -{ - // By design we ignore the build version in the library search. - ovrBool initializeResult; - ovrResult result = OVR_LoadSharedLibrary(OVR_PRODUCT_VERSION, OVR_MAJOR_VERSION); + // Zero the API table just to be paranoid + memset(&API, 0, sizeof(API)); - if (result != ovrSuccess) - return ovrFalse; +// Load the current API entrypoint using the catenated FunctionName and OptionalVersion +#define OVR_GETFUNCTION(ReturnValue, FunctionName, OptionalVersion, Arguments) \ + SymbolName = #FunctionName #OptionalVersion; \ + API.FunctionName.Symbol = OVR_DLSYM(hLibOVR, SymbolName); \ + if (!API.FunctionName.Symbol) { \ + LastInitializeErrorInfo.Result = result = ovrError_LibSymbols; \ + OVR_strlcpy( \ + LastInitializeErrorInfo.ErrorString, \ + "Unable to locate LibOVRRT symbol: ", \ + sizeof(LastInitializeErrorInfo.ErrorString)); \ + OVR_strlcat( \ + LastInitializeErrorInfo.ErrorString, \ + SymbolName, \ + sizeof(LastInitializeErrorInfo.ErrorString)); \ + goto FailedToLoadSymbol; \ + } - initializeResult = ovr_InitializeRenderingShimVersionPtr(requestedMinorVersion); + OVR_LIST_APIS(OVR_GETFUNCTION, OVR_IGNORE_IMPORT) - if (initializeResult == ovrFalse) - OVR_UnloadSharedLibrary(); +#undef OVR_GETFUNCTION - return initializeResult; -} + return result; +FailedToLoadSymbol: + // Check SymbolName for the name of the API which failed to load + OVR_UnloadSharedLibrary(); + return result; +} // These defaults are also in CAPI.cpp static const ovrInitParams DefaultParams = { ovrInit_RequestVersion, // Flags - OVR_MINOR_VERSION, // RequestedMinorVersion - 0, // LogCallback - 0, // UserData - 0, // ConnectionTimeoutSeconds - OVR_ON64("") // pad0 + OVR_MINOR_VERSION, // RequestedMinorVersion + 0, // LogCallback + 0, // UserData + 0, // ConnectionTimeoutSeconds + OVR_ON64("") // pad0 }; -OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* inputParams) -{ - ovrResult result; - ovrInitParams params; - - typedef void (OVR_CDECL *ovr_ReportClientInfoType)( - unsigned int compilerVersion, - int productVersion, int majorVersion, int minorVersion, - int patchVersion, int buildNumber); - ovr_ReportClientInfoType reportClientInfo; - - // Do something with our version signature hash to prevent - // it from being optimized out. In this case, compute - // a cheap CRC. - uint8_t crc = 0; - size_t i; - - for (i = 0; i < (sizeof(OculusSDKUniqueIdentifier) - 3); ++i) // Minus 3 because we have trailing OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_PATCH_VERSION which vary per version. - { - crc ^= OculusSDKUniqueIdentifier[i]; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* inputParams) { + ovrResult result; + ovrInitParams params; + + typedef void(OVR_CDECL * ovr_ReportClientInfoType)( + unsigned int compilerVersion, + int productVersion, + int majorVersion, + int minorVersion, + int patchVersion, + int buildNumber); + ovr_ReportClientInfoType reportClientInfo; + + // Do something with our version signature hash to prevent + // it from being optimized out. In this case, compute + // a cheap CRC. + uint8_t crc = 0; + size_t i; + + for (i = 0; i < (sizeof(OculusSDKUniqueIdentifier) - 3); + ++i) // Minus 3 because we have trailing OVR_MAJOR_VERSION, OVR_MINOR_VERSION, + // OVR_PATCH_VERSION which vary per version. + { + crc ^= OculusSDKUniqueIdentifier[i]; + } + + assert(crc == OculusSDKUniqueIdentifierXORResult); + if (crc != OculusSDKUniqueIdentifierXORResult) { + return ovrError_Initialize; + } + + if (!inputParams) { + params = DefaultParams; + } else { + params = *inputParams; + + // If not requesting a particular minor version, + if (!(params.Flags & ovrInit_RequestVersion)) { + // Enable requesting the default minor version. + params.Flags |= ovrInit_RequestVersion; + params.RequestedMinorVersion = OVR_MINOR_VERSION; } + } - assert(crc == OculusSDKUniqueIdentifierXORResult); - if (crc != OculusSDKUniqueIdentifierXORResult) - { - return ovrError_Initialize; - } + // Clear non-writable bits provided by client code. + params.Flags &= ovrinit_WritableBits; - if (!inputParams) - { - params = DefaultParams; - } - else - { - params = *inputParams; - // If not requesting a particular minor version, - if (!(params.Flags & ovrInit_RequestVersion)) - { - // Enable requesting the default minor version. - params.Flags |= ovrInit_RequestVersion; - params.RequestedMinorVersion = OVR_MINOR_VERSION; - } + + // Error out if the requested minor version is less than our lowest deemed compatible version + // denoted by OVR_MIN_REQUESTABLE_MINOR_VERSION. + // Note: This code has to be in the shim as we want to enforce usage of the new API versions for + // applications being recompiled while maintaining backwards compatibility with older apps + if (params.RequestedMinorVersion < OVR_MIN_REQUESTABLE_MINOR_VERSION) { + // Requested LibOVRRT version too low + result = ovrError_LibVersion; + return result; + } + + // By design we ignore the build version in the library search. + result = OVR_LoadSharedLibrary(OVR_PRODUCT_VERSION, OVR_MAJOR_VERSION); + if (result != ovrSuccess) + return result; + + result = API.ovr_Initialize.Ptr(¶ms); + + if (result != ovrSuccess) { + // Stash the last initialization error for the shim to return if + // ovr_GetLastErrorInfo is called after we unload the dll below + if (API.ovr_GetLastErrorInfo.Ptr) { + API.ovr_GetLastErrorInfo.Ptr(&LastInitializeErrorInfo); } + OVR_UnloadSharedLibrary(); + } - // Clear non-writable bits provided by client code. - params.Flags &= ovrinit_WritableBits; + reportClientInfo = + (ovr_ReportClientInfoType)(uintptr_t)OVR_DLSYM(hLibOVR, "ovr_ReportClientInfo"); + if (reportClientInfo) { + unsigned int mscFullVer = 0; +#if defined(_MSC_FULL_VER) + mscFullVer = _MSC_FULL_VER; +#endif // _MSC_FULL_VER + reportClientInfo( + mscFullVer, + OVR_PRODUCT_VERSION, + OVR_MAJOR_VERSION, + OVR_MINOR_VERSION, + OVR_PATCH_VERSION, + OVR_BUILD_NUMBER); + } - // By design we ignore the build version in the library search. - result = OVR_LoadSharedLibrary(OVR_PRODUCT_VERSION, OVR_MAJOR_VERSION); - if (result != ovrSuccess) - return result; + return result; +} - result = ovr_InitializePtr(¶ms); - if (result != ovrSuccess) - OVR_UnloadSharedLibrary(); +OVR_PUBLIC_FUNCTION(void) ovr_Shutdown() { + if (!API.ovr_Shutdown.Ptr) + return; + API.ovr_Shutdown.Ptr(); + OVR_UnloadSharedLibrary(); +} - reportClientInfo = (ovr_ReportClientInfoType)(uintptr_t)OVR_DLSYM(hLibOVR, "ovr_ReportClientInfo"); +OVR_PUBLIC_FUNCTION(const char*) ovr_GetVersionString() { + // We don't directly return the value of the DLL API.ovr_GetVersionString.Ptr call, + // because that call returns a pointer to memory within the DLL. If the DLL goes + // away then that pointer becomes invalid while the process may still be holding + // onto it. So we save a local copy of it which is always valid. + static char dllVersionStringLocal[32]; + const char* dllVersionString; - if (reportClientInfo) - { - unsigned int mscFullVer = 0; -#if defined (_MSC_FULL_VER) - mscFullVer = _MSC_FULL_VER; -#endif // _MSC_FULL_VER + if (!API.ovr_GetVersionString.Ptr) + return "(Unable to load LibOVR)"; - reportClientInfo(mscFullVer, OVR_PRODUCT_VERSION, OVR_MAJOR_VERSION, - OVR_MINOR_VERSION, OVR_PATCH_VERSION, OVR_BUILD_NUMBER); - } + dllVersionString = API.ovr_GetVersionString.Ptr(); // Guaranteed to always be valid. + assert(dllVersionString != NULL); + OVR_strlcpy(dllVersionStringLocal, dllVersionString, sizeof(dllVersionStringLocal)); - return result; + return dllVersionStringLocal; } -OVR_PUBLIC_FUNCTION(void) ovr_Shutdown() -{ - if (!ovr_ShutdownPtr) - return; - ovr_ShutdownPtr(); - OVR_UnloadSharedLibrary(); +OVR_PUBLIC_FUNCTION(void) ovr_GetLastErrorInfo(ovrErrorInfo* errorInfo) { + if (!API.ovr_GetLastErrorInfo.Ptr) { + *errorInfo = LastInitializeErrorInfo; + } else + API.ovr_GetLastErrorInfo.Ptr(errorInfo); } -OVR_PUBLIC_FUNCTION(const char*) ovr_GetVersionString() -{ - // We don't directly return the value of the DLL ovr_GetVersionStringPtr call, - // because that call returns a pointer to memory within the DLL. If the DLL goes - // away then that pointer becomes invalid while the process may still be holding - // onto it. So we save a local copy of it which is always valid. - static char dllVersionStringLocal[32]; - const char* dllVersionString; +OVR_PUBLIC_FUNCTION(ovrHmdDesc) ovr_GetHmdDesc(ovrSession session) { + if (!API.ovr_GetHmdDesc.Ptr) { + ovrHmdDesc hmdDesc; + memset(&hmdDesc, 0, sizeof(hmdDesc)); + hmdDesc.Type = ovrHmd_None; + return hmdDesc; + } + + return API.ovr_GetHmdDesc.Ptr(session); +} - if (!ovr_GetVersionStringPtr) - return "(Unable to load LibOVR)"; - dllVersionString = ovr_GetVersionStringPtr(); // Guaranteed to always be valid. - assert(dllVersionString != NULL); - OVR_strlcpy(dllVersionStringLocal, dllVersionString, sizeof(dllVersionStringLocal)); +OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackerCount(ovrSession session) { + if (!API.ovr_GetTrackerCount.Ptr) { + return 0; + } - return dllVersionStringLocal; + return API.ovr_GetTrackerCount.Ptr(session); } -OVR_PUBLIC_FUNCTION(void) ovr_GetLastErrorInfo(ovrErrorInfo* errorInfo) -{ - if (!ovr_GetLastErrorInfoPtr) - { - memset(errorInfo, 0, sizeof(ovrErrorInfo)); - errorInfo->Result = ovrError_LibLoad; - } - else - ovr_GetLastErrorInfoPtr(errorInfo); +OVR_PUBLIC_FUNCTION(ovrTrackerDesc) +ovr_GetTrackerDesc(ovrSession session, unsigned int trackerDescIndex) { + if (!API.ovr_GetTrackerDesc.Ptr) { + ovrTrackerDesc trackerDesc; + memset(&trackerDesc, 0, sizeof(trackerDesc)); + return trackerDesc; + } + + return API.ovr_GetTrackerDesc.Ptr(session, trackerDescIndex); } -OVR_PUBLIC_FUNCTION(ovrHmdDesc) ovr_GetHmdDesc(ovrSession session) -{ - if (!ovr_GetHmdDescPtr) - { - ovrHmdDesc hmdDesc; - memset(&hmdDesc, 0, sizeof(hmdDesc)); - hmdDesc.Type = ovrHmd_None; - return hmdDesc; - } +OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid) { + if (!API.ovr_Create.Ptr) + return ovrError_NotInitialized; + return API.ovr_Create.Ptr(pSession, pLuid); +} - return ovr_GetHmdDescPtr(session); +OVR_PUBLIC_FUNCTION(void) ovr_Destroy(ovrSession session) { + if (!API.ovr_Destroy.Ptr) + return; + API.ovr_Destroy.Ptr(session); } -OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackerCount(ovrSession session) -{ - if (!ovr_GetTrackerCountPtr) - { - return 0; + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetSessionStatus(ovrSession session, ovrSessionStatus* sessionStatus) { + if (!API.ovr_GetSessionStatus.Ptr) { + if (sessionStatus) { + sessionStatus->IsVisible = ovrFalse; + sessionStatus->HmdPresent = ovrFalse; + sessionStatus->HmdMounted = ovrFalse; + sessionStatus->ShouldQuit = ovrFalse; + sessionStatus->DisplayLost = ovrFalse; + sessionStatus->ShouldRecenter = ovrFalse; + sessionStatus->HasInputFocus = ovrFalse; + sessionStatus->OverlayPresent = ovrFalse; + sessionStatus->DepthRequested = ovrFalse; } - - return ovr_GetTrackerCountPtr(session); + + return ovrError_NotInitialized; + } + + return API.ovr_GetSessionStatus.Ptr(session, sessionStatus); } -OVR_PUBLIC_FUNCTION(ovrTrackerDesc) ovr_GetTrackerDesc(ovrSession session, unsigned int trackerDescIndex) -{ - if (!ovr_GetTrackerDescPtr) - { - ovrTrackerDesc trackerDesc; - memset(&trackerDesc, 0, sizeof(trackerDesc)); - return trackerDesc; - } - - return ovr_GetTrackerDescPtr(session, trackerDescIndex); + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_IsExtensionSupported(ovrSession session, ovrExtensions extension, ovrBool* extensionSupported) { + if (!API.ovr_IsExtensionSupported.Ptr) + return ovrError_NotInitialized; + return API.ovr_IsExtensionSupported.Ptr(session, extension, extensionSupported); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid) -{ - if (!ovr_CreatePtr) - return ovrError_NotInitialized; - return ovr_CreatePtr(pSession, pLuid); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_EnableExtension(ovrSession session, ovrExtensions extension) { + if (!API.ovr_EnableExtension.Ptr) + return ovrError_NotInitialized; + return API.ovr_EnableExtension.Ptr(session, extension); } -OVR_PUBLIC_FUNCTION(void) ovr_Destroy(ovrSession session) -{ - if (!ovr_DestroyPtr) - return; - ovr_DestroyPtr(session); + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetTrackingOriginType(ovrSession session, ovrTrackingOrigin origin) { + if (!API.ovr_SetTrackingOriginType.Ptr) + return ovrError_NotInitialized; + return API.ovr_SetTrackingOriginType.Ptr(session, origin); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessionStatus* sessionStatus) -{ - if (!ovr_GetSessionStatusPtr) - { - if (sessionStatus) - { - sessionStatus->IsVisible = ovrFalse; - sessionStatus->HmdPresent = ovrFalse; - sessionStatus->HmdMounted = ovrFalse; - sessionStatus->ShouldQuit = ovrFalse; - sessionStatus->DisplayLost = ovrFalse; - sessionStatus->ShouldRecenter = ovrFalse; - } +OVR_PUBLIC_FUNCTION(ovrTrackingOrigin) ovr_GetTrackingOriginType(ovrSession session) { + if (!API.ovr_GetTrackingOriginType.Ptr) + return ovrTrackingOrigin_EyeLevel; + return API.ovr_GetTrackingOriginType.Ptr(session); +} - return ovrError_NotInitialized; - } +OVR_PUBLIC_FUNCTION(ovrResult) ovr_RecenterTrackingOrigin(ovrSession session) { + if (!API.ovr_RecenterTrackingOrigin.Ptr) + return ovrError_NotInitialized; + return API.ovr_RecenterTrackingOrigin.Ptr(session); +} - return ovr_GetSessionStatusPtr(session, sessionStatus); +OVR_PUBLIC_FUNCTION(ovrResult) ovr_SpecifyTrackingOrigin(ovrSession session, ovrPosef originPose) { + if (!API.ovr_SpecifyTrackingOrigin.Ptr) + return ovrError_NotInitialized; + return API.ovr_SpecifyTrackingOrigin.Ptr(session, originPose); } +OVR_PUBLIC_FUNCTION(void) ovr_ClearShouldRecenterFlag(ovrSession session) { + if (!API.ovr_ClearShouldRecenterFlag.Ptr) + return; + API.ovr_ClearShouldRecenterFlag.Ptr(session); +} + +OVR_PUBLIC_FUNCTION(ovrTrackingState) +ovr_GetTrackingState(ovrSession session, double absTime, ovrBool latencyMarker) { + if (!API.ovr_GetTrackingState.Ptr) { + ovrTrackingState nullTrackingState; + memset(&nullTrackingState, 0, sizeof(nullTrackingState)); + return nullTrackingState; + } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetTrackingOriginType(ovrSession session, ovrTrackingOrigin origin) -{ - if (!ovr_SetTrackingOriginTypePtr) - return ovrError_NotInitialized; - return ovr_SetTrackingOriginTypePtr(session, origin); + return API.ovr_GetTrackingState.Ptr(session, absTime, latencyMarker); } -OVR_PUBLIC_FUNCTION(ovrTrackingOrigin) ovr_GetTrackingOriginType(ovrSession session) -{ - if (!ovr_GetTrackingOriginTypePtr) - return ovrTrackingOrigin_EyeLevel; - return ovr_GetTrackingOriginTypePtr(session); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetDevicePoses( + ovrSession session, + ovrTrackedDeviceType* deviceTypes, + int deviceCount, + double absTime, + ovrPoseStatef* outDevicePoses) { + if (!API.ovr_GetDevicePoses.Ptr) + return ovrError_NotInitialized; + return API.ovr_GetDevicePoses.Ptr(session, deviceTypes, deviceCount, absTime, outDevicePoses); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_RecenterTrackingOrigin(ovrSession session) -{ - if (!ovr_RecenterTrackingOriginPtr) - return ovrError_NotInitialized; - return ovr_RecenterTrackingOriginPtr(session); + +OVR_PUBLIC_FUNCTION(ovrTrackerPose) +ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex) { + if (!API.ovr_GetTrackerPose.Ptr) { + ovrTrackerPose nullTrackerPose; + memset(&nullTrackerPose, 0, sizeof(nullTrackerPose)); + return nullTrackerPose; + } + + return API.ovr_GetTrackerPose.Ptr(session, trackerPoseIndex); } -OVR_PUBLIC_FUNCTION(void) ovr_ClearShouldRecenterFlag(ovrSession session) -{ - if (!ovr_ClearShouldRecenterFlagPtr) - return; - ovr_ClearShouldRecenterFlagPtr(session); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetInputState(ovrSession session, ovrControllerType controllerType, ovrInputState* inputState) { + if (!API.ovr_GetInputState.Ptr) { + if (inputState) + memset(inputState, 0, sizeof(ovrInputState)); + return ovrError_NotInitialized; + } + return API.ovr_GetInputState.Ptr(session, controllerType, inputState); } -OVR_PUBLIC_FUNCTION(ovrTrackingState) ovr_GetTrackingState(ovrSession session, double absTime, ovrBool latencyMarker) -{ - if (!ovr_GetTrackingStatePtr) - { - ovrTrackingState nullTrackingState; - memset(&nullTrackingState, 0, sizeof(nullTrackingState)); - return nullTrackingState; - } +OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetConnectedControllerTypes(ovrSession session) { + if (!API.ovr_GetConnectedControllerTypes.Ptr) { + return 0; + } + return API.ovr_GetConnectedControllerTypes.Ptr(session); +} + +OVR_PUBLIC_FUNCTION(ovrTouchHapticsDesc) +ovr_GetTouchHapticsDesc(ovrSession session, ovrControllerType controllerType) { + if (!API.ovr_GetTouchHapticsDesc.Ptr) { + ovrTouchHapticsDesc nullDesc; + memset(&nullDesc, 0, sizeof(nullDesc)); + return nullDesc; + } - return ovr_GetTrackingStatePtr(session, absTime, latencyMarker); + return API.ovr_GetTouchHapticsDesc.Ptr(session, controllerType); } +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetControllerVibration( + ovrSession session, + ovrControllerType controllerType, + float frequency, + float amplitude) { + if (!API.ovr_SetControllerVibration.Ptr) + return ovrError_NotInitialized; -OVR_PUBLIC_FUNCTION(ovrTrackerPose) ovr_GetTrackerPose(ovrSession session, unsigned int trackerPoseIndex) -{ - if (!ovr_GetTrackerPosePtr) - { - ovrTrackerPose nullTrackerPose; - memset(&nullTrackerPose, 0, sizeof(nullTrackerPose)); - return nullTrackerPose; - } + return API.ovr_SetControllerVibration.Ptr(session, controllerType, frequency, amplitude); +} - return ovr_GetTrackerPosePtr(session, trackerPoseIndex); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SubmitControllerVibration( + ovrSession session, + ovrControllerType controllerType, + const ovrHapticsBuffer* buffer) { + if (!API.ovr_SubmitControllerVibration.Ptr) + return ovrError_NotInitialized; + + return API.ovr_SubmitControllerVibration.Ptr(session, controllerType, buffer); } +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetControllerVibrationState( + ovrSession session, + ovrControllerType controllerType, + ovrHapticsPlaybackState* outState) { + if (!API.ovr_GetControllerVibrationState.Ptr) + return ovrError_NotInitialized; -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetInputState(ovrSession session, ovrControllerType controllerType, ovrInputState* inputState) -{ - if (!ovr_GetInputStatePtr) - { - if (inputState) - memset(inputState, 0, sizeof(ovrInputState)); - return ovrError_NotInitialized; - } - return ovr_GetInputStatePtr(session, controllerType, inputState); + return API.ovr_GetControllerVibrationState.Ptr(session, controllerType, outState); } -OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetConnectedControllerTypes(ovrSession session) -{ - if (!ovr_GetConnectedControllerTypesPtr) - { - return 0; - } - return ovr_GetConnectedControllerTypesPtr(session); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_TestBoundary( + ovrSession session, + ovrTrackedDeviceType deviceBitmask, + ovrBoundaryType singleBoundaryType, + ovrBoundaryTestResult* outTestResult) { + if (!API.ovr_TestBoundary.Ptr) + return ovrError_NotInitialized; + + return API.ovr_TestBoundary.Ptr(session, deviceBitmask, singleBoundaryType, outTestResult); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetControllerVibration(ovrSession session, ovrControllerType controllerType, float frequency, float amplitude) -{ - if (!ovr_SetControllerVibrationPtr) - { - return ovrError_NotInitialized; - } - return ovr_SetControllerVibrationPtr(session, controllerType, frequency, amplitude); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_TestBoundaryPoint( + ovrSession session, + const ovrVector3f* point, + ovrBoundaryType singleBoundaryType, + ovrBoundaryTestResult* outTestResult) { + if (!API.ovr_TestBoundaryPoint.Ptr) + return ovrError_NotInitialized; + + return API.ovr_TestBoundaryPoint.Ptr(session, point, singleBoundaryType, outTestResult); } -OVR_PUBLIC_FUNCTION(ovrSizei) ovr_GetFovTextureSize(ovrSession session, ovrEyeType eye, ovrFovPort fov, - float pixelsPerDisplayPixel) -{ - if (!ovr_GetFovTextureSizePtr) - { - ovrSizei nullSize; - memset(&nullSize, 0, sizeof(nullSize)); - return nullSize; - } +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetBoundaryLookAndFeel(ovrSession session, const ovrBoundaryLookAndFeel* lookAndFeel) { + if (!API.ovr_SetBoundaryLookAndFeel.Ptr) + return ovrError_NotInitialized; - return ovr_GetFovTextureSizePtr(session, eye, fov, pixelsPerDisplayPixel); + return API.ovr_SetBoundaryLookAndFeel.Ptr(session, lookAndFeel); } -#if defined (_WIN32) -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateTextureSwapChainDX(ovrSession session, - IUnknown* d3dPtr, - const ovrTextureSwapChainDesc* desc, - ovrTextureSwapChain* outTextureSet) -{ - if (!ovr_CreateTextureSwapChainDXPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_ResetBoundaryLookAndFeel(ovrSession session) { + if (!API.ovr_ResetBoundaryLookAndFeel.Ptr) + return ovrError_NotInitialized; - return ovr_CreateTextureSwapChainDXPtr(session, d3dPtr, desc, outTextureSet); + return API.ovr_ResetBoundaryLookAndFeel.Ptr(session); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureDX(ovrSession session, - IUnknown* d3dPtr, - const ovrMirrorTextureDesc* desc, - ovrMirrorTexture* outMirrorTexture) -{ - if (!ovr_CreateMirrorTextureDXPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetBoundaryGeometry( + ovrSession session, + ovrBoundaryType singleBoundaryType, + ovrVector3f* outFloorPoints, + int* outFloorPointsCount) { + if (!API.ovr_GetBoundaryGeometry.Ptr) + return ovrError_NotInitialized; - return ovr_CreateMirrorTextureDXPtr(session, d3dPtr, desc, outMirrorTexture); + return API.ovr_GetBoundaryGeometry.Ptr( + session, singleBoundaryType, outFloorPoints, outFloorPointsCount); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferDX(ovrSession session, - ovrTextureSwapChain chain, - int index, - IID iid, - void** ppObject) -{ - if (!ovr_GetTextureSwapChainBufferDXPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetBoundaryDimensions( + ovrSession session, + ovrBoundaryType singleBoundaryType, + ovrVector3f* outDimensions) { + if (!API.ovr_GetBoundaryDimensions.Ptr) + return ovrError_NotInitialized; - return ovr_GetTextureSwapChainBufferDXPtr(session, chain, index, iid, ppObject); + return API.ovr_GetBoundaryDimensions.Ptr(session, singleBoundaryType, outDimensions); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetMirrorTextureBufferDX(ovrSession session, - ovrMirrorTexture mirror, - IID iid, - void** ppObject) -{ - if (!ovr_GetMirrorTextureBufferDXPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetBoundaryVisible(ovrSession session, ovrBool* outIsVisible) { + if (!API.ovr_GetBoundaryVisible.Ptr) + return ovrError_NotInitialized; - return ovr_GetMirrorTextureBufferDXPtr(session, mirror, iid, ppObject); + return API.ovr_GetBoundaryVisible.Ptr(session, outIsVisible); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutWaveId(unsigned int* deviceOutId) -{ - if (!ovr_GetAudioDeviceOutWaveIdPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_RequestBoundaryVisible(ovrSession session, ovrBool visible) { + if (!API.ovr_RequestBoundaryVisible.Ptr) + return ovrError_NotInitialized; - return ovr_GetAudioDeviceOutWaveIdPtr(deviceOutId); + return API.ovr_RequestBoundaryVisible.Ptr(session, visible); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInWaveId(unsigned int* deviceInId) -{ - if (!ovr_GetAudioDeviceInWaveIdPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrSizei) +ovr_GetFovTextureSize( + ovrSession session, + ovrEyeType eye, + ovrFovPort fov, + float pixelsPerDisplayPixel) { + if (!API.ovr_GetFovTextureSize.Ptr) { + ovrSizei nullSize; + memset(&nullSize, 0, sizeof(nullSize)); + return nullSize; + } - return ovr_GetAudioDeviceInWaveIdPtr(deviceInId); + return API.ovr_GetFovTextureSize.Ptr(session, eye, fov, pixelsPerDisplayPixel); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuidStr(WCHAR* deviceOutStrBuffer) -{ - if (!ovr_GetAudioDeviceOutGuidStrPtr) - return ovrError_NotInitialized; +#if defined(_WIN32) +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* outTextureSet) { + if (!API.ovr_CreateTextureSwapChainDX.Ptr) + return ovrError_NotInitialized; - return ovr_GetAudioDeviceOutGuidStrPtr(deviceOutStrBuffer); + return API.ovr_CreateTextureSwapChainDX.Ptr(session, d3dPtr, desc, outTextureSet); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid) -{ - if (!ovr_GetAudioDeviceOutGuidPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* outMirrorTexture) { + if (!API.ovr_CreateMirrorTextureDX.Ptr) + return ovrError_NotInitialized; - return ovr_GetAudioDeviceOutGuidPtr(deviceOutGuid); + return API.ovr_CreateMirrorTextureDX.Ptr(session, d3dPtr, desc, outMirrorTexture); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuidStr(WCHAR* deviceInStrBuffer) -{ - if (!ovr_GetAudioDeviceInGuidStrPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsDX( + ovrSession session, + IUnknown* d3dPtr, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* outMirrorTexture) { + if (!API.ovr_CreateMirrorTextureWithOptionsDX.Ptr) + return ovrError_NotInitialized; - return ovr_GetAudioDeviceInGuidStrPtr(deviceInStrBuffer); + return API.ovr_CreateMirrorTextureWithOptionsDX.Ptr(session, d3dPtr, desc, outMirrorTexture); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuid(GUID* deviceInGuid) -{ - if (!ovr_GetAudioDeviceInGuidPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferDX( + ovrSession session, + ovrTextureSwapChain chain, + int index, + IID iid, + void** ppObject) { + if (!API.ovr_GetTextureSwapChainBufferDX.Ptr) + return ovrError_NotInitialized; - return ovr_GetAudioDeviceInGuidPtr(deviceInGuid); + return API.ovr_GetTextureSwapChainBufferDX.Ptr(session, chain, index, iid, ppObject); } -#endif +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferDX( + ovrSession session, + ovrMirrorTexture mirror, + IID iid, + void** ppObject) { + if (!API.ovr_GetMirrorTextureBufferDX.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetMirrorTextureBufferDX.Ptr(session, mirror, iid, ppObject); +} -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateTextureSwapChainGL(ovrSession session, - const ovrTextureSwapChainDesc* desc, - ovrTextureSwapChain* outTextureSet) -{ - if (!ovr_CreateTextureSwapChainGLPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutWaveId(unsigned int* deviceOutId) { + if (!API.ovr_GetAudioDeviceOutWaveId.Ptr) + return ovrError_NotInitialized; - return ovr_CreateTextureSwapChainGLPtr(session, desc, outTextureSet); + return API.ovr_GetAudioDeviceOutWaveId.Ptr(deviceOutId); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CreateMirrorTextureGL(ovrSession session, - const ovrMirrorTextureDesc* desc, - ovrMirrorTexture* outMirrorTexture) -{ - if (!ovr_CreateMirrorTextureGLPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInWaveId(unsigned int* deviceInId) { + if (!API.ovr_GetAudioDeviceInWaveId.Ptr) + return ovrError_NotInitialized; - return ovr_CreateMirrorTextureGLPtr(session, desc, outMirrorTexture); + return API.ovr_GetAudioDeviceInWaveId.Ptr(deviceInId); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainBufferGL(ovrSession session, - ovrTextureSwapChain chain, - int index, - unsigned int* texId) -{ - if (!ovr_GetTextureSwapChainBufferGLPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuidStr(WCHAR* deviceOutStrBuffer) { + if (!API.ovr_GetAudioDeviceOutGuidStr.Ptr) + return ovrError_NotInitialized; - return ovr_GetTextureSwapChainBufferGLPtr(session, chain, index, texId); + return API.ovr_GetAudioDeviceOutGuidStr.Ptr(deviceOutStrBuffer); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetMirrorTextureBufferGL(ovrSession session, - ovrMirrorTexture mirror, - unsigned int* texId) -{ - if (!ovr_GetMirrorTextureBufferGLPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceOutGuid(GUID* deviceOutGuid) { + if (!API.ovr_GetAudioDeviceOutGuid.Ptr) + return ovrError_NotInitialized; - return ovr_GetMirrorTextureBufferGLPtr(session, mirror, texId); + return API.ovr_GetAudioDeviceOutGuid.Ptr(deviceOutGuid); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainLength(ovrSession session, - ovrTextureSwapChain chain, - int* length) -{ - if (!ovr_GetTextureSwapChainLengthPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuidStr(WCHAR* deviceInStrBuffer) { + if (!API.ovr_GetAudioDeviceInGuidStr.Ptr) + return ovrError_NotInitialized; - return ovr_GetTextureSwapChainLengthPtr(session, chain, length); + return API.ovr_GetAudioDeviceInGuidStr.Ptr(deviceInStrBuffer); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainCurrentIndex(ovrSession session, - ovrTextureSwapChain chain, - int* currentIndex) -{ - if (!ovr_GetTextureSwapChainCurrentIndexPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetAudioDeviceInGuid(GUID* deviceInGuid) { + if (!API.ovr_GetAudioDeviceInGuid.Ptr) + return ovrError_NotInitialized; - return ovr_GetTextureSwapChainCurrentIndexPtr(session, chain, currentIndex); + return API.ovr_GetAudioDeviceInGuid.Ptr(deviceInGuid); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetTextureSwapChainDesc(ovrSession session, - ovrTextureSwapChain chain, - ovrTextureSwapChainDesc* desc) -{ - if (!ovr_GetTextureSwapChainDescPtr) - return ovrError_NotInitialized; +#endif // _WIN32 - return ovr_GetTextureSwapChainDescPtr(session, chain, desc); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainGL( + ovrSession session, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* outTextureSet) { + if (!API.ovr_CreateTextureSwapChainGL.Ptr) + return ovrError_NotInitialized; + + return API.ovr_CreateTextureSwapChainGL.Ptr(session, desc, outTextureSet); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_CommitTextureSwapChain(ovrSession session, - ovrTextureSwapChain chain) -{ - if (!ovr_CommitTextureSwapChainPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureGL( + ovrSession session, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* outMirrorTexture) { + if (!API.ovr_CreateMirrorTextureGL.Ptr) + return ovrError_NotInitialized; - return ovr_CommitTextureSwapChainPtr(session, chain); + return API.ovr_CreateMirrorTextureGL.Ptr(session, desc, outMirrorTexture); } -OVR_PUBLIC_FUNCTION(void) ovr_DestroyTextureSwapChain(ovrSession session, ovrTextureSwapChain chain) -{ - if (!ovr_DestroyTextureSwapChainPtr) - return; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsGL( + ovrSession session, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* outMirrorTexture) { + if (!API.ovr_CreateMirrorTextureWithOptionsGL.Ptr) + return ovrError_NotInitialized; - ovr_DestroyTextureSwapChainPtr(session, chain); + return API.ovr_CreateMirrorTextureWithOptionsGL.Ptr(session, desc, outMirrorTexture); } -OVR_PUBLIC_FUNCTION(void) ovr_DestroyMirrorTexture(ovrSession session, ovrMirrorTexture mirrorTexture) -{ - if (!ovr_DestroyMirrorTexturePtr) - return; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferGL( + ovrSession session, + ovrTextureSwapChain chain, + int index, + unsigned int* texId) { + if (!API.ovr_GetTextureSwapChainBufferGL.Ptr) + return ovrError_NotInitialized; - ovr_DestroyMirrorTexturePtr(session, mirrorTexture); + return API.ovr_GetTextureSwapChainBufferGL.Ptr(session, chain, index, texId); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetQueueAheadFraction(ovrSession session, float queueAheadFraction) -{ - if (!ovr_SetQueueAheadFractionPtr) - return ovrError_NotInitialized; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferGL(ovrSession session, ovrMirrorTexture mirror, unsigned int* texId) { + if (!API.ovr_GetMirrorTextureBufferGL.Ptr) + return ovrError_NotInitialized; - return ovr_SetQueueAheadFractionPtr(session, queueAheadFraction); + return API.ovr_GetMirrorTextureBufferGL.Ptr(session, mirror, texId); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_SubmitFrame(ovrSession session, long long frameIndex, const ovrViewScaleDesc* viewScaleDesc, ovrLayerHeader const * const * layerPtrList, unsigned int layerCount) -{ - if (!ovr_SubmitFramePtr) - return ovrError_NotInitialized; +#if defined(_WIN32) +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetInstanceExtensionsVk( + ovrGraphicsLuid luid, + char* extensionNames, + uint32_t* inoutExtensionNamesSize) { + if (!API.ovr_GetInstanceExtensionsVk.Ptr) + return ovrError_NotInitialized; - return ovr_SubmitFramePtr(session, frameIndex, viewScaleDesc, layerPtrList, layerCount); + return API.ovr_GetInstanceExtensionsVk.Ptr(luid, extensionNames, inoutExtensionNamesSize); } -OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session, ovrEyeType eyeType, ovrFovPort fov) -{ - if (!ovr_GetRenderDescPtr) - { - ovrEyeRenderDesc nullEyeRenderDesc; - memset(&nullEyeRenderDesc, 0, sizeof(nullEyeRenderDesc)); - return nullEyeRenderDesc; - } - return ovr_GetRenderDescPtr(session, eyeType, fov); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetDeviceExtensionsVk( + ovrGraphicsLuid luid, + char* extensionNames, + uint32_t* inoutExtensionNamesSize) { + if (!API.ovr_GetDeviceExtensionsVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetDeviceExtensionsVk.Ptr(luid, extensionNames, inoutExtensionNamesSize); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetSessionPhysicalDeviceVk( + ovrSession session, + ovrGraphicsLuid luid, + VkInstance instance, + VkPhysicalDevice* out_physicalDevice) { + if (!API.ovr_GetSessionPhysicalDeviceVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetSessionPhysicalDeviceVk.Ptr(session, luid, instance, out_physicalDevice); +} + +OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetSynchronizationQueueVk(ovrSession session, VkQueue queue) { + if (!API.ovr_SetSynchronizationQueueVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_SetSynchronizationQueueVk.Ptr(session, queue); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateTextureSwapChainVk( + ovrSession session, + VkDevice device, + const ovrTextureSwapChainDesc* desc, + ovrTextureSwapChain* out_TextureSwapChain) { + if (!API.ovr_CreateTextureSwapChainVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_CreateTextureSwapChainVk.Ptr(session, device, desc, out_TextureSwapChain); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainBufferVk( + ovrSession session, + ovrTextureSwapChain chain, + int index, + VkImage* out_Image) { + if (!API.ovr_GetTextureSwapChainBufferVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetTextureSwapChainBufferVk.Ptr(session, chain, index, out_Image); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CreateMirrorTextureWithOptionsVk( + ovrSession session, + VkDevice device, + const ovrMirrorTextureDesc* desc, + ovrMirrorTexture* out_MirrorTexture) { + if (!API.ovr_CreateMirrorTextureWithOptionsVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_CreateMirrorTextureWithOptionsVk.Ptr(session, device, desc, out_MirrorTexture); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetMirrorTextureBufferVk( + ovrSession session, + ovrMirrorTexture mirrorTexture, + VkImage* out_Image) { + if (!API.ovr_GetMirrorTextureBufferVk.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetMirrorTextureBufferVk.Ptr(session, mirrorTexture, out_Image); +} +#endif // defined (_WIN32) + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainLength(ovrSession session, ovrTextureSwapChain chain, int* length) { + if (!API.ovr_GetTextureSwapChainLength.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetTextureSwapChainLength.Ptr(session, chain, length); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainCurrentIndex( + ovrSession session, + ovrTextureSwapChain chain, + int* currentIndex) { + if (!API.ovr_GetTextureSwapChainCurrentIndex.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetTextureSwapChainCurrentIndex.Ptr(session, chain, currentIndex); } -OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long long frameIndex) -{ - if (!ovr_GetPredictedDisplayTimePtr) - return 0.0; +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetTextureSwapChainDesc( + ovrSession session, + ovrTextureSwapChain chain, + ovrTextureSwapChainDesc* desc) { + if (!API.ovr_GetTextureSwapChainDesc.Ptr) + return ovrError_NotInitialized; - return ovr_GetPredictedDisplayTimePtr(session, frameIndex); + return API.ovr_GetTextureSwapChainDesc.Ptr(session, chain, desc); } -OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds() -{ - if (!ovr_GetTimeInSecondsPtr) - return 0.; - return ovr_GetTimeInSecondsPtr(); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_CommitTextureSwapChain(ovrSession session, ovrTextureSwapChain chain) { + if (!API.ovr_CommitTextureSwapChain.Ptr) + return ovrError_NotInitialized; + + return API.ovr_CommitTextureSwapChain.Ptr(session, chain); +} + +OVR_PUBLIC_FUNCTION(void) +ovr_DestroyTextureSwapChain(ovrSession session, ovrTextureSwapChain chain) { + if (!API.ovr_DestroyTextureSwapChain.Ptr) + return; + + API.ovr_DestroyTextureSwapChain.Ptr(session, chain); +} + +OVR_PUBLIC_FUNCTION(void) +ovr_DestroyMirrorTexture(ovrSession session, ovrMirrorTexture mirrorTexture) { + if (!API.ovr_DestroyMirrorTexture.Ptr) + return; + + API.ovr_DestroyMirrorTexture.Ptr(session, mirrorTexture); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetFovStencil( + ovrSession session, + const ovrFovStencilDesc* fovStencilDesc, + ovrFovStencilMeshBuffer* meshBuffer) { + if (!API.ovr_GetFovStencil.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetFovStencil.Ptr(session, fovStencilDesc, meshBuffer); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_WaitToBeginFrame(ovrSession session, long long frameIndex) { + if (!API.ovr_WaitToBeginFrame.Ptr) + return ovrError_NotInitialized; + + return API.ovr_WaitToBeginFrame.Ptr(session, frameIndex); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_GetBool(ovrSession session, const char* propertyName, ovrBool defaultVal) -{ - if (!ovr_GetBoolPtr) - return ovrFalse; - return ovr_GetBoolPtr(session, propertyName, defaultVal); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_BeginFrame(ovrSession session, long long frameIndex) { + if (!API.ovr_BeginFrame.Ptr) + return ovrError_NotInitialized; + + return API.ovr_BeginFrame.Ptr(session, frameIndex); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetBool(ovrSession session, const char* propertyName, ovrBool value) -{ - if (!ovr_SetBoolPtr) - return ovrFalse; - return ovr_SetBoolPtr(session, propertyName, value); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_EndFrame( + ovrSession session, + long long frameIndex, + const ovrViewScaleDesc* viewScaleDesc, + ovrLayerHeader const* const* layerPtrList, + unsigned int layerCount) { + if (!API.ovr_EndFrame.Ptr) + return ovrError_NotInitialized; + + return API.ovr_EndFrame.Ptr(session, frameIndex, viewScaleDesc, layerPtrList, layerCount); } -OVR_PUBLIC_FUNCTION(int) ovr_GetInt(ovrSession session, const char* propertyName, int defaultVal) -{ - if (!ovr_GetIntPtr) - return 0; - return ovr_GetIntPtr(session, propertyName, defaultVal); +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SubmitFrame( + ovrSession session, + long long frameIndex, + const ovrViewScaleDesc* viewScaleDesc, + ovrLayerHeader const* const* layerPtrList, + unsigned int layerCount) { + if (!API.ovr_SubmitFrame.Ptr) + return ovrError_NotInitialized; + + return API.ovr_SubmitFrame.Ptr(session, frameIndex, viewScaleDesc, layerPtrList, layerCount); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetInt(ovrSession session, const char* propertyName, int value) -{ - if (!ovr_SetIntPtr) - return ovrFalse; - return ovr_SetIntPtr(session, propertyName, value); + +OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) +ovr_GetRenderDesc(ovrSession session, ovrEyeType eyeType, ovrFovPort fov) { + if (!API.ovr_GetRenderDesc.Ptr) { + ovrEyeRenderDesc nullEyeRenderDesc; + memset(&nullEyeRenderDesc, 0, sizeof(nullEyeRenderDesc)); + return nullEyeRenderDesc; + } + return API.ovr_GetRenderDesc.Ptr(session, eyeType, fov); } -OVR_PUBLIC_FUNCTION(float) ovr_GetFloat(ovrSession session, const char* propertyName, float defaultVal) -{ - if (!ovr_GetFloatPtr) - return 0.f; - return ovr_GetFloatPtr(session, propertyName, defaultVal); +OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetPerfStats(ovrSession session, ovrPerfStats* outPerfStats) { + if (!API.ovr_GetPerfStats.Ptr) + return ovrError_NotInitialized; + + return API.ovr_GetPerfStats.Ptr(session, outPerfStats); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloat(ovrSession session, const char* propertyName, float value) -{ - if (!ovr_SetFloatPtr) - return ovrFalse; - return ovr_SetFloatPtr(session, propertyName, value); +OVR_PUBLIC_FUNCTION(ovrResult) ovr_ResetPerfStats(ovrSession session) { + if (!API.ovr_ResetPerfStats.Ptr) + return ovrError_NotInitialized; + + return API.ovr_ResetPerfStats.Ptr(session); } -OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetFloatArray(ovrSession session, const char* propertyName, - float values[], unsigned int arraySize) -{ - if (!ovr_GetFloatArrayPtr) - return 0; - return ovr_GetFloatArrayPtr(session, propertyName, values, arraySize); +OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long long frameIndex) { + if (!API.ovr_GetPredictedDisplayTime.Ptr) + return 0.0; + + return API.ovr_GetPredictedDisplayTime.Ptr(session, frameIndex); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloatArray(ovrSession session, const char* propertyName, - const float values[], unsigned int arraySize) -{ - if (!ovr_SetFloatArrayPtr) - return ovrFalse; - return ovr_SetFloatArrayPtr(session, propertyName, values, arraySize); +OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds() { + if (!API.ovr_GetTimeInSeconds.Ptr) + return 0.; + return API.ovr_GetTimeInSeconds.Ptr(); } -OVR_PUBLIC_FUNCTION(const char*) ovr_GetString(ovrSession session, const char* propertyName, - const char* defaultVal) -{ - if (!ovr_GetStringPtr) - return "(Unable to load LibOVR)"; - return ovr_GetStringPtr(session, propertyName, defaultVal); +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_GetBool(ovrSession session, const char* propertyName, ovrBool defaultVal) { + if (!API.ovr_GetBool.Ptr) + return ovrFalse; + return API.ovr_GetBool.Ptr(session, propertyName, defaultVal); } -OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetString(ovrSession session, const char* propertyName, - const char* value) -{ - if (!ovr_SetStringPtr) - return ovrFalse; - return ovr_SetStringPtr(session, propertyName, value); +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetBool(ovrSession session, const char* propertyName, ovrBool value) { + if (!API.ovr_SetBool.Ptr) + return ovrFalse; + return API.ovr_SetBool.Ptr(session, propertyName, value); } -OVR_PUBLIC_FUNCTION(int) ovr_TraceMessage(int level, const char* message) -{ - if (!ovr_TraceMessagePtr) - return -1; +OVR_PUBLIC_FUNCTION(int) ovr_GetInt(ovrSession session, const char* propertyName, int defaultVal) { + if (!API.ovr_GetInt.Ptr) + return 0; + return API.ovr_GetInt.Ptr(session, propertyName, defaultVal); +} - return ovr_TraceMessagePtr(level, message); +OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetInt(ovrSession session, const char* propertyName, int value) { + if (!API.ovr_SetInt.Ptr) + return ovrFalse; + return API.ovr_SetInt.Ptr(session, propertyName, value); } -OVR_PUBLIC_FUNCTION(ovrResult) ovr_Lookup(const char* name, void** data) -{ - if (!ovr_LookupPtr) - return ovrError_NotInitialized; - return ovr_LookupPtr(name, data); +OVR_PUBLIC_FUNCTION(float) +ovr_GetFloat(ovrSession session, const char* propertyName, float defaultVal) { + if (!API.ovr_GetFloat.Ptr) + return 0.f; + return API.ovr_GetFloat.Ptr(session, propertyName, defaultVal); } +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetFloat(ovrSession session, const char* propertyName, float value) { + if (!API.ovr_SetFloat.Ptr) + return ovrFalse; + return API.ovr_SetFloat.Ptr(session, propertyName, value); +} + +OVR_PUBLIC_FUNCTION(unsigned int) +ovr_GetFloatArray( + ovrSession session, + const char* propertyName, + float values[], + unsigned int arraySize) { + if (!API.ovr_GetFloatArray.Ptr) + return 0; + return API.ovr_GetFloatArray.Ptr(session, propertyName, values, arraySize); +} + +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetFloatArray( + ovrSession session, + const char* propertyName, + const float values[], + unsigned int arraySize) { + if (!API.ovr_SetFloatArray.Ptr) + return ovrFalse; + return API.ovr_SetFloatArray.Ptr(session, propertyName, values, arraySize); +} + +OVR_PUBLIC_FUNCTION(const char*) +ovr_GetString(ovrSession session, const char* propertyName, const char* defaultVal) { + if (!API.ovr_GetString.Ptr) + return "(Unable to load LibOVR)"; + return API.ovr_GetString.Ptr(session, propertyName, defaultVal); +} + +OVR_PUBLIC_FUNCTION(ovrBool) +ovr_SetString(ovrSession session, const char* propertyName, const char* value) { + if (!API.ovr_SetString.Ptr) + return ovrFalse; + return API.ovr_SetString.Ptr(session, propertyName, value); +} + +OVR_PUBLIC_FUNCTION(int) ovr_TraceMessage(int level, const char* message) { + if (!API.ovr_TraceMessage.Ptr) + return -1; + + return API.ovr_TraceMessage.Ptr(level, message); +} + +OVR_PUBLIC_FUNCTION(ovrResult) ovr_IdentifyClient(const char* identity) { + if (!API.ovr_IdentifyClient.Ptr) + return ovrError_NotInitialized; + + return API.ovr_IdentifyClient.Ptr(identity); +} + +OVR_PUBLIC_FUNCTION(ovrResult) ovr_Lookup(const char* name, void** data) { + if (!API.ovr_Lookup.Ptr) + return ovrError_NotInitialized; + return API.ovr_Lookup.Ptr(name, data); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GetExternalCameras( + ovrSession session, + ovrExternalCamera* outCameras, + unsigned int* outCameraCount) { + if (!API.ovr_GetExternalCameras.Ptr) + return ovrError_NotInitialized; + if (!outCameras || !outCameraCount) + return ovrError_InvalidParameter; + + return API.ovr_GetExternalCameras.Ptr(session, outCameras, outCameraCount); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_SetExternalCameraProperties( + ovrSession session, + const char* name, + const ovrCameraIntrinsics* const intrinsics, + const ovrCameraExtrinsics* const extrinsics) { + if (!API.ovr_SetExternalCameraProperties.Ptr) + return ovrError_NotInitialized; + if (!name || (!intrinsics && !extrinsics)) + return ovrError_InvalidParameter; + + return API.ovr_SetExternalCameraProperties.Ptr(session, name, intrinsics, extrinsics); +} #if defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif - diff --git a/ext/LibOVR/Src/OVR_CAPI_Prototypes.h b/ext/LibOVR/Src/OVR_CAPI_Prototypes.h new file mode 100644 index 0000000..ff18b12 --- /dev/null +++ b/ext/LibOVR/Src/OVR_CAPI_Prototypes.h @@ -0,0 +1,169 @@ +/********************************************************************************/ /** + \file OVR_CAPI_Prototypes.h + \brief Internal CAPI prototype listing macros + \copyright Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. + ************************************************************************************/ + +#ifndef OVR_CAPI_Prototypes_h +#define OVR_CAPI_Prototypes_h + +#include "OVR_CAPI.h" + + +// +// OVR_LIST_*_APIS - apply passed in macros to a list of API entrypoints +// +// The _ macro argument is applied for all current API versions +// The X macro argument is applied for back-compat API versions +// +// The tuple passed to either macro is (ReturnType, FunctionName, OptionalVersion, ParameterList) +// + + +struct ovrViewportStencilDesc_; +typedef struct ovrViewportStencilDesc_ ovrViewportStencilDesc; + +// clang-format off + +#define OVR_LIST_PUBLIC_APIS(_,X) \ +X(ovrBool, ovr_InitializeRenderingShimVersion, , (int requestedMinorVersion)) \ +_(ovrResult, ovr_Initialize, , (const ovrInitParams* params)) \ +_(void, ovr_Shutdown, , (void)) \ +_(const char*, ovr_GetVersionString, , (void)) \ +_(void, ovr_GetLastErrorInfo, , (ovrErrorInfo* errorInfo)) \ +_(ovrHmdDesc, ovr_GetHmdDesc, , (ovrSession session)) \ +_(unsigned int, ovr_GetTrackerCount, , (ovrSession session)) \ +_(ovrTrackerDesc, ovr_GetTrackerDesc, , (ovrSession session, unsigned int trackerDescIndex)) \ +_(ovrResult, ovr_Create, , (ovrSession* pSession, ovrGraphicsLuid* pLuid)) \ +_(void, ovr_Destroy, , (ovrSession session)) \ +_(ovrResult, ovr_GetSessionStatus, , (ovrSession session, ovrSessionStatus* sessionStatus)) \ +_(ovrResult, ovr_IsExtensionSupported, , (ovrSession session, ovrExtensions extension, ovrBool* outExtensionSupported)) \ +_(ovrResult, ovr_EnableExtension, , (ovrSession session, ovrExtensions extension)) \ +_(ovrResult, ovr_SetTrackingOriginType, , (ovrSession session, ovrTrackingOrigin origin)) \ +_(ovrTrackingOrigin, ovr_GetTrackingOriginType, , (ovrSession session)) \ +_(ovrResult, ovr_RecenterTrackingOrigin, , (ovrSession session)) \ +_(ovrResult, ovr_SpecifyTrackingOrigin, , (ovrSession session, ovrPosef originPose)) \ +_(void, ovr_ClearShouldRecenterFlag, , (ovrSession session)) \ +_(ovrTrackingState, ovr_GetTrackingState, , (ovrSession session, double absTime, ovrBool latencyMarker)) \ +_(ovrResult, ovr_GetDevicePoses, , (ovrSession session, ovrTrackedDeviceType* deviceTypes, int deviceCount, double absTime, ovrPoseStatef* outDevicePoses)) \ +_(ovrTrackerPose, ovr_GetTrackerPose, , (ovrSession session, unsigned int index)) \ +_(ovrResult, ovr_GetInputState, , (ovrSession session, ovrControllerType controllerType, ovrInputState*)) \ +_(unsigned int, ovr_GetConnectedControllerTypes, , (ovrSession session)) \ +_(ovrSizei, ovr_GetFovTextureSize, , (ovrSession session, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel)) \ +X(ovrResult, ovr_GetViewportStencil, , (ovrSession session, const ovrViewportStencilDesc* viewportStencilDesc, ovrFovStencilMeshBuffer* meshBuffer)) \ +_(ovrResult, ovr_GetFovStencil, , (ovrSession session, const ovrFovStencilDesc* fovStencilDesc, ovrFovStencilMeshBuffer* meshBuffer)) \ +_(ovrResult, ovr_WaitToBeginFrame, , (ovrSession session, long long frameIndex)) \ +_(ovrResult, ovr_BeginFrame, , (ovrSession session, long long frameIndex)) \ +_(ovrResult, ovr_EndFrame, , (ovrSession session, long long frameIndex, const ovrViewScaleDesc* viewScaleDesc, ovrLayerHeader const * const * layerPtrList, unsigned int layerCount)) \ +X(ovrResult, ovr_SubmitFrame, , (ovrSession session, long long frameIndex, const ovrViewScaleDescPre117* viewScaleDesc, ovrLayerHeader const * const * layerPtrList, unsigned int layerCount)) \ +_(ovrResult, ovr_SubmitFrame, 2, (ovrSession session, long long frameIndex, const ovrViewScaleDesc* viewScaleDesc, ovrLayerHeader const * const * layerPtrList, unsigned int layerCount)) \ +X(ovrEyeRenderDescPre117, ovr_GetRenderDesc, , (ovrSession session, ovrEyeType eyeType, ovrFovPort fov)) \ +_(ovrEyeRenderDesc, ovr_GetRenderDesc, 2, (ovrSession session, ovrEyeType eyeType, ovrFovPort fov)) \ +_(double, ovr_GetPredictedDisplayTime, , (ovrSession session, long long frameIndex)) \ +_(double, ovr_GetTimeInSeconds, , (void)) \ +_(ovrBool, ovr_GetBool, , (ovrSession session, const char* propertyName, ovrBool defaultVal)) \ +_(ovrBool, ovr_SetBool, , (ovrSession session, const char* propertyName, ovrBool value)) \ +_(int, ovr_GetInt, , (ovrSession session, const char* propertyName, int defaultVal)) \ +_(ovrBool, ovr_SetInt, , (ovrSession session, const char* propertyName, int value)) \ +_(float, ovr_GetFloat, , (ovrSession session, const char* propertyName, float defaultVal)) \ +_(ovrBool, ovr_SetFloat, , (ovrSession session, const char* propertyName, float value)) \ +_(unsigned int, ovr_GetFloatArray, , (ovrSession session, const char* propertyName, float values[], unsigned int arraySize)) \ +_(ovrBool, ovr_SetFloatArray, , (ovrSession session, const char* propertyName, const float values[], unsigned int arraySize)) \ +_(const char*, ovr_GetString, , (ovrSession session, const char* propertyName, const char* defaultVal)) \ +_(ovrBool, ovr_SetString, , (ovrSession session, const char* propertyName, const char* value)) \ +_(int, ovr_TraceMessage, , (int level, const char* message)) \ +_(ovrResult, ovr_IdentifyClient, , (const char* identity)) \ +_(ovrResult, ovr_CreateTextureSwapChainGL, , (ovrSession session, const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* outTextureChain)) \ +_(ovrResult, ovr_CreateMirrorTextureGL, , (ovrSession session, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) \ +_(ovrResult, ovr_CreateMirrorTextureWithOptionsGL, , (ovrSession session, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) \ +_(ovrResult, ovr_GetTextureSwapChainBufferGL, , (ovrSession session, ovrTextureSwapChain chain, int index, unsigned int* texId)) \ +_(ovrResult, ovr_GetMirrorTextureBufferGL, , (ovrSession session, ovrMirrorTexture mirror, unsigned int* texId)) \ +_(ovrResult, ovr_GetTextureSwapChainLength, , (ovrSession session, ovrTextureSwapChain chain, int* length)) \ +_(ovrResult, ovr_GetTextureSwapChainCurrentIndex, , (ovrSession session, ovrTextureSwapChain chain, int* currentIndex)) \ +_(ovrResult, ovr_GetTextureSwapChainDesc, , (ovrSession session, ovrTextureSwapChain chain, ovrTextureSwapChainDesc* desc)) \ +_(ovrResult, ovr_CommitTextureSwapChain, , (ovrSession session, ovrTextureSwapChain chain)) \ +_(void, ovr_DestroyTextureSwapChain, , (ovrSession session, ovrTextureSwapChain chain)) \ +_(void, ovr_DestroyMirrorTexture, , (ovrSession session, ovrMirrorTexture texture)) \ +X(ovrResult, ovr_SetQueueAheadFraction, , (ovrSession session, float queueAheadFraction)) \ +_(ovrResult, ovr_Lookup, , (const char* name, void** data)) \ +_(ovrTouchHapticsDesc, ovr_GetTouchHapticsDesc, , (ovrSession session, ovrControllerType controllerType)) \ +_(ovrResult, ovr_SetControllerVibration, , (ovrSession session, ovrControllerType controllerType, float frequency, float amplitude)) \ +_(ovrResult, ovr_SubmitControllerVibration, , (ovrSession session, ovrControllerType controllerType, const ovrHapticsBuffer* buffer)) \ +_(ovrResult, ovr_GetControllerVibrationState, , (ovrSession session, ovrControllerType controllerType, ovrHapticsPlaybackState* outState)) \ +_(ovrResult, ovr_TestBoundary, , (ovrSession session, ovrTrackedDeviceType deviceBitmask, ovrBoundaryType singleBoundaryType, ovrBoundaryTestResult* outTestResult)) \ +_(ovrResult, ovr_TestBoundaryPoint, , (ovrSession session, const ovrVector3f* point, ovrBoundaryType singleBoundaryType, ovrBoundaryTestResult* outTestResult)) \ +_(ovrResult, ovr_SetBoundaryLookAndFeel, , (ovrSession session, const ovrBoundaryLookAndFeel* lookAndFeel)) \ +_(ovrResult, ovr_ResetBoundaryLookAndFeel, , (ovrSession session)) \ +_(ovrResult, ovr_GetBoundaryGeometry, , (ovrSession session, ovrBoundaryType singleBoundaryType, ovrVector3f* outFloorPoints, int* outFloorPointsCount)) \ +_(ovrResult, ovr_GetBoundaryDimensions, , (ovrSession session, ovrBoundaryType singleBoundaryType, ovrVector3f* outDimension)) \ +_(ovrResult, ovr_GetBoundaryVisible, , (ovrSession session, ovrBool* outIsVisible)) \ +_(ovrResult, ovr_RequestBoundaryVisible, , (ovrSession session, ovrBool visible)) \ +_(ovrResult, ovr_GetPerfStats, , (ovrSession session, ovrPerfStats* outPerfStats)) \ +_(ovrResult, ovr_ResetPerfStats, , (ovrSession session))\ +_(ovrResult, ovr_GetExternalCameras, , (ovrSession session, ovrExternalCamera* outCameras, unsigned int* outCameraCount))\ +_(ovrResult, ovr_SetExternalCameraProperties, , (ovrSession session, const char* name, const ovrCameraIntrinsics* const intrinsics, const ovrCameraExtrinsics* const extrinsics )) + +#if defined (_WIN32) +#define OVR_LIST_WIN32_APIS(_,X) \ + _(ovrResult, ovr_CreateTextureSwapChainDX, , (ovrSession session, IUnknown* d3dPtr, const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* outTextureChain)) \ + _(ovrResult, ovr_CreateMirrorTextureDX, , (ovrSession session, IUnknown* d3dPtr, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) \ + _(ovrResult, ovr_CreateMirrorTextureWithOptionsDX, , (ovrSession session, IUnknown* d3dPtr, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* outMirrorTexture)) \ + _(ovrResult, ovr_GetTextureSwapChainBufferDX, , (ovrSession session, ovrTextureSwapChain chain, int index, IID iid, void** ppObject)) \ + _(ovrResult, ovr_GetMirrorTextureBufferDX, , (ovrSession session, ovrMirrorTexture mirror, IID iid, void** ppObject)) \ + _(ovrResult, ovr_GetAudioDeviceOutWaveId, , (UINT* deviceOutId)) \ + _(ovrResult, ovr_GetAudioDeviceInWaveId, , (UINT* deviceInId)) \ + _(ovrResult, ovr_GetAudioDeviceOutGuidStr, , (WCHAR* deviceOutStrBuffer)) \ + _(ovrResult, ovr_GetAudioDeviceOutGuid, , (GUID* deviceOutGuid)) \ + _(ovrResult, ovr_GetAudioDeviceInGuidStr, , (WCHAR* deviceInStrBuffer)) \ + _(ovrResult, ovr_GetAudioDeviceInGuid, , (GUID* deviceInGuid)) \ + _(ovrResult, ovr_GetInstanceExtensionsVk, , (ovrGraphicsLuid luid, char* extensionNames, uint32_t* inoutExtensionNamesSize)) \ + _(ovrResult, ovr_GetDeviceExtensionsVk, , (ovrGraphicsLuid luid, char* extensionNames, uint32_t* inoutExtensionNamesSize)) \ + _(ovrResult, ovr_GetSessionPhysicalDeviceVk, , (ovrSession session, ovrGraphicsLuid luid, VkInstance instance, VkPhysicalDevice* out_physicalDevice)) \ + X(ovrResult, ovr_SetSynchonizationQueueVk, , (ovrSession session, VkQueue queue)) \ + _(ovrResult, ovr_SetSynchronizationQueueVk, , (ovrSession session, VkQueue queue)) \ + _(ovrResult, ovr_CreateTextureSwapChainVk, , (ovrSession session, VkDevice device, const ovrTextureSwapChainDesc* desc, ovrTextureSwapChain* out_TextureSwapChain)) \ + _(ovrResult, ovr_GetTextureSwapChainBufferVk, , (ovrSession session, ovrTextureSwapChain chain, int index, VkImage* out_Image)) \ + _(ovrResult, ovr_CreateMirrorTextureWithOptionsVk, , (ovrSession session, VkDevice device, const ovrMirrorTextureDesc* desc, ovrMirrorTexture* out_MirrorTexture)) \ + _(ovrResult, ovr_GetMirrorTextureBufferVk, , (ovrSession session, ovrMirrorTexture mirrorTexture, VkImage* out_Image)) +#else +#define OVR_LIST_WIN32_APIS(_,X) +#endif + +#define OVR_LIST_INTERNAL_APIS(_,X) + +// We need to forward declare the ovrSensorData type here, as it won't be in a public OVR_CAPI.h header. +struct ovrSensorData_; +typedef struct ovrSensorData_ ovrSensorData; + +// Hybrid Apps API forward declaration which won't be in a public OVR_CAPI.h header for now. +// -------------------------------------------------------------------------- +struct ovrDesktopWindowDesc_; +typedef struct ovrDesktopWindowDesc_ ovrDesktopWindowDesc; + +struct ovrKeyboardDesc_; +typedef struct ovrKeyboardDesc_ ovrKeyboardDesc; + +enum ovrHybridInputFocusType_ ; +typedef enum ovrHybridInputFocusType_ ovrHybridInputFocusType; + +struct ovrHybridInputFocusState_; +typedef struct ovrHybridInputFocusState_ ovrHybridInputFocusState; + +typedef uint32_t ovrDesktopWindowHandle; +// -------------------------------------------------------------------------- + +#define OVR_LIST_PRIVATE_APIS(_,X) + +// clang-format on + +// +// OVR_LIST_APIS - master list of all API entrypoints +// + +#define OVR_LIST_APIS(_, X) \ + OVR_LIST_PUBLIC_APIS(_, X) \ + OVR_LIST_WIN32_APIS(_, X) \ + OVR_LIST_INTERNAL_APIS(_, X) \ + OVR_LIST_PRIVATE_APIS(_, X) + +#endif // OVR_CAPI_Prototypes_h diff --git a/ext/LibOVR/Src/OVR_CAPI_Util.cpp b/ext/LibOVR/Src/OVR_CAPI_Util.cpp index 7369388..8908bd3 100644 --- a/ext/LibOVR/Src/OVR_CAPI_Util.cpp +++ b/ext/LibOVR/Src/OVR_CAPI_Util.cpp @@ -1,18 +1,18 @@ /************************************************************************************ PublicHeader: OVR_CAPI_Util.c -Copyright : Copyright 2014-2016 Oculus VR, LLC All Rights reserved. +Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which +Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which otherwise accompanies this software in either electronic or hard copy form. You may obtain a copy of the License at -http://www.oculusvr.com/licenses/LICENSE-3.3 +http://www.oculusvr.com/licenses/LICENSE-3.3 -Unless required by applicable law or agreed to in writing, the Oculus VR SDK +Unless required by applicable law or agreed to in writing, the Oculus VR SDK distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -20,203 +20,418 @@ limitations under the License. *************************************************************************************/ - #include #include +#include + +#if !defined(_WIN32) +#include +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1800 // MSVC < 2013 +#define round(dbl) \ + (dbl) >= 0.0 ? (int)((dbl) + 0.5) \ + : (((dbl) - (double)(int)(dbl)) <= -0.5 ? (int)(dbl) : (int)((dbl)-0.5)) +#endif + #if defined(_MSC_VER) - #include - #pragma intrinsic(_mm_pause) +#include +#pragma intrinsic(_mm_pause) #endif #if defined(_WIN32) - #include +#include #endif +#if defined(OVR_DLL_BUILD) && defined(OVR_OPENXR_SUPPORT_ENABLED) +// This forces transitive export of the symbols marked for export in OVR_OpenXR_Impl.cpp: +__pragma(comment(linker, "/INCLUDE:" OVR_ON32("_") "exported_openxr_version")) +#endif // defined(OVR_DLL_BUILD) && defined(OVR_OPENXR_SUPPORT_ENABLED) + + template + T ovrMax(T a, T b) { + return a > b ? a : b; +} +template +T ovrMin(T a, T b) { + return a < b ? a : b; +} // Used to generate projection from ovrEyeDesc::Fov -OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_Projection( - ovrFovPort fov, float znear, float zfar, unsigned int projectionModFlags) -{ - bool leftHanded = (projectionModFlags & ovrProjection_LeftHanded) > 0; - bool flipZ = (projectionModFlags & ovrProjection_FarLessThanNear) > 0; - bool farAtInfinity = (projectionModFlags & ovrProjection_FarClipAtInfinity) > 0; - bool isOpenGL = (projectionModFlags & ovrProjection_ClipRangeOpenGL) > 0; - - // TODO: Pass in correct eye to CreateProjection if we want to support canted displays from CAPI - return OVR::CreateProjection(leftHanded , isOpenGL, fov, OVR::StereoEye_Center, znear, zfar, flipZ, farAtInfinity); -} - -OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) ovrTimewarpProjectionDesc_FromProjection( - ovrMatrix4f Projection, unsigned int projectionModFlags) -{ - ovrTimewarpProjectionDesc res; - res.Projection22 = Projection.M[2][2]; - res.Projection23 = Projection.M[2][3]; +OVR_PUBLIC_FUNCTION(ovrMatrix4f) +ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, unsigned int projectionModFlags) { + bool leftHanded = (projectionModFlags & ovrProjection_LeftHanded) > 0; + bool flipZ = (projectionModFlags & ovrProjection_FarLessThanNear) > 0; + bool farAtInfinity = (projectionModFlags & ovrProjection_FarClipAtInfinity) > 0; + bool isOpenGL = (projectionModFlags & ovrProjection_ClipRangeOpenGL) > 0; + + // TODO: Pass in correct eye to CreateProjection if we want to support canted displays from CAPI + return OVR::CreateProjection( + leftHanded, isOpenGL, fov, OVR::StereoEye_Center, znear, zfar, flipZ, farAtInfinity); +} + +OVR_PUBLIC_FUNCTION(ovrTimewarpProjectionDesc) +ovrTimewarpProjectionDesc_FromProjection(ovrMatrix4f Projection, unsigned int projectionModFlags) { + ovrTimewarpProjectionDesc res; + res.Projection22 = Projection.M[2][2]; + res.Projection23 = Projection.M[2][3]; + res.Projection32 = Projection.M[3][2]; + + if ((res.Projection32 != 1.0f) && (res.Projection32 != -1.0f)) { + // This is a very strange projection matrix, and probably won't work. + // If you need it to work, please contact Oculus and let us know your usage scenario. + } + + if ((projectionModFlags & ovrProjection_ClipRangeOpenGL) != 0) { + // Internally we use the D3D range of [0,+w] not the OGL one of [-w,+w], so we need to convert + // one to the other. + // Note that the values in the depth buffer, and the actual linear depth we want is the same for + // both APIs, + // the difference is purely in the values inside the projection matrix. + + // D3D does this: + // depthBuffer = ( ProjD3D.M[2][2] * linearDepth + ProjD3D.M[2][3] ) / ( linearDepth + // * ProjD3D.M[3][2] ); + // OGL does this: + // depthBuffer = 0.5 + 0.5 * ( ProjOGL.M[2][2] * linearDepth + ProjOGL.M[2][3] ) / ( linearDepth + // * ProjOGL.M[3][2] ); + + // Therefore: + // ProjD3D.M[2][2] = 0.5 * ( ProjOGL.M[2][2] + ProjOGL.M[3][2] ); + // ProjD3D.M[2][3] = 0.5 * ProjOGL.M[2][3]; + // ProjD3D.M[3][2] = ProjOGL.M[3][2]; + + res.Projection22 = 0.5f * (Projection.M[2][2] + Projection.M[3][2]); + res.Projection23 = 0.5f * Projection.M[2][3]; res.Projection32 = Projection.M[3][2]; + } + return res; +} - if ((res.Projection32 != 1.0f) && (res.Projection32 != -1.0f)) - { - // This is a very strange projection matrix, and probably won't work. - // If you need it to work, please contact Oculus and let us know your usage scenario. - } +OVR_PUBLIC_FUNCTION(ovrMatrix4f) +ovrMatrix4f_OrthoSubProjection( + ovrMatrix4f projection, + ovrVector2f orthoScale, + float orthoDistance, + float hmdToEyeOffsetX) { + ovrMatrix4f ortho; + // Negative sign is correct! + // If the eye is offset to the left, then the ortho view needs to be offset to the right relative + // to the camera. + float orthoHorizontalOffset = -hmdToEyeOffsetX / orthoDistance; + + // Current projection maps real-world vector (x,y,1) to the RT. + // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to + // the physical [-orthoHalfFov,orthoHalfFov] + // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means + // we don't have to feed in Z=1 all the time. + // The horizontal offset math is a little hinky because the destination is + // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] + // So we need to first map [-FovPixels/2,FovPixels/2] to + // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: + // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; + // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; + // But then we need the same mapping as the existing projection matrix, i.e. + // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + + // Projection.M[0][2]; = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + + // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; + // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels + // and offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. + + ortho.M[0][0] = projection.M[0][0] * orthoScale.x; + ortho.M[0][1] = 0.0f; + ortho.M[0][2] = 0.0f; + ortho.M[0][3] = -projection.M[0][2] + (orthoHorizontalOffset * projection.M[0][0]); + + ortho.M[1][0] = 0.0f; + ortho.M[1][1] = + -projection.M[1][1] * orthoScale.y; /* Note sign flip (text rendering uses Y=down). */ + ortho.M[1][2] = 0.0f; + ortho.M[1][3] = -projection.M[1][2]; + + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = 0.0f; + + /* No perspective correction for ortho. */ + ortho.M[3][0] = 0.0f; + ortho.M[3][1] = 0.0f; + ortho.M[3][2] = 0.0f; + ortho.M[3][3] = 1.0f; + + return ortho; +} - if ( ( projectionModFlags & ovrProjection_ClipRangeOpenGL ) != 0 ) - { - // Internally we use the D3D range of [0,+w] not the OGL one of [-w,+w], so we need to convert one to the other. - // Note that the values in the depth buffer, and the actual linear depth we want is the same for both APIs, - // the difference is purely in the values inside the projection matrix. - - // D3D does this: - // depthBuffer = ( ProjD3D.M[2][2] * linearDepth + ProjD3D.M[2][3] ) / ( linearDepth * ProjD3D.M[3][2] ); - // OGL does this: - // depthBuffer = 0.5 + 0.5 * ( ProjOGL.M[2][2] * linearDepth + ProjOGL.M[2][3] ) / ( linearDepth * ProjOGL.M[3][2] ); - - // Therefore: - // ProjD3D.M[2][2] = 0.5 * ( ProjOGL.M[2][2] + ProjOGL.M[3][2] ); - // ProjD3D.M[2][3] = 0.5 * ProjOGL.M[2][3]; - // ProjD3D.M[3][2] = ProjOGL.M[3][2]; - - res.Projection22 = 0.5f * ( Projection.M[2][2] + Projection.M[3][2] ); - res.Projection23 = 0.5f * Projection.M[2][3]; - res.Projection32 = Projection.M[3][2]; - } - return res; -} - -OVR_PUBLIC_FUNCTION(ovrMatrix4f) ovrMatrix4f_OrthoSubProjection( - ovrMatrix4f projection, ovrVector2f orthoScale, - float orthoDistance, float hmdToEyeOffsetX) -{ - ovrMatrix4f ortho; - // Negative sign is correct! - // If the eye is offset to the left, then the ortho view needs to be offset to the right relative to the camera. - float orthoHorizontalOffset = -hmdToEyeOffsetX / orthoDistance; - - /* - // Current projection maps real-world vector (x,y,1) to the RT. - // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to - // the physical [-orthoHalfFov,orthoHalfFov] - // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means - // we don't have to feed in Z=1 all the time. - // The horizontal offset math is a little hinky because the destination is - // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] - // So we need to first map [-FovPixels/2,FovPixels/2] to - // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: - // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; - // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; - // But then we need the same mapping as the existing projection matrix, i.e. - // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; - // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + Projection.M[0][2]; - // = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + - // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; - // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels and - // offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. - */ - - ortho.M[0][0] = projection.M[0][0] * orthoScale.x; - ortho.M[0][1] = 0.0f; - ortho.M[0][2] = 0.0f; - ortho.M[0][3] = -projection.M[0][2] + ( orthoHorizontalOffset * projection.M[0][0] ); - - ortho.M[1][0] = 0.0f; - ortho.M[1][1] = -projection.M[1][1] * orthoScale.y; /* Note sign flip (text rendering uses Y=down). */ - ortho.M[1][2] = 0.0f; - ortho.M[1][3] = -projection.M[1][2]; - - ortho.M[2][0] = 0.0f; - ortho.M[2][1] = 0.0f; - ortho.M[2][2] = 0.0f; - ortho.M[2][3] = 0.0f; - - /* No perspective correction for ortho. */ - ortho.M[3][0] = 0.0f; - ortho.M[3][1] = 0.0f; - ortho.M[3][2] = 0.0f; - ortho.M[3][3] = 1.0f; - - return ortho; -} - - -OVR_PUBLIC_FUNCTION(void) ovr_CalcEyePoses(ovrPosef headPose, - const ovrVector3f hmdToEyeOffset[2], - ovrPosef outEyePoses[2]) -{ - if (!hmdToEyeOffset || !outEyePoses) - { - return; - } +#undef ovr_CalcEyePoses +OVR_PUBLIC_FUNCTION(void) +ovr_CalcEyePoses(ovrPosef headPose, const ovrVector3f hmdToEyeOffset[2], ovrPosef outEyePoses[2]) { + if (!hmdToEyeOffset || !outEyePoses) { + return; + } + + using OVR::Posef; + using OVR::Vector3f; + + // Currently hmdToEyeOffset is only a 3D vector + outEyePoses[0] = + Posef(headPose.Orientation, ((Posef)headPose).Apply((Vector3f)hmdToEyeOffset[0])); + outEyePoses[1] = + Posef(headPose.Orientation, ((Posef)headPose).Apply((Vector3f)hmdToEyeOffset[1])); +} + +OVR_PRIVATE_FUNCTION(void) +ovr_CalcEyePoses2(ovrPosef headPose, const ovrPosef hmdToEyePose[2], ovrPosef outEyePoses[2]) { + if (!hmdToEyePose || !outEyePoses) { + return; + } - using OVR::Posef; - using OVR::Vector3f; + using OVR::Posef; + using OVR::Vector3f; - // Currently hmdToEyeOffset is only a 3D vector - outEyePoses[0] = Posef(headPose.Orientation, ((Posef)headPose).Apply((Vector3f)hmdToEyeOffset[0])); - outEyePoses[1] = Posef(headPose.Orientation, ((Posef)headPose).Apply((Vector3f)hmdToEyeOffset[1])); + outEyePoses[0] = (Posef)headPose * (Posef)hmdToEyePose[0]; + outEyePoses[1] = (Posef)headPose * (Posef)hmdToEyePose[1]; } +#undef ovr_GetEyePoses +OVR_PUBLIC_FUNCTION(void) +ovr_GetEyePoses( + ovrSession session, + long long frameIndex, + ovrBool latencyMarker, + const ovrVector3f hmdToEyeOffset[2], + ovrPosef outEyePoses[2], + double* outSensorSampleTime) { + double frameTime = ovr_GetPredictedDisplayTime(session, frameIndex); + ovrTrackingState trackingState = ovr_GetTrackingState(session, frameTime, latencyMarker); + ovr_CalcEyePoses(trackingState.HeadPose.ThePose, hmdToEyeOffset, outEyePoses); + + if (outSensorSampleTime != nullptr) { + *outSensorSampleTime = ovr_GetTimeInSeconds(); + } +} -OVR_PUBLIC_FUNCTION(void) ovr_GetEyePoses(ovrSession session, long long frameIndex, ovrBool latencyMarker, - const ovrVector3f hmdToEyeOffset[2], +OVR_PRIVATE_FUNCTION(void) +ovr_GetEyePoses2( + ovrSession session, + long long frameIndex, + ovrBool latencyMarker, + const ovrPosef hmdToEyePose[2], ovrPosef outEyePoses[2], - double* outSensorSampleTime) -{ - double frameTime = ovr_GetPredictedDisplayTime(session, frameIndex); - ovrTrackingState trackingState = ovr_GetTrackingState(session, frameTime, latencyMarker); - ovr_CalcEyePoses(trackingState.HeadPose.ThePose, hmdToEyeOffset, outEyePoses); - - if (outSensorSampleTime != nullptr) - { - *outSensorSampleTime = ovr_GetTimeInSeconds(); - } + double* outSensorSampleTime) { + double frameTime = ovr_GetPredictedDisplayTime(session, frameIndex); + ovrTrackingState trackingState = ovr_GetTrackingState(session, frameTime, latencyMarker); + ovr_CalcEyePoses2(trackingState.HeadPose.ThePose, hmdToEyePose, outEyePoses); + + if (outSensorSampleTime != nullptr) { + *outSensorSampleTime = ovr_GetTimeInSeconds(); + } } -OVR_PUBLIC_FUNCTION(ovrDetectResult) ovr_Detect(int timeoutMilliseconds) -{ - // Initially we assume everything is not running. - ovrDetectResult result; - result.IsOculusHMDConnected = ovrFalse; - result.IsOculusServiceRunning = ovrFalse; +OVR_PUBLIC_FUNCTION(ovrDetectResult) ovr_Detect(int timeoutMilliseconds) { + // Initially we assume everything is not running. + ovrDetectResult result; + result.IsOculusHMDConnected = ovrFalse; + result.IsOculusServiceRunning = ovrFalse; #if defined(_WIN32) - // Attempt to open the named event. - HANDLE hServiceEvent = ::OpenEventW(SYNCHRONIZE, FALSE, OVR_HMD_CONNECTED_EVENT_NAME); - - // If event exists, - if (hServiceEvent != nullptr) - { - // This indicates that the Oculus Runtime is installed and running. - result.IsOculusServiceRunning = ovrTrue; - - // Poll for event state. - DWORD objectResult = ::WaitForSingleObject(hServiceEvent, timeoutMilliseconds); - - // If the event is signaled, - if (objectResult == WAIT_OBJECT_0) - { - // This indicates that the Oculus HMD is connected. - result.IsOculusHMDConnected = ovrTrue; - } - - ::CloseHandle(hServiceEvent); + // Attempt to open the named event. + HANDLE hServiceEvent = ::OpenEventW(SYNCHRONIZE, FALSE, OVR_HMD_CONNECTED_EVENT_NAME); + + // If event exists, + if (hServiceEvent != nullptr) { + // This indicates that the Oculus Runtime is installed and running. + result.IsOculusServiceRunning = ovrTrue; + + // Poll for event state. + DWORD objectResult = ::WaitForSingleObject(hServiceEvent, timeoutMilliseconds); + + // If the event is signaled, + if (objectResult == WAIT_OBJECT_0) { + // This indicates that the Oculus HMD is connected. + result.IsOculusHMDConnected = ovrTrue; } -#endif // _WIN32 + ::CloseHandle(hServiceEvent); + } +#else + (void)timeoutMilliseconds; + fprintf(stderr, __FILE__ "::[%s] Not implemented. Assuming single-process.\n", __func__); + result.IsOculusServiceRunning = ovrTrue; + result.IsOculusHMDConnected = ovrTrue; +#endif // OSX_UNIMPLEMENTED + + + return result; +} + +OVR_PUBLIC_FUNCTION(void) ovrPosef_FlipHandedness(const ovrPosef* inPose, ovrPosef* outPose) { + outPose->Orientation.x = -inPose->Orientation.x; + outPose->Orientation.y = inPose->Orientation.y; + outPose->Orientation.z = inPose->Orientation.z; + outPose->Orientation.w = -inPose->Orientation.w; - return result; + outPose->Position.x = -inPose->Position.x; + outPose->Position.y = inPose->Position.y; + outPose->Position.z = inPose->Position.z; } -OVR_PUBLIC_FUNCTION(void) ovrPosef_FlipHandedness(const ovrPosef* inPose, ovrPosef* outPose) -{ - outPose->Orientation.x = -inPose->Orientation.x; - outPose->Orientation.y = inPose->Orientation.y; - outPose->Orientation.z = inPose->Orientation.z; - outPose->Orientation.w = -inPose->Orientation.w; +static float wavPcmBytesToFloat(const void* data, int32_t sizeInBits, bool swapBytes) { + // TODO Support big endian + (void)swapBytes; + + // There's not a strong standard to convert 8/16/32b PCM to float. + // For 16b: MSDN says range is [-32760, 32760], Pyton Scipy uses [-32767, 32767] and Audacity + // outputs the full range [-32768, 32767]. + // We use the same range on both sides and clamp to [-1, 1]. + + float result = 0.0f; + if (sizeInBits == 8) + // uint8_t is a special case, unsigned where 128 is zero + result = (*((uint8_t*)data) / (float)UCHAR_MAX) * 2.0f - 1.0f; + else if (sizeInBits == 16) + result = *((int16_t*)data) / (float)SHRT_MAX; + // else if (sizeInBits == 24) { + // int value = data[0] | data[1] << 8 | data[2] << 16; // Need consider 2's complement + // return value / 8388607.0f; + //} + else if (sizeInBits == 32) + result = *((int32_t*)data) / (float)INT_MAX; + + return ovrMax(-1.0f, result); +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_GenHapticsFromAudioData( + ovrHapticsClip* outHapticsClip, + const ovrAudioChannelData* audioChannel, + ovrHapticsGenMode genMode) { + if (!outHapticsClip || !audioChannel || genMode != ovrHapticsGenMode_PointSample) + return ovrError_InvalidParameter; + // Validate audio channel + if (audioChannel->Frequency <= 0 || audioChannel->SamplesCount <= 0 || + audioChannel->Samples == nullptr) + return ovrError_InvalidParameter; + + const int32_t kHapticsFrequency = 320; + const int32_t kHapticsMaxAmplitude = 255; + float samplesPerStep = audioChannel->Frequency / (float)kHapticsFrequency; + int32_t hapticsSampleCount = (int32_t)ceil(audioChannel->SamplesCount / samplesPerStep); + + uint8_t* hapticsSamples = new uint8_t[hapticsSampleCount]; + for (int32_t i = 0; i < hapticsSampleCount; ++i) { + float sample = audioChannel->Samples[(int32_t)(i * samplesPerStep)]; + uint8_t hapticSample = + (uint8_t)ovrMin(UCHAR_MAX, (int)round(fabs(sample) * kHapticsMaxAmplitude)); + hapticsSamples[i] = hapticSample; + } + + outHapticsClip->Samples = hapticsSamples; + outHapticsClip->SamplesCount = hapticsSampleCount; + + return ovrSuccess; +} + +OVR_PUBLIC_FUNCTION(ovrResult) +ovr_ReadWavFromBuffer( + ovrAudioChannelData* outAudioChannel, + const void* inputData, + int dataSizeInBytes, + int stereoChannelToUse) { + // We don't support any format other than PCM and IEEE Float + enum WavFormats { + kWavFormatUnknown = 0x0000, + kWavFormatLPCM = 0x0001, + kWavFormatFloatIEEE = 0x0003, + kWavFormatExtensible = 0xFFFE + }; + + struct WavHeader { + char RiffId[4]; // "RIFF" = little-endian, "RIFX" = big-endian + int32_t Size; // 4 + (8 + FmtChunkSize) + (8 + DataChunkSize) + char WavId[4]; // Must be "WAVE" + + char FmtChunckId[4]; // Must be "fmt " + uint32_t FmtChunkSize; // Remaining size of this chunk (16B) + uint16_t Format; // WavFormats: PCM or Float supported + uint16_t Channels; // 1 = Mono, 2 = Stereo + uint32_t SampleRate; // e.g. 44100 + uint32_t BytesPerSec; // SampleRate * BytesPerBlock + uint16_t BytesPerBlock; // (NumChannels * BitsPerSample/8) + uint16_t BitsPerSample; // 8, 16, 32 + + char DataChunckId[4]; // Must be "data" + uint32_t DataChunkSize; // Remaining size of this chunk + }; + + const int32_t kMinWavFileSize = sizeof(WavHeader) + 1; + if (!outAudioChannel || !inputData || dataSizeInBytes < kMinWavFileSize) + return ovrError_InvalidParameter; + + WavHeader* header = (WavHeader*)inputData; + uint8_t* data = (uint8_t*)inputData + sizeof(WavHeader); + + // Validate + const char* wavId = header->RiffId; + // TODO We need to support RIFX when supporting big endian formats + // bool isValidWav = (wavId[0] == 'R' && wavId[1] == 'I' && wavId[2] == 'F' && (wavId[3] == 'F' || + // wavId[3] == 'X')) && + bool isValidWav = (wavId[0] == 'R' && wavId[1] == 'I' && wavId[2] == 'F' && wavId[3] == 'F') && + memcmp(header->WavId, "WAVE", 4) == 0; + bool hasValidChunks = + memcmp(header->FmtChunckId, "fmt ", 4) == 0 && memcmp(header->DataChunckId, "data ", 4) == 0; + if (!isValidWav || !hasValidChunks) { + return ovrError_InvalidOperation; + } + + // We only support PCM + bool isSupported = (header->Format == kWavFormatLPCM || header->Format == kWavFormatFloatIEEE) && + (header->Channels == 1 || header->Channels == 2) && + (header->BitsPerSample == 8 || header->BitsPerSample == 16 || header->BitsPerSample == 32); + if (!isSupported) { + return ovrError_Unsupported; + } + + // Channel selection + bool useSecondChannel = (header->Channels == 2 && stereoChannelToUse == 1); + int32_t channelOffset = (useSecondChannel) ? header->BytesPerBlock / 2 : 0; + + // TODO Support big-endian + int32_t blockCount = header->DataChunkSize / header->BytesPerBlock; + float* samples = new float[blockCount]; + + for (int32_t i = 0; i < blockCount; i++) { + int32_t dataIndex = i * header->BytesPerBlock; + uint8_t* dataPtr = &data[dataIndex + channelOffset]; + float sample = (header->Format == kWavFormatLPCM) + ? wavPcmBytesToFloat(dataPtr, header->BitsPerSample, false) + : *(float*)dataPtr; + + samples[i] = sample; + } + + // Output + outAudioChannel->Samples = samples; + outAudioChannel->SamplesCount = blockCount; + outAudioChannel->Frequency = header->SampleRate; + + return ovrSuccess; +} + +OVR_PUBLIC_FUNCTION(void) ovr_ReleaseAudioChannelData(ovrAudioChannelData* audioChannel) { + if (audioChannel != nullptr && audioChannel->Samples != nullptr) { + delete[] audioChannel->Samples; + memset(audioChannel, 0, sizeof(ovrAudioChannelData)); + } +} - outPose->Position.x = -inPose->Position.x; - outPose->Position.y = inPose->Position.y; - outPose->Position.z = inPose->Position.z; +OVR_PUBLIC_FUNCTION(void) ovr_ReleaseHapticsClip(ovrHapticsClip* hapticsClip) { + if (hapticsClip != nullptr && hapticsClip->Samples != nullptr) { + delete[](uint8_t*) hapticsClip->Samples; + memset(hapticsClip, 0, sizeof(ovrHapticsClip)); + } } diff --git a/ext/LibOVR/Src/OVR_StereoProjection.cpp b/ext/LibOVR/Src/OVR_StereoProjection.cpp index ce8e499..ff3a0f6 100644 --- a/ext/LibOVR/Src/OVR_StereoProjection.cpp +++ b/ext/LibOVR/Src/OVR_StereoProjection.cpp @@ -5,18 +5,18 @@ Content : Stereo rendering functions Created : November 30, 2013 Authors : Tom Fosyth -Copyright : Copyright 2014-2016 Oculus VR, LLC All Rights reserved. +Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. -Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); -you may not use the Oculus VR Rift SDK except in compliance with the License, -which is provided at the time of installation or download, or which +Licensed under the Oculus VR Rift SDK License Version 3.3 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which otherwise accompanies this software in either electronic or hard copy form. You may obtain a copy of the License at -http://www.oculusvr.com/licenses/LICENSE-3.3 +http://www.oculusvr.com/licenses/LICENSE-3.3 -Unless required by applicable law or agreed to in writing, the Oculus VR SDK +Unless required by applicable law or agreed to in writing, the Oculus VR SDK distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -26,202 +26,193 @@ limitations under the License. #include - namespace OVR { +ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov(FovPort tanHalfFov) { + float projXScale = 2.0f / (tanHalfFov.LeftTan + tanHalfFov.RightTan); + float projXOffset = (tanHalfFov.LeftTan - tanHalfFov.RightTan) * projXScale * 0.5f; + float projYScale = 2.0f / (tanHalfFov.UpTan + tanHalfFov.DownTan); + float projYOffset = (tanHalfFov.UpTan - tanHalfFov.DownTan) * projYScale * 0.5f; -ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort tanHalfFov ) -{ - float projXScale = 2.0f / ( tanHalfFov.LeftTan + tanHalfFov.RightTan ); - float projXOffset = ( tanHalfFov.LeftTan - tanHalfFov.RightTan ) * projXScale * 0.5f; - float projYScale = 2.0f / ( tanHalfFov.UpTan + tanHalfFov.DownTan ); - float projYOffset = ( tanHalfFov.UpTan - tanHalfFov.DownTan ) * projYScale * 0.5f; - - ScaleAndOffset2D result; - result.Scale = Vector2f(projXScale, projYScale); - result.Offset = Vector2f(projXOffset, projYOffset); - // Hey - why is that Y.Offset negated? - // It's because a projection matrix transforms from world coords with Y=up, - // whereas this is from NDC which is Y=down. + ScaleAndOffset2D result; + result.Scale = Vector2f(projXScale, projYScale); + result.Offset = Vector2f(projXOffset, projYOffset); + // Hey - why is that Y.Offset negated? + // It's because a projection matrix transforms from world coords with Y=up, + // whereas this is from NDC which is Y=down. - return result; + return result; } - - -Matrix4f CreateProjection( bool leftHanded, bool isOpenGL, FovPort tanHalfFov, StereoEye /*eye*/, - float zNear /*= 0.01f*/, float zFar /*= 10000.0f*/, - bool flipZ /*= false*/, bool farAtInfinity /*= false*/) -{ - if(!flipZ && farAtInfinity) - { - //OVR_ASSERT_M(false, "Cannot push Far Clip to Infinity when Z-order is not flipped"); Assertion disabled because this code no longer has access to LibOVRKernel assertion functionality. - farAtInfinity = false; +Matrix4f CreateProjection( + bool leftHanded, + bool isOpenGL, + FovPort tanHalfFov, + StereoEye /*eye*/, + float zNear /*= 0.01f*/, + float zFar /*= 10000.0f*/, + bool flipZ /*= false*/, + bool farAtInfinity /*= false*/) { + if (!flipZ && farAtInfinity) { + // OVR_ASSERT_M(false, "Cannot push Far Clip to Infinity when Z-order is not flipped"); + // Assertion disabled because this code no longer has access to LibOVRKernel assertion + // functionality. + farAtInfinity = false; + } + + // A projection matrix is very like a scaling from NDC, so we can start with that. + ScaleAndOffset2D scaleAndOffset = CreateNDCScaleAndOffsetFromFov(tanHalfFov); + + float handednessScale = leftHanded ? 1.0f : -1.0f; + + Matrix4f projection; + // Produces X result, mapping clip edges to [-w,+w] + projection.M[0][0] = scaleAndOffset.Scale.x; + projection.M[0][1] = 0.0f; + projection.M[0][2] = handednessScale * scaleAndOffset.Offset.x; + projection.M[0][3] = 0.0f; + + // Produces Y result, mapping clip edges to [-w,+w] + // Hey - why is that YOffset negated? + // It's because a projection matrix transforms from world coords with Y=up, + // whereas this is derived from an NDC scaling, which is Y=down. + projection.M[1][0] = 0.0f; + projection.M[1][1] = scaleAndOffset.Scale.y; + projection.M[1][2] = handednessScale * -scaleAndOffset.Offset.y; + projection.M[1][3] = 0.0f; + + // Produces Z-buffer result - app needs to fill this in with whatever Z range it wants. + // We'll just use some defaults for now. + projection.M[2][0] = 0.0f; + projection.M[2][1] = 0.0f; + + if (farAtInfinity) { + if (isOpenGL) { + // It's not clear this makes sense for OpenGL - you don't get the same precision benefits you + // do in D3D. + projection.M[2][2] = -handednessScale; + projection.M[2][3] = 2.0f * zNear; + } else { + projection.M[2][2] = 0.0f; + projection.M[2][3] = zNear; } - - // A projection matrix is very like a scaling from NDC, so we can start with that. - ScaleAndOffset2D scaleAndOffset = CreateNDCScaleAndOffsetFromFov ( tanHalfFov ); - - float handednessScale = leftHanded ? 1.0f : -1.0f; - - Matrix4f projection; - // Produces X result, mapping clip edges to [-w,+w] - projection.M[0][0] = scaleAndOffset.Scale.x; - projection.M[0][1] = 0.0f; - projection.M[0][2] = handednessScale * scaleAndOffset.Offset.x; - projection.M[0][3] = 0.0f; - - // Produces Y result, mapping clip edges to [-w,+w] - // Hey - why is that YOffset negated? - // It's because a projection matrix transforms from world coords with Y=up, - // whereas this is derived from an NDC scaling, which is Y=down. - projection.M[1][0] = 0.0f; - projection.M[1][1] = scaleAndOffset.Scale.y; - projection.M[1][2] = handednessScale * -scaleAndOffset.Offset.y; - projection.M[1][3] = 0.0f; - - // Produces Z-buffer result - app needs to fill this in with whatever Z range it wants. - // We'll just use some defaults for now. - projection.M[2][0] = 0.0f; - projection.M[2][1] = 0.0f; - - if (farAtInfinity) - { - if (isOpenGL) - { - // It's not clear this makes sense for OpenGL - you don't get the same precision benefits you do in D3D. - projection.M[2][2] = -handednessScale; - projection.M[2][3] = 2.0f * zNear; - } - else - { - projection.M[2][2] = 0.0f; - projection.M[2][3] = zNear; - } - } - else - { - if (isOpenGL) - { - // Clip range is [-w,+w], so 0 is at the middle of the range. - projection.M[2][2] = -handednessScale * (flipZ ? -1.0f : 1.0f) * (zNear + zFar) / (zNear - zFar); - projection.M[2][3] = 2.0f * ((flipZ ? -zFar : zFar) * zNear) / (zNear - zFar); - } - else - { - // Clip range is [0,+w], so 0 is at the start of the range. - projection.M[2][2] = -handednessScale * (flipZ ? -zNear : zFar) / (zNear - zFar); - projection.M[2][3] = ((flipZ ? -zFar : zFar) * zNear) / (zNear - zFar); - } + } else { + if (isOpenGL) { + // Clip range is [-w,+w], so 0 is at the middle of the range. + projection.M[2][2] = + -handednessScale * (flipZ ? -1.0f : 1.0f) * (zNear + zFar) / (zNear - zFar); + projection.M[2][3] = 2.0f * ((flipZ ? -zFar : zFar) * zNear) / (zNear - zFar); + } else { + // Clip range is [0,+w], so 0 is at the start of the range. + projection.M[2][2] = -handednessScale * (flipZ ? -zNear : zFar) / (zNear - zFar); + projection.M[2][3] = ((flipZ ? -zFar : zFar) * zNear) / (zNear - zFar); } + } - // Produces W result (= Z in) - projection.M[3][0] = 0.0f; - projection.M[3][1] = 0.0f; - projection.M[3][2] = handednessScale; - projection.M[3][3] = 0.0f; + // Produces W result (= Z in) + projection.M[3][0] = 0.0f; + projection.M[3][1] = 0.0f; + projection.M[3][2] = handednessScale; + projection.M[3][3] = 0.0f; - return projection; + return projection; } - -Matrix4f CreateOrthoSubProjection ( bool /*rightHanded*/, StereoEye eyeType, - float tanHalfFovX, float tanHalfFovY, - float unitsX, float unitsY, - float distanceFromCamera, float interpupillaryDistance, - Matrix4f const &projection, - float zNear /*= 0.0f*/, float zFar /*= 0.0f*/, - bool flipZ /*= false*/, bool farAtInfinity /*= false*/) -{ - if(!flipZ && farAtInfinity) - { - //OVR_ASSERT_M(false, "Cannot push Far Clip to Infinity when Z-order is not flipped"); Assertion disabled because this code no longer has access to LibOVRKernel assertion functionality. - farAtInfinity = false; - } - - float orthoHorizontalOffset = interpupillaryDistance * 0.5f / distanceFromCamera; - switch ( eyeType ) - { +Matrix4f CreateOrthoSubProjection( + bool /*rightHanded*/, + StereoEye eyeType, + float tanHalfFovX, + float tanHalfFovY, + float unitsX, + float unitsY, + float distanceFromCamera, + float interpupillaryDistance, + Matrix4f const& projection, + float zNear /*= 0.0f*/, + float zFar /*= 0.0f*/, + bool flipZ /*= false*/, + bool farAtInfinity /*= false*/) { + if (!flipZ && farAtInfinity) { + // OVR_ASSERT_M(false, "Cannot push Far Clip to Infinity when Z-order is not flipped"); + // Assertion disabled because this code no longer has access to LibOVRKernel assertion + // functionality. + farAtInfinity = false; + } + + float orthoHorizontalOffset = interpupillaryDistance * 0.5f / distanceFromCamera; + switch (eyeType) { case StereoEye_Left: - break; + break; case StereoEye_Right: - orthoHorizontalOffset = -orthoHorizontalOffset; - break; + orthoHorizontalOffset = -orthoHorizontalOffset; + break; case StereoEye_Center: - orthoHorizontalOffset = 0.0f; - break; - default: - break; - } - - // Current projection maps real-world vector (x,y,1) to the RT. - // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to - // the physical [-orthoHalfFov,orthoHalfFov] - // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means - // we don't have to feed in Z=1 all the time. - // The horizontal offset math is a little hinky because the destination is - // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] - // So we need to first map [-FovPixels/2,FovPixels/2] to - // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: - // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; - // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; - // But then we need the sam mapping as the existing projection matrix, i.e. - // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; - // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + Projection.M[0][2]; - // = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + - // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; - // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels and - // offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. - - float orthoScaleX = 2.0f * tanHalfFovX / unitsX; - float orthoScaleY = 2.0f * tanHalfFovY / unitsY; - Matrix4f ortho; - ortho.M[0][0] = projection.M[0][0] * orthoScaleX; - ortho.M[0][1] = 0.0f; - ortho.M[0][2] = 0.0f; - ortho.M[0][3] = -projection.M[0][2] + ( orthoHorizontalOffset * projection.M[0][0] ); - - ortho.M[1][0] = 0.0f; - ortho.M[1][1] = -projection.M[1][1] * orthoScaleY; // Note sign flip (text rendering uses Y=down). - ortho.M[1][2] = 0.0f; - ortho.M[1][3] = -projection.M[1][2]; - - const float zDiff = zNear - zFar; - if (fabsf(zDiff) < 0.001f) - { - ortho.M[2][0] = 0.0f; - ortho.M[2][1] = 0.0f; - ortho.M[2][2] = 0.0f; - ortho.M[2][3] = flipZ ? zNear : zFar; - } - else - { - ortho.M[2][0] = 0.0f; - ortho.M[2][1] = 0.0f; - - if(farAtInfinity) - { - ortho.M[2][2] = 0.0f; - ortho.M[2][3] = zNear; - } - else if (zDiff != 0.0f) - { - ortho.M[2][2] = (flipZ ? zNear : zFar) / zDiff; - ortho.M[2][3] = ((flipZ ? -zFar : zFar) * zNear) / zDiff; - } + orthoHorizontalOffset = 0.0f; + break; + default: + break; + } + + // Current projection maps real-world vector (x,y,1) to the RT. + // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to + // the physical [-orthoHalfFov,orthoHalfFov] + // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means + // we don't have to feed in Z=1 all the time. + // The horizontal offset math is a little hinky because the destination is + // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] + // So we need to first map [-FovPixels/2,FovPixels/2] to + // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: + // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; + // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; + // But then we need the sam mapping as the existing projection matrix, i.e. + // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + + // Projection.M[0][2]; + // = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + + // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; + // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels + // and + // offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. + + float orthoScaleX = 2.0f * tanHalfFovX / unitsX; + float orthoScaleY = 2.0f * tanHalfFovY / unitsY; + Matrix4f ortho; + ortho.M[0][0] = projection.M[0][0] * orthoScaleX; + ortho.M[0][1] = 0.0f; + ortho.M[0][2] = 0.0f; + ortho.M[0][3] = -projection.M[0][2] + (orthoHorizontalOffset * projection.M[0][0]); + + ortho.M[1][0] = 0.0f; + ortho.M[1][1] = -projection.M[1][1] * orthoScaleY; // Note sign flip (text rendering uses Y=down). + ortho.M[1][2] = 0.0f; + ortho.M[1][3] = -projection.M[1][2]; + + const float zDiff = zNear - zFar; + if (fabsf(zDiff) < 0.001f) { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = flipZ ? zNear : zFar; + } else { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + + if (farAtInfinity) { + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = zNear; + } else if (zDiff != 0.0f) { + ortho.M[2][2] = (flipZ ? zNear : zFar) / zDiff; + ortho.M[2][3] = ((flipZ ? -zFar : zFar) * zNear) / zDiff; } + } - // No perspective correction for ortho. - ortho.M[3][0] = 0.0f; - ortho.M[3][1] = 0.0f; - ortho.M[3][2] = 0.0f; - ortho.M[3][3] = 1.0f; + // No perspective correction for ortho. + ortho.M[3][0] = 0.0f; + ortho.M[3][1] = 0.0f; + ortho.M[3][2] = 0.0f; + ortho.M[3][3] = 1.0f; - return ortho; + return ortho; } - - -} //namespace OVR - - +} // namespace OVR diff --git a/ext/LibOVR/Src/Resources/Windows/LibOVR.rc b/ext/LibOVR/Src/Resources/Windows/LibOVR.rc index 578fe2d..4ebba8d 100644 Binary files a/ext/LibOVR/Src/Resources/Windows/LibOVR.rc and b/ext/LibOVR/Src/Resources/Windows/LibOVR.rc differ diff --git a/ext/OpenVR/bin/msw/x64/openvr_api.dll b/ext/OpenVR/bin/msw/x64/openvr_api.dll index dbf1531..6b0c8fe 100644 Binary files a/ext/OpenVR/bin/msw/x64/openvr_api.dll and b/ext/OpenVR/bin/msw/x64/openvr_api.dll differ diff --git a/ext/OpenVR/bin/msw/x64/openvr_api.dll.sig b/ext/OpenVR/bin/msw/x64/openvr_api.dll.sig new file mode 100644 index 0000000..58c40fb Binary files /dev/null and b/ext/OpenVR/bin/msw/x64/openvr_api.dll.sig differ diff --git a/ext/OpenVR/bin/msw/x64/openvr_api.pdb b/ext/OpenVR/bin/msw/x64/openvr_api.pdb index 8a2095e..d82ded0 100644 Binary files a/ext/OpenVR/bin/msw/x64/openvr_api.pdb and b/ext/OpenVR/bin/msw/x64/openvr_api.pdb differ diff --git a/ext/OpenVR/bin/msw/x86/openvr_api.dll b/ext/OpenVR/bin/msw/x86/openvr_api.dll index f845d44..5d33527 100644 Binary files a/ext/OpenVR/bin/msw/x86/openvr_api.dll and b/ext/OpenVR/bin/msw/x86/openvr_api.dll differ diff --git a/ext/OpenVR/bin/msw/x86/openvr_api.dll.sig b/ext/OpenVR/bin/msw/x86/openvr_api.dll.sig new file mode 100644 index 0000000..8668ce4 Binary files /dev/null and b/ext/OpenVR/bin/msw/x86/openvr_api.dll.sig differ diff --git a/ext/OpenVR/bin/msw/x86/openvr_api.pdb b/ext/OpenVR/bin/msw/x86/openvr_api.pdb index a2c9adc..6014a38 100644 Binary files a/ext/OpenVR/bin/msw/x86/openvr_api.pdb and b/ext/OpenVR/bin/msw/x86/openvr_api.pdb differ diff --git a/ext/OpenVR/headers/openvr.h b/ext/OpenVR/headers/openvr.h index deb3142..e3f7c16 100644 --- a/ext/OpenVR/headers/openvr.h +++ b/ext/OpenVR/headers/openvr.h @@ -11,23 +11,35 @@ +// version.h +namespace vr +{ + static const uint32_t k_nSteamVRVersionMajor = 1; + static const uint32_t k_nSteamVRVersionMinor = 12; + static const uint32_t k_nSteamVRVersionBuild = 5; +} // namespace vr + // vrtypes.h #ifndef _INCLUDE_VRTYPES_H -#define _INCLUDE_VRTYPES_H +#define _INCLUDE_VRTYPES_H + +// Forward declarations to avoid requiring vulkan.h +struct VkDevice_T; +struct VkPhysicalDevice_T; +struct VkInstance_T; +struct VkQueue_T; + +// Forward declarations to avoid requiring d3d12.h +struct ID3D12Resource; +struct ID3D12CommandQueue; namespace vr { +#pragma pack( push, 8 ) -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +/** A handle for a spatial anchor. This handle is only valid during the session it was created in. +* Anchors that live beyond one session should be saved by their string descriptors. */ +typedef uint32_t SpatialAnchorHandle_t; typedef void* glSharedTextureHandle_t; typedef int32_t glInt_t; @@ -36,13 +48,18 @@ typedef uint32_t glUInt_t; // right-handed system // +y is up // +x is to the right -// -z is going away from you +// -z is forward // Distance unit is meters struct HmdMatrix34_t { float m[3][4]; }; +struct HmdMatrix33_t +{ + float m[3][3]; +}; + struct HmdMatrix44_t { float m[4][4]; @@ -73,6 +90,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; @@ -105,10 +127,19 @@ enum EVREye Eye_Right = 1 }; -enum EGraphicsAPIConvention +enum ETextureType { - API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane - API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane + TextureType_Invalid = -1, // Handle has been invalidated + TextureType_DirectX = 0, // Handle is an ID3D11Texture + TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags + TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure + TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef, deprecated in favor of TextureType_Metal on supported platforms + TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure + TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets. + // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it + TextureType_Metal = 6, // Handle is a MTLTexture conforming to the MTLSharedTexture protocol. Textures submitted to IVRCompositor::Submit which + // are of type MTLTextureType2DArray assume layer 0 is the left eye texture (vr::EVREye::Eye_left), layer 1 is the right + // eye texture (vr::EVREye::Eye_Right) }; enum EColorSpace @@ -120,11 +151,15 @@ enum EColorSpace struct Texture_t { - void* handle; // Native d3d texture pointer or GL texture id. - EGraphicsAPIConvention eType; + void* handle; // See ETextureType definition above + ETextureType eType; EColorSpace eColorSpace; }; +// Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource). +typedef uint64_t SharedTextureHandle_t; +#define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0) + enum ETrackingResult { TrackingResult_Uninitialized = 1, @@ -134,15 +169,19 @@ enum ETrackingResult TrackingResult_Running_OK = 200, TrackingResult_Running_OutOfRange = 201, + + TrackingResult_Fallback_RotationOnly = 300, }; -static const uint32_t k_unTrackingStringSize = 32; +typedef uint32_t DriverId_t; +static const uint32_t k_nDriverNone = 0xFFFFFFFF; + static const uint32_t k_unMaxDriverDebugResponseSize = 32768; /** Used to pass device IDs to API calls */ typedef uint32_t TrackedDeviceIndex_t; static const uint32_t k_unTrackedDeviceIndex_Hmd = 0; -static const uint32_t k_unMaxTrackedDeviceCount = 16; +static const uint32_t k_unMaxTrackedDeviceCount = 64; static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE; static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF; @@ -152,9 +191,11 @@ enum ETrackedDeviceClass TrackedDeviceClass_Invalid = 0, // the ID was not valid. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays TrackedDeviceClass_Controller = 2, // Tracked controllers + TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points + TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices - TrackedDeviceClass_Other = 1000, + TrackedDeviceClass_Max }; @@ -164,9 +205,28 @@ enum ETrackedControllerRole TrackedControllerRole_Invalid = 0, // Invalid value for controller type TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand + TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection + TrackedControllerRole_Treadmill = 4, // Tracked device is a treadmill or other locomotion device + TrackedControllerRole_Stylus = 5, // Tracked device is a stylus + TrackedControllerRole_Max = 5 }; +/** Returns true if the tracked controller role is allowed to be a hand */ +inline bool IsRoleAllowedAsHand( ETrackedControllerRole eRole ) +{ + switch ( eRole ) + { + case TrackedControllerRole_Invalid: + case TrackedControllerRole_LeftHand: + case TrackedControllerRole_RightHand: + return true; + default: + return false; + } +} + + /** describes a single pose for a tracked object */ struct TrackedDevicePose_t { @@ -187,14 +247,68 @@ enum ETrackingUniverseOrigin { TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user - TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. You probably don't want this one. + TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one. +}; + +enum EAdditionalRadioFeatures +{ + AdditionalRadioFeatures_None = 0x00000000, + AdditionalRadioFeatures_HTCLinkBox = 0x00000001, + AdditionalRadioFeatures_InternalDongle = 0x00000002, + AdditionalRadioFeatures_ExternalDongle = 0x00000004, }; +typedef uint64_t WebConsoleHandle_t; +#define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0) + +// Refers to a single container of properties +typedef uint64_t PropertyContainerHandle_t; +typedef uint32_t PropertyTypeTag_t; + +static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0; +static const PropertyTypeTag_t k_unInvalidPropertyTag = 0; + +typedef PropertyContainerHandle_t DriverHandle_t; +static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0; + +// Use these tags to set/get common types as struct properties +static const PropertyTypeTag_t k_unFloatPropertyTag = 1; +static const PropertyTypeTag_t k_unInt32PropertyTag = 2; +static const PropertyTypeTag_t k_unUint64PropertyTag = 3; +static const PropertyTypeTag_t k_unBoolPropertyTag = 4; +static const PropertyTypeTag_t k_unStringPropertyTag = 5; +static const PropertyTypeTag_t k_unErrorPropertyTag = 6; +static const PropertyTypeTag_t k_unDoublePropertyTag = 7; + +static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20; +static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21; +static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22; +static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23; +static const PropertyTypeTag_t k_unHmdVector2PropertyTag = 24; +static const PropertyTypeTag_t k_unHmdQuadPropertyTag = 25; + +static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30; +static const PropertyTypeTag_t k_unPathHandleInfoTag = 31; +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_unSpatialAnchorPosePropertyTag = 40; +static const PropertyTypeTag_t k_unJsonPropertyTag = 41; +static const PropertyTypeTag_t k_unActiveActionSetPropertyTag = 42; + +static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; +static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; + /** Each entry in this enum represents a property that can be retrieved about a * tracked device. Many fields are only valid for one ETrackedDeviceClass. */ enum ETrackedDeviceProperty { + Prop_Invalid = 0, + // general properties that apply to all device classes Prop_TrackingSystemName_String = 1000, Prop_ModelNumber_String = 1001, @@ -229,6 +343,25 @@ enum ETrackedDeviceProperty Prop_HasCamera_Bool = 1030, Prop_DriverVersion_String = 1031, Prop_Firmware_ForceUpdateRequired_Bool = 1032, + Prop_ViveSystemButtonFixRequired_Bool = 1033, + Prop_ParentDriver_Uint64 = 1034, + Prop_ResourceRoot_String = 1035, + Prop_RegisteredDeviceType_String = 1036, + Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided + Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design + Prop_NumCameras_Int32 = 1039, + Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value + Prop_CameraStreamFormat_Int32 = 1041, // ECameraVideoStreamFormat value + Prop_AdditionalDeviceSettingsPath_String = 1042, // driver-relative path to additional device and global configuration settings + Prop_Identifiable_Bool = 1043, // Whether device supports being identified from vrmonitor (e.g. blink LED, vibrate haptics, etc) + Prop_BootloaderVersion_Uint64 = 1044, + Prop_AdditionalSystemReportData_String = 1045, // additional string to include in system reports about a tracked device + Prop_CompositeFirmwareVersion_String = 1046, // additional FW components from a device that gets propagated into reports + Prop_Firmware_RemindUpdate_Bool = 1047, + Prop_PeripheralApplicationVersion_Uint64 = 1048, + Prop_ManufacturerSerialNumber_String = 1049, + Prop_ComputedSerialNumber_String = 1050, + Prop_EstimatedDeviceFirstUseTime_Int32 = 1051, // Properties that are unique to TrackedDeviceClass_HMD Prop_ReportsTimeSinceVSync_Bool = 2000, @@ -268,6 +401,75 @@ enum ETrackedDeviceProperty Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, Prop_DisplaySuppressed_Bool = 2036, + Prop_DisplayAllowNightMode_Bool = 2037, + Prop_DisplayMCImageWidth_Int32 = 2038, + Prop_DisplayMCImageHeight_Int32 = 2039, + Prop_DisplayMCImageNumChannels_Int32 = 2040, + Prop_DisplayMCImageData_Binary = 2041, + Prop_SecondsFromPhotonsToVblank_Float = 2042, + Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, + Prop_DisplayDebugMode_Bool = 2044, + Prop_GraphicsAdapterLuid_Uint64 = 2045, + Prop_DriverProvidedChaperonePath_String = 2048, + Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for + Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for + Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded + Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded + Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded + Prop_DoNotApplyPrediction_Bool = 2054, // currently no effect. was used to disable HMD pose prediction on MR, which is now done by MR driver setting velocity=0 + Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion + Prop_DriverIsDrawingControllers_Bool = 2057, + Prop_DriverRequestsApplicationPause_Bool = 2058, + Prop_DriverRequestsReducedRendering_Bool = 2059, + 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, + // reserved 2068 + Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069, + Prop_AdditionalRadioFeatures_Uint64 = 2070, + Prop_CameraWhiteBalance_Vector4_Array = 2071, // Prop_NumCameras_Int32-sized array of float[4] RGBG white balance calibration data (max size is vr::k_unMaxCameras) + Prop_CameraDistortionFunction_Int32_Array = 2072, // Prop_NumCameras_Int32-sized array of vr::EVRDistortionFunctionType values (max size is vr::k_unMaxCameras) + Prop_CameraDistortionCoefficients_Float_Array = 2073, // Prop_NumCameras_Int32-sized array of double[vr::k_unMaxDistortionFunctionParameters] (max size is vr::k_unMaxCameras) + Prop_ExpectedControllerType_String = 2074, + Prop_HmdTrackingStyle_Int32 = 2075, // one of EHmdTrackingStyle + Prop_DriverProvidedChaperoneVisibility_Bool = 2076, + Prop_HmdColumnCorrectionSettingPrefix_String = 2077, + Prop_CameraSupportsCompatibilityModes_Bool = 2078, + + Prop_DisplayAvailableFrameRates_Float_Array = 2080, // populated by compositor from actual EDID list when available from GPU driver + Prop_DisplaySupportsMultipleFramerates_Bool = 2081, // if this is true but Prop_DisplayAvailableFrameRates_Float_Array is empty, explain to user + Prop_DisplayColorMultLeft_Vector3 = 2082, + Prop_DisplayColorMultRight_Vector3 = 2083, + Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084, + Prop_DisplaySupportsAnalogGain_Bool = 2085, + Prop_DisplayMinAnalogGain_Float = 2086, + Prop_DisplayMaxAnalogGain_Float = 2087, + + // Prop_DashboardLayoutPathName_String = 2090, // DELETED + Prop_DashboardScale_Float = 2091, + Prop_IpdUIRangeMinMeters_Float = 2100, + Prop_IpdUIRangeMaxMeters_Float = 2101, + + // Driver requested mura correction properties + Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, + + Prop_Audio_DefaultPlaybackDeviceId_String = 2300, + Prop_Audio_DefaultRecordingDeviceId_String = 2301, + Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302, // Properties that are unique to TrackedDeviceClass_Controller Prop_AttachedDeviceId_String = 3000, @@ -287,10 +489,47 @@ enum ETrackedDeviceProperty Prop_TrackingRangeMinimumMeters_Float = 4004, Prop_TrackingRangeMaximumMeters_Float = 4005, Prop_ModeLabel_String = 4006, + Prop_CanWirelessIdentify_Bool = 4007, // volatile, based on radio presence and fw discovery + Prop_Nonce_Int32 = 4008, + + // Properties that are used for user interface like icons names + Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties. + Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceStandbyAlert_String = 5009, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + + // Properties that are used by helpers, but are opaque to applications + Prop_DisplayHiddenArea_Binary_Start = 5100, + Prop_DisplayHiddenArea_Binary_End = 5150, + Prop_ParentContainer = 5151, + Prop_OverrideContainer_Uint64 = 5152, + + // Properties that are unique to drivers + Prop_UserConfigPath_String = 6000, + Prop_InstallPath_String = 6001, + Prop_HasDisplayComponent_Bool = 6002, + Prop_HasControllerComponent_Bool = 6003, + Prop_HasCameraComponent_Bool = 6004, + Prop_HasDriverDirectModeComponent_Bool = 6005, + Prop_HasVirtualDisplayComponent_Bool = 6006, + Prop_HasSpatialAnchorsSupport_Bool = 6007, + + // Properties that are set internally based on other information provided by drivers + Prop_ControllerType_String = 7000, + //Prop_LegacyInputProfile_String = 7001, // This is no longer used. See "legacy_binding" in the input profile instead. + Prop_ControllerHandSelectionPriority_Int32 = 7002, // Allows hand assignments to prefer some controllers over others. High numbers are selected over low numbers // Vendors are free to expose private debug data in this reserved region Prop_VendorSpecific_Reserved_Start = 10000, Prop_VendorSpecific_Reserved_End = 10999, + + Prop_TrackedDeviceProperty_Max = 1000000, }; /** No string property will ever be longer than this length */ @@ -303,14 +542,39 @@ enum ETrackedPropertyError TrackedProp_WrongDataType = 1, TrackedProp_WrongDeviceClass = 2, TrackedProp_BufferTooSmall = 3, - TrackedProp_UnknownProperty = 4, + TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever). TrackedProp_InvalidDevice = 5, TrackedProp_CouldNotContactServer = 6, TrackedProp_ValueNotProvidedByDevice = 7, TrackedProp_StringExceedsMaximumLength = 8, TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later. + TrackedProp_PermissionDenied = 10, + TrackedProp_InvalidOperation = 11, + TrackedProp_CannotWriteToWildcards = 12, + TrackedProp_IPCReadFailure = 13, + TrackedProp_OutOfMemory = 14, + TrackedProp_InvalidContainer = 15, +}; + +/** Used to drive certain text in the UI when talking about the tracking system for the HMD */ +enum EHmdTrackingStyle +{ + HmdTrackingStyle_Unknown = 0, + + HmdTrackingStyle_Lighthouse = 1, // base stations and lasers + HmdTrackingStyle_OutsideInCameras = 2, // Cameras and LED, Rift 1 style + HmdTrackingStyle_InsideOutCameras = 3, // Cameras on HMD looking at the world }; +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; + + /** Allows the application to control what part of the provided texture will be used in the * frame buffer. */ struct VRTextureBounds_t @@ -319,6 +583,28 @@ struct VRTextureBounds_t float uMax, vMax; }; +/** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */ +struct VRTextureWithPose_t : public Texture_t +{ + HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures. +}; + +struct VRTextureDepthInfo_t +{ + void* handle; // See ETextureType definition above + HmdMatrix44_t mProjection; + HmdVector2_t vRange; // 0..1 +}; + +struct VRTextureWithDepth_t : public Texture_t +{ + VRTextureDepthInfo_t depth; +}; + +struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t +{ + VRTextureDepthInfo_t depth; +}; /** Allows the application to control how scene textures are used by the compositor when calling Submit. */ enum EVRSubmitFlags @@ -333,8 +619,57 @@ enum EVRSubmitFlags // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag. Submit_GlRenderBuffer = 0x02, + + // Do not use + Submit_Reserved = 0x04, + + // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t. + // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t. + Submit_TextureWithPose = 0x08, + + // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t. + // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t. + Submit_TextureWithDepth = 0x10, + + // Set to indicate a discontinuity between this and the last frame. + // This will prevent motion smoothing from attempting to extrapolate using the pair. + Submit_FrameDiscontinuty = 0x20, + + // Set to indicate that pTexture->handle is a contains VRVulkanTextureArrayData_t + Submit_VulkanTextureWithArrayData = 0x40, +}; + +/** Data required for passing Vulkan textures to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. +* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */ +struct VRVulkanTextureData_t +{ + uint64_t m_nImage; // VkImage + VkDevice_T *m_pDevice; + VkPhysicalDevice_T *m_pPhysicalDevice; + VkInstance_T *m_pInstance; + VkQueue_T *m_pQueue; + uint32_t m_nQueueFamilyIndex; + uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount; +}; + +/** Data required for passing Vulkan texture arrays to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. +* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */ +struct VRVulkanTextureArrayData_t : public VRVulkanTextureData_t +{ + uint32_t m_unArrayIndex; + uint32_t m_unArraySize; }; +/** Data required for passing D3D12 textures to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. */ +struct D3D12TextureData_t +{ + ID3D12Resource *m_pResource; + ID3D12CommandQueue *m_pCommandQueue; + uint32_t m_nNodeMask; +}; /** Status of the overall system or tracked objects */ enum EVRState @@ -358,136 +693,231 @@ enum EVREventType VREvent_TrackedDeviceActivated = 100, VREvent_TrackedDeviceDeactivated = 101, VREvent_TrackedDeviceUpdated = 102, - VREvent_TrackedDeviceUserInteractionStarted = 103, + VREvent_TrackedDeviceUserInteractionStarted = 103, VREvent_TrackedDeviceUserInteractionEnded = 104, VREvent_IpdChanged = 105, VREvent_EnterStandbyMode = 106, VREvent_LeaveStandbyMode = 107, VREvent_TrackedDeviceRoleChanged = 108, VREvent_WatchdogWakeUpRequested = 109, + VREvent_LensDistortionChanged = 110, + VREvent_PropertyChanged = 111, + VREvent_WirelessDisconnect = 112, + VREvent_WirelessReconnect = 113, VREvent_ButtonPress = 200, // data is controller VREvent_ButtonUnpress = 201, // data is controller VREvent_ButtonTouch = 202, // data is controller VREvent_ButtonUntouch = 203, // data is controller + // VREvent_DualAnalog_Press = 250, // No longer sent + // VREvent_DualAnalog_Unpress = 251, // No longer sent + // VREvent_DualAnalog_Touch = 252, // No longer sent + // VREvent_DualAnalog_Untouch = 253, // No longer sent + // VREvent_DualAnalog_Move = 254, // No longer sent + // VREvent_DualAnalog_ModeSwitch1 = 255, // No longer sent + // VREvent_DualAnalog_ModeSwitch2 = 256, // No longer sent + VREvent_Modal_Cancel = 257, // Sent to overlays with the + VREvent_MouseMove = 300, // data is mouse VREvent_MouseButtonDown = 301, // data is mouse VREvent_MouseButtonUp = 302, // data is mouse VREvent_FocusEnter = 303, // data is overlay VREvent_FocusLeave = 304, // data is overlay - VREvent_Scroll = 305, // data is mouse + VREvent_ScrollDiscrete = 305, // data is scroll VREvent_TouchPadMove = 306, // data is mouse VREvent_OverlayFocusChanged = 307, // data is overlay, global event + VREvent_ReloadOverlays = 308, + VREvent_ScrollSmooth = 309, // data is scroll + VREvent_LockMousePosition = 310, + VREvent_UnlockMousePosition = 311, VREvent_InputFocusCaptured = 400, // data is process DEPRECATED VREvent_InputFocusReleased = 401, // data is process DEPRECATED - VREvent_SceneFocusLost = 402, // data is process - VREvent_SceneFocusGained = 403, // data is process + // VREvent_SceneFocusLost = 402, // data is process + // VREvent_SceneFocusGained = 403, // data is process VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor) VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene VREvent_InputFocusChanged = 406, // data is process - VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process + // VREvent_SceneApplicationSecondaryRenderingStarted = 407, + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process + VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility + VREvent_SceneApplicationStateChanged = 412, // No data; but query VRApplications()->GetSceneApplicationState(); + + VREvent_ConsoleOpened = 420, + VREvent_ConsoleClosed = 421, + VREvent_OverlayShown = 500, VREvent_OverlayHidden = 501, - VREvent_DashboardActivated = 502, - VREvent_DashboardDeactivated = 503, - VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay - VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay - VREvent_ResetDashboard = 506, // Send to the overlay manager - VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID - VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading - VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it - VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it - VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it - VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else + VREvent_DashboardActivated = 502, + VREvent_DashboardDeactivated = 503, + //VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay - No longer sent + VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay + VREvent_ResetDashboard = 506, // Send to the overlay manager + //VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID -- no longer sent + VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading + VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it + VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it + VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it + VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else VREvent_OverlaySharedTextureChanged = 513, - VREvent_DashboardGuideButtonDown = 514, - VREvent_DashboardGuideButtonUp = 515, - VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot - VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load + //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent + //VREvent_DashboardGuideButtonUp = 515, + VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot + VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load + VREvent_DashboardOverlayCreated = 518, + VREvent_SwitchGamepadFocus = 519, // Screenshot API - VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot - VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken - VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken - VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted - VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted + VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot + VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken + VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken + VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted + VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted + + VREvent_PrimaryDashboardDeviceChanged = 525, + VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled + VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled + VREvent_ShowUI = 528, // data is showUi + VREvent_ShowDevTools = 529, // data is showDevTools VREvent_Notification_Shown = 600, VREvent_Notification_Hidden = 601, VREvent_Notification_BeginInteraction = 602, VREvent_Notification_Destroyed = 603, - VREvent_Quit = 700, // data is process - VREvent_ProcessQuit = 701, // data is process - VREvent_QuitAborted_UserPrompt = 702, // data is process - VREvent_QuitAcknowledged = 703, // data is process - VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down - - VREvent_ChaperoneDataHasChanged = 800, - VREvent_ChaperoneUniverseHasChanged = 801, - VREvent_ChaperoneTempDataHasChanged = 802, - VREvent_ChaperoneSettingsHaveChanged = 803, - VREvent_SeatedZeroPoseReset = 804, - - VREvent_AudioSettingsHaveChanged = 820, - - VREvent_BackgroundSettingHasChanged = 850, - VREvent_CameraSettingsHaveChanged = 851, - VREvent_ReprojectionSettingHasChanged = 852, - VREvent_ModelSkinSettingsHaveChanged = 853, - VREvent_EnvironmentSettingsHaveChanged = 854, - - VREvent_StatusUpdate = 900, - - VREvent_MCImageUpdated = 1000, - - VREvent_FirmwareUpdateStarted = 1100, - VREvent_FirmwareUpdateFinished = 1101, - - VREvent_KeyboardClosed = 1200, - VREvent_KeyboardCharInput = 1201, - VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard - - VREvent_ApplicationTransitionStarted = 1300, - VREvent_ApplicationTransitionAborted = 1301, - VREvent_ApplicationTransitionNewAppStarted = 1302, - VREvent_ApplicationListUpdated = 1303, - VREvent_ApplicationMimeTypeLoad = 1304, - - VREvent_Compositor_MirrorWindowShown = 1400, - VREvent_Compositor_MirrorWindowHidden = 1401, - VREvent_Compositor_ChaperoneBoundsShown = 1410, - VREvent_Compositor_ChaperoneBoundsHidden = 1411, + VREvent_Quit = 700, // data is process + VREvent_ProcessQuit = 701, // data is process + //VREvent_QuitAborted_UserPrompt = 702, // data is process + VREvent_QuitAcknowledged = 703, // data is process + VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down + VREvent_RestartRequested = 705, // A driver or other component wants the user to restart SteamVR + + VREvent_ChaperoneDataHasChanged = 800, // this will never happen with the new chaperone system + VREvent_ChaperoneUniverseHasChanged = 801, + VREvent_ChaperoneTempDataHasChanged = 802, // this will never happen with the new chaperone system + VREvent_ChaperoneSettingsHaveChanged = 803, + VREvent_SeatedZeroPoseReset = 804, + VREvent_ChaperoneFlushCache = 805, // Sent when the process needs to reload any cached data it retrieved from VRChaperone() + VREvent_ChaperoneRoomSetupStarting = 806, // Triggered by CVRChaperoneClient::RoomSetupStarting + VREvent_ChaperoneRoomSetupFinished = 807, // Triggered by CVRChaperoneClient::CommitWorkingCopy + + VREvent_AudioSettingsHaveChanged = 820, + + VREvent_BackgroundSettingHasChanged = 850, + VREvent_CameraSettingsHaveChanged = 851, + VREvent_ReprojectionSettingHasChanged = 852, + VREvent_ModelSkinSettingsHaveChanged = 853, + VREvent_EnvironmentSettingsHaveChanged = 854, + VREvent_PowerSettingsHaveChanged = 855, + VREvent_EnableHomeAppSettingsHaveChanged = 856, + VREvent_SteamVRSectionSettingChanged = 857, + VREvent_LighthouseSectionSettingChanged = 858, + VREvent_NullSectionSettingChanged = 859, + VREvent_UserInterfaceSectionSettingChanged = 860, + VREvent_NotificationsSectionSettingChanged = 861, + VREvent_KeyboardSectionSettingChanged = 862, + VREvent_PerfSectionSettingChanged = 863, + VREvent_DashboardSectionSettingChanged = 864, + VREvent_WebInterfaceSectionSettingChanged = 865, + VREvent_TrackersSectionSettingChanged = 866, + VREvent_LastKnownSectionSettingChanged = 867, + VREvent_DismissedWarningsSectionSettingChanged = 868, + VREvent_GpuSpeedSectionSettingChanged = 869, + VREvent_WindowsMRSectionSettingChanged = 870, + VREvent_OtherSectionSettingChanged = 871, + + VREvent_StatusUpdate = 900, + + VREvent_WebInterface_InstallDriverCompleted = 950, + + VREvent_MCImageUpdated = 1000, + + VREvent_FirmwareUpdateStarted = 1100, + VREvent_FirmwareUpdateFinished = 1101, + + VREvent_KeyboardClosed = 1200, + VREvent_KeyboardCharInput = 1201, + VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard + + //VREvent_ApplicationTransitionStarted = 1300, + //VREvent_ApplicationTransitionAborted = 1301, + //VREvent_ApplicationTransitionNewAppStarted = 1302, + VREvent_ApplicationListUpdated = 1303, + VREvent_ApplicationMimeTypeLoad = 1304, + // VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, + VREvent_ProcessConnected = 1306, + VREvent_ProcessDisconnected = 1307, + + //VREvent_Compositor_MirrorWindowShown = 1400, // DEPRECATED + //VREvent_Compositor_MirrorWindowHidden = 1401, // DEPRECATED + VREvent_Compositor_ChaperoneBoundsShown = 1410, + VREvent_Compositor_ChaperoneBoundsHidden = 1411, + VREvent_Compositor_DisplayDisconnected = 1412, + VREvent_Compositor_DisplayReconnected = 1413, + VREvent_Compositor_HDCPError = 1414, // data is hdcpError + VREvent_Compositor_ApplicationNotResponding = 1415, + VREvent_Compositor_ApplicationResumed = 1416, + VREvent_Compositor_OutOfVideoMemory = 1417, + VREvent_Compositor_DisplayModeNotSupported = 1418, // k_pch_SteamVR_PreferredRefreshRate + VREvent_Compositor_StageOverrideReady = 1419, VREvent_TrackedCamera_StartVideoStream = 1500, VREvent_TrackedCamera_StopVideoStream = 1501, VREvent_TrackedCamera_PauseVideoStream = 1502, VREvent_TrackedCamera_ResumeVideoStream = 1503, + VREvent_TrackedCamera_EditingSurface = 1550, - VREvent_PerformanceTest_EnableCapture = 1600, - VREvent_PerformanceTest_DisableCapture = 1601, - VREvent_PerformanceTest_FidelityLevel = 1602, + VREvent_PerformanceTest_EnableCapture = 1600, + VREvent_PerformanceTest_DisableCapture = 1601, + VREvent_PerformanceTest_FidelityLevel = 1602, + + VREvent_MessageOverlay_Closed = 1650, + VREvent_MessageOverlayCloseRequested = 1651, + VREvent_Input_HapticVibration = 1700, // data is hapticVibration + VREvent_Input_BindingLoadFailed = 1701, // data is inputBinding + VREvent_Input_BindingLoadSuccessful = 1702, // data is inputBinding + VREvent_Input_ActionManifestReloaded = 1703, // no data + VREvent_Input_ActionManifestLoadFailed = 1704, // data is actionManifest + VREvent_Input_ProgressUpdate = 1705, // data is progressUpdate + VREvent_Input_TrackerActivated = 1706, + VREvent_Input_BindingsUpdated = 1707, + VREvent_Input_BindingSubscriptionChanged = 1708, + + VREvent_SpatialAnchors_PoseUpdated = 1800, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_DescriptorUpdated = 1801, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_RequestPoseUpdate = 1802, // data is spatialAnchor. sent to specific driver + VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, // data is spatialAnchor. sent to specific driver + + VREvent_SystemReport_Started = 1900, // user or system initiated generation of a system report. broadcast + + VREvent_Monitor_ShowHeadsetView = 2000, // data is process + VREvent_Monitor_HideHeadsetView = 2001, // data is process + // Vendors are free to expose private events in this reserved region - VREvent_VendorSpecific_Reserved_Start = 10000, - VREvent_VendorSpecific_Reserved_End = 19999, + VREvent_VendorSpecific_Reserved_Start = 10000, + VREvent_VendorSpecific_Reserved_End = 19999, }; /** Level of Hmd activity */ +// UserInteraction_Timeout means the device is in the process of timing out. +// InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout ) +// VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction. +// VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle enum EDeviceActivityLevel -{ - k_EDeviceActivityLevel_Unknown = -1, - k_EDeviceActivityLevel_Idle = 0, - k_EDeviceActivityLevel_UserInteraction = 1, - k_EDeviceActivityLevel_UserInteraction_Timeout = 2, - k_EDeviceActivityLevel_Standby = 3, +{ + k_EDeviceActivityLevel_Unknown = -1, + k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds + k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now + k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds + k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management) + k_EDeviceActivityLevel_Idle_Timeout = 4, }; @@ -502,6 +932,8 @@ enum EVRButtonId k_EButton_DPad_Right = 5, k_EButton_DPad_Down = 6, k_EButton_A = 7, + + k_EButton_ProximitySensor = 31, k_EButton_Axis0 = 32, k_EButton_Axis1 = 33, @@ -515,6 +947,10 @@ enum EVRButtonId k_EButton_Dashboard_Back = k_EButton_Grip, + k_EButton_IndexController_A = k_EButton_Grip, + k_EButton_IndexController_B = k_EButton_ApplicationMenu, + k_EButton_IndexController_JoyStick = k_EButton_Axis3, + k_EButton_Max = 64 }; @@ -543,15 +979,17 @@ struct VREvent_Mouse_t uint32_t button; // EVRMouseButton enum }; -/** used for simulated mouse wheel scroll in overlay space */ +/** used for simulated mouse wheel scroll */ struct VREvent_Scroll_t { - float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe - uint32_t repeatCount; + float xdelta, ydelta; + uint32_t unused; + float viewportscale; // For scrolling on an overlay with laser mouse, this is the overlay's vertical size relative to the overlay height. Range: [0,1] }; /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger - is on the touchpad (or just released from it) + is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents + flag set. **/ struct VREvent_TouchPadMove_t { @@ -583,6 +1021,8 @@ struct VREvent_Process_t uint32_t pid; uint32_t oldPid; bool bForced; + // If the associated event was triggered by a connection loss + bool bConnectionLost; }; @@ -590,6 +1030,7 @@ struct VREvent_Process_t struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; }; @@ -622,6 +1063,10 @@ struct VREvent_Reserved_t { uint64_t reserved0; uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; }; struct VREvent_PerformanceTest_t @@ -651,7 +1096,104 @@ struct VREvent_ApplicationLaunch_t uint32_t unArgsHandle; }; -/** If you change this you must manually update openvr_interop.cs.py */ +struct VREvent_EditingCameraSurface_t +{ + uint64_t overlayHandle; + uint32_t nVisualMode; +}; + +struct VREvent_MessageOverlay_t +{ + uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum +}; + +struct VREvent_Property_t +{ + PropertyContainerHandle_t container; + ETrackedDeviceProperty prop; +}; + +struct VREvent_HapticVibration_t +{ + uint64_t containerHandle; // property container handle of the device with the haptic component + uint64_t componentHandle; // Which haptic component needs to vibrate + float fDurationSeconds; + float fFrequency; + float fAmplitude; +}; + +struct VREvent_WebConsole_t +{ + WebConsoleHandle_t webConsoleHandle; +}; + +struct VREvent_InputBindingLoad_t +{ + vr::PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; + uint64_t pathControllerType; +}; + +struct VREvent_InputActionManifestLoad_t +{ + uint64_t pathAppKey; + uint64_t pathMessage; + uint64_t pathMessageParam; + uint64_t pathManifestPath; +}; + +struct VREvent_SpatialAnchor_t +{ + SpatialAnchorHandle_t unHandle; +}; + +struct VREvent_ProgressUpdate_t +{ + uint64_t ulApplicationPropertyContainer; + uint64_t pathDevice; + uint64_t pathInputSource; + uint64_t pathProgressAction; + uint64_t pathIcon; + float fProgress; +}; + +enum EShowUIType +{ + ShowUI_ControllerBinding = 0, + ShowUI_ManageTrackers = 1, + // ShowUI_QuickStart = 2, // Deprecated + ShowUI_Pairing = 3, + ShowUI_Settings = 4, + ShowUI_DebugCommands = 5, + ShowUI_FullControllerBinding = 6, + ShowUI_ManageDrivers = 7, +}; + +struct VREvent_ShowUI_t +{ + EShowUIType eType; +}; + +struct VREvent_ShowDevTools_t +{ + int32_t nBrowserIdentifier; +}; + +enum EHDCPError +{ + HDCPError_None = 0, + HDCPError_LinkLost = 1, + HDCPError_Tampered = 2, + HDCPError_DeviceRevoked = 3, + HDCPError_Unknown = 4 +}; + +struct VREvent_HDCPError_t +{ + EHDCPError eCode; +}; + typedef union { VREvent_Reserved_t reserved; @@ -671,8 +1213,28 @@ typedef union VREvent_Screenshot_t screenshot; VREvent_ScreenshotProgress_t screenshotProgress; VREvent_ApplicationLaunch_t applicationLaunch; + VREvent_EditingCameraSurface_t cameraSurface; + VREvent_MessageOverlay_t messageOverlay; + VREvent_Property_t property; + VREvent_HapticVibration_t hapticVibration; + VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; + VREvent_InputActionManifestLoad_t actionManifest; + VREvent_SpatialAnchor_t spatialAnchor; + VREvent_ProgressUpdate_t progressUpdate; + VREvent_ShowUI_t showUi; + VREvent_ShowDevTools_t showDevTools; + VREvent_HDCPError_t hdcpError; + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ } VREvent_Data_t; + +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + /** An event posted by the server to all running applications */ struct VREvent_t { @@ -683,6 +1245,74 @@ struct VREvent_t VREvent_Data_t data; }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif + +typedef uint32_t VRComponentProperties; + +enum EVRComponentProperty +{ + VRComponentProperty_IsStatic = (1 << 0), + VRComponentProperty_IsVisible = (1 << 1), + VRComponentProperty_IsTouched = (1 << 2), + VRComponentProperty_IsPressed = (1 << 3), + VRComponentProperty_IsScrolled = (1 << 4), + VRComponentProperty_IsHighlighted = (1 << 5), +}; + + +/** Describes state information about a render-model component, including transforms and other dynamic properties */ +struct RenderModel_ComponentState_t +{ + HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model + HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface ) + VRComponentProperties uProperties; +}; + + +enum EVRInputError +{ + VRInputError_None = 0, + VRInputError_NameNotFound = 1, + VRInputError_WrongType = 2, + VRInputError_InvalidHandle = 3, + VRInputError_InvalidParam = 4, + VRInputError_NoSteam = 5, + VRInputError_MaxCapacityReached = 6, + 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, + VRInputError_MissingSkeletonData = 16, + VRInputError_InvalidBoneIndex = 17, + VRInputError_InvalidPriority = 18, + VRInputError_PermissionDenied = 19, + VRInputError_InvalidRenderModel = 20, +}; + +enum EVRSpatialAnchorError +{ + VRSpatialAnchorError_Success = 0, + VRSpatialAnchorError_Internal = 1, + VRSpatialAnchorError_UnknownHandle = 2, + VRSpatialAnchorError_ArrayTooSmall = 3, + VRSpatialAnchorError_InvalidDescriptorChar = 4, + VRSpatialAnchorError_NotYetAvailable = 5, + VRSpatialAnchorError_NotAvailableInThisUniverse = 6, + VRSpatialAnchorError_PermanentlyUnavailable = 7, + VRSpatialAnchorError_WrongDriver = 8, + VRSpatialAnchorError_DescriptorTooLong = 9, + VRSpatialAnchorError_Unknown = 10, + VRSpatialAnchorError_NoRoomCalibration = 11, + VRSpatialAnchorError_InvalidArgument = 12, + VRSpatialAnchorError_UnknownDriver = 13, +}; /** The mesh to draw into the stencil (or depth) buffer to perform * early stencil (or depth) kills of pixels that will never appear on the HMD. @@ -697,6 +1327,16 @@ struct HiddenAreaMesh_t }; +enum EHiddenAreaMeshType +{ + k_eHiddenAreaMesh_Standard = 0, + k_eHiddenAreaMesh_Inverse = 1, + k_eHiddenAreaMesh_LineLoop = 2, + + k_eHiddenAreaMesh_Max = 3, +}; + + /** Identifies what kind of axis is on the controller at index n. Read this type * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n ); */ @@ -721,6 +1361,12 @@ struct VRControllerAxis_t static const uint32_t k_unControllerStateAxisCount = 5; +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + /** Holds all the state of a controller at one moment in time. */ struct VRControllerState001_t { @@ -735,6 +1381,9 @@ struct VRControllerState001_t // Axis data for the controller's analog inputs VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ]; }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif typedef VRControllerState001_t VRControllerState_t; @@ -761,17 +1410,6 @@ enum ECollisionBoundsStyle COLLISION_BOUNDS_STYLE_COUNT }; -/** Allows the application to customize how the overlay appears in the compositor */ -struct Compositor_OverlaySettings -{ - uint32_t size; // sizeof(Compositor_OverlaySettings) - bool curved, antialias; - float scale, distance, alpha; - float uOffset, vOffset, uScale, vScale; - float gridDivs, gridWidth, gridScale; - HmdMatrix44_t transform; -}; - /** used to refer to a single VR overlay */ typedef uint64_t VROverlayHandle_t; @@ -780,26 +1418,31 @@ static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0; /** Errors that can occur around VR overlays */ enum EVROverlayError { - VROverlayError_None = 0, - - VROverlayError_UnknownOverlay = 10, - VROverlayError_InvalidHandle = 11, - VROverlayError_PermissionDenied = 12, - VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist - VROverlayError_WrongVisibilityType = 14, - VROverlayError_KeyTooLong = 15, - VROverlayError_NameTooLong = 16, - VROverlayError_KeyInUse = 17, - VROverlayError_WrongTransformType = 18, - VROverlayError_InvalidTrackedDevice = 19, - VROverlayError_InvalidParameter = 20, - VROverlayError_ThumbnailCantBeDestroyed = 21, - VROverlayError_ArrayTooSmall = 22, - VROverlayError_RequestFailed = 23, - VROverlayError_InvalidTexture = 24, - VROverlayError_UnableToLoadFile = 25, - VROVerlayError_KeyboardAlreadyInUse = 26, - VROverlayError_NoNeighbor = 27, + VROverlayError_None = 0, + + VROverlayError_UnknownOverlay = 10, + VROverlayError_InvalidHandle = 11, + VROverlayError_PermissionDenied = 12, + VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist + VROverlayError_WrongVisibilityType = 14, + VROverlayError_KeyTooLong = 15, + VROverlayError_NameTooLong = 16, + VROverlayError_KeyInUse = 17, + VROverlayError_WrongTransformType = 18, + VROverlayError_InvalidTrackedDevice = 19, + VROverlayError_InvalidParameter = 20, + VROverlayError_ThumbnailCantBeDestroyed = 21, + VROverlayError_ArrayTooSmall = 22, + VROverlayError_RequestFailed = 23, + VROverlayError_InvalidTexture = 24, + VROverlayError_UnableToLoadFile = 25, + VROverlayError_KeyboardAlreadyInUse = 26, + VROverlayError_NoNeighbor = 27, + VROverlayError_TooManyMaskPrimitives = 29, + VROverlayError_BadMaskPrimitive = 30, + VROverlayError_TextureAlreadyLocked = 31, + VROverlayError_TextureLockCapacityReached = 32, + VROverlayError_TextureNotLocked = 33, }; /** enum values to pass in to VR_Init to identify whether the application will @@ -815,6 +1458,8 @@ enum EVRApplicationType // interfaces (like IVRSettings and IVRApplications) but not hardware. VRApplication_VRMonitor = 5, // Reserved for vrmonitor VRApplication_SteamWatchdog = 6,// Reserved for Steam + VRApplication_Bootstrapper = 7, // reserved for vrstartup + VRApplication_WebHelper = 8, // reserved for vrwebhelper VRApplication_Max }; @@ -840,6 +1485,53 @@ enum EVRNotificationError }; +enum EVRSkeletalMotionRange +{ + // The range of motion of the skeleton takes into account any physical limits imposed by + // the controller itself. This will tend to be the most accurate pose compared to the user's + // actual hand pose, but might not allow a closed fist for example + VRSkeletalMotionRange_WithController = 0, + + // Retarget the range of motion provided by the input device to make the hand appear to move + // as if it was not holding a controller. eg: map "hand grasping controller" to "closed fist" + VRSkeletalMotionRange_WithoutController = 1, +}; + +enum EVRSkeletalTrackingLevel +{ + // body part location can't be directly determined by the device. Any skeletal pose provided by + // the device is estimated by assuming the position required to active buttons, triggers, joysticks, + // or other input sensors. + // E.g. Vive Controller, Gamepad + VRSkeletalTracking_Estimated = 0, + + // body part location can be measured directly but with fewer degrees of freedom than the actual body + // part. Certain body part positions may be unmeasured by the device and estimated from other input data. + // E.g. Index Controllers, gloves that only measure finger curl + VRSkeletalTracking_Partial = 1, + + // Body part location can be measured directly throughout the entire range of motion of the body part. + // E.g. Mocap suit for the full body, gloves that measure rotation of each finger segment + VRSkeletalTracking_Full = 2, + + VRSkeletalTrackingLevel_Count, + VRSkeletalTrackingLevel_Max = VRSkeletalTrackingLevel_Count - 1 +}; + + + +/** Holds the transform for a single bone */ +struct VRBoneTransform_t +{ + HmdVector4_t position; + HmdQuaternionf_t orientation; +}; + +/** Type used for referring to bones by their index */ +typedef int32_t BoneIndex_t; +const BoneIndex_t k_unInvalidBoneIndex = -1; + + /** error codes returned by Vr_Init */ // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp @@ -848,71 +1540,176 @@ enum EVRInitError VRInitError_None = 0, VRInitError_Unknown = 1, - VRInitError_Init_InstallationNotFound = 100, - VRInitError_Init_InstallationCorrupt = 101, - VRInitError_Init_VRClientDLLNotFound = 102, - VRInitError_Init_FileNotFound = 103, - VRInitError_Init_FactoryNotFound = 104, - VRInitError_Init_InterfaceNotFound = 105, - VRInitError_Init_InvalidInterface = 106, - VRInitError_Init_UserConfigDirectoryInvalid = 107, - VRInitError_Init_HmdNotFound = 108, - VRInitError_Init_NotInitialized = 109, - VRInitError_Init_PathRegistryNotFound = 110, - VRInitError_Init_NoConfigPath = 111, - VRInitError_Init_NoLogPath = 112, - VRInitError_Init_PathRegistryNotWritable = 113, - VRInitError_Init_AppInfoInitFailed = 114, - VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver - VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup - VRInitError_Init_AnotherAppLaunching = 117, - VRInitError_Init_SettingsInitFailed = 118, - VRInitError_Init_ShuttingDown = 119, - VRInitError_Init_TooManyObjects = 120, - VRInitError_Init_NoServerForBackgroundApp = 121, - VRInitError_Init_NotSupportedWithCompositor = 122, - VRInitError_Init_NotAvailableToUtilityApps = 123, - VRInitError_Init_Internal = 124, - VRInitError_Init_HmdDriverIdIsNone = 125, - VRInitError_Init_HmdNotFoundPresenceFailed = 126, - VRInitError_Init_VRMonitorNotFound = 127, - VRInitError_Init_VRMonitorStartupFailed = 128, - VRInitError_Init_LowPowerWatchdogNotSupported = 129, - VRInitError_Init_InvalidApplicationType = 130, - VRInitError_Init_NotAvailableToWatchdogApps = 131, - VRInitError_Init_WatchdogDisabledInSettings = 132, - - VRInitError_Driver_Failed = 200, - VRInitError_Driver_Unknown = 201, - VRInitError_Driver_HmdUnknown = 202, - VRInitError_Driver_NotLoaded = 203, - VRInitError_Driver_RuntimeOutOfDate = 204, - VRInitError_Driver_HmdInUse = 205, - VRInitError_Driver_NotCalibrated = 206, - VRInitError_Driver_CalibrationInvalid = 207, - VRInitError_Driver_HmdDisplayNotFound = 208, + VRInitError_Init_InstallationNotFound = 100, + VRInitError_Init_InstallationCorrupt = 101, + VRInitError_Init_VRClientDLLNotFound = 102, + VRInitError_Init_FileNotFound = 103, + VRInitError_Init_FactoryNotFound = 104, + VRInitError_Init_InterfaceNotFound = 105, + VRInitError_Init_InvalidInterface = 106, + VRInitError_Init_UserConfigDirectoryInvalid = 107, + VRInitError_Init_HmdNotFound = 108, + VRInitError_Init_NotInitialized = 109, + VRInitError_Init_PathRegistryNotFound = 110, + VRInitError_Init_NoConfigPath = 111, + VRInitError_Init_NoLogPath = 112, + VRInitError_Init_PathRegistryNotWritable = 113, + VRInitError_Init_AppInfoInitFailed = 114, + VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver + VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup + VRInitError_Init_AnotherAppLaunching = 117, + VRInitError_Init_SettingsInitFailed = 118, + VRInitError_Init_ShuttingDown = 119, + VRInitError_Init_TooManyObjects = 120, + VRInitError_Init_NoServerForBackgroundApp = 121, + VRInitError_Init_NotSupportedWithCompositor = 122, + VRInitError_Init_NotAvailableToUtilityApps = 123, + VRInitError_Init_Internal = 124, + VRInitError_Init_HmdDriverIdIsNone = 125, + VRInitError_Init_HmdNotFoundPresenceFailed = 126, + VRInitError_Init_VRMonitorNotFound = 127, + VRInitError_Init_VRMonitorStartupFailed = 128, + VRInitError_Init_LowPowerWatchdogNotSupported = 129, + VRInitError_Init_InvalidApplicationType = 130, + VRInitError_Init_NotAvailableToWatchdogApps = 131, + VRInitError_Init_WatchdogDisabledInSettings = 132, + VRInitError_Init_VRDashboardNotFound = 133, + VRInitError_Init_VRDashboardStartupFailed = 134, + VRInitError_Init_VRHomeNotFound = 135, + VRInitError_Init_VRHomeStartupFailed = 136, + VRInitError_Init_RebootingBusy = 137, + VRInitError_Init_FirmwareUpdateBusy = 138, + VRInitError_Init_FirmwareRecoveryBusy = 139, + VRInitError_Init_USBServiceBusy = 140, + VRInitError_Init_VRWebHelperStartupFailed = 141, + VRInitError_Init_TrackerManagerInitFailed = 142, + VRInitError_Init_AlreadyRunning = 143, + VRInitError_Init_FailedForVrMonitor = 144, + VRInitError_Init_PropertyManagerInitFailed = 145, + VRInitError_Init_WebServerFailed = 146, + + VRInitError_Driver_Failed = 200, + VRInitError_Driver_Unknown = 201, + VRInitError_Driver_HmdUnknown = 202, + VRInitError_Driver_NotLoaded = 203, + VRInitError_Driver_RuntimeOutOfDate = 204, + VRInitError_Driver_HmdInUse = 205, + VRInitError_Driver_NotCalibrated = 206, + VRInitError_Driver_CalibrationInvalid = 207, + VRInitError_Driver_HmdDisplayNotFound = 208, VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, - // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons - VRInitError_Driver_HmdDriverIdOutOfBounds = 211, - VRInitError_Driver_HmdDisplayMirrored = 212, - - VRInitError_IPC_ServerInitFailed = 300, - VRInitError_IPC_ConnectFailed = 301, - VRInitError_IPC_SharedStateInitFailed = 302, - VRInitError_IPC_CompositorInitFailed = 303, - VRInitError_IPC_MutexInitFailed = 304, - VRInitError_IPC_Failed = 305, - VRInitError_IPC_CompositorConnectFailed = 306, + // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons + VRInitError_Driver_HmdDriverIdOutOfBounds = 211, + VRInitError_Driver_HmdDisplayMirrored = 212, + VRInitError_Driver_HmdDisplayNotFoundLaptop = 213, + // Never make error 259 because we return it from main and it would conflict with STILL_ACTIVE + + VRInitError_IPC_ServerInitFailed = 300, + VRInitError_IPC_ConnectFailed = 301, + VRInitError_IPC_SharedStateInitFailed = 302, + VRInitError_IPC_CompositorInitFailed = 303, + VRInitError_IPC_MutexInitFailed = 304, + VRInitError_IPC_Failed = 305, + VRInitError_IPC_CompositorConnectFailed = 306, VRInitError_IPC_CompositorInvalidConnectResponse = 307, VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, - - VRInitError_Compositor_Failed = 400, - VRInitError_Compositor_D3D11HardwareRequired = 401, - VRInitError_Compositor_FirmwareRequiresUpdate = 402, - VRInitError_Compositor_OverlayInitFailed = 403, - VRInitError_Compositor_ScreenshotsInitFailed = 404, - - VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + VRInitError_IPC_ConnectFailedAfterTargetExited = 309, + VRInitError_IPC_NamespaceUnavailable = 310, + + VRInitError_Compositor_Failed = 400, + VRInitError_Compositor_D3D11HardwareRequired = 401, + VRInitError_Compositor_FirmwareRequiresUpdate = 402, + VRInitError_Compositor_OverlayInitFailed = 403, + VRInitError_Compositor_ScreenshotsInitFailed = 404, + VRInitError_Compositor_UnableToCreateDevice = 405, + VRInitError_Compositor_SharedStateIsNull = 406, + VRInitError_Compositor_NotificationManagerIsNull = 407, + VRInitError_Compositor_ResourceManagerClientIsNull = 408, + VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409, + VRInitError_Compositor_PropertiesInterfaceIsNull = 410, + VRInitError_Compositor_CreateFullscreenWindowFailed = 411, + VRInitError_Compositor_SettingsInterfaceIsNull = 412, + VRInitError_Compositor_FailedToShowWindow = 413, + VRInitError_Compositor_DistortInterfaceIsNull = 414, + VRInitError_Compositor_DisplayFrequencyFailure = 415, + VRInitError_Compositor_RendererInitializationFailed = 416, + VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417, + VRInitError_Compositor_DXGIFactoryCreateFailed = 418, + VRInitError_Compositor_DXGIFactoryQueryFailed = 419, + VRInitError_Compositor_InvalidAdapterDesktop = 420, + VRInitError_Compositor_InvalidHmdAttachment = 421, + VRInitError_Compositor_InvalidOutputDesktop = 422, + VRInitError_Compositor_InvalidDeviceProvided = 423, + VRInitError_Compositor_D3D11RendererInitializationFailed = 424, + VRInitError_Compositor_FailedToFindDisplayMode = 425, + VRInitError_Compositor_FailedToCreateSwapChain = 426, + VRInitError_Compositor_FailedToGetBackBuffer = 427, + VRInitError_Compositor_FailedToCreateRenderTarget = 428, + VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429, + VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430, + VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431, + VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432, + VRInitError_Compositor_SelectDisplayMode = 433, + VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434, + VRInitError_Compositor_NvAPISetDisplayMode = 435, + VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436, + VRInitError_Compositor_InvalidHmdPropertyContainer = 437, + VRInitError_Compositor_UpdateDisplayFrequency = 438, + VRInitError_Compositor_CreateRasterizerState = 439, + VRInitError_Compositor_CreateWireframeRasterizerState = 440, + VRInitError_Compositor_CreateSamplerState = 441, + VRInitError_Compositor_CreateClampToBorderSamplerState = 442, + VRInitError_Compositor_CreateAnisoSamplerState = 443, + VRInitError_Compositor_CreateOverlaySamplerState = 444, + VRInitError_Compositor_CreatePanoramaSamplerState = 445, + VRInitError_Compositor_CreateFontSamplerState = 446, + VRInitError_Compositor_CreateNoBlendState = 447, + VRInitError_Compositor_CreateBlendState = 448, + VRInitError_Compositor_CreateAlphaBlendState = 449, + VRInitError_Compositor_CreateBlendStateMaskR = 450, + VRInitError_Compositor_CreateBlendStateMaskG = 451, + VRInitError_Compositor_CreateBlendStateMaskB = 452, + VRInitError_Compositor_CreateDepthStencilState = 453, + VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454, + VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455, + VRInitError_Compositor_CreateFlushTexture = 456, + VRInitError_Compositor_CreateDistortionSurfaces = 457, + VRInitError_Compositor_CreateConstantBuffer = 458, + VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459, + VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460, + VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461, + VRInitError_Compositor_CreateOverlayConstantBuffer = 462, + VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463, + VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464, + VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465, + VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466, + VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467, + VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468, + VRInitError_Compositor_CreateGeomConstantBuffer = 469, + VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470, + VRInitError_Compositor_CreatePixelSimUBO = 471, + VRInitError_Compositor_CreateMSAARenderTextures = 472, + VRInitError_Compositor_CreateResolveRenderTextures = 473, + VRInitError_Compositor_CreateComputeResolveRenderTextures = 474, + VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475, + VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476, + VRInitError_Compositor_CreateFallbackSyncTexture = 477, + VRInitError_Compositor_ShareFallbackSyncTexture = 478, + VRInitError_Compositor_CreateOverlayIndexBuffer = 479, + VRInitError_Compositor_CreateOverlayVertexBuffer = 480, + VRInitError_Compositor_CreateTextVertexBuffer = 481, + VRInitError_Compositor_CreateTextIndexBuffer = 482, + VRInitError_Compositor_CreateMirrorTextures = 483, + VRInitError_Compositor_CreateLastFrameRenderTexture = 484, + VRInitError_Compositor_CreateMirrorOverlay = 485, + VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486, + VRInitError_Compositor_DisplayModeNotSupported = 487, + VRInitError_Compositor_CreateOverlayInvalidCall = 488, + VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489, + VRInitError_Compositor_FailedToCreateMailbox = 490, + + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + VRInitError_VendorSpecific_WindowsNotInDevMode = 1001, VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, @@ -927,8 +1724,12 @@ enum EVRInitError VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111, VRInitError_VendorSpecific_HmdFound_UserDataError = 1112, VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, + VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114, VRInitError_Steam_SteamInstallationNotFound = 2000, + + // Strictly a placeholder + VRInitError_LastError }; enum EVRScreenshotType @@ -968,6 +1769,14 @@ enum EVRTrackedCameraError VRTrackedCameraError_InvalidFrameBufferSize = 115, }; +enum EVRTrackedCameraFrameLayout +{ + EVRTrackedCameraFrameLayout_Mono = 0x0001, + EVRTrackedCameraFrameLayout_Stereo = 0x0002, + EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right) + EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right +}; + enum EVRTrackedCameraFrameType { VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted. @@ -976,6 +1785,16 @@ enum EVRTrackedCameraFrameType MAX_CAMERA_FRAME_TYPES }; +enum EVRDistortionFunctionType +{ + VRDistortionFunctionType_None, + VRDistortionFunctionType_FTheta, + VRDistortionFunctionType_Extended_FTheta, + MAX_DISTORTION_FUNCTION_TYPES, +}; + +static const uint32_t k_unMaxDistortionFunctionParameters = 8; + typedef uint64_t TrackedCameraHandle_t; #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0) @@ -989,7 +1808,9 @@ struct CameraVideoStreamFrameHeader_t uint32_t nFrameSequence; - TrackedDevicePose_t standingTrackedDevicePose; + TrackedDevicePose_t trackedDevicePose; + + uint64_t ulFrameExposureTime; // mid-point of the exposure of the image in host system ticks }; // Screenshot types @@ -997,39 +1818,167 @@ typedef uint32_t ScreenshotHandle_t; static const uint32_t k_unScreenshotHandleInvalid = 0; -#pragma pack( pop ) +/** Compositor frame timing reprojection flags. */ +const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01; +const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02; +const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicates the async reprojection mode is active, + // but does not indicate if reprojection actually happened or not. + // Use the ReprojectionReason flags above to check if reprojection + // was actually applied (i.e. scene texture was reused). + // NumFramePresents > 1 also indicates the scene texture was reused, + // and also the number of times that it was presented in total. -// figure out how to import from the VR API dll -#if defined(_WIN32) +const uint32_t VRCompositor_ReprojectionMotion = 0x08; // This flag indicates whether or not motion smoothing was triggered for this frame -#ifdef VR_API_EXPORT -#define VR_INTERFACE extern "C" __declspec( dllexport ) -#else -#define VR_INTERFACE extern "C" __declspec( dllimport ) -#endif +const uint32_t VRCompositor_PredictionMask = 0x30; // The runtime may predict more than one frame (up to four) ahead if + // it detects the application is taking too long to render. These two + // bits will contain the count of additional frames (normally zero). + // Use the VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES macro to read from + // the latest frame timing entry. -#elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__) +const uint32_t VRCompositor_ThrottleMask = 0xC0; // Number of frames the compositor is throttling the application. + // Use the VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES macro to read from + // the latest frame timing entry. -#ifdef VR_API_EXPORT -#define VR_INTERFACE extern "C" __attribute__((visibility("default"))) -#else -#define VR_INTERFACE extern "C" -#endif +#define VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_PredictionMask ) >> 4 ) +#define VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_ThrottleMask ) >> 6 ) -#else -#error "Unsupported Platform." -#endif +/** Provides a single frame's timing information to the app */ +struct Compositor_FrameTiming +{ + uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming ) + uint32_t m_nFrameIndex; + uint32_t m_nNumFramePresents; // number of times this frame was presented + uint32_t m_nNumMisPresented; // number of times this frame was presented on a vsync other than it was originally predicted to + uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out + uint32_t m_nReprojectionFlags; + /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */ + double m_flSystemTimeInSeconds; -#if defined( _WIN32 ) -#define VR_CALLTYPE __cdecl -#else -#define VR_CALLTYPE -#endif + /** These times may include work from other processes due to OS scheduling. + * The fewer packets of work these are broken up into, the less likely this will happen. + * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started + * processing that work earlier in the frame. */ + float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit) + float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window) + float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work + float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc. + float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame + float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time) -} // namespace vr + /** Miscellaneous measured intervals. */ + float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses + float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long) + float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure) + float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue) -#endif // _INCLUDE_VRTYPES_H + /** The following are all relative to this frame's SystemTimeInSeconds */ + float m_flWaitGetPosesCalledMs; + float m_flNewPosesReadyMs; + float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit + float m_flCompositorUpdateStartMs; + float m_flCompositorUpdateEndMs; + float m_flCompositorRenderStartMs; + + vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame + + uint32_t m_nNumVSyncsReadyForUse; + uint32_t m_nNumVSyncsToFirstView; +}; + +/** Provides compositor benchmark results to the app */ +struct Compositor_BenchmarkResults +{ + float m_flMegaPixelsPerSecond; // Measurement of GPU MP/s performed by compositor benchmark + float m_flHmdRecommendedMegaPixelsPerSecond; // Recommended default MP/s given the HMD resolution, refresh, and panel mask. +}; + +/** Frame timing data provided by direct mode drivers. */ +struct DriverDirectMode_FrameTiming +{ + uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming ) + uint32_t m_nNumFramePresents; // number of times frame was presented + uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to + uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync) + uint32_t m_nReprojectionFlags; +}; + +/** These flags will be set on DriverDirectMode_FrameTiming::m_nReprojectionFlags when IVRDriverDirectModeComponent::GetFrameTiming is called for drivers to optionally respond to. */ +const uint32_t VRCompositor_ReprojectionMotion_Enabled = 0x100; // Motion Smoothing is enabled in the UI for the currently running application +const uint32_t VRCompositor_ReprojectionMotion_ForcedOn = 0x200; // Motion Smoothing is forced on in the UI for the currently running application +const uint32_t VRCompositor_ReprojectionMotion_AppThrottled = 0x400; // Application is requesting throttling via ForceInterleavedReprojectionOn + + +enum EVSync +{ + VSync_None, + VSync_WaitRender, // block following render work until vsync + VSync_NoWaitRender, // do not block following render work (allow to get started early) +}; + +enum EVRMuraCorrectionMode +{ + EVRMuraCorrectionMode_Default = 0, + EVRMuraCorrectionMode_NoCorrection +}; + +/** 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 +#if defined(_WIN32) + + #if !defined(OPENVR_BUILD_STATIC) + #ifdef VR_API_EXPORT + #define VR_INTERFACE extern "C" __declspec( dllexport ) + #else + #define VR_INTERFACE extern "C" __declspec( dllimport ) + #endif + #else + #define VR_INTERFACE extern "C" + #endif + +#elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__) + +#ifdef VR_API_EXPORT + #define VR_INTERFACE extern "C" __attribute__((visibility("default"))) +#else + #define VR_INTERFACE extern "C" +#endif + +#else + #error "Unsupported Platform." +#endif + + +#if defined( _WIN32 ) + #define VR_CALLTYPE __cdecl +#else + #define VR_CALLTYPE +#endif + +} // namespace vr + +#endif // _INCLUDE_VRTYPES_H // vrannotation.h @@ -1068,15 +2017,16 @@ class IVRSystem virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0; /** The projection matrix for the specified eye */ - virtual HmdMatrix44_t GetProjectionMatrix( EVREye eEye, float fNearZ, float fFarZ, EGraphicsAPIConvention eProjType ) = 0; + virtual HmdMatrix44_t GetProjectionMatrix( EVREye eEye, float fNearZ, float fFarZ ) = 0; /** The components necessary to build your own projection matrix in case your * application is doing something fancy like infinite Z */ virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0; - /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in - * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */ - virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0; + /** Gets the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in + * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. + * Returns true for success. Otherwise, returns false, and distortion coordinates are not suitable. */ + virtual bool ComputeDistortion( EVREye eEye, float fU, float fV, DistortionCoordinates_t *pDistortionCoordinates ) = 0; /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection. @@ -1097,10 +2047,34 @@ class IVRSystem virtual int32_t GetD3D9AdapterIndex() = 0; /** [D3D10/11 Only] - * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs - * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1. + * Returns the adapter index that the user should pass into EnumAdapters to create the device + * and swap chain in DX10 and DX11. If an error occurs the index will be set to -1. */ virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex ) = 0; + + /** + * Returns platform- and texture-type specific adapter identification so that applications and the + * compositor are creating textures and swap chains on the same GPU. If an error occurs the device + * will be set to 0. + * pInstance is an optional parameter that is required only when textureType is TextureType_Vulkan. + * [D3D10/11/12 Only (D3D9 Not Supported)] + * Returns the adapter LUID that identifies the GPU attached to the HMD. The user should + * enumerate all adapters using IDXGIFactory::EnumAdapters and IDXGIAdapter::GetDesc to find + * the adapter with the matching LUID, or use IDXGIFactory4::EnumAdapterByLuid. + * The discovered IDXGIAdapter should be used to create the device and swap chain. + * [Vulkan Only] + * Returns the VkPhysicalDevice that should be used by the application. + * pInstance must be the instance the application will use to query for the VkPhysicalDevice. The application + * must create the VkInstance with extensions returned by IVRCompositor::GetVulkanInstanceExtensionsRequired enabled. + * [macOS Only] + * For TextureType_IOSurface returns the id that should be used by the application. + * On 10.13+ for TextureType_OpenGL returns the 'registryId' of the renderer which should be used + * by the application. See Apple Technical Q&A QA1168 for information on enumerating GL Renderers, and the + * new kCGLRPRegistryIDLow and kCGLRPRegistryIDHigh CGLRendererProperty values in the 10.13 SDK. + * Pre 10.13 for TextureType_OpenGL returns 0, as there is no dependable way to correlate the HMDs MTLDevice + * with a GL Renderer. + */ + virtual void GetOutputDevice( uint64_t *pnDevice, ETextureType textureType, VkInstance_T *pInstance = nullptr ) = 0; // ------------------------------------ // Display Mode methods @@ -1171,10 +2145,10 @@ class IVRSystem */ virtual void ApplyTransform( TrackedDevicePose_t *pOutputPose, const TrackedDevicePose_t *pTrackedDevicePose, const HmdMatrix34_t *pTransform ) = 0; - /** Returns the device index associated with a specific role, for example the left hand or the right hand. */ + /** Returns the device index associated with a specific role, for example the left hand or the right hand. This function is deprecated in favor of the new IVRInput system. */ virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole( vr::ETrackedControllerRole unDeviceType ) = 0; - /** Returns the controller type associated with a device index. */ + /** Returns the controller type associated with a device index. This function is deprecated in favor of the new IVRInput system. */ virtual vr::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0; // ------------------------------------ @@ -1207,10 +2181,15 @@ class IVRSystem /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */ virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; + + /** Returns an array of one type of property. If the device index is not valid or the property is not a single value or an array of the specified type, + * this function will return 0. Otherwise it returns the number of bytes necessary to hold the array of properties. If unBufferSize is + * greater than the returned size and pBuffer is non-NULL, pBuffer is filled with the contents of array of properties. */ + virtual uint32_t GetArrayTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, PropertyTypeTag_t propType, void *pBuffer, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0; /** Returns a string property. If the device index is not valid or the property is not a string type this function will * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing - * null. Strings will generally fit in buffers of k_unTrackingStringSize characters. */ + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0; /** returns a string that corresponds with the specified property error. The string will be the name @@ -1238,59 +2217,54 @@ class IVRSystem // Rendering helper methods // ------------------------------------ - /** Returns the stencil mesh information for the current HMD. If this HMD does not have a stencil mesh the vertex data and count will be - * NULL and 0 respectively. This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering - * each eye's view. The pixels covered by this mesh will never be seen by the user after the lens distortion is applied and based on visibility to the panels. - * This will improve perf by letting the GPU early-reject pixels the user will never see before running the pixel shader. + /** Returns the hidden area mesh for the current HMD. The pixels covered by this mesh will never be seen by the user after the lens distortion is + * applied based on visibility to the panels. If this HMD does not have a hidden area mesh, the vertex data and count will be NULL and 0 respectively. + * This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering each eye's view. + * This will improve performance by letting the GPU early-reject pixels the user will never see before running the pixel shader. * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye. + * Setting the bInverse argument to true will produce the visible area mesh that is commonly used in place of full-screen quads. The visible area mesh covers all of the pixels the hidden area mesh does not cover. + * Setting the bLineLoop argument will return a line loop of vertices in HiddenAreaMesh_t->pVertexData with HiddenAreaMesh_t->unTriangleCount set to the number of vertices. */ - virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye ) = 0; - + virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye, EHiddenAreaMeshType type = k_eHiddenAreaMesh_Standard ) = 0; // ------------------------------------ // Controller methods // ------------------------------------ /** Fills the supplied struct with the current state of the controller. Returns false if the controller index - * is invalid. */ - virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState ) = 0; + * is invalid. This function is deprecated in favor of the new IVRInput system. */ + virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize ) = 0; /** fills the supplied struct with the current state of the controller and the provided pose with the pose of * the controller when the controller state was updated most recently. Use this form if you need a precise controller - * pose as input to your application when the user presses or releases a button. */ - virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, TrackedDevicePose_t *pTrackedDevicePose ) = 0; + * pose as input to your application when the user presses or releases a button. This function is deprecated in favor of the new IVRInput system. */ + virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize, TrackedDevicePose_t *pTrackedDevicePose ) = 0; /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller - * and axis combination for 5ms. */ + * and axis combination for 5ms. This function is deprecated in favor of the new IVRInput system. */ virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0; - /** returns the name of an EVRButtonId enum value */ + /** returns the name of an EVRButtonId enum value. This function is deprecated in favor of the new IVRInput system. */ virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0; - /** returns the name of an EVRControllerAxisType enum value */ + /** returns the name of an EVRControllerAxisType enum value. This function is deprecated in favor of the new IVRInput system. */ virtual const char *GetControllerAxisTypeNameFromEnum( EVRControllerAxisType eAxisType ) = 0; - /** Tells OpenVR that this process wants exclusive access to controller button states and button events. Other apps will be notified that - * they have lost input focus with a VREvent_InputFocusCaptured event. Returns false if input focus could not be captured for - * some reason. */ - virtual bool CaptureInputFocus() = 0; + /** Returns true if this application is receiving input from the system. This would return false if + * system-related functionality is consuming the input stream. */ + virtual bool IsInputAvailable() = 0; - /** Tells OpenVR that this process no longer wants exclusive access to button states and button events. Other apps will be notified - * that input focus has been released with a VREvent_InputFocusReleased event. */ - virtual void ReleaseInputFocus() = 0; - - /** Returns true if input focus is captured by another process. */ - virtual bool IsInputFocusCapturedByAnotherProcess() = 0; - - // ------------------------------------ - // Debug Methods - // ------------------------------------ + /** Returns true SteamVR is drawing controllers on top of the application. Applications should consider + * not drawing anything attached to the user's hands in this case. */ + virtual bool IsSteamVRDrawingControllers() = 0; - /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k, - * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated. - * The size of the response including its terminating null is returned. */ - virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; + /** Returns true if the user has put SteamVR into a mode that is distracting them from the application. + * For applications where this is appropriate, the application should pause ongoing activity. */ + virtual bool ShouldApplicationPause() = 0; + /** Returns true if SteamVR is doing significant rendering work and the game should do what it can to reduce + * its own workload. One common way to do this is to reduce the size of the render target provided for each eye. */ + virtual bool ShouldApplicationReduceRenderingWork() = 0; // ------------------------------------ // Firmware methods @@ -1303,7 +2277,6 @@ class IVRSystem * Prop_Firmware_ManualUpdateURL_String should point to an URL describing the manual update process */ virtual vr::EVRFirmwareError PerformFirmwareUpdate( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0; - // ------------------------------------ // Application life cycle methods // ------------------------------------ @@ -1312,14 +2285,29 @@ class IVRSystem * This extends the timeout until the process is killed. */ virtual void AcknowledgeQuit_Exiting() = 0; - /** Call this to tell the system that the user is being prompted to save data. This - * halts the timeout and dismisses the dashboard (if it was up). Applications should be sure to actually - * prompt the user to save and then exit afterward, otherwise the user will be left in a confusing state. */ - virtual void AcknowledgeQuit_UserPrompt() = 0; + // ------------------------------------- + // App container sandbox methods + // ------------------------------------- + + /** Retrieves a null-terminated, semicolon-delimited list of UTF8 file paths that an application + * must have read access to when running inside of an app container. Returns the number of bytes + * needed to hold the list. */ + virtual uint32_t GetAppContainerFilePaths( VR_OUT_STRING() char *pchBuffer, uint32_t unBufferSize ) = 0; + + // ------------------------------------- + // System methods + // ------------------------------------- + + /** Returns the current version of the SteamVR runtime. The returned string will remain valid until VR_Shutdown is called. + * + * NOTE: Is it not appropriate to use this version to test for the presence of any SteamVR feature. Only use this version + * number for logging or showing to a user, and not to try to detect anything at runtime. When appropriate, feature-specific + * presence information is provided by other APIs. */ + virtual const char *GetRuntimeVersion() = 0; }; -static const char * const IVRSystem_Version = "IVRSystem_012"; +static const char * const IVRSystem_Version = "IVRSystem_021"; } @@ -1348,6 +2336,7 @@ namespace vr VRApplicationError_OldApplicationQuitting = 112, VRApplicationError_TransitionAborted = 113, VRApplicationError_IsTemplate = 114, // error when you try to call LaunchApplication() on a template type app (use LaunchTemplateApplication) + VRApplicationError_SteamVRIsExiting = 115, VRApplicationError_BufferTooSmall = 200, // The provided buffer was too small to fit the requested data VRApplicationError_PropertyNotSet = 201, // The requested property was not set @@ -1373,23 +2362,25 @@ namespace vr VRApplicationProperty_NewsURL_String = 51, VRApplicationProperty_ImagePath_String = 52, VRApplicationProperty_Source_String = 53, + VRApplicationProperty_ActionManifestURL_String = 54, VRApplicationProperty_IsDashboardOverlay_Bool = 60, VRApplicationProperty_IsTemplate_Bool = 61, VRApplicationProperty_IsInstanced_Bool = 62, + VRApplicationProperty_IsInternal_Bool = 63, + VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64, + VRApplicationProperty_IsHidden_Bool = 65, VRApplicationProperty_LastLaunchTime_Uint64 = 70, }; - /** These are states the scene application startup process will go through. */ - enum EVRApplicationTransitionState + enum EVRSceneApplicationState { - VRApplicationTransition_None = 0, - - VRApplicationTransition_OldAppQuitSent = 10, - VRApplicationTransition_WaitingForExternalLaunch = 11, - - VRApplicationTransition_NewAppLaunched = 20, + EVRSceneApplicationState_None = 0, // Scene Application is not running + EVRSceneApplicationState_Starting = 1, // Scene Application is starting + EVRSceneApplicationState_Quitting = 2, // Scene Application is quitting + EVRSceneApplicationState_Running = 3, // Scene Application is running, and submitting frames, a custom skybox, or a visible overlay + EVRSceneApplicationState_Waiting = 4, // Scene Application is running, but not drawing anything }; struct AppOverrideKeys_t @@ -1398,6 +2389,10 @@ namespace vr const char *pchValue; }; + /** Currently recognized mime types */ + static const char * const k_pch_MimeType_HomeApp = "vr/home"; + static const char * const k_pch_MimeType_GameTheater = "vr/game_theater"; + class IVRApplications { public: @@ -1420,11 +2415,11 @@ namespace vr /** Returns the key of the specified application. The index is at least 0 and is less than the return * value of GetApplicationCount(). The buffer should be at least k_unMaxApplicationKeyLength in order to * fit the key. */ - virtual EVRApplicationError GetApplicationKeyByIndex( uint32_t unApplicationIndex, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual EVRApplicationError GetApplicationKeyByIndex( uint32_t unApplicationIndex, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Returns the key of the application for the specified Process Id. The buffer should be at least * k_unMaxApplicationKeyLength in order to fit the key. */ - virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Launches the application. The existing scene application will exit and then the new application will start. * This call is not valid for dashboard overlay applications. */ @@ -1460,7 +2455,7 @@ namespace vr // --------------- Application properties --------------- // /** Returns a value for an application property. The required buffer size to fit this value will be returned. */ - virtual uint32_t GetApplicationPropertyString( const char *pchAppKey, EVRApplicationProperty eProperty, char *pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError *peError = nullptr ) = 0; + virtual uint32_t GetApplicationPropertyString( const char *pchAppKey, EVRApplicationProperty eProperty, VR_OUT_STRING() char *pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError *peError = nullptr ) = 0; /** Returns a bool value for an application property. Returns false in all error cases. */ virtual bool GetApplicationPropertyBool( const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr ) = 0; @@ -1478,24 +2473,24 @@ namespace vr virtual EVRApplicationError SetDefaultApplicationForMimeType( const char *pchAppKey, const char *pchMimeType ) = 0; /** return the app key that will open this mime type */ - virtual bool GetDefaultApplicationForMimeType( const char *pchMimeType, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual bool GetDefaultApplicationForMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Get the list of supported mime types for this application, comma-delimited */ - virtual bool GetApplicationSupportedMimeTypes( const char *pchAppKey, char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer ) = 0; + virtual bool GetApplicationSupportedMimeTypes( const char *pchAppKey, VR_OUT_STRING() char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer ) = 0; /** Get the list of app-keys that support this mime type, comma-delimited, the return value is number of bytes you need to return the full string */ - virtual uint32_t GetApplicationsThatSupportMimeType( const char *pchMimeType, char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer ) = 0; + virtual uint32_t GetApplicationsThatSupportMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer ) = 0; /** Get the args list from an app launch that had the process already running, you call this when you get a VREvent_ApplicationMimeTypeLoad */ - virtual uint32_t GetApplicationLaunchArguments( uint32_t unHandle, char *pchArgs, uint32_t unArgs ) = 0; + virtual uint32_t GetApplicationLaunchArguments( uint32_t unHandle, VR_OUT_STRING() char *pchArgs, uint32_t unArgs ) = 0; // --------------- Transition methods --------------- // /** Returns the app key for the application that is starting up */ - virtual EVRApplicationError GetStartingApplication( char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; + virtual EVRApplicationError GetStartingApplication( VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0; /** Returns the application transition state */ - virtual EVRApplicationTransitionState GetTransitionState() = 0; + virtual EVRSceneApplicationState GetSceneApplicationState() = 0; /** Returns errors that would prevent the specified application from launching immediately. Calling this function will * cause the current scene application to quit, so only call it when you are actually about to launch something else. @@ -1509,10 +2504,7 @@ namespace vr virtual EVRApplicationError PerformApplicationPrelaunchCheck( const char *pchAppKey ) = 0; /** Returns a string for an application transition state */ - virtual const char *GetApplicationsTransitionStateNameFromEnum( EVRApplicationTransitionState state ) = 0; - - /** Returns true if the outgoing scene app has requested a save prompt before exiting */ - virtual bool IsQuitUserPromptRequested() = 0; + virtual const char *GetSceneApplicationStateNameFromEnum( EVRSceneApplicationState state ) = 0; /** Starts a subprocess within the calling application. This * suppresses all application transition UI and automatically identifies the new executable @@ -1520,13 +2512,20 @@ namespace vr * If working directory is NULL or "" the directory portion of the binary path will be * the working directory. */ virtual EVRApplicationError LaunchInternalProcess( const char *pchBinaryPath, const char *pchArguments, const char *pchWorkingDirectory ) = 0; + + /** Returns the current scene process ID according to the application system. A scene process will get scene + * focus once it starts rendering, but it will appear here once it calls VR_Init with the Scene application + * type. */ + virtual uint32_t GetCurrentSceneProcessId() = 0; }; - static const char * const IVRApplications_Version = "IVRApplications_006"; + static const char * const IVRApplications_Version = "IVRApplications_007"; } // namespace vr // ivrsettings.h +#include + namespace vr { enum EVRSettingsError @@ -1535,6 +2534,8 @@ namespace vr VRSettingsError_IPCFailed = 1, VRSettingsError_WriteFailed = 2, VRSettingsError_ReadFailed = 3, + VRSettingsError_JsonParseFailed = 4, + VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set }; // The maximum length of a settings key @@ -1545,88 +2546,201 @@ namespace vr public: virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0; - // Returns true if file sync occurred (force or settings dirty) - virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0; - - virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, bool bDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; - virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; - virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, float flDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; - virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, const char *pchDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0; - + + // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory + // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or "" + virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0; + virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0; virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; }; //----------------------------------------------------------------------------- - static const char * const IVRSettings_Version = "IVRSettings_001"; + static const char * const IVRSettings_Version = "IVRSettings_003"; + + class CVRSettingHelper + { + IVRSettings *m_pSettings; + public: + CVRSettingHelper( IVRSettings *pSettings ) + { + m_pSettings = pSettings; + } + + const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) + { + return m_pSettings->GetSettingsErrorNameFromEnum( eError ); + } + + void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetBool( pchSection, pchSettingsKey, bValue, peError ); + } + + void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetInt32( pchSection, pchSettingsKey, nValue, peError ); + } + void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetFloat( pchSection, pchSettingsKey, flValue, peError ); + } + void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( pchSection, pchSettingsKey, pchValue, peError ); + } + void SetString( const std::string & sSection, const std::string & sSettingsKey, const std::string & sValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( sSection.c_str(), sSettingsKey.c_str(), sValue.c_str(), peError ); + } + + bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetBool( pchSection, pchSettingsKey, peError ); + } + int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetInt32( pchSection, pchSettingsKey, peError ); + } + float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetFloat( pchSection, pchSettingsKey, peError ); + } + void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) + { + m_pSettings->GetString( pchSection, pchSettingsKey, pchValue, unValueLen, peError ); + } + std::string GetString( const std::string & sSection, const std::string & sSettingsKey, EVRSettingsError *peError = nullptr ) + { + char buf[4096]; + vr::EVRSettingsError eError; + m_pSettings->GetString( sSection.c_str(), sSettingsKey.c_str(), buf, sizeof( buf ), &eError ); + if ( peError ) + *peError = eError; + if ( eError == vr::VRSettingsError_None ) + return buf; + else + return ""; + } + + void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveSection( pchSection, peError ); + } + void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveKeyInSection( pchSection, pchSettingsKey, peError ); + } + }; + //----------------------------------------------------------------------------- // steamvr keys - static const char * const k_pch_SteamVR_Section = "steamvr"; static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd"; static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; - static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps"; static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel"; static const char * const k_pch_SteamVR_IPD_Float = "ipd"; static const char * const k_pch_SteamVR_Background_String = "background"; + static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; - static const char * const k_pch_SteamVR_Environment_String = "environment"; static const char * const k_pch_SteamVR_GridColor_String = "gridColor"; static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; + static const char * const k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor"; static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage"; static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; - static const char * const k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit"; - static const char * const k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout"; - static const char * const k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout"; - static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode"; - static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; - static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; - static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; + static const char * const k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement"; + static const char * const k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip"; static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; - static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier"; - static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection"; - static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; + static const char * const k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; + static const char * const k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; + static const char * const k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; + static const char * const k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync"; static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; - static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; - static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; + static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; + static const char * const k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView"; + static const char * const k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView"; + static const char * const k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode"; + static const char * const k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye"; + static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; + static const char * const k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; + static const char * const k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph"; static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; - static const char * const k_pch_SteamVR_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; - static const char * const k_pch_SteamVR_UseGenericGraphcisDevice_Bool = "useGenericGraphicsDevice"; + static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; + static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; + static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; + static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; + static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; + static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; + static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; + static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; + static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; + static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; + static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; + static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; + static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; + static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; + static const char * const k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid"; + static const char * const k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; + static const char * const k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; + static const char * const k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; + static const char * const k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; + static const char * const k_pch_SteamVR_LastVersionNotice = "lastVersionNotice"; + static const char * const k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB"; + static const char * const k_pch_SteamVR_CustomIconStyle_String = "customIconStyle"; + static const char * const k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle"; + static const char * const k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate"; + static const char * const k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority"; + static const char * const k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2"; + static const char * const k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption"; + static const char * const k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches"; + //----------------------------------------------------------------------------- + // direct mode keys + static const char * const k_pch_DirectMode_Section = "direct_mode"; + static const char * const k_pch_DirectMode_Enable_Bool = "enable"; + static const char * const k_pch_DirectMode_Count_Int32 = "count"; + static const char * const k_pch_DirectMode_EdidVid_Int32 = "edidVid"; + static const char * const k_pch_DirectMode_EdidPid_Int32 = "edidPid"; //----------------------------------------------------------------------------- // lighthouse keys - static const char * const k_pch_Lighthouse_Section = "driver_lighthouse"; static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; + static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; - static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; - static const char * const k_pch_Lighthouse_LighthouseName_String = "lighthousename"; - static const char * const k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; - static const char * const k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; + static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; + static const char * const k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations"; + static const char * const k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; //----------------------------------------------------------------------------- // null keys - static const char * const k_pch_Null_Section = "driver_null"; - static const char * const k_pch_Null_EnableNullDriver_Bool = "enable"; static const char * const k_pch_Null_SerialNumber_String = "serialNumber"; static const char * const k_pch_Null_ModelNumber_String = "modelNumber"; static const char * const k_pch_Null_WindowX_Int32 = "windowX"; @@ -1638,10 +2752,16 @@ namespace vr static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency"; + //----------------------------------------------------------------------------- + // Windows MR keys + static const char * const k_pch_WindowsMR_Section = "driver_holographic"; + //----------------------------------------------------------------------------- // user interface keys static const char * const k_pch_UserInterface_Section = "userinterface"; static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; + static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; + static const char * const k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots"; static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; @@ -1664,12 +2784,11 @@ namespace vr //----------------------------------------------------------------------------- // perf keys static const char * const k_pch_Perf_Section = "perfcheck"; - static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; - static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; - static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; + static const char * const k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; static const char * const k_pch_Perf_TestData_Float = "perfTestData"; + static const char * const k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; //----------------------------------------------------------------------------- // collision bounds keys @@ -1679,10 +2798,12 @@ namespace vr static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; + static const char * const k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight"; static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; + static const char * const k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport"; //----------------------------------------------------------------------------- // camera keys @@ -1695,37 +2816,120 @@ namespace vr static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; + static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; + static const char * const k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; //----------------------------------------------------------------------------- // audio keys static const char * const k_pch_audio_Section = "audio"; - static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; - static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice"; - static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; - static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; - static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice"; + static const char * const k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice"; + static const char * const k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride"; + static const char * const k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride"; + static const char * const k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName"; + static const char * const k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice"; + static const char * const k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride"; + static const char * const k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride"; + static const char * const k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName"; + static const char * const k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror"; + static const char * const k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice"; + static const char * const k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName"; + static const char * const k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; + static const char * const k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice"; + static const char * const k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume"; + static const char * const k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; + //----------------------------------------------------------------------------- + // power management keys + static const char * const k_pch_Power_Section = "power"; + static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; + static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; + static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; + static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; + static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; + static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; + + //----------------------------------------------------------------------------- + // dashboard keys + static const char * const k_pch_Dashboard_Section = "dashboard"; + static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; + static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; + static const char * const k_pch_Dashboard_Position = "position"; + static const char * const k_pch_Dashboard_DesktopScale = "desktopScale"; + static const char * const k_pch_Dashboard_DashboardScale = "dashboardScale"; + //----------------------------------------------------------------------------- // model skin keys static const char * const k_pch_modelskin_Section = "modelskins"; + //----------------------------------------------------------------------------- + // driver keys - These could be checked in any driver_ section + static const char * const k_pch_Driver_Enable_Bool = "enable"; + static const char * const k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode"; + static const char * const k_pch_Driver_LoadPriority_Int32 = "loadPriority"; + + //----------------------------------------------------------------------------- + // web interface keys + static const char* const k_pch_WebInterface_Section = "WebInterface"; + + //----------------------------------------------------------------------------- + // vrwebhelper keys + static const char* const k_pch_VRWebHelper_Section = "VRWebHelper"; + static const char* const k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; + static const char* const k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; + + //----------------------------------------------------------------------------- + // 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_BindingLegacyAPISuffix_String = "_legacy"; + static const char* const k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput"; + static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + static const char* const k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL"; + static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + static const char* const k_pch_App_DominantHand_Int32 = "DominantHand"; + static const char* const k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK"; + + //----------------------------------------------------------------------------- + // configuration for trackers + static const char * const k_pch_Trackers_Section = "trackers"; + + //----------------------------------------------------------------------------- + // configuration for desktop UI windows + static const char * const k_pch_DesktopUI_Section = "DesktopUI"; + + //----------------------------------------------------------------------------- + // Last known keys for righting recovery + static const char * const k_pch_LastKnown_Section = "LastKnown"; + static const char* const k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; + static const char* const k_pch_LastKnown_HMDModel_String = "HMDModel"; + + //----------------------------------------------------------------------------- + // Dismissed warnings + static const char * const k_pch_DismissedWarnings_Section = "DismissedWarnings"; + + //----------------------------------------------------------------------------- + // Input Settings + static const char * const k_pch_Input_Section = "input"; + static const char* const k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation"; + static const char* const k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation"; + static const char* const k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone"; + + //----------------------------------------------------------------------------- + // Log of GPU performance + static const char * const k_pch_GpuSpeed_Section = "GpuSpeed"; + } // namespace vr // ivrchaperone.h namespace vr { -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +#pragma pack( push, 8 ) enum ChaperoneCalibrationState { @@ -1740,7 +2944,7 @@ enum ChaperoneCalibrationState // Errors ChaperoneCalibrationState_Error = 200, // The UniverseID is invalid - ChaperoneCalibrationState_Error_BaseStationUninitalized = 201, // Tracking center hasn't be calibrated for at least one of the base stations + ChaperoneCalibrationState_Error_BaseStationUninitialized = 201, // Tracking center hasn't be calibrated for at least one of the base stations ChaperoneCalibrationState_Error_BaseStationConflict = 202, // Tracking center is calibrated, but base stations disagree on the tracking space ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, // Play Area hasn't been calibrated for the current tracking center ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, // Collision Bounds haven't been calibrated for the current tracking center @@ -1852,9 +3056,12 @@ class IVRChaperoneSetup /** Sets the Play Area in the working copy. */ virtual void SetWorkingPlayAreaSize( float sizeX, float sizeZ ) = 0; - /** Sets the Collision Bounds in the working copy. */ + /** Sets the Collision Bounds in the working copy. Note: ceiling height is ignored. */ virtual void SetWorkingCollisionBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0; + /** Sets the Collision Bounds in the working copy. */ + virtual void SetWorkingPerimeter( VR_ARRAY_COUNT( unPointCount ) HmdVector2_t *pPointBuffer, uint32_t unPointCount ) = 0; + /** Sets the preferred seated position in the working copy. */ virtual void SetWorkingSeatedZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatSeatedZeroPoseToRawTrackingPose ) = 0; @@ -1867,17 +3074,22 @@ class IVRChaperoneSetup /** Returns the preferred seated position. */ virtual bool GetLiveSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0; - virtual void SetWorkingCollisionBoundsTagsInfo( VR_ARRAY_COUNT(unTagCount) uint8_t *pTagsBuffer, uint32_t unTagCount ) = 0; - virtual bool GetLiveCollisionBoundsTagsInfo( VR_OUT_ARRAY_COUNT(punTagCount) uint8_t *pTagsBuffer, uint32_t *punTagCount ) = 0; - - virtual bool SetWorkingPhysicalBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0; - virtual bool GetLivePhysicalBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0; - virtual bool ExportLiveToBuffer( VR_OUT_STRING() char *pBuffer, uint32_t *pnBufferLength ) = 0; virtual bool ImportFromBufferToWorking( const char *pBuffer, uint32_t nImportFlags ) = 0; + + /** Shows the chaperone data in the working set to preview in the compositor.*/ + virtual void ShowWorkingSetPreview() = 0; + + /** Hides the chaperone data in the working set to preview in the compositor (if it was visible).*/ + virtual void HideWorkingSetPreview() = 0; + + /** Fire an event that the tracking system can use to know room setup is about to begin. This lets the tracking + * system make any last minute adjustments that should be incorporated into the new setup. If the user is adjusting + * live in HMD using a tweak tool, keep in mind that calling this might cause the user to see the room jump. */ + virtual void RoomSetupStarting() = 0; }; -static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; +static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_006"; } @@ -1886,16 +3098,7 @@ static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; namespace vr { -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +#pragma pack( push, 8 ) /** Errors that can occur with the VR compositor */ enum EVRCompositorError @@ -1910,49 +3113,17 @@ enum EVRCompositorError VRCompositorError_TextureUsesUnsupportedFormat = 105, VRCompositorError_SharedTexturesNotSupported = 106, VRCompositorError_IndexOutOfRange = 107, + VRCompositorError_AlreadySubmitted = 108, + VRCompositorError_InvalidBounds = 109, + VRCompositorError_AlreadySet = 110, }; -const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01; -const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02; - -/** Provides a single frame's timing information to the app */ -struct Compositor_FrameTiming +/** Timing mode passed to SetExplicitTimingMode(); see that function for documentation */ +enum EVRCompositorTimingMode { - uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming ) - uint32_t m_nFrameIndex; - uint32_t m_nNumFramePresents; // number of times this frame was presented - uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out - uint32_t m_nReprojectionFlags; - - /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */ - double m_flSystemTimeInSeconds; - - /** These times may include work from other processes due to OS scheduling. - * The fewer packets of work these are broken up into, the less likely this will happen. - * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started - * processing that work earlier in the frame. */ - float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit) - float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window) - float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work - float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc. - float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame - float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time) - - /** Miscellaneous measured intervals. */ - float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses - float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long) - float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure) - float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue) - - /** The following are all relative to this frame's SystemTimeInSeconds */ - float m_flWaitGetPosesCalledMs; - float m_flNewPosesReadyMs; - float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit - float m_flCompositorUpdateStartMs; - float m_flCompositorUpdateEndMs; - float m_flCompositorRenderStartMs; - - vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame + VRCompositorTimingMode_Implicit = 0, + VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1, + VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2, }; /** Cumulative stats for current application. These are not cleared until a new app connects, @@ -1985,6 +3156,52 @@ struct Compositor_CumulativeStats uint32_t m_nNumReprojectedFramesTimedOut; }; +struct Compositor_StageRenderSettings +{ + /** Primary color is applied as a tint to (i.e. multiplied with) the model's texture */ + HmdColor_t m_PrimaryColor; + HmdColor_t m_SecondaryColor; + + /** Vignette radius is in meters and is used to fade to the specified secondary solid color over + * that 3D distance from the origin of the playspace. */ + float m_flVignetteInnerRadius; + float m_flVignetteOuterRadius; + + /** Fades to the secondary color based on view incidence. This variable controls the linearity + * of the effect. It is mutually exclusive with vignette. Additionally, it treats the mesh as faceted. */ + float m_flFresnelStrength; + + /** Controls backface culling. */ + bool m_bBackfaceCulling; + + /** Converts the render model's texture to luma and applies to rgb equally. This is useful to + * combat compression artifacts that can occur on desaturated source material. */ + bool m_bGreyscale; + + /** Renders mesh as a wireframe. */ + bool m_bWireframe; +}; + +static inline Compositor_StageRenderSettings DefaultStageRenderSettings() +{ + Compositor_StageRenderSettings settings; + settings.m_PrimaryColor.r = 1.0f; + settings.m_PrimaryColor.g = 1.0f; + settings.m_PrimaryColor.b = 1.0f; + settings.m_PrimaryColor.a = 1.0f; + settings.m_SecondaryColor.r = 1.0f; + settings.m_SecondaryColor.g = 1.0f; + settings.m_SecondaryColor.b = 1.0f; + settings.m_SecondaryColor.a = 1.0f; + settings.m_flVignetteInnerRadius = 0.0f; + settings.m_flVignetteOuterRadius = 0.0f; + settings.m_flFresnelStrength = 0.0f; + settings.m_bBackfaceCulling = false; + settings.m_bGreyscale = false; + settings.m_bWireframe = false; + return settings; +} + #pragma pack( pop ) /** Allows the application to interact with the compositor */ @@ -1997,9 +3214,16 @@ class IVRCompositor /** Gets current tracking space returned by WaitGetPoses */ virtual ETrackingUniverseOrigin GetTrackingSpace() = 0; - /** Returns pose(s) to use to render scene (and optionally poses predicted two frames out for gameplay). */ - virtual EVRCompositorError WaitGetPoses( VR_ARRAY_COUNT(unRenderPoseArrayCount) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount, - VR_ARRAY_COUNT(unGamePoseArrayCount) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0; + /** Scene applications should call this function to get poses to render with (and optionally poses predicted an additional frame out to use for gameplay). + * This function will block until "running start" milliseconds before the start of the frame, and should be called at the last moment before needing to + * start rendering. + * + * Return codes: + * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene) + * - DoNotHaveFocus (some other app has taken focus - this will throttle the call to 10hz to reduce the impact on that app) + */ + virtual EVRCompositorError WaitGetPoses( VR_ARRAY_COUNT( unRenderPoseArrayCount ) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount, + VR_ARRAY_COUNT( unGamePoseArrayCount ) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0; /** Get the last set of poses returned by WaitGetPoses. */ virtual EVRCompositorError GetLastPoses( VR_ARRAY_COUNT( unRenderPoseArrayCount ) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount, @@ -2015,6 +3239,15 @@ class IVRCompositor * * OpenGL dirty state: * glBindTexture + * + * Return codes: + * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene) + * - DoNotHaveFocus (some other app has taken focus) + * - TextureIsOnWrongDevice (application did not use proper AdapterIndex - see IVRSystem.GetDXGIOutputInfo) + * - SharedTexturesNotSupported (application needs to call CreateDXGIFactory1 or later before creating DX device) + * - TextureUsesUnsupportedFormat (scene textures must be compatible with DXGI sharing rules - e.g. uncompressed, no mips, etc.) + * - InvalidTexture (usually means bad arguments passed in) + * - AlreadySubmitted (app has submitted two left textures or two right textures in a single frame - i.e. before calling WaitGetPoses again) */ virtual EVRCompositorError Submit( EVREye eEye, const Texture_t *pTexture, const VRTextureBounds_t* pBounds = 0, EVRSubmitFlags nSubmitFlags = Submit_Default ) = 0; @@ -2033,6 +3266,10 @@ class IVRCompositor * Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function. */ virtual bool GetFrameTiming( Compositor_FrameTiming *pTiming, uint32_t unFramesAgo = 0 ) = 0; + /** Interface for copying a range of timing data. Frames are returned in ascending order (oldest to newest) with the last being the most recent frame. + * Only the first entry's m_nSize needs to be set, as the rest will be inferred from that. Returns total number of entries filled out. */ + virtual uint32_t GetFrameTimings( VR_ARRAY_COUNT( nFrames ) Compositor_FrameTiming *pTiming, uint32_t nFrames ) = 0; + /** Returns the time in seconds left in the current (as identified by FrameTiming's frameIndex) frame. * Due to "running start", this value may roll over to the next frame before ever reaching 0.0. */ virtual float GetFrameTimeRemaining() = 0; @@ -2045,9 +3282,15 @@ class IVRCompositor * would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). Values are in un-premultiplied alpha space. */ virtual void FadeToColor( float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground = false ) = 0; + /** Get current fade color value. */ + virtual HmdColor_t GetCurrentFadeColor( bool bBackground = false ) = 0; + /** Fading the Grid in or out in fSeconds */ virtual void FadeGrid( float fSeconds, bool bFadeIn ) = 0; + /** Get current alpha value of grid. */ + virtual float GetCurrentGridAlpha() = 0; + /** Override the skybox used in the compositor (e.g. for during level loads when the app can't feed scene images fast enough) * Order is Front, Back, Left, Right, Top, Bottom. If only a single texture is passed, it is assumed in lat-long format. * If two are passed, it is assumed a lat-long stereo pair. */ @@ -2080,16 +3323,17 @@ class IVRCompositor /** Returns true if the current process has the scene focus */ virtual bool CanRenderScene() = 0; - /** Creates a window on the primary monitor to display what is being shown in the headset. */ + /** DEPRECATED: Opens the headset view (as either a window or docked widget depending on user's preferences) that displays what the user + * sees in the headset. */ virtual void ShowMirrorWindow() = 0; - /** Closes the mirror window. */ + /** DEPRECATED: Closes the headset view, either as a window or docked widget. */ virtual void HideMirrorWindow() = 0; - /** Returns true if the mirror window is shown. */ + /** DEPRECATED: Returns true if the headset view (either as a window or docked widget) is shown. */ virtual bool IsMirrorWindowVisible() = 0; - /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */ + /** Writes back buffer and stereo left/right pair from the application to a 'screenshots' folder in the SteamVR runtime root. */ virtual void CompositorDumpImages() = 0; /** Let an app know it should be rendering with low resources. */ @@ -2104,36 +3348,155 @@ class IVRCompositor /** Temporarily suspends rendering (useful for finer control over scene transitions). */ virtual void SuspendRendering( bool bSuspend ) = 0; - /** Opens a shared D3D11 texture with the undistorted composited image for each eye. */ + /** Opens a shared D3D11 texture with the undistorted composited image for each eye. Use ReleaseMirrorTextureD3D11 when finished + * instead of calling Release on the resource itself. */ virtual vr::EVRCompositorError GetMirrorTextureD3D11( vr::EVREye eEye, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView ) = 0; + virtual void ReleaseMirrorTextureD3D11( void *pD3D11ShaderResourceView ) = 0; /** Access to mirror textures from OpenGL. */ virtual vr::EVRCompositorError GetMirrorTextureGL( vr::EVREye eEye, vr::glUInt_t *pglTextureId, vr::glSharedTextureHandle_t *pglSharedTextureHandle ) = 0; virtual bool ReleaseSharedGLTexture( vr::glUInt_t glTextureId, vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0; virtual void LockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0; virtual void UnlockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0; + + /** [Vulkan Only] + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing + * null. The string will be a space separated list of-required instance extensions to enable in VkCreateInstance */ + virtual uint32_t GetVulkanInstanceExtensionsRequired( VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; + + /** [Vulkan only] + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing + * null. The string will be a space separated list of required device extensions to enable in VkCreateDevice */ + virtual uint32_t GetVulkanDeviceExtensionsRequired( VkPhysicalDevice_T *pPhysicalDevice, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; + + /** [ Vulkan/D3D12 Only ] + * There are two purposes for SetExplicitTimingMode: + * 1. To get a more accurate GPU timestamp for when the frame begins in Vulkan/D3D12 applications. + * 2. (Optional) To avoid having WaitGetPoses access the Vulkan queue so that the queue can be accessed from + * another thread while WaitGetPoses is executing. + * + * More accurate GPU timestamp for the start of the frame is achieved by the application calling + * SubmitExplicitTimingData immediately before its first submission to the Vulkan/D3D12 queue. + * This is more accurate because normally this GPU timestamp is recorded during WaitGetPoses. In D3D11, + * WaitGetPoses queues a GPU timestamp write, but it does not actually get submitted to the GPU until the + * application flushes. By using SubmitExplicitTimingData, the timestamp is recorded at the same place for + * Vulkan/D3D12 as it is for D3D11, resulting in a more accurate GPU time measurement for the frame. + * + * Avoiding WaitGetPoses accessing the Vulkan queue can be achieved using SetExplicitTimingMode as well. If this is desired, + * the application should set the timing mode to Explicit_ApplicationPerformsPostPresentHandoff and *MUST* call PostPresentHandoff + * itself. If these conditions are met, then WaitGetPoses is guaranteed not to access the queue. Note that PostPresentHandoff + * and SubmitExplicitTimingData will access the queue, so only WaitGetPoses becomes safe for accessing the queue from another + * thread. */ + virtual void SetExplicitTimingMode( EVRCompositorTimingMode eTimingMode ) = 0; + + /** [ Vulkan/D3D12 Only ] + * Submit explicit timing data. When SetExplicitTimingMode is true, this must be called immediately before + * the application's first vkQueueSubmit (Vulkan) or ID3D12CommandQueue::ExecuteCommandLists (D3D12) of each frame. + * This function will insert a GPU timestamp write just before the application starts its rendering. This function + * will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread. + * Returns VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled. */ + virtual EVRCompositorError SubmitExplicitTimingData() = 0; + + /** Indicates whether or not motion smoothing is enabled by the user settings. + * If you want to know if motion smoothing actually triggered due to a late frame, check Compositor_FrameTiming + * m_nReprojectionFlags & VRCompositor_ReprojectionMotion instead. */ + virtual bool IsMotionSmoothingEnabled() = 0; + + /** Indicates whether or not motion smoothing is supported by the current hardware. */ + virtual bool IsMotionSmoothingSupported() = 0; + + /** Indicates whether or not the current scene focus app is currently loading. This is inferred from its use of FadeGrid to + * explicitly fade to the compositor to cover up the fact that it cannot render at a sustained full framerate during this time. */ + virtual bool IsCurrentSceneFocusAppLoading() = 0; + + /** Override the stage model used in the compositor to replace the grid. RenderModelPath is a full path the an OBJ file to load. + * This file will be loaded asynchronously from disk and uploaded to the gpu by the runtime. Once ready for rendering, the + * VREvent StageOverrideReady will be sent. Use FadeToGrid to reveal. Call ClearStageOverride to free the associated resources when finished. */ + virtual EVRCompositorError SetStageOverride_Async( const char *pchRenderModelPath, const HmdMatrix34_t *pTransform = 0, + const Compositor_StageRenderSettings *pRenderSettings = 0, uint32_t nSizeOfRenderSettings = 0 ) = 0; + + /** Resets the stage to its default user specified setting. */ + virtual void ClearStageOverride() = 0; + + /** Returns true if pBenchmarkResults is filled it. Sets pBenchmarkResults with the result of the compositor benchmark. + * nSizeOfBenchmarkResults should be set to sizeof(Compositor_BenchmarkResults) */ + virtual bool GetCompositorBenchmarkResults( Compositor_BenchmarkResults *pBenchmarkResults, uint32_t nSizeOfBenchmarkResults ) = 0; + + /** Returns the frame id associated with the poses last returned by WaitGetPoses. Deltas between IDs correspond to number of headset vsync intervals. */ + virtual EVRCompositorError GetLastPosePredictionIDs( uint32_t *pRenderPosePredictionID, uint32_t *pGamePosePredictionID ) = 0; + + /** Get the most up-to-date predicted (or recorded - up to 100ms old) set of poses for a given frame id. */ + virtual EVRCompositorError GetPosesForFrame( uint32_t unPosePredictionID, VR_ARRAY_COUNT( unPoseArrayCount ) TrackedDevicePose_t* pPoseArray, uint32_t unPoseArrayCount ) = 0; }; -static const char * const IVRCompositor_Version = "IVRCompositor_016"; +static const char * const IVRCompositor_Version = "IVRCompositor_026"; } // namespace vr +// ivrheadsetview.h +namespace vr +{ + enum HeadsetViewMode_t + { + HeadsetViewMode_Left = 0, + HeadsetViewMode_Right, + HeadsetViewMode_Both + }; + + class IVRHeadsetView + { + public: + /** Sets the resolution in pixels to render the headset view. These values are clamped to k_unHeadsetViewMaxWidth + * and k_unHeadsetViewMaxHeight respectively. For cropped views, the rendered output will be fit to aspect ratio + * defined by the the specified dimensions. For uncropped views, the caller should use GetHeadsetViewAspectRation + * to adjust the requested render size to avoid squashing or stretching, and then apply letterboxing to compensate + * when displaying the results. */ + virtual void SetHeadsetViewSize( uint32_t nWidth, uint32_t nHeight ) = 0; + + /** Gets the current resolution used to render the headset view. */ + virtual void GetHeadsetViewSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0; + + /** Set the mode used to render the headset view. */ + virtual void SetHeadsetViewMode( HeadsetViewMode_t eHeadsetViewMode ) = 0; + + /** Get the current mode used to render the headset view. */ + virtual HeadsetViewMode_t GetHeadsetViewMode() = 0; + + /** Set whether or not the headset view should be rendered cropped to hide the hidden area mesh or not. */ + virtual void SetHeadsetViewCropped( bool bCropped ) = 0; + + /** Get the current cropping status of the headset view. */ + virtual bool GetHeadsetViewCropped() = 0; + + /** Get the aspect ratio (width:height) of the uncropped headset view (accounting for the current set mode). */ + virtual float GetHeadsetViewAspectRatio() = 0; + + /** Set the range [0..1] that the headset view blends across the stereo overlapped area in cropped both mode. */ + virtual void SetHeadsetViewBlendRange( float flStartPct, float flEndPct ) = 0; + + /** Get the current range [0..1] that the headset view blends across the stereo overlapped area in cropped both mode. */ + virtual void GetHeadsetViewBlendRange( float *pStartPct, float *pEndPct ) = 0; + }; + + static const uint32_t k_unHeadsetViewMaxWidth = 3840; + static const uint32_t k_unHeadsetViewMaxHeight = 2160; + static const char * const k_pchHeadsetViewOverlayKey = "system.HeadsetView"; + + static const char * const IVRHeadsetView_Version = "IVRHeadsetView_001"; + + /** Returns the current IVRHeadsetView pointer or NULL the interface could not be found. */ + VR_INTERFACE vr::IVRHeadsetView *VR_CALLTYPE VRHeadsetView(); + +} // namespace vr + + // ivrnotifications.h namespace vr { -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +#pragma pack( push, 8 ) // Used for passing graphic data struct NotificationBitmap_t @@ -2144,7 +3507,7 @@ struct NotificationBitmap_t , m_nHeight( 0 ) , m_nBytesPerPixel( 0 ) { - }; + } void *m_pImageData; int32_t m_nWidth; @@ -2229,67 +3592,103 @@ namespace vr static const uint32_t k_unVROverlayMaxNameLength = 128; /** The maximum number of overlays that can exist in the system at one time. */ - static const uint32_t k_unMaxOverlayCount = 64; + static const uint32_t k_unMaxOverlayCount = 128; + + /** The maximum number of overlay intersection mask primitives per overlay */ + static const uint32_t k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; /** Types of input supported by VR Overlays */ enum VROverlayInputMethod { VROverlayInputMethod_None = 0, // No input events will be generated automatically for this overlay VROverlayInputMethod_Mouse = 1, // Tracked controllers will get mouse events automatically + // VROverlayInputMethod_DualAnalog = 2, // No longer supported }; /** Allows the caller to figure out which overlay transform getter to call. */ enum VROverlayTransformType { + VROverlayTransform_Invalid = -1, VROverlayTransform_Absolute = 0, VROverlayTransform_TrackedDeviceRelative = 1, VROverlayTransform_SystemOverlay = 2, VROverlayTransform_TrackedComponent = 3, + VROverlayTransform_Cursor = 4, + VROverlayTransform_DashboardTab = 5, + VROverlayTransform_DashboardThumb = 6, + VROverlayTransform_Mountable = 7, }; /** Overlay control settings */ enum VROverlayFlags { - VROverlayFlags_None = 0, - - // The following only take effect when rendered using the high quality render path (see SetHighQualityOverlay). - VROverlayFlags_Curved = 1, - VROverlayFlags_RGSS4X = 2, - // Set this flag on a dashboard overlay to prevent a tab from showing up for that overlay - VROverlayFlags_NoDashboardTab = 3, - - // Set this flag on a dashboard that is able to deal with gamepad focus events - VROverlayFlags_AcceptsGamepadEvents = 4, + VROverlayFlags_NoDashboardTab = 1 << 3, - // Indicates that the overlay should dim/brighten to show gamepad focus - VROverlayFlags_ShowGamepadFocus = 5, + // When this is set the overlay will receive VREvent_ScrollDiscrete events like a mouse wheel. + // Requires mouse input mode. + VROverlayFlags_SendVRDiscreteScrollEvents = 1 << 6, - // When in VROverlayInputMethod_Mouse you can optionally enable sending VRScroll_t - VROverlayFlags_SendVRScrollEvents = 6, - VROverlayFlags_SendVRTouchpadEvents = 7, + // Indicates that the overlay would like to receive + VROverlayFlags_SendVRTouchpadEvents = 1 << 7, // If set this will render a vertical scroll wheel on the primary controller, // only needed if not using VROverlayFlags_SendVRScrollEvents but you still want to represent a scroll wheel - VROverlayFlags_ShowTouchPadScrollWheel = 8, + VROverlayFlags_ShowTouchPadScrollWheel = 1 << 8, // If this is set ownership and render access to the overlay are transferred // to the new scene process on a call to IVRApplications::LaunchInternalProcess - VROverlayFlags_TransferOwnershipToInternalProcess = 9, + VROverlayFlags_TransferOwnershipToInternalProcess = 1 << 9, // If set, renders 50% of the texture in each eye, side by side - VROverlayFlags_SideBySide_Parallel = 10, // Texture is left/right - VROverlayFlags_SideBySide_Crossed = 11, // Texture is crossed and right/left + VROverlayFlags_SideBySide_Parallel = 1 << 10, // Texture is left/right + VROverlayFlags_SideBySide_Crossed = 1 << 11, // Texture is crossed and right/left - VROverlayFlags_Panorama = 12, // Texture is a panorama - VROverlayFlags_StereoPanorama = 13, // Texture is a stereo panorama + VROverlayFlags_Panorama = 1 << 12, // Texture is a panorama + VROverlayFlags_StereoPanorama = 1 << 13, // Texture is a stereo panorama // If this is set on an overlay owned by the scene application that overlay // will be sorted with the "Other" overlays on top of all other scene overlays - VROverlayFlags_SortWithNonSceneOverlays = 14, - }; + VROverlayFlags_SortWithNonSceneOverlays = 1 << 14, - struct VROverlayIntersectionParams_t + // If set, the overlay will be shown in the dashboard, otherwise it will be hidden. + VROverlayFlags_VisibleInDashboard = 1 << 15, + + // If this is set and the overlay's input method is not none, the system-wide laser mouse + // mode will be activated whenever this overlay is visible. + VROverlayFlags_MakeOverlaysInteractiveIfVisible = 1 << 16, + + // If this is set the overlay will receive smooth VREvent_ScrollSmooth that emulate trackpad scrolling. + // Requires mouse input mode. + VROverlayFlags_SendVRSmoothScrollEvents = 1 << 17, + + // If this is set, the overlay texture will be protected content, preventing unauthorized reads. + VROverlayFlags_ProtectedContent = 1 << 18, + + // If this is set, the laser mouse splat will not be drawn over this overlay. The overlay will + // be responsible for drawing its own "cursor". + VROverlayFlags_HideLaserIntersection = 1 << 19, + + // If this is set, clicking away from the overlay will cause it to receive a VREvent_Modal_Cancel event. + // This is ignored for dashboard overlays. + VROverlayFlags_WantsModalBehavior = 1 << 20, + + // If this is set, alpha composition assumes the texture is pre-multiplied + VROverlayFlags_IsPremultiplied = 1 << 21, + }; + + enum VRMessageOverlayResponse + { + VRMessageOverlayResponse_ButtonPress_0 = 0, + VRMessageOverlayResponse_ButtonPress_1 = 1, + VRMessageOverlayResponse_ButtonPress_2 = 2, + VRMessageOverlayResponse_ButtonPress_3 = 3, + VRMessageOverlayResponse_CouldntFindSystemOverlay = 4, + VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay= 5, + VRMessageOverlayResponse_ApplicationQuit = 6 + }; + + struct VROverlayIntersectionParams_t { HmdVector3_t vSource; HmdVector3_t vDirection; @@ -2319,17 +3718,47 @@ namespace vr k_EGamepadTextInputLineModeMultipleLines = 1 }; - /** Directions for changing focus between overlays with the gamepad */ - enum EOverlayDirection + enum EVROverlayIntersectionMaskPrimitiveType { - OverlayDirection_Up = 0, - OverlayDirection_Down = 1, - OverlayDirection_Left = 2, - OverlayDirection_Right = 3, - - OverlayDirection_Count = 4, + OverlayIntersectionPrimitiveType_Rectangle, + OverlayIntersectionPrimitiveType_Circle, + }; + + struct IntersectionMaskRectangle_t + { + float m_flTopLeftX; + float m_flTopLeftY; + float m_flWidth; + float m_flHeight; + }; + + struct IntersectionMaskCircle_t + { + float m_flCenterX; + float m_flCenterY; + float m_flRadius; + }; + + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py and openvr_api_flat.h.py */ + typedef union + { + IntersectionMaskRectangle_t m_Rectangle; + IntersectionMaskCircle_t m_Circle; + } VROverlayIntersectionMaskPrimitive_Data_t; + + struct VROverlayIntersectionMaskPrimitive_t + { + EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType; + VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; }; + enum EKeyboardFlags + { + KeyboardFlag_Minimal = 1 << 0, // makes the keyboard send key events immediately instead of accumulating a buffer + KeyboardFlag_Modal = 2 << 0, // makes the keyboard take all focus and dismiss when clicking off the panel + }; + + class IVROverlay { public: @@ -2342,23 +3771,12 @@ namespace vr virtual EVROverlayError FindOverlay( const char *pchOverlayKey, VROverlayHandle_t * pOverlayHandle ) = 0; /** Creates a new named overlay. All overlays start hidden and with default settings. */ - virtual EVROverlayError CreateOverlay( const char *pchOverlayKey, const char *pchOverlayFriendlyName, VROverlayHandle_t * pOverlayHandle ) = 0; + virtual EVROverlayError CreateOverlay( const char *pchOverlayKey, const char *pchOverlayName, VROverlayHandle_t * pOverlayHandle ) = 0; /** Destroys the specified overlay. When an application calls VR_Shutdown all overlays created by that app are * automatically destroyed. */ virtual EVROverlayError DestroyOverlay( VROverlayHandle_t ulOverlayHandle ) = 0; - /** Specify which overlay to use the high quality render path. This overlay will be composited in during the distortion pass which - * results in it drawing on top of everything else, but also at a higher quality as it samples the source texture directly rather than - * rasterizing into each eye's render texture first. Because if this, only one of these is supported at any given time. It is most useful - * for overlays that are expected to take up most of the user's view (e.g. streaming video). - * This mode does not support mouse input to your overlay. */ - virtual EVROverlayError SetHighQualityOverlay( VROverlayHandle_t ulOverlayHandle ) = 0; - - /** Returns the overlay handle of the current overlay being rendered using the single high quality overlay render path. - * Otherwise it will return k_ulOverlayHandleInvalid. */ - virtual vr::VROverlayHandle_t GetHighQualityOverlay() = 0; - /** Fills the provided buffer with the string key of the overlay. Returns the size of buffer required to store the key, including * the terminating null character. k_unVROverlayMaxKeyLength will be enough bytes to fit the string. */ virtual uint32_t GetOverlayKey( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0; @@ -2367,6 +3785,9 @@ namespace vr * the terminating null character. k_unVROverlayMaxNameLength will be enough bytes to fit the string. */ virtual uint32_t GetOverlayName( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0; + /** set the name to use for this overlay */ + virtual EVROverlayError SetOverlayName( VROverlayHandle_t ulOverlayHandle, const char *pchName ) = 0; + /** Gets the raw image data from an overlay. Overlay image data is always returned as RGBA data, 4 bytes per pixel. If the buffer is not large enough, width and height * will be set and VROverlayError_ArrayTooSmall is returned. */ virtual EVROverlayError GetOverlayImageData( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unBufferSize, uint32_t *punWidth, uint32_t *punHeight ) = 0; @@ -2375,7 +3796,6 @@ namespace vr * of the error enum value for all valid error codes */ virtual const char *GetOverlayErrorNameFromEnum( EVROverlayError error ) = 0; - // --------------------------------------------- // Overlay rendering methods // --------------------------------------------- @@ -2393,6 +3813,9 @@ namespace vr /** Sets flag setting for a given overlay */ virtual EVROverlayError GetOverlayFlag( VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool *pbEnabled ) = 0; + /** Gets all the flags for a given overlay */ + virtual EVROverlayError GetOverlayFlags( VROverlayHandle_t ulOverlayHandle, uint32_t *pFlags ) = 0; + /** Sets the color tint of the overlay quad. Use 0.0 to 1.0 per channel. */ virtual EVROverlayError SetOverlayColor( VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue ) = 0; @@ -2431,13 +3854,12 @@ namespace vr /** Returns the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */ virtual EVROverlayError GetOverlayWidthInMeters( VROverlayHandle_t ulOverlayHandle, float *pfWidthInMeters ) = 0; - /** For high-quality curved overlays only, sets the distance range in meters from the overlay used to automatically curve - * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */ - virtual EVROverlayError SetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters ) = 0; + /** Use to draw overlay as a curved surface. Curvature is a percentage from (0..1] where 1 is a fully closed cylinder. + * For a specific radius, curvature can be computed as: overlay.width / (2 PI r). */ + virtual EVROverlayError SetOverlayCurvature( VROverlayHandle_t ulOverlayHandle, float fCurvature ) = 0; - /** For high-quality curved overlays only, gets the distance range in meters from the overlay used to automatically curve - * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */ - virtual EVROverlayError GetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float *pfMinDistanceInMeters, float *pfMaxDistanceInMeters ) = 0; + /** Returns the curvature of the overlay as a percentage from (0..1] where 1 is a fully closed cylinder. */ + virtual EVROverlayError GetOverlayCurvature( VROverlayHandle_t ulOverlayHandle, float *pfCurvature ) = 0; /** Sets the colorspace the overlay texture's data is in. Defaults to 'auto'. * If the texture needs to be resolved, you should call SetOverlayTexture with the appropriate colorspace instead. */ @@ -2472,7 +3894,20 @@ namespace vr virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, const char *pchComponentName ) = 0; /** Gets the transform information when the overlay is rendering on a component. */ - virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, char *pchComponentName, uint32_t unComponentNameSize ) = 0; + virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, VR_OUT_STRING() char *pchComponentName, uint32_t unComponentNameSize ) = 0; + + /** Gets the transform if it is relative to another overlay. Returns an error if the transform is some other type. */ + virtual vr::EVROverlayError GetOverlayTransformOverlayRelative( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t *ulOverlayHandleParent, HmdMatrix34_t *pmatParentOverlayToOverlayTransform ) = 0; + + /** Sets the transform to relative to the transform of the specified overlay. This overlays visibility will also track the parents visibility */ + virtual vr::EVROverlayError SetOverlayTransformOverlayRelative( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulOverlayHandleParent, const HmdMatrix34_t *pmatParentOverlayToOverlayTransform ) = 0; + + /** Sets the hotspot for the specified overlay when that overlay is used as a cursor. These are in texture space with 0,0 in the upper left corner of + * the texture and 1,1 in the lower right corner of the texture. */ + virtual EVROverlayError SetOverlayTransformCursor( VROverlayHandle_t ulCursorOverlayHandle, const HmdVector2_t *pvHotspot ) = 0; + + /** Gets cursor hotspot/transform for the specified overlay */ + virtual vr::EVROverlayError GetOverlayTransformCursor( VROverlayHandle_t ulOverlayHandle, HmdVector2_t *pvHotspot ) = 0; /** Shows the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */ virtual EVROverlayError ShowOverlay( VROverlayHandle_t ulOverlayHandle ) = 0; @@ -2512,31 +3947,26 @@ namespace vr * specified settings. Returns false if there is no intersection. */ virtual bool ComputeOverlayIntersection( VROverlayHandle_t ulOverlayHandle, const VROverlayIntersectionParams_t *pParams, VROverlayIntersectionResults_t *pResults ) = 0; - /** Processes mouse input from the specified controller as though it were a mouse pointed at a compositor overlay with the - * specified settings. The controller is treated like a laser pointer on the -z axis. The point where the laser pointer would - * intersect with the overlay is the mouse position, the trigger is left mouse, and the track pad is right mouse. - * - * Return true if the controller is pointed at the overlay and an event was generated. */ - virtual bool HandleControllerOverlayInteractionAsMouse( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unControllerDeviceIndex ) = 0; - /** Returns true if the specified overlay is the hover target. An overlay is the hover target when it is the last overlay "moused over" * by the virtual mouse pointer */ virtual bool IsHoverTargetOverlay( VROverlayHandle_t ulOverlayHandle ) = 0; - /** Returns the current Gamepad focus overlay */ - virtual vr::VROverlayHandle_t GetGamepadFocusOverlay() = 0; + /** Sets a list of primitives to be used for controller ray intersection + * typically the size of the underlying UI in pixels (not in world space). */ + virtual EVROverlayError SetOverlayIntersectionMask( VROverlayHandle_t ulOverlayHandle, VROverlayIntersectionMaskPrimitive_t *pMaskPrimitives, uint32_t unNumMaskPrimitives, uint32_t unPrimitiveSize = sizeof( VROverlayIntersectionMaskPrimitive_t ) ) = 0; + + /** Triggers a haptic event on the laser mouse controller for the specified overlay */ + virtual EVROverlayError TriggerLaserMouseHapticVibration( VROverlayHandle_t ulOverlayHandle, float fDurationSeconds, float fFrequency, float fAmplitude ) = 0; - /** Sets the current Gamepad focus overlay */ - virtual EVROverlayError SetGamepadFocusOverlay( VROverlayHandle_t ulNewFocusOverlay ) = 0; + /** Sets the cursor to use for the specified overlay. This will be drawn instead of the generic blob when the laser mouse is pointed at the specified overlay */ + virtual EVROverlayError SetOverlayCursor( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulCursorHandle ) = 0; - /** Sets an overlay's neighbor. This will also set the neighbor of the "to" overlay - * to point back to the "from" overlay. If an overlay's neighbor is set to invalid both - * ends will be cleared */ - virtual EVROverlayError SetOverlayNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom, VROverlayHandle_t ulTo ) = 0; + /** Sets the override cursor position to use for this overlay in overlay mouse coordinates. This position will be used to draw the cursor + * instead of whatever the laser mouse cursor position is. */ + virtual EVROverlayError SetOverlayCursorPositionOverride( VROverlayHandle_t ulOverlayHandle, const HmdVector2_t *pvCursor ) = 0; - /** Changes the Gamepad focus from one overlay to one of its neighbors. Returns VROverlayError_NoNeighbor if there is no - * neighbor in that direction */ - virtual EVROverlayError MoveGamepadFocusToNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom ) = 0; + /** Clears the override cursor position for this overlay */ + virtual EVROverlayError ClearOverlayCursorPositionOverride( VROverlayHandle_t ulOverlayHandle ) = 0; // --------------------------------------------- // Overlay texture methods @@ -2554,7 +3984,7 @@ namespace vr /** Separate interface for providing the data as a stream of bytes, but there is an upper bound on data * that can be sent. This function can only be called by the overlay's renderer process. */ - virtual EVROverlayError SetOverlayRaw( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unDepth ) = 0; + virtual EVROverlayError SetOverlayRaw( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unBytesPerPixel ) = 0; /** Separate interface for providing the image through a filename: can be png or jpg, and should not be bigger than 1920x1080. * This function can only be called by the overlay's renderer process */ @@ -2570,7 +4000,7 @@ namespace vr * pNativeTextureHandle is an OUTPUT, it will be a pointer to a ID3D11ShaderResourceView *. * pNativeTextureRef is an INPUT and should be a ID3D11Resource *. The device used by pNativeTextureRef will be used to bind pNativeTextureHandle. */ - virtual EVROverlayError GetOverlayTexture( VROverlayHandle_t ulOverlayHandle, void **pNativeTextureHandle, void *pNativeTextureRef, uint32_t *pWidth, uint32_t *pHeight, uint32_t *pNativeFormat, EGraphicsAPIConvention *pAPI, EColorSpace *pColorSpace ) = 0; + virtual EVROverlayError GetOverlayTexture( VROverlayHandle_t ulOverlayHandle, void **pNativeTextureHandle, void *pNativeTextureRef, uint32_t *pWidth, uint32_t *pHeight, uint32_t *pNativeFormat, ETextureType *pAPIType, EColorSpace *pColorSpace, VRTextureBounds_t *pTextureBounds ) = 0; /** Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object, * so only do it once you stop rendering this texture. @@ -2609,10 +4039,16 @@ namespace vr // Keyboard methods // --------------------------------------------- - /** Show the virtual keyboard to accept input **/ - virtual EVROverlayError ShowKeyboard( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue ) = 0; + /** Show the virtual keyboard to accept input. In most cases, you should pass KeyboardFlag_Modal to enable modal overlay + * behavior on the keyboard itself. See EKeyboardFlags for more. */ + virtual EVROverlayError ShowKeyboard( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, + const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, uint64_t uUserValue ) = 0; - virtual EVROverlayError ShowKeyboardForOverlay( VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue ) = 0; + /** Show the virtual keyboard to accept input for an overlay. In most cases, you should pass KeyboardFlag_Modal to enable modal + * overlay behavior on the keyboard itself. See EKeyboardFlags for more. */ + virtual EVROverlayError ShowKeyboardForOverlay( VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, + EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, const char *pchDescription, uint32_t unCharMax, + const char *pchExistingText, uint64_t uUserValue ) = 0; /** Get the text that was entered into the text input **/ virtual uint32_t GetKeyboardText( VR_OUT_STRING() char *pchText, uint32_t cchText ) = 0; @@ -2626,12 +4062,98 @@ namespace vr /** Set the position of the keyboard in overlay space by telling it to avoid a rectangle in the overlay. Rectangle coords have (0,0) in the bottom left **/ virtual void SetKeyboardPositionForOverlay( VROverlayHandle_t ulOverlayHandle, HmdRect2_t avoidRect ) = 0; + // --------------------------------------------- + // Message box methods + // --------------------------------------------- + + /** Show the message overlay. This will block and return you a result. **/ + virtual VRMessageOverlayResponse ShowMessageOverlay( const char* pchText, const char* pchCaption, const char* pchButton0Text, const char* pchButton1Text = nullptr, const char* pchButton2Text = nullptr, const char* pchButton3Text = nullptr ) = 0; + + /** If the calling process owns the overlay and it's open, this will close it. **/ + virtual void CloseMessageOverlay() = 0; }; - static const char * const IVROverlay_Version = "IVROverlay_013"; + static const char * const IVROverlay_Version = "IVROverlay_024"; } // namespace vr +// ivroverlayview.h +namespace vr +{ + struct VROverlayView_t + { + VROverlayHandle_t overlayHandle; + Texture_t texture; + VRTextureBounds_t textureBounds; + }; + + enum EDeviceType + { + DeviceType_Invalid = -1, // Invalid handle + DeviceType_DirectX11 = 0, // Handle is an ID3D11Device + DeviceType_Vulkan = 1, // Handle is a pointer to a VRVulkanDevice_t structure + }; + + struct VRVulkanDevice_t + { + VkInstance_T *m_pInstance; + VkDevice_T *m_pDevice; + VkPhysicalDevice_T *m_pPhysicalDevice; + VkQueue_T *m_pQueue; + uint32_t m_uQueueFamilyIndex; + }; + + struct VRNativeDevice_t + { + void *handle; // See EDeviceType definition above + EDeviceType eType; + }; + + class IVROverlayView + { + public: + /** Acquire an OverlayView_t from an overlay handle + * + * The overlay view can be used to sample the contents directly by a native API. The + * contents of the OverlayView_t will remain unchanged through the lifetime of the + * OverlayView_t. + * + * The caller acquires read privileges over the OverlayView_t, but should not + * write to it. + * + * AcquireOverlayView() may be called on the same ulOverlayHandle multiple times to + * refresh the image contents. In this case the caller is strongly encouraged to re-use + * the same pOverlayView for all re-acquisition calls. + * + * If the producer has not yet queued an image, AcquireOverlayView will return success, + * and the Texture_t will have the expected ETextureType. However, the Texture_t->handle + * will be nullptr. Once the producer generates the first overlay frame, Texture_t->handle + * will become a valid handle. + */ + virtual EVROverlayError AcquireOverlayView(VROverlayHandle_t ulOverlayHandle, VRNativeDevice_t *pNativeDevice, VROverlayView_t *pOverlayView, uint32_t unOverlayViewSize ) = 0; + + /** Release an acquired OverlayView_t + * + * Denotes that pOverlayView will no longer require access to the resources it acquired in + * all previous calls to AcquireOverlayView(). + * + * All OverlayView_t*'s provided to AcquireOverlayView() as pOverlayViews must be + * passed into ReleaseOverlayView() in order for the underlying GPU resources to be freed. + */ + virtual EVROverlayError ReleaseOverlayView(VROverlayView_t *pOverlayView) = 0; + + /** Posts an overlay event */ + virtual void PostOverlayEvent(VROverlayHandle_t ulOverlayHandle, const VREvent_t *pvrEvent) = 0; + + /** Determines whether this process is permitted to view an overlay's content. */ + virtual bool IsViewingPermitted( VROverlayHandle_t ulOverlayHandle ) = 0; + + }; + + static const char * const IVROverlayView_Version = "IVROverlayView_003"; + +} + // ivrrendermodels.h namespace vr { @@ -2642,16 +4164,7 @@ static const char * const k_pch_Controller_Component_Tip = "tip"; // F static const char * const k_pch_Controller_Component_HandGrip = "handgrip"; // Neutral, ambidextrous hand-pose when holding controller. On plane between neutrally posed index finger and thumb static const char * const k_pch_Controller_Component_Status = "status"; // 1:1 aspect ratio status area, with canonical [0,1] uv mapping -#if defined(__linux__) || defined(__APPLE__) -// The 32-bit version of gcc has the alignment requirement for uint64 and double set to -// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. -// The 64-bit version of gcc has the alignment requirement for these types set to -// 8 meaning that unless we use #pragma pack(4) our structures will get bigger. -// The 64-bit structure packing has to match the 32-bit structure packing for each platform. -#pragma pack( push, 4 ) -#else #pragma pack( push, 8 ) -#endif /** Errors that can occur with the VR compositor */ enum EVRRenderModelError @@ -2672,23 +4185,13 @@ enum EVRRenderModelError VRRenderModelError_InvalidTexture = 400, }; -typedef uint32_t VRComponentProperties; - -enum EVRComponentProperty -{ - VRComponentProperty_IsStatic = (1 << 0), - VRComponentProperty_IsVisible = (1 << 1), - VRComponentProperty_IsTouched = (1 << 2), - VRComponentProperty_IsPressed = (1 << 3), - VRComponentProperty_IsScrolled = (1 << 4), -}; - -/** Describes state information about a render-model component, including transforms and other dynamic properties */ -struct RenderModel_ComponentState_t +enum EVRRenderModelTextureFormat { - HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model - HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface ) - VRComponentProperties uProperties; + VRRenderModelTextureFormat_RGBA8_SRGB = 0, // RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub + VRRenderModelTextureFormat_BC2, + VRRenderModelTextureFormat_BC4, + VRRenderModelTextureFormat_BC7, + VRRenderModelTextureFormat_BC7_SRGB }; /** A single vertex in a render model */ @@ -2700,11 +4203,21 @@ struct RenderModel_Vertex_t }; /** A texture map for use on a render model */ +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + struct RenderModel_TextureMap_t { uint16_t unWidth, unHeight; // width and height of the texture map in pixels - const uint8_t *rubTextureMapData; // Map texture data. All textures are RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub + const uint8_t *rubTextureMapData; // Map texture data. + EVRRenderModelTextureFormat format; // Refer to EVRRenderModelTextureFormat }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif /** Session unique texture identifier. Rendermodels which share the same texture will have the same id. IDs <0 denote the texture is not present */ @@ -2713,6 +4226,12 @@ typedef int32_t TextureID_t; const TextureID_t INVALID_TEXTURE_ID = -1; +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + struct RenderModel_t { const RenderModel_Vertex_t *rVertexData; // Vertex data for the mesh @@ -2721,6 +4240,10 @@ struct RenderModel_t uint32_t unTriangleCount; // Number of triangles in the mesh. Index count is 3 * TriangleCount TextureID_t diffuseTextureId; // Session unique texture identifier. Rendermodels which share the same texture will have the same id. <0 == texture not present }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif + struct RenderModel_ControllerMode_State_t { @@ -2806,6 +4329,9 @@ class IVRRenderModels * If the pchRenderModelName or pchComponentName is invalid, this will return false (and transforms will be set to identity). * Otherwise, return true * Note: For dynamic objects, visibility may be dynamic. (I.e., true/false will be returned based on controller state and controller mode state ) */ + virtual bool GetComponentStateForDevicePath( const char *pchRenderModelName, const char *pchComponentName, vr::VRInputValueHandle_t devicePath, const vr::RenderModel_ControllerMode_State_t *pState, vr::RenderModel_ComponentState_t *pComponentState ) = 0; + + /** This version of GetComponentState takes a controller state block instead of an action origin. This function is deprecated. You should use the new input system and GetComponentStateForDevicePath instead. */ virtual bool GetComponentState( const char *pchRenderModelName, const char *pchComponentName, const vr::VRControllerState_t *pControllerState, const RenderModel_ControllerMode_State_t *pState, RenderModel_ComponentState_t *pComponentState ) = 0; /** Returns true if the render model has a component with the specified name */ @@ -2823,7 +4349,7 @@ class IVRRenderModels virtual const char *GetRenderModelErrorNameFromEnum( vr::EVRRenderModelError error ) = 0; }; -static const char * const IVRRenderModels_Version = "IVRRenderModels_005"; +static const char * const IVRRenderModels_Version = "IVRRenderModels_006"; } @@ -2873,9 +4399,9 @@ class IVRTrackedCamera /** Gets size of the image frame. */ virtual vr::EVRTrackedCameraError GetCameraFrameSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pnWidth, uint32_t *pnHeight, uint32_t *pnFrameBufferSize ) = 0; - virtual vr::EVRTrackedCameraError GetCameraIntrinisics( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0; + virtual vr::EVRTrackedCameraError GetCameraIntrinsics( vr::TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0; - virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; + virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; /** Acquiring streaming service permits video streaming for the caller. Releasing hints the system that video services do not need to be maintained for this client. * If the camera has not already been activated, a one time spin up may incur some auto exposure as well as initial streaming frame delays. @@ -2894,15 +4420,22 @@ class IVRTrackedCamera /** Gets size of the image frame. */ virtual vr::EVRTrackedCameraError GetVideoStreamTextureSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::VRTextureBounds_t *pTextureBounds, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; - /** Access a shared D3D11 texture for the specified tracked camera stream */ + /** Access a shared D3D11 texture for the specified tracked camera stream. + * The camera frame type VRTrackedCameraFrameType_Undistorted is not supported directly as a shared texture. It is an interior subregion of the shared texture VRTrackedCameraFrameType_MaximumUndistorted. + * Instead, use GetVideoStreamTextureSize() with VRTrackedCameraFrameType_Undistorted to determine the proper interior subregion bounds along with GetVideoStreamTextureD3D11() with + * VRTrackedCameraFrameType_MaximumUndistorted to provide the texture. The VRTrackedCameraFrameType_MaximumUndistorted will yield an image where the invalid regions are decoded + * by the alpha channel having a zero component. The valid regions all have a non-zero alpha component. The subregion as described by VRTrackedCameraFrameType_Undistorted + * guarantees a rectangle where all pixels are valid. */ virtual vr::EVRTrackedCameraError GetVideoStreamTextureD3D11( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0; /** Access a shared GL texture for the specified tracked camera stream */ virtual vr::EVRTrackedCameraError GetVideoStreamTextureGL( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, vr::glUInt_t *pglTextureId, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0; virtual vr::EVRTrackedCameraError ReleaseVideoStreamTextureGL( vr::TrackedCameraHandle_t hTrackedCamera, vr::glUInt_t glTextureId ) = 0; + virtual void SetCameraTrackingSpace( vr::ETrackingUniverseOrigin eUniverse ) = 0; + virtual vr::ETrackingUniverseOrigin GetCameraTrackingSpace( ) = 0; }; -static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_003"; +static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_006"; } // namespace vr @@ -2952,7 +4485,7 @@ class IVRScreenshots * once SubmitScreenshot() is called. * If Steam is not running, the paths will be in the user's * documents folder under Documents\SteamVR\Screenshots. - * Other VR applications can call this to initate a + * Other VR applications can call this to initiate a * screenshot outside of user control. * The destination file names do not need an extension, * will be replaced with the correct one for the format @@ -2990,7 +4523,7 @@ class IVRScreenshots * submitted scene textures of the running application and * write them into the preview image and a side-by-side file * for the VR image. - * This is similiar to request screenshot, but doesn't ever + * This is similar to request screenshot, but doesn't ever * talk to the application, just takes the shot and submits. */ virtual vr::EVRScreenshotError TakeStereoScreenshot( vr::ScreenshotHandle_t *pOutScreenshotHandle, const char *pchPreviewFilename, const char *pchVRFilename ) = 0; @@ -3001,8 +4534,7 @@ class IVRScreenshots * function will display a notification to the user that the * screenshot was taken. The paths should be full paths with * extensions. - * File paths should be absolute including - * exntensions. + * File paths should be absolute including extensions. * screenshotHandle can be k_unScreenshotHandleInvalid if this * was a new shot taking by the app to be saved and not * initiated by a user (achievement earned or something) */ @@ -3034,27 +4566,551 @@ class IVRResources /** Provides the full path to the specified resource. Resource names can include named directories for * drivers and other things, and this resolves all of those and returns the actual physical path. * pchResourceTypeDirectory is the subdirectory of resources to look in. */ - virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, char *pchPathBuffer, uint32_t unBufferLen ) = 0; + virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0; }; static const char * const IVRResources_Version = "IVRResources_001"; -}// End +} +// ivrdrivermanager.h +namespace vr +{ + +class IVRDriverManager +{ +public: + virtual uint32_t GetDriverCount() const = 0; + + /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */ + virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; + + virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0; + + virtual bool IsEnabled( vr::DriverId_t nDriver ) const = 0; +}; + +static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; + +} // namespace vr + + + +// ivrinput.h +namespace vr +{ + // Maximum number of characters in an action name, including the trailing null + static const uint32_t k_unMaxActionNameLength = 64; + + // Maximum number of characters in an action set name, including the trailing null + static const uint32_t k_unMaxActionSetNameLength = 64; + + // Maximum number of origins for an action + static const uint32_t k_unMaxActionOriginCount = 16; + + // Maximum number of characters in a bone name, including the trailing null + static const uint32_t k_unMaxBoneNameLength = 32; + + enum EVRSkeletalTransformSpace + { + VRSkeletalTransformSpace_Model = 0, + VRSkeletalTransformSpace_Parent = 1 + }; + + enum EVRSkeletalReferencePose + { + VRSkeletalReferencePose_BindPose = 0, + VRSkeletalReferencePose_OpenHand, + VRSkeletalReferencePose_Fist, + VRSkeletalReferencePose_GripLimit + }; + + enum EVRFinger + { + VRFinger_Thumb = 0, + VRFinger_Index, + VRFinger_Middle, + VRFinger_Ring, + VRFinger_Pinky, + VRFinger_Count + }; + + enum EVRFingerSplay + { + VRFingerSplay_Thumb_Index = 0, + VRFingerSplay_Index_Middle, + VRFingerSplay_Middle_Ring, + VRFingerSplay_Ring_Pinky, + VRFingerSplay_Count + }; + + enum EVRSummaryType + { + // The skeletal summary data will match the animated bone transforms for the action. + VRSummaryType_FromAnimation = 0, + + // The skeletal summary data will include unprocessed data directly from the device when available. + // This data is generally less latent than the data that is computed from the animations. + VRSummaryType_FromDevice = 1, + }; + + enum EVRInputFilterCancelType + { + VRInputFilterCancel_Timers = 0, + VRInputFilterCancel_Momentum = 1, + }; + + enum EVRInputStringBits + { + VRInputString_Hand = 0x01, + VRInputString_ControllerType = 0x02, + VRInputString_InputSource = 0x04, + + VRInputString_All = 0xFFFFFFFF + }; + + 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; + }; + + struct InputSkeletalActionData_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; + }; + + struct InputOriginInfo_t + { + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char rchRenderModelComponentName[128]; + }; + + struct InputBindingInfo_t + { + char rchDevicePathName[128]; + char rchInputPathName[128]; + char rchModeName[128]; + char rchSlotName[128]; + char rchInputSourceType[ 32 ]; + }; + + // * Experimental global action set priority * + // These constants are part of the experimental support in SteamVR for overlay + // apps selectively overriding input in the base scene application. This may be + // useful for overlay applications that need to use part or all of a controller + // without taking away all input to the game. This system must be enabled by the + // "Experimental overlay input overrides" setting in the developer section of + // SteamVR settings. + // + // To use this system, set the nPriority field of an action set to any number in + // this range. + static const int32_t k_nActionSetOverlayGlobalPriorityMin = 0x01000000; + static const int32_t k_nActionSetOverlayGlobalPriorityMax = 0x01FFFFFF; + + static const int32_t k_nActionSetPriorityReservedMin = 0x02000000; + + 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; + + // This field is ignored + uint32_t unPadding; + + /** The priority of this action set relative to other action sets. Any inputs + * bound to a source (e.g. trackpad, joystick, trigger) will disable bindings in + * other active action sets with a smaller priority. + * + * Overlay applications (i.e. ApplicationType_Overlay) may set their action set priority + * to a value between k_nActionSetOverlayGlobalPriorityMin and k_nActionSetOverlayGlobalPriorityMax + * to cause any inputs bound to a source used by that action set to be disabled in scene applications. + * + * No action set priority may value may be larger than k_nActionSetPriorityReservedMin + */ + int32_t nPriority; + }; + + /** Contains summary information about the current skeletal pose */ + struct VRSkeletalSummaryData_t + { + /** The amount that each finger is 'curled' inwards towards the palm. In the case of the thumb, + * this represents how much the thumb is wrapped around the fist. + * 0 means straight, 1 means fully curled */ + float flFingerCurl[ VRFinger_Count ]; + + /** The amount that each pair of adjacent fingers are separated. + * 0 means the digits are touching, 1 means they are fully separated. + */ + float flFingerSplay[ VRFingerSplay_Count ]; + }; + + + 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, VRInputValueHandle_t ulRestrictToDevice ) = 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, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of a pose action given its handle for the number of seconds relative to now. This + * will generally be called with negative times from the fUpdateTime fields in other actions. */ + virtual EVRInputError GetPoseActionDataRelativeToNow( VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t *pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of a pose action given its handle. The returned values will match the values returned + * by the last call to IVRCompositor::WaitGetPoses(). */ + virtual EVRInputError GetPoseActionDataForNextFrame( VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, InputPoseActionData_t *pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice ) = 0; + + /** Reads the state of a skeletal action given its handle. */ + virtual EVRInputError GetSkeletalActionData( VRActionHandle_t action, InputSkeletalActionData_t *pActionData, uint32_t unActionDataSize ) = 0; + + /** Returns the current dominant hand for the user for this application. This function will only return success for applications + * which include "supports_dominant_hand_setting": true in their action manifests. The dominant hand will only change after + * a call to UpdateActionState, and the action data returned after that point will use the new dominant hand. */ + virtual EVRInputError GetDominantHand( ETrackedControllerRole *peDominantHand ) = 0; + + /** Sets the dominant hand for the user for this application. */ + virtual EVRInputError SetDominantHand( ETrackedControllerRole eDominantHand ) = 0; + + // --------------- Static Skeletal Data ------------------- // + + /** Reads the number of bones in skeleton associated with the given action */ + virtual EVRInputError GetBoneCount( VRActionHandle_t action, uint32_t* pBoneCount ) = 0; + + /** Fills the given array with the index of each bone's parent in the skeleton associated with the given action */ + virtual EVRInputError GetBoneHierarchy( VRActionHandle_t action, VR_ARRAY_COUNT( unIndexArayCount ) BoneIndex_t* pParentIndices, uint32_t unIndexArayCount ) = 0; + + /** Fills the given buffer with the name of the bone at the given index in the skeleton associated with the given action */ + virtual EVRInputError GetBoneName( VRActionHandle_t action, BoneIndex_t nBoneIndex, VR_OUT_STRING() char* pchBoneName, uint32_t unNameBufferSize ) = 0; + + /** Fills the given buffer with the transforms for a specific static skeletal reference pose */ + virtual EVRInputError GetSkeletalReferenceTransforms( VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + /** Reads the level of accuracy to which the controller is able to track the user to recreate a skeletal pose */ + virtual EVRInputError GetSkeletalTrackingLevel( VRActionHandle_t action, EVRSkeletalTrackingLevel* pSkeletalTrackingLevel ) = 0; + + // --------------- Dynamic Skeletal Data ------------------- // + + /** Reads the state of the skeletal bone data associated with this action and copies it into the given buffer. */ + virtual EVRInputError GetSkeletalBoneData( VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, VR_ARRAY_COUNT( unTransformArrayCount ) VRBoneTransform_t *pTransformArray, uint32_t unTransformArrayCount ) = 0; + + /** Reads summary information about the current pose of the skeleton associated with the given action. */ + virtual EVRInputError GetSkeletalSummaryData( VRActionHandle_t action, EVRSummaryType eSummaryType, VRSkeletalSummaryData_t * pSkeletalSummaryData ) = 0; + + /** Reads the state of the skeletal bone data 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 GetSkeletalBoneDataCompressed( VRActionHandle_t action, EVRSkeletalMotionRange eMotionRange, VR_OUT_BUFFER_COUNT( unCompressedSize ) void *pvCompressedData, uint32_t unCompressedSize, uint32_t *punRequiredCompressedSize ) = 0; + + /** Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array. */ + virtual EVRInputError DecompressSkeletalBoneData( const void *pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, 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, VRInputValueHandle_t ulRestrictToDevice ) = 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. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the + application to specify which parts of the origin's information it wants a string for. */ + virtual EVRInputError GetOriginLocalizedName( VRInputValueHandle_t origin, VR_OUT_STRING() char *pchNameArray, uint32_t unNameArraySize, int32_t unStringSectionsToInclude ) = 0; + + /** Retrieves useful information for the origin of this action */ + virtual EVRInputError GetOriginTrackedDeviceInfo( VRInputValueHandle_t origin, InputOriginInfo_t *pOriginInfo, uint32_t unOriginInfoSize ) = 0; + + /** Retrieves useful information about the bindings for an action */ + virtual EVRInputError GetActionBindingInfo( VRActionHandle_t action, InputBindingInfo_t *pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, uint32_t *punReturnedBindingInfoCount ) = 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; + + /** Use this to query what action on the component returned by GetOriginTrackedDeviceInfo would trigger this binding. */ + virtual EVRInputError GetComponentStateForBinding( const char *pchRenderModelName, const char *pchComponentName, + const InputBindingInfo_t *pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, + vr::RenderModel_ComponentState_t *pComponentState ) = 0; + + + // --------------- Legacy Input ------------------- // + virtual bool IsUsingLegacyInput() = 0; + + + // --------------- Utilities ------------------- // + + /** Opens the binding user interface. If no app key is provided it will use the key from the calling process. + * If no set is provided it will open to the root of the app binding page. */ + virtual EVRInputError OpenBindingUI( const char* pchAppKey, VRActionSetHandle_t ulActionSetHandle, VRInputValueHandle_t ulDeviceHandle, bool bShowOnDesktop ) = 0; + + /** Returns the variant set in the current bindings. If the binding doesn't include a variant setting, this function + * will return an empty string */ + virtual EVRInputError GetBindingVariant( vr::VRInputValueHandle_t ulDevicePath, + VR_OUT_STRING() char *pchVariantArray, uint32_t unVariantArraySize ) = 0; + + }; + + static const char * const IVRInput_Version = "IVRInput_010"; + +} // 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; + + /** inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes. */ + virtual bool HasReaders( vr::IOBufferHandle_t ulBuffer ) = 0; + }; + + static const char *IVRIOBuffer_Version = "IVRIOBuffer_002"; +} + +// ivrspatialanchors.h +namespace vr +{ + static const SpatialAnchorHandle_t k_ulInvalidSpatialAnchorHandle = 0; + + struct SpatialAnchorPose_t + { + HmdMatrix34_t mAnchorToAbsoluteTracking; + }; + + class IVRSpatialAnchors + { + public: + + /** Returns a handle for an spatial anchor described by "descriptor". On success, pHandle + * will contain a handle valid for this session. Caller can wait for an event or occasionally + * poll GetSpatialAnchorPose() to find the virtual coordinate associated with this anchor. */ + virtual EVRSpatialAnchorError CreateSpatialAnchorFromDescriptor( const char *pchDescriptor, SpatialAnchorHandle_t *pHandleOut ) = 0; + + /** Returns a handle for an new spatial anchor at pPose. On success, pHandle + * will contain a handle valid for this session. Caller can wait for an event or occasionally + * poll GetSpatialAnchorDescriptor() to find the permanent descriptor for this pose. + * The result of GetSpatialAnchorPose() may evolve from this initial position if the driver chooses + * to update it. + * The anchor will be associated with the driver that provides unDeviceIndex, and the driver may use that specific + * device as a hint for how to best create the anchor. + * The eOrigin must match whatever tracking origin you are working in (seated/standing/raw). + * This should be called when the user is close to (and ideally looking at/interacting with) the target physical + * location. At that moment, the driver will have the most information about how to recover that physical point + * in the future, and the quality of the anchor (when the descriptor is re-used) will be highest. + * The caller may decide to apply offsets from this initial pose, but is advised to stay relatively close to the + * original pose location for highest fidelity. */ + virtual EVRSpatialAnchorError CreateSpatialAnchorFromPose( TrackedDeviceIndex_t unDeviceIndex, ETrackingUniverseOrigin eOrigin, SpatialAnchorPose_t *pPose, SpatialAnchorHandle_t *pHandleOut ) = 0; + + /** Get the pose for a given handle. This is intended to be cheap enough to call every frame (or fairly often) + * so that the driver can refine this position when it has more information available. */ + virtual EVRSpatialAnchorError GetSpatialAnchorPose( SpatialAnchorHandle_t unHandle, ETrackingUniverseOrigin eOrigin, SpatialAnchorPose_t *pPoseOut ) = 0; + + /** Get the descriptor for a given handle. This will be empty for handles where the driver has not + * yet built a descriptor. It will be the application-supplied descriptor for previously saved anchors + * that the application is requesting poses for. If the driver has called UpdateSpatialAnchorDescriptor() + * already in this session, it will be the descriptor provided by the driver. + * Returns true if the descriptor fits into the buffer, else false. Buffer size should be at least + * k_unMaxSpatialAnchorDescriptorSize. */ + virtual EVRSpatialAnchorError GetSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, VR_OUT_STRING() char *pchDescriptorOut, uint32_t *punDescriptorBufferLenInOut ) = 0; + + }; + + static const char * const IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; + +} // namespace vr + +// ivrdebug.h +namespace vr +{ + enum EVRDebugError + { + VRDebugError_Success = 0, + VRDebugError_BadParameter + }; + + /** Handle for vr profiler events */ + typedef uint64_t VrProfilerEventHandle_t; + + class IVRDebug + { + public: + + /** Create a vr profiler discrete event (point) + * The event will be associated with the message provided in pchMessage, and the current + * time will be used as the event timestamp. */ + virtual EVRDebugError EmitVrProfilerEvent( const char *pchMessage ) = 0; + + /** Create an vr profiler duration event (line) + * The current time will be used as the timestamp for the start of the line. + * On success, pHandleOut will contain a handle valid for terminating this event. */ + virtual EVRDebugError BeginVrProfilerEvent( VrProfilerEventHandle_t *pHandleOut ) = 0; + + /** Terminate a vr profiler event + * The event associated with hHandle will be considered completed when this method is called. + * The current time will be used assocaited to the termination time of the event, and + * pchMessage will be used as the event title. */ + virtual EVRDebugError FinishVrProfilerEvent( VrProfilerEventHandle_t hHandle, const char *pchMessage ) = 0; + + /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k, + * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated. + * The size of the response including its terminating null is returned. */ + virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, VR_OUT_STRING() char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; + + }; + + static const char * const IVRDebug_Version = "IVRDebug_001"; + +} // namespace vr +// End #endif // _OPENVR_API + namespace vr { +#if !defined( OPENVR_INTERFACE_INTERNAL ) + /** Finds the active installation of the VR API and initializes it. The provided path must be absolute * or relative to the current working directory. These are the local install versions of the equivalent * functions in steamvr.h and will work without a local Steam install. * * This path is to the "root" of the VR API install. That's the directory with * the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself. + * + * pStartupInfo is reserved for future use. */ - inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType ); + inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo = nullptr ); /** unloads vrclient.dll. Any interface pointers from the interface are * invalid after this point */ @@ -3070,12 +5126,12 @@ namespace vr VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled(); /** Returns where the OpenVR runtime is installed. */ - VR_INTERFACE const char *VR_CALLTYPE VR_RuntimePath(); - + VR_INTERFACE bool VR_GetRuntimePath( VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferSize, uint32_t *punRequiredBufferSize ); + /** Returns the name of the enum value for an EVRInitError. This function may be called outside of VR_Init()/VR_Shutdown(). */ VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsSymbol( EVRInitError error ); - /** Returns an english string for an EVRInitError. Applications should call VR_GetVRInitErrorAsSymbol instead and + /** Returns an English string for an EVRInitError. Applications should call VR_GetVRInitErrorAsSymbol instead and * use that as a key to look up their own localized error message. This function may be called outside of VR_Init()/VR_Shutdown(). */ VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription( EVRInitError error ); @@ -3095,7 +5151,6 @@ namespace vr // They will go away in the future. typedef EVRInitError HmdError; typedef EVREye Hmd_Eye; - typedef EGraphicsAPIConvention GraphicsAPIConvention; typedef EColorSpace ColorSpace; typedef ETrackingResult HmdTrackingResult; typedef ETrackedDeviceClass TrackedDeviceClass; @@ -3185,6 +5240,28 @@ namespace vr return m_pVROverlay; } + IVROverlayView *VROverlayView() + { + CheckClear(); + if ( m_pVROverlayView == nullptr ) + { + EVRInitError eError; + m_pVROverlayView = ( IVROverlayView * ) VR_GetGenericInterface( IVROverlayView_Version, &eError ); + } + return m_pVROverlayView; + } + + IVRHeadsetView *VRHeadsetView() + { + CheckClear(); + if ( m_pVRHeadsetView == nullptr ) + { + EVRInitError eError; + m_pVRHeadsetView = ( IVRHeadsetView * ) VR_GetGenericInterface( IVRHeadsetView_Version, &eError ); + } + return m_pVRHeadsetView; + } + IVRResources *VRResources() { CheckClear(); @@ -3262,12 +5339,79 @@ namespace vr return m_pVRTrackedCamera; } + IVRDriverManager *VRDriverManager() + { + CheckClear(); + if ( !m_pVRDriverManager ) + { + EVRInitError eError; + m_pVRDriverManager = ( IVRDriverManager * )VR_GetGenericInterface( IVRDriverManager_Version, &eError ); + } + 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; + } + + IVRSpatialAnchors *VRSpatialAnchors() + { + CheckClear(); + if ( !m_pVRSpatialAnchors ) + { + EVRInitError eError; + m_pVRSpatialAnchors = (IVRSpatialAnchors *)VR_GetGenericInterface( IVRSpatialAnchors_Version, &eError ); + } + return m_pVRSpatialAnchors; + } + + IVRDebug *VRDebug() + { + CheckClear(); + if ( !m_pVRDebug ) + { + EVRInitError eError; + m_pVRDebug = (IVRDebug *)VR_GetGenericInterface( IVRDebug_Version, &eError ); + } + return m_pVRDebug; + } + + IVRNotifications *VRNotifications() + { + CheckClear(); + if ( !m_pVRNotifications ) + { + EVRInitError eError; + m_pVRNotifications = ( IVRNotifications * )VR_GetGenericInterface( IVRNotifications_Version, &eError ); + } + return m_pVRNotifications; + } + private: IVRSystem *m_pVRSystem; IVRChaperone *m_pVRChaperone; IVRChaperoneSetup *m_pVRChaperoneSetup; IVRCompositor *m_pVRCompositor; + IVRHeadsetView *m_pVRHeadsetView; IVROverlay *m_pVROverlay; + IVROverlayView *m_pVROverlayView; IVRResources *m_pVRResources; IVRRenderModels *m_pVRRenderModels; IVRExtendedDisplay *m_pVRExtendedDisplay; @@ -3275,6 +5419,12 @@ namespace vr IVRApplications *m_pVRApplications; IVRTrackedCamera *m_pVRTrackedCamera; IVRScreenshots *m_pVRScreenshots; + IVRDriverManager *m_pVRDriverManager; + IVRInput *m_pVRInput; + IVRIOBuffer *m_pVRIOBuffer; + IVRSpatialAnchors *m_pVRSpatialAnchors; + IVRDebug *m_pVRDebug; + IVRNotifications *m_pVRNotifications; }; inline COpenVRContext &OpenVRInternal_ModuleContext() @@ -3288,6 +5438,8 @@ namespace vr inline IVRChaperoneSetup *VR_CALLTYPE VRChaperoneSetup() { return OpenVRInternal_ModuleContext().VRChaperoneSetup(); } inline IVRCompositor *VR_CALLTYPE VRCompositor() { return OpenVRInternal_ModuleContext().VRCompositor(); } inline IVROverlay *VR_CALLTYPE VROverlay() { return OpenVRInternal_ModuleContext().VROverlay(); } + inline IVROverlayView *VR_CALLTYPE VROverlayView() { return OpenVRInternal_ModuleContext().VROverlayView(); } + inline IVRHeadsetView *VR_CALLTYPE VRHeadsetView() { return OpenVRInternal_ModuleContext().VRHeadsetView(); } inline IVRScreenshots *VR_CALLTYPE VRScreenshots() { return OpenVRInternal_ModuleContext().VRScreenshots(); } inline IVRRenderModels *VR_CALLTYPE VRRenderModels() { return OpenVRInternal_ModuleContext().VRRenderModels(); } inline IVRApplications *VR_CALLTYPE VRApplications() { return OpenVRInternal_ModuleContext().VRApplications(); } @@ -3295,6 +5447,12 @@ namespace vr inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleContext().VRResources(); } 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 IVRSpatialAnchors *VR_CALLTYPE VRSpatialAnchors() { return OpenVRInternal_ModuleContext().VRSpatialAnchors(); } + inline IVRNotifications *VR_CALLTYPE VRNotifications() { return OpenVRInternal_ModuleContext().VRNotifications(); } + inline IVRDebug *VR_CALLTYPE VRDebug() { return OpenVRInternal_ModuleContext().VRDebug(); } inline void COpenVRContext::Clear() { @@ -3303,6 +5461,8 @@ namespace vr m_pVRChaperoneSetup = nullptr; m_pVRCompositor = nullptr; m_pVROverlay = nullptr; + m_pVROverlayView = nullptr; + m_pVRHeadsetView = nullptr; m_pVRRenderModels = nullptr; m_pVRExtendedDisplay = nullptr; m_pVRSettings = nullptr; @@ -3310,18 +5470,24 @@ namespace vr m_pVRTrackedCamera = nullptr; m_pVRResources = nullptr; m_pVRScreenshots = nullptr; + m_pVRDriverManager = nullptr; + m_pVRInput = nullptr; + m_pVRIOBuffer = nullptr; + m_pVRSpatialAnchors = nullptr; + m_pVRNotifications = nullptr; + m_pVRDebug = nullptr; } - - VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal( EVRInitError *peError, EVRApplicationType eApplicationType ); + + VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal(); /** Finds the active installation of vrclient.dll and initializes it */ - inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType ) + inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ) { IVRSystem *pVRSystem = nullptr; EVRInitError eError; - VRToken() = VR_InitInternal( &eError, eApplicationType ); + VRToken() = VR_InitInternal2( &eError, eApplicationType, pStartupInfo ); COpenVRContext &ctx = OpenVRInternal_ModuleContext(); ctx.Clear(); @@ -3349,4 +5515,6 @@ namespace vr { VR_ShutdownInternal(); } + +#endif // OPENVR_INTERFACE_INTERNAL } diff --git a/ext/OpenVR/headers/openvr_api.cs b/ext/OpenVR/headers/openvr_api.cs index 9b04cc3..ef55a5f 100644 --- a/ext/OpenVR/headers/openvr_api.cs +++ b/ext/OpenVR/headers/openvr_api.cs @@ -9,6 +9,10 @@ using System.Runtime.InteropServices; using Valve.VR; +#if UNITY_5_3_OR_NEWER +using UnityEngine; +#endif + namespace Valve.VR { @@ -21,7 +25,7 @@ public struct IVRSystem internal _GetRecommendedRenderTargetSize GetRecommendedRenderTargetSize; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate HmdMatrix44_t _GetProjectionMatrix(EVREye eEye, float fNearZ, float fFarZ, EGraphicsAPIConvention eProjType); + internal delegate HmdMatrix44_t _GetProjectionMatrix(EVREye eEye, float fNearZ, float fFarZ); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetProjectionMatrix GetProjectionMatrix; @@ -31,7 +35,7 @@ public struct IVRSystem internal _GetProjectionRaw GetProjectionRaw; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate DistortionCoordinates_t _ComputeDistortion(EVREye eEye, float fU, float fV); + internal delegate bool _ComputeDistortion(EVREye eEye, float fU, float fV, ref DistortionCoordinates_t pDistortionCoordinates); [MarshalAs(UnmanagedType.FunctionPtr)] internal _ComputeDistortion ComputeDistortion; @@ -55,6 +59,11 @@ public struct IVRSystem [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetDXGIOutputInfo GetDXGIOutputInfo; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _GetOutputDevice(ref ulong pnDevice, ETextureType textureType, IntPtr pInstance); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOutputDevice GetOutputDevice; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate bool _IsDisplayOnDesktop(); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -145,6 +154,11 @@ public struct IVRSystem [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetMatrix34TrackedDeviceProperty GetMatrix34TrackedDeviceProperty; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetArrayTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, uint propType, IntPtr pBuffer, uint unBufferSize, ref ETrackedPropertyError pError); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetArrayTrackedDeviceProperty GetArrayTrackedDeviceProperty; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate uint _GetStringTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, System.Text.StringBuilder pchValue, uint unBufferSize, ref ETrackedPropertyError pError); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -171,22 +185,22 @@ public struct IVRSystem internal _GetEventTypeNameFromEnum GetEventTypeNameFromEnum; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate HiddenAreaMesh_t _GetHiddenAreaMesh(EVREye eEye); + internal delegate HiddenAreaMesh_t _GetHiddenAreaMesh(EVREye eEye, EHiddenAreaMeshType type); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetHiddenAreaMesh GetHiddenAreaMesh; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetControllerState(uint unControllerDeviceIndex, ref VRControllerState_t pControllerState); + internal delegate bool _GetControllerState(uint unControllerDeviceIndex, ref VRControllerState_t pControllerState, uint unControllerStateSize); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetControllerState GetControllerState; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ref VRControllerState_t pControllerState, ref TrackedDevicePose_t pTrackedDevicePose); + internal delegate bool _GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ref VRControllerState_t pControllerState, uint unControllerStateSize, ref TrackedDevicePose_t pTrackedDevicePose); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetControllerStateWithPose GetControllerStateWithPose; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _TriggerHapticPulse(uint unControllerDeviceIndex, uint unAxisId, char usDurationMicroSec); + internal delegate void _TriggerHapticPulse(uint unControllerDeviceIndex, uint unAxisId, ushort usDurationMicroSec); [MarshalAs(UnmanagedType.FunctionPtr)] internal _TriggerHapticPulse TriggerHapticPulse; @@ -201,24 +215,24 @@ public struct IVRSystem internal _GetControllerAxisTypeNameFromEnum GetControllerAxisTypeNameFromEnum; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _CaptureInputFocus(); + internal delegate bool _IsInputAvailable(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _CaptureInputFocus CaptureInputFocus; + internal _IsInputAvailable IsInputAvailable; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _ReleaseInputFocus(); + internal delegate bool _IsSteamVRDrawingControllers(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _ReleaseInputFocus ReleaseInputFocus; + internal _IsSteamVRDrawingControllers IsSteamVRDrawingControllers; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _IsInputFocusCapturedByAnotherProcess(); + internal delegate bool _ShouldApplicationPause(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _IsInputFocusCapturedByAnotherProcess IsInputFocusCapturedByAnotherProcess; + internal _ShouldApplicationPause ShouldApplicationPause; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _DriverDebugRequest(uint unDeviceIndex, string pchRequest, string pchResponseBuffer, uint unResponseBufferSize); + internal delegate bool _ShouldApplicationReduceRenderingWork(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _DriverDebugRequest DriverDebugRequest; + internal _ShouldApplicationReduceRenderingWork ShouldApplicationReduceRenderingWork; [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVRFirmwareError _PerformFirmwareUpdate(uint unDeviceIndex); @@ -231,9 +245,14 @@ public struct IVRSystem internal _AcknowledgeQuit_Exiting AcknowledgeQuit_Exiting; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _AcknowledgeQuit_UserPrompt(); + internal delegate uint _GetAppContainerFilePaths(System.Text.StringBuilder pchBuffer, uint unBufferSize); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _AcknowledgeQuit_UserPrompt AcknowledgeQuit_UserPrompt; + internal _GetAppContainerFilePaths GetAppContainerFilePaths; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate IntPtr _GetRuntimeVersion(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetRuntimeVersion GetRuntimeVersion; } @@ -276,12 +295,12 @@ public struct IVRTrackedCamera internal _GetCameraFrameSize GetCameraFrameSize; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRTrackedCameraError _GetCameraIntrinisics(uint nDeviceIndex, EVRTrackedCameraFrameType eFrameType, ref HmdVector2_t pFocalLength, ref HmdVector2_t pCenter); + internal delegate EVRTrackedCameraError _GetCameraIntrinsics(uint nDeviceIndex, uint nCameraIndex, EVRTrackedCameraFrameType eFrameType, ref HmdVector2_t pFocalLength, ref HmdVector2_t pCenter); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetCameraIntrinisics GetCameraIntrinisics; + internal _GetCameraIntrinsics GetCameraIntrinsics; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRTrackedCameraError _GetCameraProjection(uint nDeviceIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, ref HmdMatrix44_t pProjection); + internal delegate EVRTrackedCameraError _GetCameraProjection(uint nDeviceIndex, uint nCameraIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, ref HmdMatrix44_t pProjection); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetCameraProjection GetCameraProjection; @@ -320,23 +339,33 @@ public struct IVRTrackedCamera [MarshalAs(UnmanagedType.FunctionPtr)] internal _ReleaseVideoStreamTextureGL ReleaseVideoStreamTextureGL; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetCameraTrackingSpace(ETrackingUniverseOrigin eUniverse); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetCameraTrackingSpace SetCameraTrackingSpace; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackingUniverseOrigin _GetCameraTrackingSpace(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetCameraTrackingSpace GetCameraTrackingSpace; + } [StructLayout(LayoutKind.Sequential)] public struct IVRApplications { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _AddApplicationManifest(string pchApplicationManifestFullPath, bool bTemporary); + internal delegate EVRApplicationError _AddApplicationManifest(IntPtr pchApplicationManifestFullPath, bool bTemporary); [MarshalAs(UnmanagedType.FunctionPtr)] internal _AddApplicationManifest AddApplicationManifest; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _RemoveApplicationManifest(string pchApplicationManifestFullPath); + internal delegate EVRApplicationError _RemoveApplicationManifest(IntPtr pchApplicationManifestFullPath); [MarshalAs(UnmanagedType.FunctionPtr)] internal _RemoveApplicationManifest RemoveApplicationManifest; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _IsApplicationInstalled(string pchAppKey); + internal delegate bool _IsApplicationInstalled(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _IsApplicationInstalled IsApplicationInstalled; @@ -346,47 +375,47 @@ public struct IVRApplications internal _GetApplicationCount GetApplicationCount; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _GetApplicationKeyByIndex(uint unApplicationIndex, string pchAppKeyBuffer, uint unAppKeyBufferLen); + internal delegate EVRApplicationError _GetApplicationKeyByIndex(uint unApplicationIndex, System.Text.StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationKeyByIndex GetApplicationKeyByIndex; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _GetApplicationKeyByProcessId(uint unProcessId, string pchAppKeyBuffer, uint unAppKeyBufferLen); + internal delegate EVRApplicationError _GetApplicationKeyByProcessId(uint unProcessId, System.Text.StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationKeyByProcessId GetApplicationKeyByProcessId; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _LaunchApplication(string pchAppKey); + internal delegate EVRApplicationError _LaunchApplication(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LaunchApplication LaunchApplication; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _LaunchTemplateApplication(string pchTemplateAppKey, string pchNewAppKey, [In, Out] AppOverrideKeys_t[] pKeys, uint unKeys); + internal delegate EVRApplicationError _LaunchTemplateApplication(IntPtr pchTemplateAppKey, IntPtr pchNewAppKey, [In, Out] AppOverrideKeys_t[] pKeys, uint unKeys); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LaunchTemplateApplication LaunchTemplateApplication; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _LaunchApplicationFromMimeType(string pchMimeType, string pchArgs); + internal delegate EVRApplicationError _LaunchApplicationFromMimeType(IntPtr pchMimeType, IntPtr pchArgs); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LaunchApplicationFromMimeType LaunchApplicationFromMimeType; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _LaunchDashboardOverlay(string pchAppKey); + internal delegate EVRApplicationError _LaunchDashboardOverlay(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LaunchDashboardOverlay LaunchDashboardOverlay; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _CancelApplicationLaunch(string pchAppKey); + internal delegate bool _CancelApplicationLaunch(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _CancelApplicationLaunch CancelApplicationLaunch; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _IdentifyApplication(uint unProcessId, string pchAppKey); + internal delegate EVRApplicationError _IdentifyApplication(uint unProcessId, IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _IdentifyApplication IdentifyApplication; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetApplicationProcessId(string pchAppKey); + internal delegate uint _GetApplicationProcessId(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationProcessId GetApplicationProcessId; @@ -396,84 +425,84 @@ public struct IVRApplications internal _GetApplicationsErrorNameFromEnum GetApplicationsErrorNameFromEnum; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetApplicationPropertyString(string pchAppKey, EVRApplicationProperty eProperty, string pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError); + internal delegate uint _GetApplicationPropertyString(IntPtr pchAppKey, EVRApplicationProperty eProperty, System.Text.StringBuilder pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationPropertyString GetApplicationPropertyString; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetApplicationPropertyBool(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError); + internal delegate bool _GetApplicationPropertyBool(IntPtr pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationPropertyBool GetApplicationPropertyBool; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate ulong _GetApplicationPropertyUint64(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError); + internal delegate ulong _GetApplicationPropertyUint64(IntPtr pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationPropertyUint64 GetApplicationPropertyUint64; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _SetApplicationAutoLaunch(string pchAppKey, bool bAutoLaunch); + internal delegate EVRApplicationError _SetApplicationAutoLaunch(IntPtr pchAppKey, bool bAutoLaunch); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetApplicationAutoLaunch SetApplicationAutoLaunch; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetApplicationAutoLaunch(string pchAppKey); + internal delegate bool _GetApplicationAutoLaunch(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationAutoLaunch GetApplicationAutoLaunch; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _SetDefaultApplicationForMimeType(string pchAppKey, string pchMimeType); + internal delegate EVRApplicationError _SetDefaultApplicationForMimeType(IntPtr pchAppKey, IntPtr pchMimeType); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetDefaultApplicationForMimeType SetDefaultApplicationForMimeType; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetDefaultApplicationForMimeType(string pchMimeType, string pchAppKeyBuffer, uint unAppKeyBufferLen); + internal delegate bool _GetDefaultApplicationForMimeType(IntPtr pchMimeType, System.Text.StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetDefaultApplicationForMimeType GetDefaultApplicationForMimeType; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetApplicationSupportedMimeTypes(string pchAppKey, string pchMimeTypesBuffer, uint unMimeTypesBuffer); + internal delegate bool _GetApplicationSupportedMimeTypes(IntPtr pchAppKey, System.Text.StringBuilder pchMimeTypesBuffer, uint unMimeTypesBuffer); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationSupportedMimeTypes GetApplicationSupportedMimeTypes; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetApplicationsThatSupportMimeType(string pchMimeType, string pchAppKeysThatSupportBuffer, uint unAppKeysThatSupportBuffer); + internal delegate uint _GetApplicationsThatSupportMimeType(IntPtr pchMimeType, System.Text.StringBuilder pchAppKeysThatSupportBuffer, uint unAppKeysThatSupportBuffer); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationsThatSupportMimeType GetApplicationsThatSupportMimeType; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetApplicationLaunchArguments(uint unHandle, string pchArgs, uint unArgs); + internal delegate uint _GetApplicationLaunchArguments(uint unHandle, System.Text.StringBuilder pchArgs, uint unArgs); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetApplicationLaunchArguments GetApplicationLaunchArguments; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _GetStartingApplication(string pchAppKeyBuffer, uint unAppKeyBufferLen); + internal delegate EVRApplicationError _GetStartingApplication(System.Text.StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetStartingApplication GetStartingApplication; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationTransitionState _GetTransitionState(); + internal delegate EVRSceneApplicationState _GetSceneApplicationState(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetTransitionState GetTransitionState; + internal _GetSceneApplicationState GetSceneApplicationState; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _PerformApplicationPrelaunchCheck(string pchAppKey); + internal delegate EVRApplicationError _PerformApplicationPrelaunchCheck(IntPtr pchAppKey); [MarshalAs(UnmanagedType.FunctionPtr)] internal _PerformApplicationPrelaunchCheck PerformApplicationPrelaunchCheck; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate IntPtr _GetApplicationsTransitionStateNameFromEnum(EVRApplicationTransitionState state); + internal delegate IntPtr _GetSceneApplicationStateNameFromEnum(EVRSceneApplicationState state); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetApplicationsTransitionStateNameFromEnum GetApplicationsTransitionStateNameFromEnum; + internal _GetSceneApplicationStateNameFromEnum GetSceneApplicationStateNameFromEnum; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _IsQuitUserPromptRequested(); + internal delegate EVRApplicationError _LaunchInternalProcess(IntPtr pchBinaryPath, IntPtr pchArguments, IntPtr pchWorkingDirectory); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _IsQuitUserPromptRequested IsQuitUserPromptRequested; + internal _LaunchInternalProcess LaunchInternalProcess; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRApplicationError _LaunchInternalProcess(string pchBinaryPath, string pchArguments, string pchWorkingDirectory); + internal delegate uint _GetCurrentSceneProcessId(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _LaunchInternalProcess LaunchInternalProcess; + internal _GetCurrentSceneProcessId GetCurrentSceneProcessId; } @@ -575,6 +604,11 @@ public struct IVRChaperoneSetup [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetWorkingCollisionBoundsInfo SetWorkingCollisionBoundsInfo; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetWorkingPerimeter([In, Out] HmdVector2_t[] pPointBuffer, uint unPointCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetWorkingPerimeter SetWorkingPerimeter; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate void _SetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -596,34 +630,29 @@ public struct IVRChaperoneSetup internal _GetLiveSeatedZeroPoseToRawTrackingPose GetLiveSeatedZeroPoseToRawTrackingPose; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _SetWorkingCollisionBoundsTagsInfo([In, Out] byte[] pTagsBuffer, uint unTagCount); - [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetWorkingCollisionBoundsTagsInfo SetWorkingCollisionBoundsTagsInfo; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetLiveCollisionBoundsTagsInfo([In, Out] byte[] pTagsBuffer, ref uint punTagCount); + internal delegate bool _ExportLiveToBuffer(System.Text.StringBuilder pBuffer, ref uint pnBufferLength); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetLiveCollisionBoundsTagsInfo GetLiveCollisionBoundsTagsInfo; + internal _ExportLiveToBuffer ExportLiveToBuffer; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _SetWorkingPhysicalBoundsInfo([In, Out] HmdQuad_t[] pQuadsBuffer, uint unQuadsCount); + internal delegate bool _ImportFromBufferToWorking(IntPtr pBuffer, uint nImportFlags); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetWorkingPhysicalBoundsInfo SetWorkingPhysicalBoundsInfo; + internal _ImportFromBufferToWorking ImportFromBufferToWorking; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetLivePhysicalBoundsInfo([In, Out] HmdQuad_t[] pQuadsBuffer, ref uint punQuadsCount); + internal delegate void _ShowWorkingSetPreview(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetLivePhysicalBoundsInfo GetLivePhysicalBoundsInfo; + internal _ShowWorkingSetPreview ShowWorkingSetPreview; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _ExportLiveToBuffer(System.Text.StringBuilder pBuffer, ref uint pnBufferLength); + internal delegate void _HideWorkingSetPreview(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _ExportLiveToBuffer ExportLiveToBuffer; + internal _HideWorkingSetPreview HideWorkingSetPreview; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _ImportFromBufferToWorking(string pBuffer, uint nImportFlags); + internal delegate void _RoomSetupStarting(); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _ImportFromBufferToWorking ImportFromBufferToWorking; + internal _RoomSetupStarting RoomSetupStarting; } @@ -675,6 +704,11 @@ public struct IVRCompositor [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetFrameTiming GetFrameTiming; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetFrameTimings([In, Out] Compositor_FrameTiming[] pTiming, uint nFrames); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetFrameTimings GetFrameTimings; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate float _GetFrameTimeRemaining(); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -690,11 +724,21 @@ public struct IVRCompositor [MarshalAs(UnmanagedType.FunctionPtr)] internal _FadeToColor FadeToColor; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate HmdColor_t _GetCurrentFadeColor(bool bBackground); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetCurrentFadeColor GetCurrentFadeColor; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate void _FadeGrid(float fSeconds, bool bFadeIn); [MarshalAs(UnmanagedType.FunctionPtr)] internal _FadeGrid FadeGrid; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate float _GetCurrentGridAlpha(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetCurrentGridAlpha GetCurrentGridAlpha; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVRCompositorError _SetSkyboxOverride([In, Out] Texture_t[] pTextures, uint unTextureCount); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -785,6 +829,11 @@ public struct IVRCompositor [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetMirrorTextureD3D11 GetMirrorTextureD3D11; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _ReleaseMirrorTextureD3D11(IntPtr pD3D11ShaderResourceView); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReleaseMirrorTextureD3D11 ReleaseMirrorTextureD3D11; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVRCompositorError _GetMirrorTextureGL(EVREye eEye, ref uint pglTextureId, IntPtr pglSharedTextureHandle); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -805,18 +854,78 @@ public struct IVRCompositor [MarshalAs(UnmanagedType.FunctionPtr)] internal _UnlockGLSharedTextureForAccess UnlockGLSharedTextureForAccess; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetVulkanInstanceExtensionsRequired(System.Text.StringBuilder pchValue, uint unBufferSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetVulkanInstanceExtensionsRequired GetVulkanInstanceExtensionsRequired; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetVulkanDeviceExtensionsRequired(IntPtr pPhysicalDevice, System.Text.StringBuilder pchValue, uint unBufferSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetVulkanDeviceExtensionsRequired GetVulkanDeviceExtensionsRequired; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetExplicitTimingMode(EVRCompositorTimingMode eTimingMode); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetExplicitTimingMode SetExplicitTimingMode; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRCompositorError _SubmitExplicitTimingData(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SubmitExplicitTimingData SubmitExplicitTimingData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsMotionSmoothingEnabled(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsMotionSmoothingEnabled IsMotionSmoothingEnabled; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsMotionSmoothingSupported(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsMotionSmoothingSupported IsMotionSmoothingSupported; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsCurrentSceneFocusAppLoading(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsCurrentSceneFocusAppLoading IsCurrentSceneFocusAppLoading; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRCompositorError _SetStageOverride_Async(IntPtr pchRenderModelPath, ref HmdMatrix34_t pTransform, ref Compositor_StageRenderSettings pRenderSettings, uint nSizeOfRenderSettings); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetStageOverride_Async SetStageOverride_Async; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _ClearStageOverride(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ClearStageOverride ClearStageOverride; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetCompositorBenchmarkResults(ref Compositor_BenchmarkResults pBenchmarkResults, uint nSizeOfBenchmarkResults); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetCompositorBenchmarkResults GetCompositorBenchmarkResults; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRCompositorError _GetLastPosePredictionIDs(ref uint pRenderPosePredictionID, ref uint pGamePosePredictionID); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetLastPosePredictionIDs GetLastPosePredictionIDs; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRCompositorError _GetPosesForFrame(uint unPosePredictionID, [In, Out] TrackedDevicePose_t[] pPoseArray, uint unPoseArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetPosesForFrame GetPosesForFrame; + } [StructLayout(LayoutKind.Sequential)] public struct IVROverlay { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _FindOverlay(string pchOverlayKey, ref ulong pOverlayHandle); + internal delegate EVROverlayError _FindOverlay(IntPtr pchOverlayKey, ref ulong pOverlayHandle); [MarshalAs(UnmanagedType.FunctionPtr)] internal _FindOverlay FindOverlay; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _CreateOverlay(string pchOverlayKey, string pchOverlayFriendlyName, ref ulong pOverlayHandle); + internal delegate EVROverlayError _CreateOverlay(IntPtr pchOverlayKey, IntPtr pchOverlayName, ref ulong pOverlayHandle); [MarshalAs(UnmanagedType.FunctionPtr)] internal _CreateOverlay CreateOverlay; @@ -825,16 +934,6 @@ public struct IVROverlay [MarshalAs(UnmanagedType.FunctionPtr)] internal _DestroyOverlay DestroyOverlay; - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetHighQualityOverlay(ulong ulOverlayHandle); - [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetHighQualityOverlay SetHighQualityOverlay; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate ulong _GetHighQualityOverlay(); - [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetHighQualityOverlay GetHighQualityOverlay; - [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate uint _GetOverlayKey(ulong ulOverlayHandle, System.Text.StringBuilder pchValue, uint unBufferSize, ref EVROverlayError pError); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -845,6 +944,11 @@ public struct IVROverlay [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetOverlayName GetOverlayName; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _SetOverlayName(ulong ulOverlayHandle, IntPtr pchName); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetOverlayName SetOverlayName; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVROverlayError _GetOverlayImageData(ulong ulOverlayHandle, IntPtr pvBuffer, uint unBufferSize, ref uint punWidth, ref uint punHeight); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -875,6 +979,11 @@ public struct IVROverlay [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetOverlayFlag GetOverlayFlag; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _GetOverlayFlags(ulong ulOverlayHandle, ref uint pFlags); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOverlayFlags GetOverlayFlags; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVROverlayError _SetOverlayColor(ulong ulOverlayHandle, float fRed, float fGreen, float fBlue); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -926,14 +1035,14 @@ public struct IVROverlay internal _GetOverlayWidthInMeters GetOverlayWidthInMeters; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetOverlayAutoCurveDistanceRangeInMeters(ulong ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters); + internal delegate EVROverlayError _SetOverlayCurvature(ulong ulOverlayHandle, float fCurvature); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetOverlayAutoCurveDistanceRangeInMeters SetOverlayAutoCurveDistanceRangeInMeters; + internal _SetOverlayCurvature SetOverlayCurvature; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _GetOverlayAutoCurveDistanceRangeInMeters(ulong ulOverlayHandle, ref float pfMinDistanceInMeters, ref float pfMaxDistanceInMeters); + internal delegate EVROverlayError _GetOverlayCurvature(ulong ulOverlayHandle, ref float pfCurvature); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetOverlayAutoCurveDistanceRangeInMeters GetOverlayAutoCurveDistanceRangeInMeters; + internal _GetOverlayCurvature GetOverlayCurvature; [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVROverlayError _SetOverlayTextureColorSpace(ulong ulOverlayHandle, EColorSpace eTextureColorSpace); @@ -981,15 +1090,35 @@ public struct IVROverlay internal _GetOverlayTransformTrackedDeviceRelative GetOverlayTransformTrackedDeviceRelative; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, uint unDeviceIndex, string pchComponentName); + internal delegate EVROverlayError _SetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, uint unDeviceIndex, IntPtr pchComponentName); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetOverlayTransformTrackedDeviceComponent SetOverlayTransformTrackedDeviceComponent; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _GetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, ref uint punDeviceIndex, string pchComponentName, uint unComponentNameSize); + internal delegate EVROverlayError _GetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, ref uint punDeviceIndex, System.Text.StringBuilder pchComponentName, uint unComponentNameSize); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetOverlayTransformTrackedDeviceComponent GetOverlayTransformTrackedDeviceComponent; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _GetOverlayTransformOverlayRelative(ulong ulOverlayHandle, ref ulong ulOverlayHandleParent, ref HmdMatrix34_t pmatParentOverlayToOverlayTransform); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOverlayTransformOverlayRelative GetOverlayTransformOverlayRelative; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _SetOverlayTransformOverlayRelative(ulong ulOverlayHandle, ulong ulOverlayHandleParent, ref HmdMatrix34_t pmatParentOverlayToOverlayTransform); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetOverlayTransformOverlayRelative SetOverlayTransformOverlayRelative; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _SetOverlayTransformCursor(ulong ulCursorOverlayHandle, ref HmdVector2_t pvHotspot); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetOverlayTransformCursor SetOverlayTransformCursor; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _GetOverlayTransformCursor(ulong ulOverlayHandle, ref HmdVector2_t pvHotspot); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetOverlayTransformCursor GetOverlayTransformCursor; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVROverlayError _ShowOverlay(ulong ulOverlayHandle); [MarshalAs(UnmanagedType.FunctionPtr)] @@ -1041,34 +1170,34 @@ public struct IVROverlay internal _ComputeOverlayIntersection ComputeOverlayIntersection; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _HandleControllerOverlayInteractionAsMouse(ulong ulOverlayHandle, uint unControllerDeviceIndex); + internal delegate bool _IsHoverTargetOverlay(ulong ulOverlayHandle); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _HandleControllerOverlayInteractionAsMouse HandleControllerOverlayInteractionAsMouse; + internal _IsHoverTargetOverlay IsHoverTargetOverlay; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _IsHoverTargetOverlay(ulong ulOverlayHandle); + internal delegate EVROverlayError _SetOverlayIntersectionMask(ulong ulOverlayHandle, ref VROverlayIntersectionMaskPrimitive_t pMaskPrimitives, uint unNumMaskPrimitives, uint unPrimitiveSize); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _IsHoverTargetOverlay IsHoverTargetOverlay; + internal _SetOverlayIntersectionMask SetOverlayIntersectionMask; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate ulong _GetGamepadFocusOverlay(); + internal delegate EVROverlayError _TriggerLaserMouseHapticVibration(ulong ulOverlayHandle, float fDurationSeconds, float fFrequency, float fAmplitude); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetGamepadFocusOverlay GetGamepadFocusOverlay; + internal _TriggerLaserMouseHapticVibration TriggerLaserMouseHapticVibration; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetGamepadFocusOverlay(ulong ulNewFocusOverlay); + internal delegate EVROverlayError _SetOverlayCursor(ulong ulOverlayHandle, ulong ulCursorHandle); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetGamepadFocusOverlay SetGamepadFocusOverlay; + internal _SetOverlayCursor SetOverlayCursor; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetOverlayNeighbor(EOverlayDirection eDirection, ulong ulFrom, ulong ulTo); + internal delegate EVROverlayError _SetOverlayCursorPositionOverride(ulong ulOverlayHandle, ref HmdVector2_t pvCursor); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetOverlayNeighbor SetOverlayNeighbor; + internal _SetOverlayCursorPositionOverride SetOverlayCursorPositionOverride; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _MoveGamepadFocusToNeighbor(EOverlayDirection eDirection, ulong ulFrom); + internal delegate EVROverlayError _ClearOverlayCursorPositionOverride(ulong ulOverlayHandle); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _MoveGamepadFocusToNeighbor MoveGamepadFocusToNeighbor; + internal _ClearOverlayCursorPositionOverride ClearOverlayCursorPositionOverride; [UnmanagedFunctionPointer(CallingConvention.StdCall)] internal delegate EVROverlayError _SetOverlayTexture(ulong ulOverlayHandle, ref Texture_t pTexture); @@ -1081,17 +1210,17 @@ public struct IVROverlay internal _ClearOverlayTexture ClearOverlayTexture; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetOverlayRaw(ulong ulOverlayHandle, IntPtr pvBuffer, uint unWidth, uint unHeight, uint unDepth); + internal delegate EVROverlayError _SetOverlayRaw(ulong ulOverlayHandle, IntPtr pvBuffer, uint unWidth, uint unHeight, uint unBytesPerPixel); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetOverlayRaw SetOverlayRaw; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _SetOverlayFromFile(ulong ulOverlayHandle, string pchFilePath); + internal delegate EVROverlayError _SetOverlayFromFile(ulong ulOverlayHandle, IntPtr pchFilePath); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetOverlayFromFile SetOverlayFromFile; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _GetOverlayTexture(ulong ulOverlayHandle, ref IntPtr pNativeTextureHandle, IntPtr pNativeTextureRef, ref uint pWidth, ref uint pHeight, ref uint pNativeFormat, ref EGraphicsAPIConvention pAPI, ref EColorSpace pColorSpace); + internal delegate EVROverlayError _GetOverlayTexture(ulong ulOverlayHandle, ref IntPtr pNativeTextureHandle, IntPtr pNativeTextureRef, ref uint pWidth, ref uint pHeight, ref uint pNativeFormat, ref ETextureType pAPIType, ref EColorSpace pColorSpace, ref VRTextureBounds_t pTextureBounds); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetOverlayTexture GetOverlayTexture; @@ -1106,7 +1235,7 @@ public struct IVROverlay internal _GetOverlayTextureSize GetOverlayTextureSize; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _CreateDashboardOverlay(string pchOverlayKey, string pchOverlayFriendlyName, ref ulong pMainHandle, ref ulong pThumbnailHandle); + internal delegate EVROverlayError _CreateDashboardOverlay(IntPtr pchOverlayKey, IntPtr pchOverlayFriendlyName, ref ulong pMainHandle, ref ulong pThumbnailHandle); [MarshalAs(UnmanagedType.FunctionPtr)] internal _CreateDashboardOverlay CreateDashboardOverlay; @@ -1131,7 +1260,7 @@ public struct IVROverlay internal _GetDashboardOverlaySceneProcess GetDashboardOverlaySceneProcess; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _ShowDashboard(string pchOverlayToShow); + internal delegate void _ShowDashboard(IntPtr pchOverlayToShow); [MarshalAs(UnmanagedType.FunctionPtr)] internal _ShowDashboard ShowDashboard; @@ -1141,12 +1270,12 @@ public struct IVROverlay internal _GetPrimaryDashboardDevice GetPrimaryDashboardDevice; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _ShowKeyboard(int eInputMode, int eLineInputMode, string pchDescription, uint unCharMax, string pchExistingText, bool bUseMinimalMode, ulong uUserValue); + internal delegate EVROverlayError _ShowKeyboard(int eInputMode, int eLineInputMode, uint unFlags, IntPtr pchDescription, uint unCharMax, IntPtr pchExistingText, ulong uUserValue); [MarshalAs(UnmanagedType.FunctionPtr)] internal _ShowKeyboard ShowKeyboard; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVROverlayError _ShowKeyboardForOverlay(ulong ulOverlayHandle, int eInputMode, int eLineInputMode, string pchDescription, uint unCharMax, string pchExistingText, bool bUseMinimalMode, ulong uUserValue); + internal delegate EVROverlayError _ShowKeyboardForOverlay(ulong ulOverlayHandle, int eInputMode, int eLineInputMode, uint unFlags, IntPtr pchDescription, uint unCharMax, IntPtr pchExistingText, ulong uUserValue); [MarshalAs(UnmanagedType.FunctionPtr)] internal _ShowKeyboardForOverlay ShowKeyboardForOverlay; @@ -1170,13 +1299,98 @@ public struct IVROverlay [MarshalAs(UnmanagedType.FunctionPtr)] internal _SetKeyboardPositionForOverlay SetKeyboardPositionForOverlay; + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate VRMessageOverlayResponse _ShowMessageOverlay(IntPtr pchText, IntPtr pchCaption, IntPtr pchButton0Text, IntPtr pchButton1Text, IntPtr pchButton2Text, IntPtr pchButton3Text); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ShowMessageOverlay ShowMessageOverlay; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _CloseMessageOverlay(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _CloseMessageOverlay CloseMessageOverlay; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVROverlayView +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _AcquireOverlayView(ulong ulOverlayHandle, ref VRNativeDevice_t pNativeDevice, ref VROverlayView_t pOverlayView, uint unOverlayViewSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _AcquireOverlayView AcquireOverlayView; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVROverlayError _ReleaseOverlayView(ref VROverlayView_t pOverlayView); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReleaseOverlayView ReleaseOverlayView; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _PostOverlayEvent(ulong ulOverlayHandle, ref VREvent_t pvrEvent); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _PostOverlayEvent PostOverlayEvent; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsViewingPermitted(ulong ulOverlayHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsViewingPermitted IsViewingPermitted; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRHeadsetView +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetHeadsetViewSize(uint nWidth, uint nHeight); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetHeadsetViewSize SetHeadsetViewSize; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _GetHeadsetViewSize(ref uint pnWidth, ref uint pnHeight); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetHeadsetViewSize GetHeadsetViewSize; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetHeadsetViewMode(uint eHeadsetViewMode); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetHeadsetViewMode SetHeadsetViewMode; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetHeadsetViewMode(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetHeadsetViewMode GetHeadsetViewMode; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetHeadsetViewCropped(bool bCropped); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetHeadsetViewCropped SetHeadsetViewCropped; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetHeadsetViewCropped(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetHeadsetViewCropped GetHeadsetViewCropped; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate float _GetHeadsetViewAspectRatio(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetHeadsetViewAspectRatio GetHeadsetViewAspectRatio; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _SetHeadsetViewBlendRange(float flStartPct, float flEndPct); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetHeadsetViewBlendRange SetHeadsetViewBlendRange; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate void _GetHeadsetViewBlendRange(ref float pStartPct, ref float pEndPct); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetHeadsetViewBlendRange GetHeadsetViewBlendRange; + } [StructLayout(LayoutKind.Sequential)] public struct IVRRenderModels { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRRenderModelError _LoadRenderModel_Async(string pchRenderModelName, ref IntPtr ppRenderModel); + internal delegate EVRRenderModelError _LoadRenderModel_Async(IntPtr pchRenderModelName, ref IntPtr ppRenderModel); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LoadRenderModel_Async LoadRenderModel_Async; @@ -1221,42 +1435,47 @@ public struct IVRRenderModels internal _GetRenderModelCount GetRenderModelCount; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetComponentCount(string pchRenderModelName); + internal delegate uint _GetComponentCount(IntPtr pchRenderModelName); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetComponentCount GetComponentCount; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetComponentName(string pchRenderModelName, uint unComponentIndex, System.Text.StringBuilder pchComponentName, uint unComponentNameLen); + internal delegate uint _GetComponentName(IntPtr pchRenderModelName, uint unComponentIndex, System.Text.StringBuilder pchComponentName, uint unComponentNameLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetComponentName GetComponentName; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate ulong _GetComponentButtonMask(string pchRenderModelName, string pchComponentName); + internal delegate ulong _GetComponentButtonMask(IntPtr pchRenderModelName, IntPtr pchComponentName); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetComponentButtonMask GetComponentButtonMask; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetComponentRenderModelName(string pchRenderModelName, string pchComponentName, System.Text.StringBuilder pchComponentRenderModelName, uint unComponentRenderModelNameLen); + internal delegate uint _GetComponentRenderModelName(IntPtr pchRenderModelName, IntPtr pchComponentName, System.Text.StringBuilder pchComponentRenderModelName, uint unComponentRenderModelNameLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetComponentRenderModelName GetComponentRenderModelName; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetComponentState(string pchRenderModelName, string pchComponentName, ref VRControllerState_t pControllerState, ref RenderModel_ControllerMode_State_t pState, ref RenderModel_ComponentState_t pComponentState); + internal delegate bool _GetComponentStateForDevicePath(IntPtr pchRenderModelName, IntPtr pchComponentName, ulong devicePath, ref RenderModel_ControllerMode_State_t pState, ref RenderModel_ComponentState_t pComponentState); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetComponentStateForDevicePath GetComponentStateForDevicePath; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetComponentState(IntPtr pchRenderModelName, IntPtr pchComponentName, ref VRControllerState_t pControllerState, ref RenderModel_ControllerMode_State_t pState, ref RenderModel_ComponentState_t pComponentState); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetComponentState GetComponentState; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _RenderModelHasComponent(string pchRenderModelName, string pchComponentName); + internal delegate bool _RenderModelHasComponent(IntPtr pchRenderModelName, IntPtr pchComponentName); [MarshalAs(UnmanagedType.FunctionPtr)] internal _RenderModelHasComponent RenderModelHasComponent; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetRenderModelThumbnailURL(string pchRenderModelName, System.Text.StringBuilder pchThumbnailURL, uint unThumbnailURLLen, ref EVRRenderModelError peError); + internal delegate uint _GetRenderModelThumbnailURL(IntPtr pchRenderModelName, System.Text.StringBuilder pchThumbnailURL, uint unThumbnailURLLen, ref EVRRenderModelError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetRenderModelThumbnailURL GetRenderModelThumbnailURL; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetRenderModelOriginalPath(string pchRenderModelName, System.Text.StringBuilder pchOriginalPath, uint unOriginalPathLen, ref EVRRenderModelError peError); + internal delegate uint _GetRenderModelOriginalPath(IntPtr pchRenderModelName, System.Text.StringBuilder pchOriginalPath, uint unOriginalPathLen, ref EVRRenderModelError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetRenderModelOriginalPath GetRenderModelOriginalPath; @@ -1271,7 +1490,7 @@ public struct IVRRenderModels public struct IVRNotifications { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRNotificationError _CreateNotification(ulong ulOverlayHandle, ulong ulUserValue, EVRNotificationType type, string pchText, EVRNotificationStyle style, ref NotificationBitmap_t pImage, ref uint pNotificationId); + internal delegate EVRNotificationError _CreateNotification(ulong ulOverlayHandle, ulong ulUserValue, EVRNotificationType type, IntPtr pchText, EVRNotificationStyle style, ref NotificationBitmap_t pImage, ref uint pNotificationId); [MarshalAs(UnmanagedType.FunctionPtr)] internal _CreateNotification CreateNotification; @@ -1291,57 +1510,52 @@ public struct IVRSettings internal _GetSettingsErrorNameFromEnum GetSettingsErrorNameFromEnum; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _Sync(bool bForce, ref EVRSettingsError peError); + internal delegate void _SetBool(IntPtr pchSection, IntPtr pchSettingsKey, bool bValue, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _Sync Sync; + internal _SetBool SetBool; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate bool _GetBool(string pchSection, string pchSettingsKey, bool bDefaultValue, ref EVRSettingsError peError); + internal delegate void _SetInt32(IntPtr pchSection, IntPtr pchSettingsKey, int nValue, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetBool GetBool; + internal _SetInt32 SetInt32; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _SetBool(string pchSection, string pchSettingsKey, bool bValue, ref EVRSettingsError peError); + internal delegate void _SetFloat(IntPtr pchSection, IntPtr pchSettingsKey, float flValue, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetBool SetBool; + internal _SetFloat SetFloat; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate int _GetInt32(string pchSection, string pchSettingsKey, int nDefaultValue, ref EVRSettingsError peError); + internal delegate void _SetString(IntPtr pchSection, IntPtr pchSettingsKey, IntPtr pchValue, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetInt32 GetInt32; + internal _SetString SetString; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _SetInt32(string pchSection, string pchSettingsKey, int nValue, ref EVRSettingsError peError); + internal delegate bool _GetBool(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetInt32 SetInt32; + internal _GetBool GetBool; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate float _GetFloat(string pchSection, string pchSettingsKey, float flDefaultValue, ref EVRSettingsError peError); + internal delegate int _GetInt32(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _GetFloat GetFloat; + internal _GetInt32 GetInt32; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _SetFloat(string pchSection, string pchSettingsKey, float flValue, ref EVRSettingsError peError); + internal delegate float _GetFloat(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetFloat SetFloat; + internal _GetFloat GetFloat; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _GetString(string pchSection, string pchSettingsKey, System.Text.StringBuilder pchValue, uint unValueLen, string pchDefaultValue, ref EVRSettingsError peError); + internal delegate void _GetString(IntPtr pchSection, IntPtr pchSettingsKey, System.Text.StringBuilder pchValue, uint unValueLen, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetString GetString; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _SetString(string pchSection, string pchSettingsKey, string pchValue, ref EVRSettingsError peError); - [MarshalAs(UnmanagedType.FunctionPtr)] - internal _SetString SetString; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _RemoveSection(string pchSection, ref EVRSettingsError peError); + internal delegate void _RemoveSection(IntPtr pchSection, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _RemoveSection RemoveSection; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate void _RemoveKeyInSection(string pchSection, string pchSettingsKey, ref EVRSettingsError peError); + internal delegate void _RemoveKeyInSection(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError); [MarshalAs(UnmanagedType.FunctionPtr)] internal _RemoveKeyInSection RemoveKeyInSection; @@ -1351,7 +1565,7 @@ public struct IVRSettings public struct IVRScreenshots { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRScreenshotError _RequestScreenshot(ref uint pOutScreenshotHandle, EVRScreenshotType type, string pchPreviewFilename, string pchVRFilename); + internal delegate EVRScreenshotError _RequestScreenshot(ref uint pOutScreenshotHandle, EVRScreenshotType type, IntPtr pchPreviewFilename, IntPtr pchVRFilename); [MarshalAs(UnmanagedType.FunctionPtr)] internal _RequestScreenshot RequestScreenshot; @@ -1376,12 +1590,12 @@ public struct IVRScreenshots internal _UpdateScreenshotProgress UpdateScreenshotProgress; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRScreenshotError _TakeStereoScreenshot(ref uint pOutScreenshotHandle, string pchPreviewFilename, string pchVRFilename); + internal delegate EVRScreenshotError _TakeStereoScreenshot(ref uint pOutScreenshotHandle, IntPtr pchPreviewFilename, IntPtr pchVRFilename); [MarshalAs(UnmanagedType.FunctionPtr)] internal _TakeStereoScreenshot TakeStereoScreenshot; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate EVRScreenshotError _SubmitScreenshot(uint screenshotHandle, EVRScreenshotType type, string pchSourcePreviewFilename, string pchSourceVRFilename); + internal delegate EVRScreenshotError _SubmitScreenshot(uint screenshotHandle, EVRScreenshotType type, IntPtr pchSourcePreviewFilename, IntPtr pchSourceVRFilename); [MarshalAs(UnmanagedType.FunctionPtr)] internal _SubmitScreenshot SubmitScreenshot; @@ -1391,1484 +1605,2863 @@ public struct IVRScreenshots public struct IVRResources { [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _LoadSharedResource(string pchResourceName, string pchBuffer, uint unBufferLen); + internal delegate uint _LoadSharedResource(IntPtr pchResourceName, string pchBuffer, uint unBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _LoadSharedResource LoadSharedResource; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - internal delegate uint _GetResourceFullPath(string pchResourceName, string pchResourceTypeDirectory, string pchPathBuffer, uint unBufferLen); + internal delegate uint _GetResourceFullPath(IntPtr pchResourceName, IntPtr pchResourceTypeDirectory, System.Text.StringBuilder pchPathBuffer, uint unBufferLen); [MarshalAs(UnmanagedType.FunctionPtr)] internal _GetResourceFullPath GetResourceFullPath; } +[StructLayout(LayoutKind.Sequential)] +public struct IVRDriverManager +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetDriverCount(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDriverCount GetDriverCount; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _GetDriverName(uint nDriver, System.Text.StringBuilder pchValue, uint unBufferSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDriverName GetDriverName; -public class CVRSystem + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ulong _GetDriverHandle(IntPtr pchDriverName); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDriverHandle GetDriverHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsEnabled(uint nDriver); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsEnabled IsEnabled; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRInput { - IVRSystem FnTable; - internal CVRSystem(IntPtr pInterface) - { - FnTable = (IVRSystem)Marshal.PtrToStructure(pInterface, typeof(IVRSystem)); - } - public void GetRecommendedRenderTargetSize(ref uint pnWidth,ref uint pnHeight) - { - pnWidth = 0; - pnHeight = 0; - FnTable.GetRecommendedRenderTargetSize(ref pnWidth,ref pnHeight); - } - public HmdMatrix44_t GetProjectionMatrix(EVREye eEye,float fNearZ,float fFarZ,EGraphicsAPIConvention eProjType) - { - HmdMatrix44_t result = FnTable.GetProjectionMatrix(eEye,fNearZ,fFarZ,eProjType); - return result; - } - public void GetProjectionRaw(EVREye eEye,ref float pfLeft,ref float pfRight,ref float pfTop,ref float pfBottom) - { - pfLeft = 0; - pfRight = 0; - pfTop = 0; - pfBottom = 0; - FnTable.GetProjectionRaw(eEye,ref pfLeft,ref pfRight,ref pfTop,ref pfBottom); - } - public DistortionCoordinates_t ComputeDistortion(EVREye eEye,float fU,float fV) - { - DistortionCoordinates_t result = FnTable.ComputeDistortion(eEye,fU,fV); - return result; - } - public HmdMatrix34_t GetEyeToHeadTransform(EVREye eEye) - { - HmdMatrix34_t result = FnTable.GetEyeToHeadTransform(eEye); - return result; - } - public bool GetTimeSinceLastVsync(ref float pfSecondsSinceLastVsync,ref ulong pulFrameCounter) - { - pfSecondsSinceLastVsync = 0; - pulFrameCounter = 0; - bool result = FnTable.GetTimeSinceLastVsync(ref pfSecondsSinceLastVsync,ref pulFrameCounter); - return result; - } - public int GetD3D9AdapterIndex() - { - int result = FnTable.GetD3D9AdapterIndex(); - return result; - } - public void GetDXGIOutputInfo(ref int pnAdapterIndex) - { - pnAdapterIndex = 0; - FnTable.GetDXGIOutputInfo(ref pnAdapterIndex); - } - public bool IsDisplayOnDesktop() - { - bool result = FnTable.IsDisplayOnDesktop(); - return result; - } - public bool SetDisplayVisibility(bool bIsVisibleOnDesktop) - { - bool result = FnTable.SetDisplayVisibility(bIsVisibleOnDesktop); - return result; - } - public void GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin eOrigin,float fPredictedSecondsToPhotonsFromNow,TrackedDevicePose_t [] pTrackedDevicePoseArray) - { + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _SetActionManifestPath(IntPtr pchActionManifestPath); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetActionManifestPath SetActionManifestPath; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetActionSetHandle(IntPtr pchActionSetName, ref ulong pHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionSetHandle GetActionSetHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetActionHandle(IntPtr pchActionName, ref ulong pHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionHandle GetActionHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetInputSourceHandle(IntPtr 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, ulong ulRestrictToDevice); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDigitalActionData GetDigitalActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetAnalogActionData(ulong action, ref InputAnalogActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetAnalogActionData GetAnalogActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetPoseActionDataRelativeToNow(ulong action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, ref InputPoseActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetPoseActionDataRelativeToNow GetPoseActionDataRelativeToNow; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetPoseActionDataForNextFrame(ulong action, ETrackingUniverseOrigin eOrigin, ref InputPoseActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetPoseActionDataForNextFrame GetPoseActionDataForNextFrame; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalActionData(ulong action, ref InputSkeletalActionData_t pActionData, uint unActionDataSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalActionData GetSkeletalActionData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetDominantHand(ref ETrackedControllerRole peDominantHand); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetDominantHand GetDominantHand; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _SetDominantHand(ETrackedControllerRole eDominantHand); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _SetDominantHand SetDominantHand; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetBoneCount(ulong action, ref uint pBoneCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetBoneCount GetBoneCount; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetBoneHierarchy(ulong action, [In, Out] int[] pParentIndices, uint unIndexArayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetBoneHierarchy GetBoneHierarchy; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetBoneName(ulong action, int nBoneIndex, System.Text.StringBuilder pchBoneName, uint unNameBufferSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetBoneName GetBoneName; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalReferenceTransforms(ulong action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, [In, Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalReferenceTransforms GetSkeletalReferenceTransforms; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalTrackingLevel(ulong action, ref EVRSkeletalTrackingLevel pSkeletalTrackingLevel); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalTrackingLevel GetSkeletalTrackingLevel; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalBoneData(ulong action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, [In, Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalBoneData GetSkeletalBoneData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalSummaryData(ulong action, EVRSummaryType eSummaryType, ref VRSkeletalSummaryData_t pSkeletalSummaryData); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalSummaryData GetSkeletalSummaryData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetSkeletalBoneDataCompressed(ulong action, EVRSkeletalMotionRange eMotionRange, IntPtr pvCompressedData, uint unCompressedSize, ref uint punRequiredCompressedSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSkeletalBoneDataCompressed GetSkeletalBoneDataCompressed; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _DecompressSkeletalBoneData(IntPtr pvCompressedBuffer, uint unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, [In, Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _DecompressSkeletalBoneData DecompressSkeletalBoneData; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _TriggerHapticVibrationAction(ulong action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, ulong ulRestrictToDevice); + [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, int unStringSectionsToInclude); + [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 _GetActionBindingInfo(ulong action, ref InputBindingInfo_t pOriginInfo, uint unBindingInfoSize, uint unBindingInfoCount, ref uint punReturnedBindingInfoCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetActionBindingInfo GetActionBindingInfo; + + [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; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetComponentStateForBinding(IntPtr pchRenderModelName, IntPtr pchComponentName, ref InputBindingInfo_t pOriginInfo, uint unBindingInfoSize, uint unBindingInfoCount, ref RenderModel_ComponentState_t pComponentState); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetComponentStateForBinding GetComponentStateForBinding; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _IsUsingLegacyInput(); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _IsUsingLegacyInput IsUsingLegacyInput; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _OpenBindingUI(IntPtr pchAppKey, ulong ulActionSetHandle, ulong ulDeviceHandle, bool bShowOnDesktop); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _OpenBindingUI OpenBindingUI; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRInputError _GetBindingVariant(ulong ulDevicePath, System.Text.StringBuilder pchVariantArray, uint unVariantArraySize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetBindingVariant GetBindingVariant; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRIOBuffer +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EIOBufferError _Open(IntPtr 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; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _HasReaders(ulong ulBuffer); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _HasReaders HasReaders; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRSpatialAnchors +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRSpatialAnchorError _CreateSpatialAnchorFromDescriptor(IntPtr pchDescriptor, ref uint pHandleOut); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _CreateSpatialAnchorFromDescriptor CreateSpatialAnchorFromDescriptor; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRSpatialAnchorError _CreateSpatialAnchorFromPose(uint unDeviceIndex, ETrackingUniverseOrigin eOrigin, ref SpatialAnchorPose_t pPose, ref uint pHandleOut); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _CreateSpatialAnchorFromPose CreateSpatialAnchorFromPose; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRSpatialAnchorError _GetSpatialAnchorPose(uint unHandle, ETrackingUniverseOrigin eOrigin, ref SpatialAnchorPose_t pPoseOut); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSpatialAnchorPose GetSpatialAnchorPose; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRSpatialAnchorError _GetSpatialAnchorDescriptor(uint unHandle, System.Text.StringBuilder pchDescriptorOut, ref uint punDescriptorBufferLenInOut); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetSpatialAnchorDescriptor GetSpatialAnchorDescriptor; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRDebug +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRDebugError _EmitVrProfilerEvent(IntPtr pchMessage); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _EmitVrProfilerEvent EmitVrProfilerEvent; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRDebugError _BeginVrProfilerEvent(ref ulong pHandleOut); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _BeginVrProfilerEvent BeginVrProfilerEvent; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EVRDebugError _FinishVrProfilerEvent(ulong hHandle, IntPtr pchMessage); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _FinishVrProfilerEvent FinishVrProfilerEvent; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate uint _DriverDebugRequest(uint unDeviceIndex, IntPtr pchRequest, System.Text.StringBuilder pchResponseBuffer, uint unResponseBufferSize); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _DriverDebugRequest DriverDebugRequest; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRProperties +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _ReadPropertyBatch(ulong ulContainerHandle, ref PropertyRead_t pBatch, uint unBatchEntryCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReadPropertyBatch ReadPropertyBatch; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _WritePropertyBatch(ulong ulContainerHandle, ref PropertyWrite_t pBatch, uint unBatchEntryCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _WritePropertyBatch WritePropertyBatch; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate IntPtr _GetPropErrorNameFromEnum(ETrackedPropertyError error); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _GetPropErrorNameFromEnum GetPropErrorNameFromEnum; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ulong _TrackedDeviceToPropertyContainer(uint nDevice); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _TrackedDeviceToPropertyContainer TrackedDeviceToPropertyContainer; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRPaths +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _ReadPathBatch(ulong ulRootHandle, ref PathRead_t pBatch, uint unBatchEntryCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReadPathBatch ReadPathBatch; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _WritePathBatch(ulong ulRootHandle, ref PathWrite_t pBatch, uint unBatchEntryCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _WritePathBatch WritePathBatch; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _StringToHandle(ref ulong pHandle, IntPtr pchPath); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _StringToHandle StringToHandle; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate ETrackedPropertyError _HandleToString(ulong pHandle, string pchBuffer, uint unBufferSize, ref uint punBufferSizeUsed); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _HandleToString HandleToString; + +} + +[StructLayout(LayoutKind.Sequential)] +public struct IVRBlockQueue +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _Create(ref ulong pulQueueHandle, IntPtr pchPath, uint unBlockDataSize, uint unBlockHeaderSize, uint unBlockCount); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Create Create; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _Connect(ref ulong pulQueueHandle, IntPtr pchPath); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Connect Connect; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _Destroy(ulong ulQueueHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _Destroy Destroy; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _AcquireWriteOnlyBlock(ulong ulQueueHandle, ref ulong pulBlockHandle, ref IntPtr ppvBuffer); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _AcquireWriteOnlyBlock AcquireWriteOnlyBlock; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _ReleaseWriteOnlyBlock(ulong ulQueueHandle, ulong ulBlockHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReleaseWriteOnlyBlock ReleaseWriteOnlyBlock; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _WaitAndAcquireReadOnlyBlock(ulong ulQueueHandle, ref ulong pulBlockHandle, ref IntPtr ppvBuffer, EBlockQueueReadType eReadType, uint unTimeoutMs); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _WaitAndAcquireReadOnlyBlock WaitAndAcquireReadOnlyBlock; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _AcquireReadOnlyBlock(ulong ulQueueHandle, ref ulong pulBlockHandle, ref IntPtr ppvBuffer, EBlockQueueReadType eReadType); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _AcquireReadOnlyBlock AcquireReadOnlyBlock; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _ReleaseReadOnlyBlock(ulong ulQueueHandle, ulong ulBlockHandle); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _ReleaseReadOnlyBlock ReleaseReadOnlyBlock; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate EBlockQueueError _QueueHasReader(ulong ulQueueHandle, ref bool pbHasReaders); + [MarshalAs(UnmanagedType.FunctionPtr)] + internal _QueueHasReader QueueHasReader; + +} + + +public class Utils +{ + public static IntPtr ToUtf8(string managedString) + { + int size = System.Text.Encoding.UTF8.GetByteCount(managedString) + 1; + if (buffer.Length < size) buffer = new byte[size]; + int written = System.Text.Encoding.UTF8.GetBytes(managedString, 0, managedString.Length, buffer, 0); + buffer[written] = 0x00; // null terminate + IntPtr nativeUtf8 = Marshal.AllocHGlobal(written+1); + Marshal.Copy(buffer, 0, nativeUtf8, written+1); + return nativeUtf8; + } + private static byte[] buffer = new byte[1024]; +} + +public class CVRSystem +{ + IVRSystem FnTable; + internal CVRSystem(IntPtr pInterface) + { + FnTable = (IVRSystem)Marshal.PtrToStructure(pInterface, typeof(IVRSystem)); + } + public void GetRecommendedRenderTargetSize(ref uint pnWidth,ref uint pnHeight) + { + pnWidth = 0; + pnHeight = 0; + FnTable.GetRecommendedRenderTargetSize(ref pnWidth,ref pnHeight); + } + public HmdMatrix44_t GetProjectionMatrix(EVREye eEye,float fNearZ,float fFarZ) + { + HmdMatrix44_t result = FnTable.GetProjectionMatrix(eEye,fNearZ,fFarZ); + return result; + } + public void GetProjectionRaw(EVREye eEye,ref float pfLeft,ref float pfRight,ref float pfTop,ref float pfBottom) + { + pfLeft = 0; + pfRight = 0; + pfTop = 0; + pfBottom = 0; + FnTable.GetProjectionRaw(eEye,ref pfLeft,ref pfRight,ref pfTop,ref pfBottom); + } + public bool ComputeDistortion(EVREye eEye,float fU,float fV,ref DistortionCoordinates_t pDistortionCoordinates) + { + bool result = FnTable.ComputeDistortion(eEye,fU,fV,ref pDistortionCoordinates); + return result; + } + public HmdMatrix34_t GetEyeToHeadTransform(EVREye eEye) + { + HmdMatrix34_t result = FnTable.GetEyeToHeadTransform(eEye); + return result; + } + public bool GetTimeSinceLastVsync(ref float pfSecondsSinceLastVsync,ref ulong pulFrameCounter) + { + pfSecondsSinceLastVsync = 0; + pulFrameCounter = 0; + bool result = FnTable.GetTimeSinceLastVsync(ref pfSecondsSinceLastVsync,ref pulFrameCounter); + return result; + } + public int GetD3D9AdapterIndex() + { + int result = FnTable.GetD3D9AdapterIndex(); + return result; + } + public void GetDXGIOutputInfo(ref int pnAdapterIndex) + { + pnAdapterIndex = 0; + FnTable.GetDXGIOutputInfo(ref pnAdapterIndex); + } + public void GetOutputDevice(ref ulong pnDevice,ETextureType textureType,IntPtr pInstance) + { + pnDevice = 0; + FnTable.GetOutputDevice(ref pnDevice,textureType,pInstance); + } + public bool IsDisplayOnDesktop() + { + bool result = FnTable.IsDisplayOnDesktop(); + return result; + } + public bool SetDisplayVisibility(bool bIsVisibleOnDesktop) + { + bool result = FnTable.SetDisplayVisibility(bIsVisibleOnDesktop); + return result; + } + public void GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin eOrigin,float fPredictedSecondsToPhotonsFromNow,TrackedDevicePose_t [] pTrackedDevicePoseArray) + { FnTable.GetDeviceToAbsoluteTrackingPose(eOrigin,fPredictedSecondsToPhotonsFromNow,pTrackedDevicePoseArray,(uint) pTrackedDevicePoseArray.Length); } - public void ResetSeatedZeroPose() + public void ResetSeatedZeroPose() + { + FnTable.ResetSeatedZeroPose(); + } + public HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() + { + HmdMatrix34_t result = FnTable.GetSeatedZeroPoseToStandingAbsoluteTrackingPose(); + return result; + } + public HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose() + { + HmdMatrix34_t result = FnTable.GetRawZeroPoseToStandingAbsoluteTrackingPose(); + return result; + } + public uint GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass eTrackedDeviceClass,uint [] punTrackedDeviceIndexArray,uint unRelativeToTrackedDeviceIndex) + { + uint result = FnTable.GetSortedTrackedDeviceIndicesOfClass(eTrackedDeviceClass,punTrackedDeviceIndexArray,(uint) punTrackedDeviceIndexArray.Length,unRelativeToTrackedDeviceIndex); + return result; + } + public EDeviceActivityLevel GetTrackedDeviceActivityLevel(uint unDeviceId) + { + EDeviceActivityLevel result = FnTable.GetTrackedDeviceActivityLevel(unDeviceId); + return result; + } + public void ApplyTransform(ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pTrackedDevicePose,ref HmdMatrix34_t pTransform) + { + FnTable.ApplyTransform(ref pOutputPose,ref pTrackedDevicePose,ref pTransform); + } + public uint GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole unDeviceType) + { + uint result = FnTable.GetTrackedDeviceIndexForControllerRole(unDeviceType); + return result; + } + public ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex(uint unDeviceIndex) + { + ETrackedControllerRole result = FnTable.GetControllerRoleForTrackedDeviceIndex(unDeviceIndex); + return result; + } + public ETrackedDeviceClass GetTrackedDeviceClass(uint unDeviceIndex) + { + ETrackedDeviceClass result = FnTable.GetTrackedDeviceClass(unDeviceIndex); + return result; + } + public bool IsTrackedDeviceConnected(uint unDeviceIndex) + { + bool result = FnTable.IsTrackedDeviceConnected(unDeviceIndex); + return result; + } + public bool GetBoolTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + { + bool result = FnTable.GetBoolTrackedDeviceProperty(unDeviceIndex,prop,ref pError); + return result; + } + public float GetFloatTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + { + float result = FnTable.GetFloatTrackedDeviceProperty(unDeviceIndex,prop,ref pError); + return result; + } + public int GetInt32TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + { + int result = FnTable.GetInt32TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + return result; + } + public ulong GetUint64TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + { + ulong result = FnTable.GetUint64TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + return result; + } + public HmdMatrix34_t GetMatrix34TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + { + HmdMatrix34_t result = FnTable.GetMatrix34TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + return result; + } + public uint GetArrayTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,uint propType,IntPtr pBuffer,uint unBufferSize,ref ETrackedPropertyError pError) + { + uint result = FnTable.GetArrayTrackedDeviceProperty(unDeviceIndex,prop,propType,pBuffer,unBufferSize,ref pError); + return result; + } + public uint GetStringTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,System.Text.StringBuilder pchValue,uint unBufferSize,ref ETrackedPropertyError pError) + { + uint result = FnTable.GetStringTrackedDeviceProperty(unDeviceIndex,prop,pchValue,unBufferSize,ref pError); + return result; + } + public string GetPropErrorNameFromEnum(ETrackedPropertyError error) + { + IntPtr result = FnTable.GetPropErrorNameFromEnum(error); + return Marshal.PtrToStringAnsi(result); + } +// This is a terrible hack to workaround the fact that VRControllerState_t and VREvent_t were +// originally mis-compiled with the wrong packing for Linux and OSX. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _PollNextEventPacked(ref VREvent_t_Packed pEvent,uint uncbVREvent); + [StructLayout(LayoutKind.Explicit)] + struct PollNextEventUnion + { + [FieldOffset(0)] + public IVRSystem._PollNextEvent pPollNextEvent; + [FieldOffset(0)] + public _PollNextEventPacked pPollNextEventPacked; + } + public bool PollNextEvent(ref VREvent_t pEvent,uint uncbVREvent) + { +#if !UNITY_METRO + if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || + (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) + { + PollNextEventUnion u; + VREvent_t_Packed event_packed = new VREvent_t_Packed(); + u.pPollNextEventPacked = null; + u.pPollNextEvent = FnTable.PollNextEvent; + bool packed_result = u.pPollNextEventPacked(ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t_Packed))); + + event_packed.Unpack(ref pEvent); + return packed_result; + } +#endif + bool result = FnTable.PollNextEvent(ref pEvent,uncbVREvent); + return result; + } + public bool PollNextEventWithPose(ETrackingUniverseOrigin eOrigin,ref VREvent_t pEvent,uint uncbVREvent,ref TrackedDevicePose_t pTrackedDevicePose) + { + bool result = FnTable.PollNextEventWithPose(eOrigin,ref pEvent,uncbVREvent,ref pTrackedDevicePose); + return result; + } + public string GetEventTypeNameFromEnum(EVREventType eType) + { + IntPtr result = FnTable.GetEventTypeNameFromEnum(eType); + return Marshal.PtrToStringAnsi(result); + } + public HiddenAreaMesh_t GetHiddenAreaMesh(EVREye eEye,EHiddenAreaMeshType type) + { + HiddenAreaMesh_t result = FnTable.GetHiddenAreaMesh(eEye,type); + return result; + } +// This is a terrible hack to workaround the fact that VRControllerState_t and VREvent_t were +// originally mis-compiled with the wrong packing for Linux and OSX. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetControllerStatePacked(uint unControllerDeviceIndex,ref VRControllerState_t_Packed pControllerState,uint unControllerStateSize); + [StructLayout(LayoutKind.Explicit)] + struct GetControllerStateUnion + { + [FieldOffset(0)] + public IVRSystem._GetControllerState pGetControllerState; + [FieldOffset(0)] + public _GetControllerStatePacked pGetControllerStatePacked; + } + public bool GetControllerState(uint unControllerDeviceIndex,ref VRControllerState_t pControllerState,uint unControllerStateSize) + { +#if !UNITY_METRO + if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || + (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) + { + GetControllerStateUnion u; + VRControllerState_t_Packed state_packed = new VRControllerState_t_Packed(pControllerState); + u.pGetControllerStatePacked = null; + u.pGetControllerState = FnTable.GetControllerState; + bool packed_result = u.pGetControllerStatePacked(unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t_Packed))); + + state_packed.Unpack(ref pControllerState); + return packed_result; + } +#endif + bool result = FnTable.GetControllerState(unControllerDeviceIndex,ref pControllerState,unControllerStateSize); + return result; + } +// This is a terrible hack to workaround the fact that VRControllerState_t and VREvent_t were +// originally mis-compiled with the wrong packing for Linux and OSX. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetControllerStateWithPosePacked(ETrackingUniverseOrigin eOrigin,uint unControllerDeviceIndex,ref VRControllerState_t_Packed pControllerState,uint unControllerStateSize,ref TrackedDevicePose_t pTrackedDevicePose); + [StructLayout(LayoutKind.Explicit)] + struct GetControllerStateWithPoseUnion + { + [FieldOffset(0)] + public IVRSystem._GetControllerStateWithPose pGetControllerStateWithPose; + [FieldOffset(0)] + public _GetControllerStateWithPosePacked pGetControllerStateWithPosePacked; + } + public bool GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin,uint unControllerDeviceIndex,ref VRControllerState_t pControllerState,uint unControllerStateSize,ref TrackedDevicePose_t pTrackedDevicePose) + { +#if !UNITY_METRO + if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || + (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) + { + GetControllerStateWithPoseUnion u; + VRControllerState_t_Packed state_packed = new VRControllerState_t_Packed(pControllerState); + u.pGetControllerStateWithPosePacked = null; + u.pGetControllerStateWithPose = FnTable.GetControllerStateWithPose; + bool packed_result = u.pGetControllerStateWithPosePacked(eOrigin,unControllerDeviceIndex,ref state_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t_Packed)),ref pTrackedDevicePose); + + state_packed.Unpack(ref pControllerState); + return packed_result; + } +#endif + bool result = FnTable.GetControllerStateWithPose(eOrigin,unControllerDeviceIndex,ref pControllerState,unControllerStateSize,ref pTrackedDevicePose); + return result; + } + public void TriggerHapticPulse(uint unControllerDeviceIndex,uint unAxisId,ushort usDurationMicroSec) + { + FnTable.TriggerHapticPulse(unControllerDeviceIndex,unAxisId,usDurationMicroSec); + } + public string GetButtonIdNameFromEnum(EVRButtonId eButtonId) + { + IntPtr result = FnTable.GetButtonIdNameFromEnum(eButtonId); + return Marshal.PtrToStringAnsi(result); + } + public string GetControllerAxisTypeNameFromEnum(EVRControllerAxisType eAxisType) + { + IntPtr result = FnTable.GetControllerAxisTypeNameFromEnum(eAxisType); + return Marshal.PtrToStringAnsi(result); + } + public bool IsInputAvailable() + { + bool result = FnTable.IsInputAvailable(); + return result; + } + public bool IsSteamVRDrawingControllers() + { + bool result = FnTable.IsSteamVRDrawingControllers(); + return result; + } + public bool ShouldApplicationPause() + { + bool result = FnTable.ShouldApplicationPause(); + return result; + } + public bool ShouldApplicationReduceRenderingWork() + { + bool result = FnTable.ShouldApplicationReduceRenderingWork(); + return result; + } + public EVRFirmwareError PerformFirmwareUpdate(uint unDeviceIndex) + { + EVRFirmwareError result = FnTable.PerformFirmwareUpdate(unDeviceIndex); + return result; + } + public void AcknowledgeQuit_Exiting() + { + FnTable.AcknowledgeQuit_Exiting(); + } + public uint GetAppContainerFilePaths(System.Text.StringBuilder pchBuffer,uint unBufferSize) + { + uint result = FnTable.GetAppContainerFilePaths(pchBuffer,unBufferSize); + return result; + } + public string GetRuntimeVersion() + { + IntPtr result = FnTable.GetRuntimeVersion(); + return Marshal.PtrToStringAnsi(result); + } +} + + +public class CVRExtendedDisplay +{ + IVRExtendedDisplay FnTable; + internal CVRExtendedDisplay(IntPtr pInterface) + { + FnTable = (IVRExtendedDisplay)Marshal.PtrToStructure(pInterface, typeof(IVRExtendedDisplay)); + } + public void GetWindowBounds(ref int pnX,ref int pnY,ref uint pnWidth,ref uint pnHeight) + { + pnX = 0; + pnY = 0; + pnWidth = 0; + pnHeight = 0; + FnTable.GetWindowBounds(ref pnX,ref pnY,ref pnWidth,ref pnHeight); + } + public void GetEyeOutputViewport(EVREye eEye,ref uint pnX,ref uint pnY,ref uint pnWidth,ref uint pnHeight) + { + pnX = 0; + pnY = 0; + pnWidth = 0; + pnHeight = 0; + FnTable.GetEyeOutputViewport(eEye,ref pnX,ref pnY,ref pnWidth,ref pnHeight); + } + public void GetDXGIOutputInfo(ref int pnAdapterIndex,ref int pnAdapterOutputIndex) + { + pnAdapterIndex = 0; + pnAdapterOutputIndex = 0; + FnTable.GetDXGIOutputInfo(ref pnAdapterIndex,ref pnAdapterOutputIndex); + } +} + + +public class CVRTrackedCamera +{ + IVRTrackedCamera FnTable; + internal CVRTrackedCamera(IntPtr pInterface) + { + FnTable = (IVRTrackedCamera)Marshal.PtrToStructure(pInterface, typeof(IVRTrackedCamera)); + } + public string GetCameraErrorNameFromEnum(EVRTrackedCameraError eCameraError) + { + IntPtr result = FnTable.GetCameraErrorNameFromEnum(eCameraError); + return Marshal.PtrToStringAnsi(result); + } + public EVRTrackedCameraError HasCamera(uint nDeviceIndex,ref bool pHasCamera) + { + pHasCamera = false; + EVRTrackedCameraError result = FnTable.HasCamera(nDeviceIndex,ref pHasCamera); + return result; + } + public EVRTrackedCameraError GetCameraFrameSize(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,ref uint pnWidth,ref uint pnHeight,ref uint pnFrameBufferSize) + { + pnWidth = 0; + pnHeight = 0; + pnFrameBufferSize = 0; + EVRTrackedCameraError result = FnTable.GetCameraFrameSize(nDeviceIndex,eFrameType,ref pnWidth,ref pnHeight,ref pnFrameBufferSize); + return result; + } + public EVRTrackedCameraError GetCameraIntrinsics(uint nDeviceIndex,uint nCameraIndex,EVRTrackedCameraFrameType eFrameType,ref HmdVector2_t pFocalLength,ref HmdVector2_t pCenter) + { + EVRTrackedCameraError result = FnTable.GetCameraIntrinsics(nDeviceIndex,nCameraIndex,eFrameType,ref pFocalLength,ref pCenter); + return result; + } + public EVRTrackedCameraError GetCameraProjection(uint nDeviceIndex,uint nCameraIndex,EVRTrackedCameraFrameType eFrameType,float flZNear,float flZFar,ref HmdMatrix44_t pProjection) + { + EVRTrackedCameraError result = FnTable.GetCameraProjection(nDeviceIndex,nCameraIndex,eFrameType,flZNear,flZFar,ref pProjection); + return result; + } + public EVRTrackedCameraError AcquireVideoStreamingService(uint nDeviceIndex,ref ulong pHandle) + { + pHandle = 0; + EVRTrackedCameraError result = FnTable.AcquireVideoStreamingService(nDeviceIndex,ref pHandle); + return result; + } + public EVRTrackedCameraError ReleaseVideoStreamingService(ulong hTrackedCamera) + { + EVRTrackedCameraError result = FnTable.ReleaseVideoStreamingService(hTrackedCamera); + return result; + } + public EVRTrackedCameraError GetVideoStreamFrameBuffer(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,IntPtr pFrameBuffer,uint nFrameBufferSize,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + { + EVRTrackedCameraError result = FnTable.GetVideoStreamFrameBuffer(hTrackedCamera,eFrameType,pFrameBuffer,nFrameBufferSize,ref pFrameHeader,nFrameHeaderSize); + return result; + } + public EVRTrackedCameraError GetVideoStreamTextureSize(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,ref VRTextureBounds_t pTextureBounds,ref uint pnWidth,ref uint pnHeight) + { + pnWidth = 0; + pnHeight = 0; + EVRTrackedCameraError result = FnTable.GetVideoStreamTextureSize(nDeviceIndex,eFrameType,ref pTextureBounds,ref pnWidth,ref pnHeight); + return result; + } + public EVRTrackedCameraError GetVideoStreamTextureD3D11(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,IntPtr pD3D11DeviceOrResource,ref IntPtr ppD3D11ShaderResourceView,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + { + EVRTrackedCameraError result = FnTable.GetVideoStreamTextureD3D11(hTrackedCamera,eFrameType,pD3D11DeviceOrResource,ref ppD3D11ShaderResourceView,ref pFrameHeader,nFrameHeaderSize); + return result; + } + public EVRTrackedCameraError GetVideoStreamTextureGL(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,ref uint pglTextureId,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + { + pglTextureId = 0; + EVRTrackedCameraError result = FnTable.GetVideoStreamTextureGL(hTrackedCamera,eFrameType,ref pglTextureId,ref pFrameHeader,nFrameHeaderSize); + return result; + } + public EVRTrackedCameraError ReleaseVideoStreamTextureGL(ulong hTrackedCamera,uint glTextureId) + { + EVRTrackedCameraError result = FnTable.ReleaseVideoStreamTextureGL(hTrackedCamera,glTextureId); + return result; + } + public void SetCameraTrackingSpace(ETrackingUniverseOrigin eUniverse) + { + FnTable.SetCameraTrackingSpace(eUniverse); + } + public ETrackingUniverseOrigin GetCameraTrackingSpace() + { + ETrackingUniverseOrigin result = FnTable.GetCameraTrackingSpace(); + return result; + } +} + + +public class CVRApplications +{ + IVRApplications FnTable; + internal CVRApplications(IntPtr pInterface) + { + FnTable = (IVRApplications)Marshal.PtrToStructure(pInterface, typeof(IVRApplications)); + } + public EVRApplicationError AddApplicationManifest(string pchApplicationManifestFullPath,bool bTemporary) + { + IntPtr pchApplicationManifestFullPathUtf8 = Utils.ToUtf8(pchApplicationManifestFullPath); + EVRApplicationError result = FnTable.AddApplicationManifest(pchApplicationManifestFullPathUtf8,bTemporary); + Marshal.FreeHGlobal(pchApplicationManifestFullPathUtf8); + return result; + } + public EVRApplicationError RemoveApplicationManifest(string pchApplicationManifestFullPath) + { + IntPtr pchApplicationManifestFullPathUtf8 = Utils.ToUtf8(pchApplicationManifestFullPath); + EVRApplicationError result = FnTable.RemoveApplicationManifest(pchApplicationManifestFullPathUtf8); + Marshal.FreeHGlobal(pchApplicationManifestFullPathUtf8); + return result; + } + public bool IsApplicationInstalled(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + bool result = FnTable.IsApplicationInstalled(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public uint GetApplicationCount() + { + uint result = FnTable.GetApplicationCount(); + return result; + } + public EVRApplicationError GetApplicationKeyByIndex(uint unApplicationIndex,System.Text.StringBuilder pchAppKeyBuffer,uint unAppKeyBufferLen) + { + EVRApplicationError result = FnTable.GetApplicationKeyByIndex(unApplicationIndex,pchAppKeyBuffer,unAppKeyBufferLen); + return result; + } + public EVRApplicationError GetApplicationKeyByProcessId(uint unProcessId,System.Text.StringBuilder pchAppKeyBuffer,uint unAppKeyBufferLen) + { + EVRApplicationError result = FnTable.GetApplicationKeyByProcessId(unProcessId,pchAppKeyBuffer,unAppKeyBufferLen); + return result; + } + public EVRApplicationError LaunchApplication(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRApplicationError result = FnTable.LaunchApplication(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public EVRApplicationError LaunchTemplateApplication(string pchTemplateAppKey,string pchNewAppKey,AppOverrideKeys_t [] pKeys) + { + IntPtr pchTemplateAppKeyUtf8 = Utils.ToUtf8(pchTemplateAppKey); + IntPtr pchNewAppKeyUtf8 = Utils.ToUtf8(pchNewAppKey); + EVRApplicationError result = FnTable.LaunchTemplateApplication(pchTemplateAppKeyUtf8,pchNewAppKeyUtf8,pKeys,(uint) pKeys.Length); + Marshal.FreeHGlobal(pchTemplateAppKeyUtf8); + Marshal.FreeHGlobal(pchNewAppKeyUtf8); + return result; + } + public EVRApplicationError LaunchApplicationFromMimeType(string pchMimeType,string pchArgs) + { + IntPtr pchMimeTypeUtf8 = Utils.ToUtf8(pchMimeType); + IntPtr pchArgsUtf8 = Utils.ToUtf8(pchArgs); + EVRApplicationError result = FnTable.LaunchApplicationFromMimeType(pchMimeTypeUtf8,pchArgsUtf8); + Marshal.FreeHGlobal(pchMimeTypeUtf8); + Marshal.FreeHGlobal(pchArgsUtf8); + return result; + } + public EVRApplicationError LaunchDashboardOverlay(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRApplicationError result = FnTable.LaunchDashboardOverlay(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public bool CancelApplicationLaunch(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + bool result = FnTable.CancelApplicationLaunch(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public EVRApplicationError IdentifyApplication(uint unProcessId,string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRApplicationError result = FnTable.IdentifyApplication(unProcessId,pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public uint GetApplicationProcessId(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + uint result = FnTable.GetApplicationProcessId(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public string GetApplicationsErrorNameFromEnum(EVRApplicationError error) + { + IntPtr result = FnTable.GetApplicationsErrorNameFromEnum(error); + return Marshal.PtrToStringAnsi(result); + } + public uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,System.Text.StringBuilder pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + uint result = FnTable.GetApplicationPropertyString(pchAppKeyUtf8,eProperty,pchPropertyValueBuffer,unPropertyValueBufferLen,ref peError); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public bool GetApplicationPropertyBool(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + bool result = FnTable.GetApplicationPropertyBool(pchAppKeyUtf8,eProperty,ref peError); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public ulong GetApplicationPropertyUint64(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + ulong result = FnTable.GetApplicationPropertyUint64(pchAppKeyUtf8,eProperty,ref peError); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public EVRApplicationError SetApplicationAutoLaunch(string pchAppKey,bool bAutoLaunch) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRApplicationError result = FnTable.SetApplicationAutoLaunch(pchAppKeyUtf8,bAutoLaunch); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public bool GetApplicationAutoLaunch(string pchAppKey) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + bool result = FnTable.GetApplicationAutoLaunch(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public EVRApplicationError SetDefaultApplicationForMimeType(string pchAppKey,string pchMimeType) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + IntPtr pchMimeTypeUtf8 = Utils.ToUtf8(pchMimeType); + EVRApplicationError result = FnTable.SetDefaultApplicationForMimeType(pchAppKeyUtf8,pchMimeTypeUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchMimeTypeUtf8); + return result; + } + public bool GetDefaultApplicationForMimeType(string pchMimeType,System.Text.StringBuilder pchAppKeyBuffer,uint unAppKeyBufferLen) + { + IntPtr pchMimeTypeUtf8 = Utils.ToUtf8(pchMimeType); + bool result = FnTable.GetDefaultApplicationForMimeType(pchMimeTypeUtf8,pchAppKeyBuffer,unAppKeyBufferLen); + Marshal.FreeHGlobal(pchMimeTypeUtf8); + return result; + } + public bool GetApplicationSupportedMimeTypes(string pchAppKey,System.Text.StringBuilder pchMimeTypesBuffer,uint unMimeTypesBuffer) + { + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + bool result = FnTable.GetApplicationSupportedMimeTypes(pchAppKeyUtf8,pchMimeTypesBuffer,unMimeTypesBuffer); + Marshal.FreeHGlobal(pchAppKeyUtf8); + return result; + } + public uint GetApplicationsThatSupportMimeType(string pchMimeType,System.Text.StringBuilder pchAppKeysThatSupportBuffer,uint unAppKeysThatSupportBuffer) + { + IntPtr pchMimeTypeUtf8 = Utils.ToUtf8(pchMimeType); + uint result = FnTable.GetApplicationsThatSupportMimeType(pchMimeTypeUtf8,pchAppKeysThatSupportBuffer,unAppKeysThatSupportBuffer); + Marshal.FreeHGlobal(pchMimeTypeUtf8); + return result; + } + public uint GetApplicationLaunchArguments(uint unHandle,System.Text.StringBuilder pchArgs,uint unArgs) + { + uint result = FnTable.GetApplicationLaunchArguments(unHandle,pchArgs,unArgs); + return result; + } + public EVRApplicationError GetStartingApplication(System.Text.StringBuilder pchAppKeyBuffer,uint unAppKeyBufferLen) { - FnTable.ResetSeatedZeroPose(); + EVRApplicationError result = FnTable.GetStartingApplication(pchAppKeyBuffer,unAppKeyBufferLen); + return result; } - public HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() + public EVRSceneApplicationState GetSceneApplicationState() { - HmdMatrix34_t result = FnTable.GetSeatedZeroPoseToStandingAbsoluteTrackingPose(); + EVRSceneApplicationState result = FnTable.GetSceneApplicationState(); return result; } - public HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose() + public EVRApplicationError PerformApplicationPrelaunchCheck(string pchAppKey) { - HmdMatrix34_t result = FnTable.GetRawZeroPoseToStandingAbsoluteTrackingPose(); + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRApplicationError result = FnTable.PerformApplicationPrelaunchCheck(pchAppKeyUtf8); + Marshal.FreeHGlobal(pchAppKeyUtf8); return result; } - public uint GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass eTrackedDeviceClass,uint [] punTrackedDeviceIndexArray,uint unRelativeToTrackedDeviceIndex) + public string GetSceneApplicationStateNameFromEnum(EVRSceneApplicationState state) { - uint result = FnTable.GetSortedTrackedDeviceIndicesOfClass(eTrackedDeviceClass,punTrackedDeviceIndexArray,(uint) punTrackedDeviceIndexArray.Length,unRelativeToTrackedDeviceIndex); + IntPtr result = FnTable.GetSceneApplicationStateNameFromEnum(state); + return Marshal.PtrToStringAnsi(result); + } + public EVRApplicationError LaunchInternalProcess(string pchBinaryPath,string pchArguments,string pchWorkingDirectory) + { + IntPtr pchBinaryPathUtf8 = Utils.ToUtf8(pchBinaryPath); + IntPtr pchArgumentsUtf8 = Utils.ToUtf8(pchArguments); + IntPtr pchWorkingDirectoryUtf8 = Utils.ToUtf8(pchWorkingDirectory); + EVRApplicationError result = FnTable.LaunchInternalProcess(pchBinaryPathUtf8,pchArgumentsUtf8,pchWorkingDirectoryUtf8); + Marshal.FreeHGlobal(pchBinaryPathUtf8); + Marshal.FreeHGlobal(pchArgumentsUtf8); + Marshal.FreeHGlobal(pchWorkingDirectoryUtf8); return result; } - public EDeviceActivityLevel GetTrackedDeviceActivityLevel(uint unDeviceId) + public uint GetCurrentSceneProcessId() { - EDeviceActivityLevel result = FnTable.GetTrackedDeviceActivityLevel(unDeviceId); + uint result = FnTable.GetCurrentSceneProcessId(); return result; } - public void ApplyTransform(ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pTrackedDevicePose,ref HmdMatrix34_t pTransform) +} + + +public class CVRChaperone +{ + IVRChaperone FnTable; + internal CVRChaperone(IntPtr pInterface) { - FnTable.ApplyTransform(ref pOutputPose,ref pTrackedDevicePose,ref pTransform); + FnTable = (IVRChaperone)Marshal.PtrToStructure(pInterface, typeof(IVRChaperone)); } - public uint GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole unDeviceType) + public ChaperoneCalibrationState GetCalibrationState() { - uint result = FnTable.GetTrackedDeviceIndexForControllerRole(unDeviceType); + ChaperoneCalibrationState result = FnTable.GetCalibrationState(); return result; } - public ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex(uint unDeviceIndex) + public bool GetPlayAreaSize(ref float pSizeX,ref float pSizeZ) { - ETrackedControllerRole result = FnTable.GetControllerRoleForTrackedDeviceIndex(unDeviceIndex); + pSizeX = 0; + pSizeZ = 0; + bool result = FnTable.GetPlayAreaSize(ref pSizeX,ref pSizeZ); return result; } - public ETrackedDeviceClass GetTrackedDeviceClass(uint unDeviceIndex) + public bool GetPlayAreaRect(ref HmdQuad_t rect) { - ETrackedDeviceClass result = FnTable.GetTrackedDeviceClass(unDeviceIndex); + bool result = FnTable.GetPlayAreaRect(ref rect); return result; } - public bool IsTrackedDeviceConnected(uint unDeviceIndex) + public void ReloadInfo() { - bool result = FnTable.IsTrackedDeviceConnected(unDeviceIndex); + FnTable.ReloadInfo(); + } + public void SetSceneColor(HmdColor_t color) + { + FnTable.SetSceneColor(color); + } + public void GetBoundsColor(ref HmdColor_t pOutputColorArray,int nNumOutputColors,float flCollisionBoundsFadeDistance,ref HmdColor_t pOutputCameraColor) + { + FnTable.GetBoundsColor(ref pOutputColorArray,nNumOutputColors,flCollisionBoundsFadeDistance,ref pOutputCameraColor); + } + public bool AreBoundsVisible() + { + bool result = FnTable.AreBoundsVisible(); return result; } - public bool GetBoolTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + public void ForceBoundsVisible(bool bForce) { - bool result = FnTable.GetBoolTrackedDeviceProperty(unDeviceIndex,prop,ref pError); + FnTable.ForceBoundsVisible(bForce); + } +} + + +public class CVRChaperoneSetup +{ + IVRChaperoneSetup FnTable; + internal CVRChaperoneSetup(IntPtr pInterface) + { + FnTable = (IVRChaperoneSetup)Marshal.PtrToStructure(pInterface, typeof(IVRChaperoneSetup)); + } + public bool CommitWorkingCopy(EChaperoneConfigFile configFile) + { + bool result = FnTable.CommitWorkingCopy(configFile); return result; } - public float GetFloatTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + public void RevertWorkingCopy() { - float result = FnTable.GetFloatTrackedDeviceProperty(unDeviceIndex,prop,ref pError); + FnTable.RevertWorkingCopy(); + } + public bool GetWorkingPlayAreaSize(ref float pSizeX,ref float pSizeZ) + { + pSizeX = 0; + pSizeZ = 0; + bool result = FnTable.GetWorkingPlayAreaSize(ref pSizeX,ref pSizeZ); return result; } - public int GetInt32TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + public bool GetWorkingPlayAreaRect(ref HmdQuad_t rect) { - int result = FnTable.GetInt32TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + bool result = FnTable.GetWorkingPlayAreaRect(ref rect); return result; } - public ulong GetUint64TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + public bool GetWorkingCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer) { - ulong result = FnTable.GetUint64TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + uint punQuadsCount = 0; + bool result = FnTable.GetWorkingCollisionBoundsInfo(null,ref punQuadsCount); + pQuadsBuffer= new HmdQuad_t[punQuadsCount]; + result = FnTable.GetWorkingCollisionBoundsInfo(pQuadsBuffer,ref punQuadsCount); return result; } - public HmdMatrix34_t GetMatrix34TrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,ref ETrackedPropertyError pError) + public bool GetLiveCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer) { - HmdMatrix34_t result = FnTable.GetMatrix34TrackedDeviceProperty(unDeviceIndex,prop,ref pError); + uint punQuadsCount = 0; + bool result = FnTable.GetLiveCollisionBoundsInfo(null,ref punQuadsCount); + pQuadsBuffer= new HmdQuad_t[punQuadsCount]; + result = FnTable.GetLiveCollisionBoundsInfo(pQuadsBuffer,ref punQuadsCount); return result; } - public uint GetStringTrackedDeviceProperty(uint unDeviceIndex,ETrackedDeviceProperty prop,System.Text.StringBuilder pchValue,uint unBufferSize,ref ETrackedPropertyError pError) + public bool GetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose) { - uint result = FnTable.GetStringTrackedDeviceProperty(unDeviceIndex,prop,pchValue,unBufferSize,ref pError); + bool result = FnTable.GetWorkingSeatedZeroPoseToRawTrackingPose(ref pmatSeatedZeroPoseToRawTrackingPose); return result; } - public string GetPropErrorNameFromEnum(ETrackedPropertyError error) + public bool GetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatStandingZeroPoseToRawTrackingPose) { - IntPtr result = FnTable.GetPropErrorNameFromEnum(error); - return Marshal.PtrToStringAnsi(result); + bool result = FnTable.GetWorkingStandingZeroPoseToRawTrackingPose(ref pmatStandingZeroPoseToRawTrackingPose); + return result; } - public bool PollNextEvent(ref VREvent_t pEvent,uint uncbVREvent) + public void SetWorkingPlayAreaSize(float sizeX,float sizeZ) { - bool result = FnTable.PollNextEvent(ref pEvent,uncbVREvent); + FnTable.SetWorkingPlayAreaSize(sizeX,sizeZ); + } + public void SetWorkingCollisionBoundsInfo(HmdQuad_t [] pQuadsBuffer) + { + FnTable.SetWorkingCollisionBoundsInfo(pQuadsBuffer,(uint) pQuadsBuffer.Length); + } + public void SetWorkingPerimeter(HmdVector2_t [] pPointBuffer) + { + FnTable.SetWorkingPerimeter(pPointBuffer,(uint) pPointBuffer.Length); + } + public void SetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose) + { + FnTable.SetWorkingSeatedZeroPoseToRawTrackingPose(ref pMatSeatedZeroPoseToRawTrackingPose); + } + public void SetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatStandingZeroPoseToRawTrackingPose) + { + FnTable.SetWorkingStandingZeroPoseToRawTrackingPose(ref pMatStandingZeroPoseToRawTrackingPose); + } + public void ReloadFromDisk(EChaperoneConfigFile configFile) + { + FnTable.ReloadFromDisk(configFile); + } + public bool GetLiveSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose) + { + bool result = FnTable.GetLiveSeatedZeroPoseToRawTrackingPose(ref pmatSeatedZeroPoseToRawTrackingPose); return result; } - public bool PollNextEventWithPose(ETrackingUniverseOrigin eOrigin,ref VREvent_t pEvent,uint uncbVREvent,ref TrackedDevicePose_t pTrackedDevicePose) + public bool ExportLiveToBuffer(System.Text.StringBuilder pBuffer,ref uint pnBufferLength) { - bool result = FnTable.PollNextEventWithPose(eOrigin,ref pEvent,uncbVREvent,ref pTrackedDevicePose); + pnBufferLength = 0; + bool result = FnTable.ExportLiveToBuffer(pBuffer,ref pnBufferLength); return result; } - public string GetEventTypeNameFromEnum(EVREventType eType) + public bool ImportFromBufferToWorking(string pBuffer,uint nImportFlags) { - IntPtr result = FnTable.GetEventTypeNameFromEnum(eType); - return Marshal.PtrToStringAnsi(result); + IntPtr pBufferUtf8 = Utils.ToUtf8(pBuffer); + bool result = FnTable.ImportFromBufferToWorking(pBufferUtf8,nImportFlags); + Marshal.FreeHGlobal(pBufferUtf8); + return result; + } + public void ShowWorkingSetPreview() + { + FnTable.ShowWorkingSetPreview(); + } + public void HideWorkingSetPreview() + { + FnTable.HideWorkingSetPreview(); + } + public void RoomSetupStarting() + { + FnTable.RoomSetupStarting(); + } +} + + +public class CVRCompositor +{ + IVRCompositor FnTable; + internal CVRCompositor(IntPtr pInterface) + { + FnTable = (IVRCompositor)Marshal.PtrToStructure(pInterface, typeof(IVRCompositor)); + } + public void SetTrackingSpace(ETrackingUniverseOrigin eOrigin) + { + FnTable.SetTrackingSpace(eOrigin); + } + public ETrackingUniverseOrigin GetTrackingSpace() + { + ETrackingUniverseOrigin result = FnTable.GetTrackingSpace(); + return result; + } + public EVRCompositorError WaitGetPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray) + { + EVRCompositorError result = FnTable.WaitGetPoses(pRenderPoseArray,(uint) pRenderPoseArray.Length,pGamePoseArray,(uint) pGamePoseArray.Length); + return result; + } + public EVRCompositorError GetLastPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray) + { + EVRCompositorError result = FnTable.GetLastPoses(pRenderPoseArray,(uint) pRenderPoseArray.Length,pGamePoseArray,(uint) pGamePoseArray.Length); + return result; + } + public EVRCompositorError GetLastPoseForTrackedDeviceIndex(uint unDeviceIndex,ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pOutputGamePose) + { + EVRCompositorError result = FnTable.GetLastPoseForTrackedDeviceIndex(unDeviceIndex,ref pOutputPose,ref pOutputGamePose); + return result; + } + public EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags) + { + EVRCompositorError result = FnTable.Submit(eEye,ref pTexture,ref pBounds,nSubmitFlags); + return result; + } + public void ClearLastSubmittedFrame() + { + FnTable.ClearLastSubmittedFrame(); + } + public void PostPresentHandoff() + { + FnTable.PostPresentHandoff(); + } + public bool GetFrameTiming(ref Compositor_FrameTiming pTiming,uint unFramesAgo) + { + bool result = FnTable.GetFrameTiming(ref pTiming,unFramesAgo); + return result; + } + public uint GetFrameTimings(Compositor_FrameTiming [] pTiming) + { + uint result = FnTable.GetFrameTimings(pTiming,(uint) pTiming.Length); + return result; + } + public float GetFrameTimeRemaining() + { + float result = FnTable.GetFrameTimeRemaining(); + return result; + } + public void GetCumulativeStats(ref Compositor_CumulativeStats pStats,uint nStatsSizeInBytes) + { + FnTable.GetCumulativeStats(ref pStats,nStatsSizeInBytes); + } + public void FadeToColor(float fSeconds,float fRed,float fGreen,float fBlue,float fAlpha,bool bBackground) + { + FnTable.FadeToColor(fSeconds,fRed,fGreen,fBlue,fAlpha,bBackground); + } + public HmdColor_t GetCurrentFadeColor(bool bBackground) + { + HmdColor_t result = FnTable.GetCurrentFadeColor(bBackground); + return result; + } + public void FadeGrid(float fSeconds,bool bFadeIn) + { + FnTable.FadeGrid(fSeconds,bFadeIn); + } + public float GetCurrentGridAlpha() + { + float result = FnTable.GetCurrentGridAlpha(); + return result; + } + public EVRCompositorError SetSkyboxOverride(Texture_t [] pTextures) + { + EVRCompositorError result = FnTable.SetSkyboxOverride(pTextures,(uint) pTextures.Length); + return result; + } + public void ClearSkyboxOverride() + { + FnTable.ClearSkyboxOverride(); + } + public void CompositorBringToFront() + { + FnTable.CompositorBringToFront(); + } + public void CompositorGoToBack() + { + FnTable.CompositorGoToBack(); + } + public void CompositorQuit() + { + FnTable.CompositorQuit(); } - public HiddenAreaMesh_t GetHiddenAreaMesh(EVREye eEye) + public bool IsFullscreen() { - HiddenAreaMesh_t result = FnTable.GetHiddenAreaMesh(eEye); + bool result = FnTable.IsFullscreen(); return result; } - public bool GetControllerState(uint unControllerDeviceIndex,ref VRControllerState_t pControllerState) + public uint GetCurrentSceneFocusProcess() { - bool result = FnTable.GetControllerState(unControllerDeviceIndex,ref pControllerState); + uint result = FnTable.GetCurrentSceneFocusProcess(); return result; } - public bool GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin,uint unControllerDeviceIndex,ref VRControllerState_t pControllerState,ref TrackedDevicePose_t pTrackedDevicePose) + public uint GetLastFrameRenderer() { - bool result = FnTable.GetControllerStateWithPose(eOrigin,unControllerDeviceIndex,ref pControllerState,ref pTrackedDevicePose); + uint result = FnTable.GetLastFrameRenderer(); return result; } - public void TriggerHapticPulse(uint unControllerDeviceIndex,uint unAxisId,char usDurationMicroSec) + public bool CanRenderScene() { - FnTable.TriggerHapticPulse(unControllerDeviceIndex,unAxisId,usDurationMicroSec); + bool result = FnTable.CanRenderScene(); + return result; } - public string GetButtonIdNameFromEnum(EVRButtonId eButtonId) + public void ShowMirrorWindow() { - IntPtr result = FnTable.GetButtonIdNameFromEnum(eButtonId); - return Marshal.PtrToStringAnsi(result); + FnTable.ShowMirrorWindow(); } - public string GetControllerAxisTypeNameFromEnum(EVRControllerAxisType eAxisType) + public void HideMirrorWindow() { - IntPtr result = FnTable.GetControllerAxisTypeNameFromEnum(eAxisType); - return Marshal.PtrToStringAnsi(result); + FnTable.HideMirrorWindow(); } - public bool CaptureInputFocus() + public bool IsMirrorWindowVisible() { - bool result = FnTable.CaptureInputFocus(); + bool result = FnTable.IsMirrorWindowVisible(); return result; } - public void ReleaseInputFocus() + public void CompositorDumpImages() { - FnTable.ReleaseInputFocus(); + FnTable.CompositorDumpImages(); } - public bool IsInputFocusCapturedByAnotherProcess() + public bool ShouldAppRenderWithLowResources() { - bool result = FnTable.IsInputFocusCapturedByAnotherProcess(); + bool result = FnTable.ShouldAppRenderWithLowResources(); return result; } - public uint DriverDebugRequest(uint unDeviceIndex,string pchRequest,string pchResponseBuffer,uint unResponseBufferSize) + public void ForceInterleavedReprojectionOn(bool bOverride) { - uint result = FnTable.DriverDebugRequest(unDeviceIndex,pchRequest,pchResponseBuffer,unResponseBufferSize); - return result; + FnTable.ForceInterleavedReprojectionOn(bOverride); } - public EVRFirmwareError PerformFirmwareUpdate(uint unDeviceIndex) + public void ForceReconnectProcess() { - EVRFirmwareError result = FnTable.PerformFirmwareUpdate(unDeviceIndex); - return result; + FnTable.ForceReconnectProcess(); } - public void AcknowledgeQuit_Exiting() + public void SuspendRendering(bool bSuspend) { - FnTable.AcknowledgeQuit_Exiting(); + FnTable.SuspendRendering(bSuspend); } - public void AcknowledgeQuit_UserPrompt() + public EVRCompositorError GetMirrorTextureD3D11(EVREye eEye,IntPtr pD3D11DeviceOrResource,ref IntPtr ppD3D11ShaderResourceView) { - FnTable.AcknowledgeQuit_UserPrompt(); + EVRCompositorError result = FnTable.GetMirrorTextureD3D11(eEye,pD3D11DeviceOrResource,ref ppD3D11ShaderResourceView); + return result; } -} - - -public class CVRExtendedDisplay -{ - IVRExtendedDisplay FnTable; - internal CVRExtendedDisplay(IntPtr pInterface) + public void ReleaseMirrorTextureD3D11(IntPtr pD3D11ShaderResourceView) { - FnTable = (IVRExtendedDisplay)Marshal.PtrToStructure(pInterface, typeof(IVRExtendedDisplay)); + FnTable.ReleaseMirrorTextureD3D11(pD3D11ShaderResourceView); } - public void GetWindowBounds(ref int pnX,ref int pnY,ref uint pnWidth,ref uint pnHeight) + public EVRCompositorError GetMirrorTextureGL(EVREye eEye,ref uint pglTextureId,IntPtr pglSharedTextureHandle) { - pnX = 0; - pnY = 0; - pnWidth = 0; - pnHeight = 0; - FnTable.GetWindowBounds(ref pnX,ref pnY,ref pnWidth,ref pnHeight); + pglTextureId = 0; + EVRCompositorError result = FnTable.GetMirrorTextureGL(eEye,ref pglTextureId,pglSharedTextureHandle); + return result; } - public void GetEyeOutputViewport(EVREye eEye,ref uint pnX,ref uint pnY,ref uint pnWidth,ref uint pnHeight) + public bool ReleaseSharedGLTexture(uint glTextureId,IntPtr glSharedTextureHandle) { - pnX = 0; - pnY = 0; - pnWidth = 0; - pnHeight = 0; - FnTable.GetEyeOutputViewport(eEye,ref pnX,ref pnY,ref pnWidth,ref pnHeight); + bool result = FnTable.ReleaseSharedGLTexture(glTextureId,glSharedTextureHandle); + return result; } - public void GetDXGIOutputInfo(ref int pnAdapterIndex,ref int pnAdapterOutputIndex) + public void LockGLSharedTextureForAccess(IntPtr glSharedTextureHandle) { - pnAdapterIndex = 0; - pnAdapterOutputIndex = 0; - FnTable.GetDXGIOutputInfo(ref pnAdapterIndex,ref pnAdapterOutputIndex); + FnTable.LockGLSharedTextureForAccess(glSharedTextureHandle); } -} - - -public class CVRTrackedCamera -{ - IVRTrackedCamera FnTable; - internal CVRTrackedCamera(IntPtr pInterface) + public void UnlockGLSharedTextureForAccess(IntPtr glSharedTextureHandle) { - FnTable = (IVRTrackedCamera)Marshal.PtrToStructure(pInterface, typeof(IVRTrackedCamera)); + FnTable.UnlockGLSharedTextureForAccess(glSharedTextureHandle); } - public string GetCameraErrorNameFromEnum(EVRTrackedCameraError eCameraError) + public uint GetVulkanInstanceExtensionsRequired(System.Text.StringBuilder pchValue,uint unBufferSize) { - IntPtr result = FnTable.GetCameraErrorNameFromEnum(eCameraError); - return Marshal.PtrToStringAnsi(result); + uint result = FnTable.GetVulkanInstanceExtensionsRequired(pchValue,unBufferSize); + return result; } - public EVRTrackedCameraError HasCamera(uint nDeviceIndex,ref bool pHasCamera) + public uint GetVulkanDeviceExtensionsRequired(IntPtr pPhysicalDevice,System.Text.StringBuilder pchValue,uint unBufferSize) { - pHasCamera = false; - EVRTrackedCameraError result = FnTable.HasCamera(nDeviceIndex,ref pHasCamera); + uint result = FnTable.GetVulkanDeviceExtensionsRequired(pPhysicalDevice,pchValue,unBufferSize); return result; } - public EVRTrackedCameraError GetCameraFrameSize(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,ref uint pnWidth,ref uint pnHeight,ref uint pnFrameBufferSize) + public void SetExplicitTimingMode(EVRCompositorTimingMode eTimingMode) { - pnWidth = 0; - pnHeight = 0; - pnFrameBufferSize = 0; - EVRTrackedCameraError result = FnTable.GetCameraFrameSize(nDeviceIndex,eFrameType,ref pnWidth,ref pnHeight,ref pnFrameBufferSize); - return result; + FnTable.SetExplicitTimingMode(eTimingMode); } - public EVRTrackedCameraError GetCameraIntrinisics(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,ref HmdVector2_t pFocalLength,ref HmdVector2_t pCenter) + public EVRCompositorError SubmitExplicitTimingData() { - EVRTrackedCameraError result = FnTable.GetCameraIntrinisics(nDeviceIndex,eFrameType,ref pFocalLength,ref pCenter); + EVRCompositorError result = FnTable.SubmitExplicitTimingData(); return result; } - public EVRTrackedCameraError GetCameraProjection(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,float flZNear,float flZFar,ref HmdMatrix44_t pProjection) + public bool IsMotionSmoothingEnabled() { - EVRTrackedCameraError result = FnTable.GetCameraProjection(nDeviceIndex,eFrameType,flZNear,flZFar,ref pProjection); + bool result = FnTable.IsMotionSmoothingEnabled(); return result; } - public EVRTrackedCameraError AcquireVideoStreamingService(uint nDeviceIndex,ref ulong pHandle) + public bool IsMotionSmoothingSupported() { - pHandle = 0; - EVRTrackedCameraError result = FnTable.AcquireVideoStreamingService(nDeviceIndex,ref pHandle); + bool result = FnTable.IsMotionSmoothingSupported(); return result; } - public EVRTrackedCameraError ReleaseVideoStreamingService(ulong hTrackedCamera) + public bool IsCurrentSceneFocusAppLoading() { - EVRTrackedCameraError result = FnTable.ReleaseVideoStreamingService(hTrackedCamera); + bool result = FnTable.IsCurrentSceneFocusAppLoading(); return result; } - public EVRTrackedCameraError GetVideoStreamFrameBuffer(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,IntPtr pFrameBuffer,uint nFrameBufferSize,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + public EVRCompositorError SetStageOverride_Async(string pchRenderModelPath,ref HmdMatrix34_t pTransform,ref Compositor_StageRenderSettings pRenderSettings,uint nSizeOfRenderSettings) { - EVRTrackedCameraError result = FnTable.GetVideoStreamFrameBuffer(hTrackedCamera,eFrameType,pFrameBuffer,nFrameBufferSize,ref pFrameHeader,nFrameHeaderSize); + IntPtr pchRenderModelPathUtf8 = Utils.ToUtf8(pchRenderModelPath); + EVRCompositorError result = FnTable.SetStageOverride_Async(pchRenderModelPathUtf8,ref pTransform,ref pRenderSettings,nSizeOfRenderSettings); + Marshal.FreeHGlobal(pchRenderModelPathUtf8); return result; } - public EVRTrackedCameraError GetVideoStreamTextureSize(uint nDeviceIndex,EVRTrackedCameraFrameType eFrameType,ref VRTextureBounds_t pTextureBounds,ref uint pnWidth,ref uint pnHeight) + public void ClearStageOverride() { - pnWidth = 0; - pnHeight = 0; - EVRTrackedCameraError result = FnTable.GetVideoStreamTextureSize(nDeviceIndex,eFrameType,ref pTextureBounds,ref pnWidth,ref pnHeight); - return result; + FnTable.ClearStageOverride(); } - public EVRTrackedCameraError GetVideoStreamTextureD3D11(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,IntPtr pD3D11DeviceOrResource,ref IntPtr ppD3D11ShaderResourceView,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + public bool GetCompositorBenchmarkResults(ref Compositor_BenchmarkResults pBenchmarkResults,uint nSizeOfBenchmarkResults) { - EVRTrackedCameraError result = FnTable.GetVideoStreamTextureD3D11(hTrackedCamera,eFrameType,pD3D11DeviceOrResource,ref ppD3D11ShaderResourceView,ref pFrameHeader,nFrameHeaderSize); + bool result = FnTable.GetCompositorBenchmarkResults(ref pBenchmarkResults,nSizeOfBenchmarkResults); return result; } - public EVRTrackedCameraError GetVideoStreamTextureGL(ulong hTrackedCamera,EVRTrackedCameraFrameType eFrameType,ref uint pglTextureId,ref CameraVideoStreamFrameHeader_t pFrameHeader,uint nFrameHeaderSize) + public EVRCompositorError GetLastPosePredictionIDs(ref uint pRenderPosePredictionID,ref uint pGamePosePredictionID) { - pglTextureId = 0; - EVRTrackedCameraError result = FnTable.GetVideoStreamTextureGL(hTrackedCamera,eFrameType,ref pglTextureId,ref pFrameHeader,nFrameHeaderSize); + pRenderPosePredictionID = 0; + pGamePosePredictionID = 0; + EVRCompositorError result = FnTable.GetLastPosePredictionIDs(ref pRenderPosePredictionID,ref pGamePosePredictionID); return result; } - public EVRTrackedCameraError ReleaseVideoStreamTextureGL(ulong hTrackedCamera,uint glTextureId) + public EVRCompositorError GetPosesForFrame(uint unPosePredictionID,TrackedDevicePose_t [] pPoseArray) { - EVRTrackedCameraError result = FnTable.ReleaseVideoStreamTextureGL(hTrackedCamera,glTextureId); + EVRCompositorError result = FnTable.GetPosesForFrame(unPosePredictionID,pPoseArray,(uint) pPoseArray.Length); return result; } } -public class CVRApplications +public class CVROverlay { - IVRApplications FnTable; - internal CVRApplications(IntPtr pInterface) + IVROverlay FnTable; + internal CVROverlay(IntPtr pInterface) { - FnTable = (IVRApplications)Marshal.PtrToStructure(pInterface, typeof(IVRApplications)); + FnTable = (IVROverlay)Marshal.PtrToStructure(pInterface, typeof(IVROverlay)); } - public EVRApplicationError AddApplicationManifest(string pchApplicationManifestFullPath,bool bTemporary) + public EVROverlayError FindOverlay(string pchOverlayKey,ref ulong pOverlayHandle) { - EVRApplicationError result = FnTable.AddApplicationManifest(pchApplicationManifestFullPath,bTemporary); + IntPtr pchOverlayKeyUtf8 = Utils.ToUtf8(pchOverlayKey); + pOverlayHandle = 0; + EVROverlayError result = FnTable.FindOverlay(pchOverlayKeyUtf8,ref pOverlayHandle); + Marshal.FreeHGlobal(pchOverlayKeyUtf8); return result; } - public EVRApplicationError RemoveApplicationManifest(string pchApplicationManifestFullPath) + public EVROverlayError CreateOverlay(string pchOverlayKey,string pchOverlayName,ref ulong pOverlayHandle) { - EVRApplicationError result = FnTable.RemoveApplicationManifest(pchApplicationManifestFullPath); + IntPtr pchOverlayKeyUtf8 = Utils.ToUtf8(pchOverlayKey); + IntPtr pchOverlayNameUtf8 = Utils.ToUtf8(pchOverlayName); + pOverlayHandle = 0; + EVROverlayError result = FnTable.CreateOverlay(pchOverlayKeyUtf8,pchOverlayNameUtf8,ref pOverlayHandle); + Marshal.FreeHGlobal(pchOverlayKeyUtf8); + Marshal.FreeHGlobal(pchOverlayNameUtf8); return result; } - public bool IsApplicationInstalled(string pchAppKey) + public EVROverlayError DestroyOverlay(ulong ulOverlayHandle) { - bool result = FnTable.IsApplicationInstalled(pchAppKey); + EVROverlayError result = FnTable.DestroyOverlay(ulOverlayHandle); return result; } - public uint GetApplicationCount() + public uint GetOverlayKey(ulong ulOverlayHandle,System.Text.StringBuilder pchValue,uint unBufferSize,ref EVROverlayError pError) { - uint result = FnTable.GetApplicationCount(); + uint result = FnTable.GetOverlayKey(ulOverlayHandle,pchValue,unBufferSize,ref pError); return result; } - public EVRApplicationError GetApplicationKeyByIndex(uint unApplicationIndex,string pchAppKeyBuffer,uint unAppKeyBufferLen) + public uint GetOverlayName(ulong ulOverlayHandle,System.Text.StringBuilder pchValue,uint unBufferSize,ref EVROverlayError pError) { - EVRApplicationError result = FnTable.GetApplicationKeyByIndex(unApplicationIndex,pchAppKeyBuffer,unAppKeyBufferLen); + uint result = FnTable.GetOverlayName(ulOverlayHandle,pchValue,unBufferSize,ref pError); return result; } - public EVRApplicationError GetApplicationKeyByProcessId(uint unProcessId,string pchAppKeyBuffer,uint unAppKeyBufferLen) + public EVROverlayError SetOverlayName(ulong ulOverlayHandle,string pchName) { - EVRApplicationError result = FnTable.GetApplicationKeyByProcessId(unProcessId,pchAppKeyBuffer,unAppKeyBufferLen); + IntPtr pchNameUtf8 = Utils.ToUtf8(pchName); + EVROverlayError result = FnTable.SetOverlayName(ulOverlayHandle,pchNameUtf8); + Marshal.FreeHGlobal(pchNameUtf8); return result; } - public EVRApplicationError LaunchApplication(string pchAppKey) + public EVROverlayError GetOverlayImageData(ulong ulOverlayHandle,IntPtr pvBuffer,uint unBufferSize,ref uint punWidth,ref uint punHeight) { - EVRApplicationError result = FnTable.LaunchApplication(pchAppKey); + punWidth = 0; + punHeight = 0; + EVROverlayError result = FnTable.GetOverlayImageData(ulOverlayHandle,pvBuffer,unBufferSize,ref punWidth,ref punHeight); return result; } - public EVRApplicationError LaunchTemplateApplication(string pchTemplateAppKey,string pchNewAppKey,AppOverrideKeys_t [] pKeys) + public string GetOverlayErrorNameFromEnum(EVROverlayError error) { - EVRApplicationError result = FnTable.LaunchTemplateApplication(pchTemplateAppKey,pchNewAppKey,pKeys,(uint) pKeys.Length); - return result; + IntPtr result = FnTable.GetOverlayErrorNameFromEnum(error); + return Marshal.PtrToStringAnsi(result); } - public EVRApplicationError LaunchApplicationFromMimeType(string pchMimeType,string pchArgs) + public EVROverlayError SetOverlayRenderingPid(ulong ulOverlayHandle,uint unPID) { - EVRApplicationError result = FnTable.LaunchApplicationFromMimeType(pchMimeType,pchArgs); + EVROverlayError result = FnTable.SetOverlayRenderingPid(ulOverlayHandle,unPID); return result; } - public EVRApplicationError LaunchDashboardOverlay(string pchAppKey) + public uint GetOverlayRenderingPid(ulong ulOverlayHandle) { - EVRApplicationError result = FnTable.LaunchDashboardOverlay(pchAppKey); + uint result = FnTable.GetOverlayRenderingPid(ulOverlayHandle); return result; } - public bool CancelApplicationLaunch(string pchAppKey) + public EVROverlayError SetOverlayFlag(ulong ulOverlayHandle,VROverlayFlags eOverlayFlag,bool bEnabled) { - bool result = FnTable.CancelApplicationLaunch(pchAppKey); + EVROverlayError result = FnTable.SetOverlayFlag(ulOverlayHandle,eOverlayFlag,bEnabled); return result; } - public EVRApplicationError IdentifyApplication(uint unProcessId,string pchAppKey) + public EVROverlayError GetOverlayFlag(ulong ulOverlayHandle,VROverlayFlags eOverlayFlag,ref bool pbEnabled) { - EVRApplicationError result = FnTable.IdentifyApplication(unProcessId,pchAppKey); + pbEnabled = false; + EVROverlayError result = FnTable.GetOverlayFlag(ulOverlayHandle,eOverlayFlag,ref pbEnabled); return result; } - public uint GetApplicationProcessId(string pchAppKey) + public EVROverlayError GetOverlayFlags(ulong ulOverlayHandle,ref uint pFlags) { - uint result = FnTable.GetApplicationProcessId(pchAppKey); + pFlags = 0; + EVROverlayError result = FnTable.GetOverlayFlags(ulOverlayHandle,ref pFlags); return result; } - public string GetApplicationsErrorNameFromEnum(EVRApplicationError error) - { - IntPtr result = FnTable.GetApplicationsErrorNameFromEnum(error); - return Marshal.PtrToStringAnsi(result); - } - public uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,string pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError) + public EVROverlayError SetOverlayColor(ulong ulOverlayHandle,float fRed,float fGreen,float fBlue) { - uint result = FnTable.GetApplicationPropertyString(pchAppKey,eProperty,pchPropertyValueBuffer,unPropertyValueBufferLen,ref peError); + EVROverlayError result = FnTable.SetOverlayColor(ulOverlayHandle,fRed,fGreen,fBlue); return result; } - public bool GetApplicationPropertyBool(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError) + public EVROverlayError GetOverlayColor(ulong ulOverlayHandle,ref float pfRed,ref float pfGreen,ref float pfBlue) { - bool result = FnTable.GetApplicationPropertyBool(pchAppKey,eProperty,ref peError); + pfRed = 0; + pfGreen = 0; + pfBlue = 0; + EVROverlayError result = FnTable.GetOverlayColor(ulOverlayHandle,ref pfRed,ref pfGreen,ref pfBlue); return result; } - public ulong GetApplicationPropertyUint64(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError) + public EVROverlayError SetOverlayAlpha(ulong ulOverlayHandle,float fAlpha) { - ulong result = FnTable.GetApplicationPropertyUint64(pchAppKey,eProperty,ref peError); + EVROverlayError result = FnTable.SetOverlayAlpha(ulOverlayHandle,fAlpha); return result; } - public EVRApplicationError SetApplicationAutoLaunch(string pchAppKey,bool bAutoLaunch) + public EVROverlayError GetOverlayAlpha(ulong ulOverlayHandle,ref float pfAlpha) { - EVRApplicationError result = FnTable.SetApplicationAutoLaunch(pchAppKey,bAutoLaunch); + pfAlpha = 0; + EVROverlayError result = FnTable.GetOverlayAlpha(ulOverlayHandle,ref pfAlpha); return result; } - public bool GetApplicationAutoLaunch(string pchAppKey) + public EVROverlayError SetOverlayTexelAspect(ulong ulOverlayHandle,float fTexelAspect) { - bool result = FnTable.GetApplicationAutoLaunch(pchAppKey); + EVROverlayError result = FnTable.SetOverlayTexelAspect(ulOverlayHandle,fTexelAspect); return result; } - public EVRApplicationError SetDefaultApplicationForMimeType(string pchAppKey,string pchMimeType) + public EVROverlayError GetOverlayTexelAspect(ulong ulOverlayHandle,ref float pfTexelAspect) { - EVRApplicationError result = FnTable.SetDefaultApplicationForMimeType(pchAppKey,pchMimeType); + pfTexelAspect = 0; + EVROverlayError result = FnTable.GetOverlayTexelAspect(ulOverlayHandle,ref pfTexelAspect); return result; } - public bool GetDefaultApplicationForMimeType(string pchMimeType,string pchAppKeyBuffer,uint unAppKeyBufferLen) + public EVROverlayError SetOverlaySortOrder(ulong ulOverlayHandle,uint unSortOrder) { - bool result = FnTable.GetDefaultApplicationForMimeType(pchMimeType,pchAppKeyBuffer,unAppKeyBufferLen); + EVROverlayError result = FnTable.SetOverlaySortOrder(ulOverlayHandle,unSortOrder); return result; } - public bool GetApplicationSupportedMimeTypes(string pchAppKey,string pchMimeTypesBuffer,uint unMimeTypesBuffer) + public EVROverlayError GetOverlaySortOrder(ulong ulOverlayHandle,ref uint punSortOrder) { - bool result = FnTable.GetApplicationSupportedMimeTypes(pchAppKey,pchMimeTypesBuffer,unMimeTypesBuffer); + punSortOrder = 0; + EVROverlayError result = FnTable.GetOverlaySortOrder(ulOverlayHandle,ref punSortOrder); return result; } - public uint GetApplicationsThatSupportMimeType(string pchMimeType,string pchAppKeysThatSupportBuffer,uint unAppKeysThatSupportBuffer) + public EVROverlayError SetOverlayWidthInMeters(ulong ulOverlayHandle,float fWidthInMeters) { - uint result = FnTable.GetApplicationsThatSupportMimeType(pchMimeType,pchAppKeysThatSupportBuffer,unAppKeysThatSupportBuffer); + EVROverlayError result = FnTable.SetOverlayWidthInMeters(ulOverlayHandle,fWidthInMeters); return result; } - public uint GetApplicationLaunchArguments(uint unHandle,string pchArgs,uint unArgs) + public EVROverlayError GetOverlayWidthInMeters(ulong ulOverlayHandle,ref float pfWidthInMeters) { - uint result = FnTable.GetApplicationLaunchArguments(unHandle,pchArgs,unArgs); + pfWidthInMeters = 0; + EVROverlayError result = FnTable.GetOverlayWidthInMeters(ulOverlayHandle,ref pfWidthInMeters); return result; } - public EVRApplicationError GetStartingApplication(string pchAppKeyBuffer,uint unAppKeyBufferLen) + public EVROverlayError SetOverlayCurvature(ulong ulOverlayHandle,float fCurvature) { - EVRApplicationError result = FnTable.GetStartingApplication(pchAppKeyBuffer,unAppKeyBufferLen); + EVROverlayError result = FnTable.SetOverlayCurvature(ulOverlayHandle,fCurvature); return result; } - public EVRApplicationTransitionState GetTransitionState() + public EVROverlayError GetOverlayCurvature(ulong ulOverlayHandle,ref float pfCurvature) { - EVRApplicationTransitionState result = FnTable.GetTransitionState(); + pfCurvature = 0; + EVROverlayError result = FnTable.GetOverlayCurvature(ulOverlayHandle,ref pfCurvature); return result; } - public EVRApplicationError PerformApplicationPrelaunchCheck(string pchAppKey) + public EVROverlayError SetOverlayTextureColorSpace(ulong ulOverlayHandle,EColorSpace eTextureColorSpace) { - EVRApplicationError result = FnTable.PerformApplicationPrelaunchCheck(pchAppKey); + EVROverlayError result = FnTable.SetOverlayTextureColorSpace(ulOverlayHandle,eTextureColorSpace); return result; } - public string GetApplicationsTransitionStateNameFromEnum(EVRApplicationTransitionState state) - { - IntPtr result = FnTable.GetApplicationsTransitionStateNameFromEnum(state); - return Marshal.PtrToStringAnsi(result); - } - public bool IsQuitUserPromptRequested() + public EVROverlayError GetOverlayTextureColorSpace(ulong ulOverlayHandle,ref EColorSpace peTextureColorSpace) { - bool result = FnTable.IsQuitUserPromptRequested(); + EVROverlayError result = FnTable.GetOverlayTextureColorSpace(ulOverlayHandle,ref peTextureColorSpace); return result; } - public EVRApplicationError LaunchInternalProcess(string pchBinaryPath,string pchArguments,string pchWorkingDirectory) + public EVROverlayError SetOverlayTextureBounds(ulong ulOverlayHandle,ref VRTextureBounds_t pOverlayTextureBounds) { - EVRApplicationError result = FnTable.LaunchInternalProcess(pchBinaryPath,pchArguments,pchWorkingDirectory); + EVROverlayError result = FnTable.SetOverlayTextureBounds(ulOverlayHandle,ref pOverlayTextureBounds); return result; } -} - - -public class CVRChaperone -{ - IVRChaperone FnTable; - internal CVRChaperone(IntPtr pInterface) + public EVROverlayError GetOverlayTextureBounds(ulong ulOverlayHandle,ref VRTextureBounds_t pOverlayTextureBounds) { - FnTable = (IVRChaperone)Marshal.PtrToStructure(pInterface, typeof(IVRChaperone)); + EVROverlayError result = FnTable.GetOverlayTextureBounds(ulOverlayHandle,ref pOverlayTextureBounds); + return result; } - public ChaperoneCalibrationState GetCalibrationState() + public EVROverlayError GetOverlayTransformType(ulong ulOverlayHandle,ref VROverlayTransformType peTransformType) { - ChaperoneCalibrationState result = FnTable.GetCalibrationState(); + EVROverlayError result = FnTable.GetOverlayTransformType(ulOverlayHandle,ref peTransformType); return result; } - public bool GetPlayAreaSize(ref float pSizeX,ref float pSizeZ) + public EVROverlayError SetOverlayTransformAbsolute(ulong ulOverlayHandle,ETrackingUniverseOrigin eTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform) { - pSizeX = 0; - pSizeZ = 0; - bool result = FnTable.GetPlayAreaSize(ref pSizeX,ref pSizeZ); + EVROverlayError result = FnTable.SetOverlayTransformAbsolute(ulOverlayHandle,eTrackingOrigin,ref pmatTrackingOriginToOverlayTransform); return result; } - public bool GetPlayAreaRect(ref HmdQuad_t rect) + public EVROverlayError GetOverlayTransformAbsolute(ulong ulOverlayHandle,ref ETrackingUniverseOrigin peTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform) { - bool result = FnTable.GetPlayAreaRect(ref rect); + EVROverlayError result = FnTable.GetOverlayTransformAbsolute(ulOverlayHandle,ref peTrackingOrigin,ref pmatTrackingOriginToOverlayTransform); return result; } - public void ReloadInfo() + public EVROverlayError SetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle,uint unTrackedDevice,ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform) { - FnTable.ReloadInfo(); + EVROverlayError result = FnTable.SetOverlayTransformTrackedDeviceRelative(ulOverlayHandle,unTrackedDevice,ref pmatTrackedDeviceToOverlayTransform); + return result; } - public void SetSceneColor(HmdColor_t color) + public EVROverlayError GetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle,ref uint punTrackedDevice,ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform) { - FnTable.SetSceneColor(color); + punTrackedDevice = 0; + EVROverlayError result = FnTable.GetOverlayTransformTrackedDeviceRelative(ulOverlayHandle,ref punTrackedDevice,ref pmatTrackedDeviceToOverlayTransform); + return result; } - public void GetBoundsColor(ref HmdColor_t pOutputColorArray,int nNumOutputColors,float flCollisionBoundsFadeDistance,ref HmdColor_t pOutputCameraColor) + public EVROverlayError SetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle,uint unDeviceIndex,string pchComponentName) { - FnTable.GetBoundsColor(ref pOutputColorArray,nNumOutputColors,flCollisionBoundsFadeDistance,ref pOutputCameraColor); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + EVROverlayError result = FnTable.SetOverlayTransformTrackedDeviceComponent(ulOverlayHandle,unDeviceIndex,pchComponentNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); + return result; } - public bool AreBoundsVisible() + public EVROverlayError GetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle,ref uint punDeviceIndex,System.Text.StringBuilder pchComponentName,uint unComponentNameSize) { - bool result = FnTable.AreBoundsVisible(); + punDeviceIndex = 0; + EVROverlayError result = FnTable.GetOverlayTransformTrackedDeviceComponent(ulOverlayHandle,ref punDeviceIndex,pchComponentName,unComponentNameSize); return result; } - public void ForceBoundsVisible(bool bForce) + public EVROverlayError GetOverlayTransformOverlayRelative(ulong ulOverlayHandle,ref ulong ulOverlayHandleParent,ref HmdMatrix34_t pmatParentOverlayToOverlayTransform) { - FnTable.ForceBoundsVisible(bForce); + ulOverlayHandleParent = 0; + EVROverlayError result = FnTable.GetOverlayTransformOverlayRelative(ulOverlayHandle,ref ulOverlayHandleParent,ref pmatParentOverlayToOverlayTransform); + return result; } -} - - -public class CVRChaperoneSetup -{ - IVRChaperoneSetup FnTable; - internal CVRChaperoneSetup(IntPtr pInterface) + public EVROverlayError SetOverlayTransformOverlayRelative(ulong ulOverlayHandle,ulong ulOverlayHandleParent,ref HmdMatrix34_t pmatParentOverlayToOverlayTransform) { - FnTable = (IVRChaperoneSetup)Marshal.PtrToStructure(pInterface, typeof(IVRChaperoneSetup)); + EVROverlayError result = FnTable.SetOverlayTransformOverlayRelative(ulOverlayHandle,ulOverlayHandleParent,ref pmatParentOverlayToOverlayTransform); + return result; } - public bool CommitWorkingCopy(EChaperoneConfigFile configFile) + public EVROverlayError SetOverlayTransformCursor(ulong ulCursorOverlayHandle,ref HmdVector2_t pvHotspot) { - bool result = FnTable.CommitWorkingCopy(configFile); + EVROverlayError result = FnTable.SetOverlayTransformCursor(ulCursorOverlayHandle,ref pvHotspot); return result; } - public void RevertWorkingCopy() + public EVROverlayError GetOverlayTransformCursor(ulong ulOverlayHandle,ref HmdVector2_t pvHotspot) { - FnTable.RevertWorkingCopy(); + EVROverlayError result = FnTable.GetOverlayTransformCursor(ulOverlayHandle,ref pvHotspot); + return result; } - public bool GetWorkingPlayAreaSize(ref float pSizeX,ref float pSizeZ) + public EVROverlayError ShowOverlay(ulong ulOverlayHandle) { - pSizeX = 0; - pSizeZ = 0; - bool result = FnTable.GetWorkingPlayAreaSize(ref pSizeX,ref pSizeZ); + EVROverlayError result = FnTable.ShowOverlay(ulOverlayHandle); return result; } - public bool GetWorkingPlayAreaRect(ref HmdQuad_t rect) + public EVROverlayError HideOverlay(ulong ulOverlayHandle) { - bool result = FnTable.GetWorkingPlayAreaRect(ref rect); + EVROverlayError result = FnTable.HideOverlay(ulOverlayHandle); return result; } - public bool GetWorkingCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer) + public bool IsOverlayVisible(ulong ulOverlayHandle) { - uint punQuadsCount = 0; - bool result = FnTable.GetWorkingCollisionBoundsInfo(null,ref punQuadsCount); - pQuadsBuffer= new HmdQuad_t[punQuadsCount]; - result = FnTable.GetWorkingCollisionBoundsInfo(pQuadsBuffer,ref punQuadsCount); + bool result = FnTable.IsOverlayVisible(ulOverlayHandle); return result; } - public bool GetLiveCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer) + public EVROverlayError GetTransformForOverlayCoordinates(ulong ulOverlayHandle,ETrackingUniverseOrigin eTrackingOrigin,HmdVector2_t coordinatesInOverlay,ref HmdMatrix34_t pmatTransform) { - uint punQuadsCount = 0; - bool result = FnTable.GetLiveCollisionBoundsInfo(null,ref punQuadsCount); - pQuadsBuffer= new HmdQuad_t[punQuadsCount]; - result = FnTable.GetLiveCollisionBoundsInfo(pQuadsBuffer,ref punQuadsCount); + EVROverlayError result = FnTable.GetTransformForOverlayCoordinates(ulOverlayHandle,eTrackingOrigin,coordinatesInOverlay,ref pmatTransform); return result; } - public bool GetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose) +// This is a terrible hack to workaround the fact that VRControllerState_t and VREvent_t were +// originally mis-compiled with the wrong packing for Linux and OSX. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _PollNextOverlayEventPacked(ulong ulOverlayHandle,ref VREvent_t_Packed pEvent,uint uncbVREvent); + [StructLayout(LayoutKind.Explicit)] + struct PollNextOverlayEventUnion { - bool result = FnTable.GetWorkingSeatedZeroPoseToRawTrackingPose(ref pmatSeatedZeroPoseToRawTrackingPose); - return result; + [FieldOffset(0)] + public IVROverlay._PollNextOverlayEvent pPollNextOverlayEvent; + [FieldOffset(0)] + public _PollNextOverlayEventPacked pPollNextOverlayEventPacked; } - public bool GetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatStandingZeroPoseToRawTrackingPose) + public bool PollNextOverlayEvent(ulong ulOverlayHandle,ref VREvent_t pEvent,uint uncbVREvent) { - bool result = FnTable.GetWorkingStandingZeroPoseToRawTrackingPose(ref pmatStandingZeroPoseToRawTrackingPose); +#if !UNITY_METRO + if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || + (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) + { + PollNextOverlayEventUnion u; + VREvent_t_Packed event_packed = new VREvent_t_Packed(); + u.pPollNextOverlayEventPacked = null; + u.pPollNextOverlayEvent = FnTable.PollNextOverlayEvent; + bool packed_result = u.pPollNextOverlayEventPacked(ulOverlayHandle,ref event_packed,(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t_Packed))); + + event_packed.Unpack(ref pEvent); + return packed_result; + } +#endif + bool result = FnTable.PollNextOverlayEvent(ulOverlayHandle,ref pEvent,uncbVREvent); return result; } - public void SetWorkingPlayAreaSize(float sizeX,float sizeZ) + public EVROverlayError GetOverlayInputMethod(ulong ulOverlayHandle,ref VROverlayInputMethod peInputMethod) { - FnTable.SetWorkingPlayAreaSize(sizeX,sizeZ); + EVROverlayError result = FnTable.GetOverlayInputMethod(ulOverlayHandle,ref peInputMethod); + return result; } - public void SetWorkingCollisionBoundsInfo(HmdQuad_t [] pQuadsBuffer) + public EVROverlayError SetOverlayInputMethod(ulong ulOverlayHandle,VROverlayInputMethod eInputMethod) { - FnTable.SetWorkingCollisionBoundsInfo(pQuadsBuffer,(uint) pQuadsBuffer.Length); + EVROverlayError result = FnTable.SetOverlayInputMethod(ulOverlayHandle,eInputMethod); + return result; } - public void SetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose) + public EVROverlayError GetOverlayMouseScale(ulong ulOverlayHandle,ref HmdVector2_t pvecMouseScale) { - FnTable.SetWorkingSeatedZeroPoseToRawTrackingPose(ref pMatSeatedZeroPoseToRawTrackingPose); + EVROverlayError result = FnTable.GetOverlayMouseScale(ulOverlayHandle,ref pvecMouseScale); + return result; } - public void SetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatStandingZeroPoseToRawTrackingPose) + public EVROverlayError SetOverlayMouseScale(ulong ulOverlayHandle,ref HmdVector2_t pvecMouseScale) { - FnTable.SetWorkingStandingZeroPoseToRawTrackingPose(ref pMatStandingZeroPoseToRawTrackingPose); + EVROverlayError result = FnTable.SetOverlayMouseScale(ulOverlayHandle,ref pvecMouseScale); + return result; } - public void ReloadFromDisk(EChaperoneConfigFile configFile) + public bool ComputeOverlayIntersection(ulong ulOverlayHandle,ref VROverlayIntersectionParams_t pParams,ref VROverlayIntersectionResults_t pResults) { - FnTable.ReloadFromDisk(configFile); + bool result = FnTable.ComputeOverlayIntersection(ulOverlayHandle,ref pParams,ref pResults); + return result; } - public bool GetLiveSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose) + public bool IsHoverTargetOverlay(ulong ulOverlayHandle) { - bool result = FnTable.GetLiveSeatedZeroPoseToRawTrackingPose(ref pmatSeatedZeroPoseToRawTrackingPose); + bool result = FnTable.IsHoverTargetOverlay(ulOverlayHandle); return result; } - public void SetWorkingCollisionBoundsTagsInfo(byte [] pTagsBuffer) + public EVROverlayError SetOverlayIntersectionMask(ulong ulOverlayHandle,ref VROverlayIntersectionMaskPrimitive_t pMaskPrimitives,uint unNumMaskPrimitives,uint unPrimitiveSize) { - FnTable.SetWorkingCollisionBoundsTagsInfo(pTagsBuffer,(uint) pTagsBuffer.Length); + EVROverlayError result = FnTable.SetOverlayIntersectionMask(ulOverlayHandle,ref pMaskPrimitives,unNumMaskPrimitives,unPrimitiveSize); + return result; } - public bool GetLiveCollisionBoundsTagsInfo(out byte [] pTagsBuffer) + public EVROverlayError TriggerLaserMouseHapticVibration(ulong ulOverlayHandle,float fDurationSeconds,float fFrequency,float fAmplitude) { - uint punTagCount = 0; - bool result = FnTable.GetLiveCollisionBoundsTagsInfo(null,ref punTagCount); - pTagsBuffer= new byte[punTagCount]; - result = FnTable.GetLiveCollisionBoundsTagsInfo(pTagsBuffer,ref punTagCount); + EVROverlayError result = FnTable.TriggerLaserMouseHapticVibration(ulOverlayHandle,fDurationSeconds,fFrequency,fAmplitude); return result; } - public bool SetWorkingPhysicalBoundsInfo(HmdQuad_t [] pQuadsBuffer) + public EVROverlayError SetOverlayCursor(ulong ulOverlayHandle,ulong ulCursorHandle) { - bool result = FnTable.SetWorkingPhysicalBoundsInfo(pQuadsBuffer,(uint) pQuadsBuffer.Length); + EVROverlayError result = FnTable.SetOverlayCursor(ulOverlayHandle,ulCursorHandle); return result; } - public bool GetLivePhysicalBoundsInfo(out HmdQuad_t [] pQuadsBuffer) + public EVROverlayError SetOverlayCursorPositionOverride(ulong ulOverlayHandle,ref HmdVector2_t pvCursor) { - uint punQuadsCount = 0; - bool result = FnTable.GetLivePhysicalBoundsInfo(null,ref punQuadsCount); - pQuadsBuffer= new HmdQuad_t[punQuadsCount]; - result = FnTable.GetLivePhysicalBoundsInfo(pQuadsBuffer,ref punQuadsCount); + EVROverlayError result = FnTable.SetOverlayCursorPositionOverride(ulOverlayHandle,ref pvCursor); return result; } - public bool ExportLiveToBuffer(System.Text.StringBuilder pBuffer,ref uint pnBufferLength) + public EVROverlayError ClearOverlayCursorPositionOverride(ulong ulOverlayHandle) { - pnBufferLength = 0; - bool result = FnTable.ExportLiveToBuffer(pBuffer,ref pnBufferLength); + EVROverlayError result = FnTable.ClearOverlayCursorPositionOverride(ulOverlayHandle); return result; } - public bool ImportFromBufferToWorking(string pBuffer,uint nImportFlags) + public EVROverlayError SetOverlayTexture(ulong ulOverlayHandle,ref Texture_t pTexture) { - bool result = FnTable.ImportFromBufferToWorking(pBuffer,nImportFlags); + EVROverlayError result = FnTable.SetOverlayTexture(ulOverlayHandle,ref pTexture); return result; } -} - - -public class CVRCompositor -{ - IVRCompositor FnTable; - internal CVRCompositor(IntPtr pInterface) + public EVROverlayError ClearOverlayTexture(ulong ulOverlayHandle) { - FnTable = (IVRCompositor)Marshal.PtrToStructure(pInterface, typeof(IVRCompositor)); + EVROverlayError result = FnTable.ClearOverlayTexture(ulOverlayHandle); + return result; } - public void SetTrackingSpace(ETrackingUniverseOrigin eOrigin) + public EVROverlayError SetOverlayRaw(ulong ulOverlayHandle,IntPtr pvBuffer,uint unWidth,uint unHeight,uint unBytesPerPixel) { - FnTable.SetTrackingSpace(eOrigin); + EVROverlayError result = FnTable.SetOverlayRaw(ulOverlayHandle,pvBuffer,unWidth,unHeight,unBytesPerPixel); + return result; } - public ETrackingUniverseOrigin GetTrackingSpace() + public EVROverlayError SetOverlayFromFile(ulong ulOverlayHandle,string pchFilePath) { - ETrackingUniverseOrigin result = FnTable.GetTrackingSpace(); + IntPtr pchFilePathUtf8 = Utils.ToUtf8(pchFilePath); + EVROverlayError result = FnTable.SetOverlayFromFile(ulOverlayHandle,pchFilePathUtf8); + Marshal.FreeHGlobal(pchFilePathUtf8); return result; } - public EVRCompositorError WaitGetPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray) + public EVROverlayError GetOverlayTexture(ulong ulOverlayHandle,ref IntPtr pNativeTextureHandle,IntPtr pNativeTextureRef,ref uint pWidth,ref uint pHeight,ref uint pNativeFormat,ref ETextureType pAPIType,ref EColorSpace pColorSpace,ref VRTextureBounds_t pTextureBounds) { - EVRCompositorError result = FnTable.WaitGetPoses(pRenderPoseArray,(uint) pRenderPoseArray.Length,pGamePoseArray,(uint) pGamePoseArray.Length); + pWidth = 0; + pHeight = 0; + pNativeFormat = 0; + EVROverlayError result = FnTable.GetOverlayTexture(ulOverlayHandle,ref pNativeTextureHandle,pNativeTextureRef,ref pWidth,ref pHeight,ref pNativeFormat,ref pAPIType,ref pColorSpace,ref pTextureBounds); return result; } - public EVRCompositorError GetLastPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray) + public EVROverlayError ReleaseNativeOverlayHandle(ulong ulOverlayHandle,IntPtr pNativeTextureHandle) { - EVRCompositorError result = FnTable.GetLastPoses(pRenderPoseArray,(uint) pRenderPoseArray.Length,pGamePoseArray,(uint) pGamePoseArray.Length); + EVROverlayError result = FnTable.ReleaseNativeOverlayHandle(ulOverlayHandle,pNativeTextureHandle); return result; } - public EVRCompositorError GetLastPoseForTrackedDeviceIndex(uint unDeviceIndex,ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pOutputGamePose) + public EVROverlayError GetOverlayTextureSize(ulong ulOverlayHandle,ref uint pWidth,ref uint pHeight) { - EVRCompositorError result = FnTable.GetLastPoseForTrackedDeviceIndex(unDeviceIndex,ref pOutputPose,ref pOutputGamePose); + pWidth = 0; + pHeight = 0; + EVROverlayError result = FnTable.GetOverlayTextureSize(ulOverlayHandle,ref pWidth,ref pHeight); return result; } - public EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags) + public EVROverlayError CreateDashboardOverlay(string pchOverlayKey,string pchOverlayFriendlyName,ref ulong pMainHandle,ref ulong pThumbnailHandle) { - EVRCompositorError result = FnTable.Submit(eEye,ref pTexture,ref pBounds,nSubmitFlags); + IntPtr pchOverlayKeyUtf8 = Utils.ToUtf8(pchOverlayKey); + IntPtr pchOverlayFriendlyNameUtf8 = Utils.ToUtf8(pchOverlayFriendlyName); + pMainHandle = 0; + pThumbnailHandle = 0; + EVROverlayError result = FnTable.CreateDashboardOverlay(pchOverlayKeyUtf8,pchOverlayFriendlyNameUtf8,ref pMainHandle,ref pThumbnailHandle); + Marshal.FreeHGlobal(pchOverlayKeyUtf8); + Marshal.FreeHGlobal(pchOverlayFriendlyNameUtf8); return result; } - public void ClearLastSubmittedFrame() + public bool IsDashboardVisible() { - FnTable.ClearLastSubmittedFrame(); + bool result = FnTable.IsDashboardVisible(); + return result; } - public void PostPresentHandoff() + public bool IsActiveDashboardOverlay(ulong ulOverlayHandle) { - FnTable.PostPresentHandoff(); + bool result = FnTable.IsActiveDashboardOverlay(ulOverlayHandle); + return result; } - public bool GetFrameTiming(ref Compositor_FrameTiming pTiming,uint unFramesAgo) + public EVROverlayError SetDashboardOverlaySceneProcess(ulong ulOverlayHandle,uint unProcessId) { - bool result = FnTable.GetFrameTiming(ref pTiming,unFramesAgo); + EVROverlayError result = FnTable.SetDashboardOverlaySceneProcess(ulOverlayHandle,unProcessId); return result; } - public float GetFrameTimeRemaining() + public EVROverlayError GetDashboardOverlaySceneProcess(ulong ulOverlayHandle,ref uint punProcessId) { - float result = FnTable.GetFrameTimeRemaining(); + punProcessId = 0; + EVROverlayError result = FnTable.GetDashboardOverlaySceneProcess(ulOverlayHandle,ref punProcessId); return result; } - public void GetCumulativeStats(ref Compositor_CumulativeStats pStats,uint nStatsSizeInBytes) + public void ShowDashboard(string pchOverlayToShow) { - FnTable.GetCumulativeStats(ref pStats,nStatsSizeInBytes); + IntPtr pchOverlayToShowUtf8 = Utils.ToUtf8(pchOverlayToShow); + FnTable.ShowDashboard(pchOverlayToShowUtf8); + Marshal.FreeHGlobal(pchOverlayToShowUtf8); } - public void FadeToColor(float fSeconds,float fRed,float fGreen,float fBlue,float fAlpha,bool bBackground) + public uint GetPrimaryDashboardDevice() { - FnTable.FadeToColor(fSeconds,fRed,fGreen,fBlue,fAlpha,bBackground); + uint result = FnTable.GetPrimaryDashboardDevice(); + return result; } - public void FadeGrid(float fSeconds,bool bFadeIn) + public EVROverlayError ShowKeyboard(int eInputMode,int eLineInputMode,uint unFlags,string pchDescription,uint unCharMax,string pchExistingText,ulong uUserValue) { - FnTable.FadeGrid(fSeconds,bFadeIn); + IntPtr pchDescriptionUtf8 = Utils.ToUtf8(pchDescription); + IntPtr pchExistingTextUtf8 = Utils.ToUtf8(pchExistingText); + EVROverlayError result = FnTable.ShowKeyboard(eInputMode,eLineInputMode,unFlags,pchDescriptionUtf8,unCharMax,pchExistingTextUtf8,uUserValue); + Marshal.FreeHGlobal(pchDescriptionUtf8); + Marshal.FreeHGlobal(pchExistingTextUtf8); + return result; } - public EVRCompositorError SetSkyboxOverride(Texture_t [] pTextures) + public EVROverlayError ShowKeyboardForOverlay(ulong ulOverlayHandle,int eInputMode,int eLineInputMode,uint unFlags,string pchDescription,uint unCharMax,string pchExistingText,ulong uUserValue) { - EVRCompositorError result = FnTable.SetSkyboxOverride(pTextures,(uint) pTextures.Length); + IntPtr pchDescriptionUtf8 = Utils.ToUtf8(pchDescription); + IntPtr pchExistingTextUtf8 = Utils.ToUtf8(pchExistingText); + EVROverlayError result = FnTable.ShowKeyboardForOverlay(ulOverlayHandle,eInputMode,eLineInputMode,unFlags,pchDescriptionUtf8,unCharMax,pchExistingTextUtf8,uUserValue); + Marshal.FreeHGlobal(pchDescriptionUtf8); + Marshal.FreeHGlobal(pchExistingTextUtf8); return result; } - public void ClearSkyboxOverride() + public uint GetKeyboardText(System.Text.StringBuilder pchText,uint cchText) { - FnTable.ClearSkyboxOverride(); + uint result = FnTable.GetKeyboardText(pchText,cchText); + return result; } - public void CompositorBringToFront() + public void HideKeyboard() { - FnTable.CompositorBringToFront(); + FnTable.HideKeyboard(); } - public void CompositorGoToBack() + public void SetKeyboardTransformAbsolute(ETrackingUniverseOrigin eTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToKeyboardTransform) { - FnTable.CompositorGoToBack(); + FnTable.SetKeyboardTransformAbsolute(eTrackingOrigin,ref pmatTrackingOriginToKeyboardTransform); } - public void CompositorQuit() + public void SetKeyboardPositionForOverlay(ulong ulOverlayHandle,HmdRect2_t avoidRect) { - FnTable.CompositorQuit(); + FnTable.SetKeyboardPositionForOverlay(ulOverlayHandle,avoidRect); } - public bool IsFullscreen() + public VRMessageOverlayResponse ShowMessageOverlay(string pchText,string pchCaption,string pchButton0Text,string pchButton1Text,string pchButton2Text,string pchButton3Text) { - bool result = FnTable.IsFullscreen(); + IntPtr pchTextUtf8 = Utils.ToUtf8(pchText); + IntPtr pchCaptionUtf8 = Utils.ToUtf8(pchCaption); + IntPtr pchButton0TextUtf8 = Utils.ToUtf8(pchButton0Text); + IntPtr pchButton1TextUtf8 = Utils.ToUtf8(pchButton1Text); + IntPtr pchButton2TextUtf8 = Utils.ToUtf8(pchButton2Text); + IntPtr pchButton3TextUtf8 = Utils.ToUtf8(pchButton3Text); + VRMessageOverlayResponse result = FnTable.ShowMessageOverlay(pchTextUtf8,pchCaptionUtf8,pchButton0TextUtf8,pchButton1TextUtf8,pchButton2TextUtf8,pchButton3TextUtf8); + Marshal.FreeHGlobal(pchTextUtf8); + Marshal.FreeHGlobal(pchCaptionUtf8); + Marshal.FreeHGlobal(pchButton0TextUtf8); + Marshal.FreeHGlobal(pchButton1TextUtf8); + Marshal.FreeHGlobal(pchButton2TextUtf8); + Marshal.FreeHGlobal(pchButton3TextUtf8); return result; } - public uint GetCurrentSceneFocusProcess() + public void CloseMessageOverlay() { - uint result = FnTable.GetCurrentSceneFocusProcess(); - return result; + FnTable.CloseMessageOverlay(); } - public uint GetLastFrameRenderer() +} + + +public class CVROverlayView +{ + IVROverlayView FnTable; + internal CVROverlayView(IntPtr pInterface) { - uint result = FnTable.GetLastFrameRenderer(); - return result; + FnTable = (IVROverlayView)Marshal.PtrToStructure(pInterface, typeof(IVROverlayView)); } - public bool CanRenderScene() + public EVROverlayError AcquireOverlayView(ulong ulOverlayHandle,ref VRNativeDevice_t pNativeDevice,ref VROverlayView_t pOverlayView,uint unOverlayViewSize) { - bool result = FnTable.CanRenderScene(); + EVROverlayError result = FnTable.AcquireOverlayView(ulOverlayHandle,ref pNativeDevice,ref pOverlayView,unOverlayViewSize); return result; } - public void ShowMirrorWindow() + public EVROverlayError ReleaseOverlayView(ref VROverlayView_t pOverlayView) { - FnTable.ShowMirrorWindow(); + EVROverlayError result = FnTable.ReleaseOverlayView(ref pOverlayView); + return result; } - public void HideMirrorWindow() + public void PostOverlayEvent(ulong ulOverlayHandle,ref VREvent_t pvrEvent) { - FnTable.HideMirrorWindow(); + FnTable.PostOverlayEvent(ulOverlayHandle,ref pvrEvent); } - public bool IsMirrorWindowVisible() + public bool IsViewingPermitted(ulong ulOverlayHandle) { - bool result = FnTable.IsMirrorWindowVisible(); + bool result = FnTable.IsViewingPermitted(ulOverlayHandle); return result; } - public void CompositorDumpImages() +} + + +public class CVRHeadsetView +{ + IVRHeadsetView FnTable; + internal CVRHeadsetView(IntPtr pInterface) { - FnTable.CompositorDumpImages(); + FnTable = (IVRHeadsetView)Marshal.PtrToStructure(pInterface, typeof(IVRHeadsetView)); } - public bool ShouldAppRenderWithLowResources() + public void SetHeadsetViewSize(uint nWidth,uint nHeight) { - bool result = FnTable.ShouldAppRenderWithLowResources(); - return result; + FnTable.SetHeadsetViewSize(nWidth,nHeight); } - public void ForceInterleavedReprojectionOn(bool bOverride) + public void GetHeadsetViewSize(ref uint pnWidth,ref uint pnHeight) { - FnTable.ForceInterleavedReprojectionOn(bOverride); + pnWidth = 0; + pnHeight = 0; + FnTable.GetHeadsetViewSize(ref pnWidth,ref pnHeight); } - public void ForceReconnectProcess() + public void SetHeadsetViewMode(uint eHeadsetViewMode) { - FnTable.ForceReconnectProcess(); + FnTable.SetHeadsetViewMode(eHeadsetViewMode); } - public void SuspendRendering(bool bSuspend) + public uint GetHeadsetViewMode() { - FnTable.SuspendRendering(bSuspend); + uint result = FnTable.GetHeadsetViewMode(); + return result; } - public EVRCompositorError GetMirrorTextureD3D11(EVREye eEye,IntPtr pD3D11DeviceOrResource,ref IntPtr ppD3D11ShaderResourceView) + public void SetHeadsetViewCropped(bool bCropped) { - EVRCompositorError result = FnTable.GetMirrorTextureD3D11(eEye,pD3D11DeviceOrResource,ref ppD3D11ShaderResourceView); - return result; + FnTable.SetHeadsetViewCropped(bCropped); } - public EVRCompositorError GetMirrorTextureGL(EVREye eEye,ref uint pglTextureId,IntPtr pglSharedTextureHandle) + public bool GetHeadsetViewCropped() { - pglTextureId = 0; - EVRCompositorError result = FnTable.GetMirrorTextureGL(eEye,ref pglTextureId,pglSharedTextureHandle); + bool result = FnTable.GetHeadsetViewCropped(); return result; } - public bool ReleaseSharedGLTexture(uint glTextureId,IntPtr glSharedTextureHandle) + public float GetHeadsetViewAspectRatio() { - bool result = FnTable.ReleaseSharedGLTexture(glTextureId,glSharedTextureHandle); + float result = FnTable.GetHeadsetViewAspectRatio(); return result; } - public void LockGLSharedTextureForAccess(IntPtr glSharedTextureHandle) + public void SetHeadsetViewBlendRange(float flStartPct,float flEndPct) { - FnTable.LockGLSharedTextureForAccess(glSharedTextureHandle); + FnTable.SetHeadsetViewBlendRange(flStartPct,flEndPct); } - public void UnlockGLSharedTextureForAccess(IntPtr glSharedTextureHandle) + public void GetHeadsetViewBlendRange(ref float pStartPct,ref float pEndPct) { - FnTable.UnlockGLSharedTextureForAccess(glSharedTextureHandle); + pStartPct = 0; + pEndPct = 0; + FnTable.GetHeadsetViewBlendRange(ref pStartPct,ref pEndPct); } } -public class CVROverlay +public class CVRRenderModels { - IVROverlay FnTable; - internal CVROverlay(IntPtr pInterface) - { - FnTable = (IVROverlay)Marshal.PtrToStructure(pInterface, typeof(IVROverlay)); - } - public EVROverlayError FindOverlay(string pchOverlayKey,ref ulong pOverlayHandle) - { - pOverlayHandle = 0; - EVROverlayError result = FnTable.FindOverlay(pchOverlayKey,ref pOverlayHandle); - return result; - } - public EVROverlayError CreateOverlay(string pchOverlayKey,string pchOverlayFriendlyName,ref ulong pOverlayHandle) + IVRRenderModels FnTable; + internal CVRRenderModels(IntPtr pInterface) { - pOverlayHandle = 0; - EVROverlayError result = FnTable.CreateOverlay(pchOverlayKey,pchOverlayFriendlyName,ref pOverlayHandle); - return result; + FnTable = (IVRRenderModels)Marshal.PtrToStructure(pInterface, typeof(IVRRenderModels)); } - public EVROverlayError DestroyOverlay(ulong ulOverlayHandle) + public EVRRenderModelError LoadRenderModel_Async(string pchRenderModelName,ref IntPtr ppRenderModel) { - EVROverlayError result = FnTable.DestroyOverlay(ulOverlayHandle); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + EVRRenderModelError result = FnTable.LoadRenderModel_Async(pchRenderModelNameUtf8,ref ppRenderModel); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); return result; } - public EVROverlayError SetHighQualityOverlay(ulong ulOverlayHandle) + public void FreeRenderModel(IntPtr pRenderModel) { - EVROverlayError result = FnTable.SetHighQualityOverlay(ulOverlayHandle); - return result; + FnTable.FreeRenderModel(pRenderModel); } - public ulong GetHighQualityOverlay() + public EVRRenderModelError LoadTexture_Async(int textureId,ref IntPtr ppTexture) { - ulong result = FnTable.GetHighQualityOverlay(); + EVRRenderModelError result = FnTable.LoadTexture_Async(textureId,ref ppTexture); return result; } - public uint GetOverlayKey(ulong ulOverlayHandle,System.Text.StringBuilder pchValue,uint unBufferSize,ref EVROverlayError pError) + public void FreeTexture(IntPtr pTexture) { - uint result = FnTable.GetOverlayKey(ulOverlayHandle,pchValue,unBufferSize,ref pError); - return result; + FnTable.FreeTexture(pTexture); } - public uint GetOverlayName(ulong ulOverlayHandle,System.Text.StringBuilder pchValue,uint unBufferSize,ref EVROverlayError pError) + public EVRRenderModelError LoadTextureD3D11_Async(int textureId,IntPtr pD3D11Device,ref IntPtr ppD3D11Texture2D) { - uint result = FnTable.GetOverlayName(ulOverlayHandle,pchValue,unBufferSize,ref pError); + EVRRenderModelError result = FnTable.LoadTextureD3D11_Async(textureId,pD3D11Device,ref ppD3D11Texture2D); return result; } - public EVROverlayError GetOverlayImageData(ulong ulOverlayHandle,IntPtr pvBuffer,uint unBufferSize,ref uint punWidth,ref uint punHeight) + public EVRRenderModelError LoadIntoTextureD3D11_Async(int textureId,IntPtr pDstTexture) { - punWidth = 0; - punHeight = 0; - EVROverlayError result = FnTable.GetOverlayImageData(ulOverlayHandle,pvBuffer,unBufferSize,ref punWidth,ref punHeight); + EVRRenderModelError result = FnTable.LoadIntoTextureD3D11_Async(textureId,pDstTexture); return result; } - public string GetOverlayErrorNameFromEnum(EVROverlayError error) + public void FreeTextureD3D11(IntPtr pD3D11Texture2D) { - IntPtr result = FnTable.GetOverlayErrorNameFromEnum(error); - return Marshal.PtrToStringAnsi(result); + FnTable.FreeTextureD3D11(pD3D11Texture2D); } - public EVROverlayError SetOverlayRenderingPid(ulong ulOverlayHandle,uint unPID) + public uint GetRenderModelName(uint unRenderModelIndex,System.Text.StringBuilder pchRenderModelName,uint unRenderModelNameLen) { - EVROverlayError result = FnTable.SetOverlayRenderingPid(ulOverlayHandle,unPID); + uint result = FnTable.GetRenderModelName(unRenderModelIndex,pchRenderModelName,unRenderModelNameLen); return result; } - public uint GetOverlayRenderingPid(ulong ulOverlayHandle) + public uint GetRenderModelCount() { - uint result = FnTable.GetOverlayRenderingPid(ulOverlayHandle); + uint result = FnTable.GetRenderModelCount(); return result; } - public EVROverlayError SetOverlayFlag(ulong ulOverlayHandle,VROverlayFlags eOverlayFlag,bool bEnabled) + public uint GetComponentCount(string pchRenderModelName) { - EVROverlayError result = FnTable.SetOverlayFlag(ulOverlayHandle,eOverlayFlag,bEnabled); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + uint result = FnTable.GetComponentCount(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); return result; } - public EVROverlayError GetOverlayFlag(ulong ulOverlayHandle,VROverlayFlags eOverlayFlag,ref bool pbEnabled) + public uint GetComponentName(string pchRenderModelName,uint unComponentIndex,System.Text.StringBuilder pchComponentName,uint unComponentNameLen) { - pbEnabled = false; - EVROverlayError result = FnTable.GetOverlayFlag(ulOverlayHandle,eOverlayFlag,ref pbEnabled); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + uint result = FnTable.GetComponentName(pchRenderModelNameUtf8,unComponentIndex,pchComponentName,unComponentNameLen); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); return result; } - public EVROverlayError SetOverlayColor(ulong ulOverlayHandle,float fRed,float fGreen,float fBlue) + public ulong GetComponentButtonMask(string pchRenderModelName,string pchComponentName) { - EVROverlayError result = FnTable.SetOverlayColor(ulOverlayHandle,fRed,fGreen,fBlue); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + ulong result = FnTable.GetComponentButtonMask(pchRenderModelNameUtf8,pchComponentNameUtf8); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public EVROverlayError GetOverlayColor(ulong ulOverlayHandle,ref float pfRed,ref float pfGreen,ref float pfBlue) + public uint GetComponentRenderModelName(string pchRenderModelName,string pchComponentName,System.Text.StringBuilder pchComponentRenderModelName,uint unComponentRenderModelNameLen) { - pfRed = 0; - pfGreen = 0; - pfBlue = 0; - EVROverlayError result = FnTable.GetOverlayColor(ulOverlayHandle,ref pfRed,ref pfGreen,ref pfBlue); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + uint result = FnTable.GetComponentRenderModelName(pchRenderModelNameUtf8,pchComponentNameUtf8,pchComponentRenderModelName,unComponentRenderModelNameLen); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public EVROverlayError SetOverlayAlpha(ulong ulOverlayHandle,float fAlpha) + public bool GetComponentStateForDevicePath(string pchRenderModelName,string pchComponentName,ulong devicePath,ref RenderModel_ControllerMode_State_t pState,ref RenderModel_ComponentState_t pComponentState) { - EVROverlayError result = FnTable.SetOverlayAlpha(ulOverlayHandle,fAlpha); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + bool result = FnTable.GetComponentStateForDevicePath(pchRenderModelNameUtf8,pchComponentNameUtf8,devicePath,ref pState,ref pComponentState); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public EVROverlayError GetOverlayAlpha(ulong ulOverlayHandle,ref float pfAlpha) +// This is a terrible hack to workaround the fact that VRControllerState_t and VREvent_t were +// originally mis-compiled with the wrong packing for Linux and OSX. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + internal delegate bool _GetComponentStatePacked(IntPtr pchRenderModelName,IntPtr pchComponentName,ref VRControllerState_t_Packed pControllerState,ref RenderModel_ControllerMode_State_t pState,ref RenderModel_ComponentState_t pComponentState); + [StructLayout(LayoutKind.Explicit)] + struct GetComponentStateUnion { - pfAlpha = 0; - EVROverlayError result = FnTable.GetOverlayAlpha(ulOverlayHandle,ref pfAlpha); - return result; + [FieldOffset(0)] + public IVRRenderModels._GetComponentState pGetComponentState; + [FieldOffset(0)] + public _GetComponentStatePacked pGetComponentStatePacked; } - public EVROverlayError SetOverlayTexelAspect(ulong ulOverlayHandle,float fTexelAspect) + public bool GetComponentState(string pchRenderModelName,string pchComponentName,ref VRControllerState_t pControllerState,ref RenderModel_ControllerMode_State_t pState,ref RenderModel_ComponentState_t pComponentState) { - EVROverlayError result = FnTable.SetOverlayTexelAspect(ulOverlayHandle,fTexelAspect); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); +#if !UNITY_METRO + if ((System.Environment.OSVersion.Platform == System.PlatformID.MacOSX) || + (System.Environment.OSVersion.Platform == System.PlatformID.Unix)) + { + GetComponentStateUnion u; + VRControllerState_t_Packed state_packed = new VRControllerState_t_Packed(pControllerState); + u.pGetComponentStatePacked = null; + u.pGetComponentState = FnTable.GetComponentState; + bool packed_result = u.pGetComponentStatePacked(pchRenderModelNameUtf8,pchComponentNameUtf8,ref state_packed,ref pState,ref pComponentState); + + state_packed.Unpack(ref pControllerState); + return packed_result; + } +#endif + bool result = FnTable.GetComponentState(pchRenderModelNameUtf8,pchComponentNameUtf8,ref pControllerState,ref pState,ref pComponentState); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public EVROverlayError GetOverlayTexelAspect(ulong ulOverlayHandle,ref float pfTexelAspect) + public bool RenderModelHasComponent(string pchRenderModelName,string pchComponentName) { - pfTexelAspect = 0; - EVROverlayError result = FnTable.GetOverlayTexelAspect(ulOverlayHandle,ref pfTexelAspect); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + bool result = FnTable.RenderModelHasComponent(pchRenderModelNameUtf8,pchComponentNameUtf8); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public EVROverlayError SetOverlaySortOrder(ulong ulOverlayHandle,uint unSortOrder) + public uint GetRenderModelThumbnailURL(string pchRenderModelName,System.Text.StringBuilder pchThumbnailURL,uint unThumbnailURLLen,ref EVRRenderModelError peError) { - EVROverlayError result = FnTable.SetOverlaySortOrder(ulOverlayHandle,unSortOrder); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + uint result = FnTable.GetRenderModelThumbnailURL(pchRenderModelNameUtf8,pchThumbnailURL,unThumbnailURLLen,ref peError); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); return result; } - public EVROverlayError GetOverlaySortOrder(ulong ulOverlayHandle,ref uint punSortOrder) + public uint GetRenderModelOriginalPath(string pchRenderModelName,System.Text.StringBuilder pchOriginalPath,uint unOriginalPathLen,ref EVRRenderModelError peError) { - punSortOrder = 0; - EVROverlayError result = FnTable.GetOverlaySortOrder(ulOverlayHandle,ref punSortOrder); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + uint result = FnTable.GetRenderModelOriginalPath(pchRenderModelNameUtf8,pchOriginalPath,unOriginalPathLen,ref peError); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); return result; } - public EVROverlayError SetOverlayWidthInMeters(ulong ulOverlayHandle,float fWidthInMeters) + public string GetRenderModelErrorNameFromEnum(EVRRenderModelError error) { - EVROverlayError result = FnTable.SetOverlayWidthInMeters(ulOverlayHandle,fWidthInMeters); - return result; + IntPtr result = FnTable.GetRenderModelErrorNameFromEnum(error); + return Marshal.PtrToStringAnsi(result); } - public EVROverlayError GetOverlayWidthInMeters(ulong ulOverlayHandle,ref float pfWidthInMeters) +} + + +public class CVRNotifications +{ + IVRNotifications FnTable; + internal CVRNotifications(IntPtr pInterface) { - pfWidthInMeters = 0; - EVROverlayError result = FnTable.GetOverlayWidthInMeters(ulOverlayHandle,ref pfWidthInMeters); - return result; + FnTable = (IVRNotifications)Marshal.PtrToStructure(pInterface, typeof(IVRNotifications)); } - public EVROverlayError SetOverlayAutoCurveDistanceRangeInMeters(ulong ulOverlayHandle,float fMinDistanceInMeters,float fMaxDistanceInMeters) + public EVRNotificationError CreateNotification(ulong ulOverlayHandle,ulong ulUserValue,EVRNotificationType type,string pchText,EVRNotificationStyle style,ref NotificationBitmap_t pImage,ref uint pNotificationId) { - EVROverlayError result = FnTable.SetOverlayAutoCurveDistanceRangeInMeters(ulOverlayHandle,fMinDistanceInMeters,fMaxDistanceInMeters); + IntPtr pchTextUtf8 = Utils.ToUtf8(pchText); + pNotificationId = 0; + EVRNotificationError result = FnTable.CreateNotification(ulOverlayHandle,ulUserValue,type,pchTextUtf8,style,ref pImage,ref pNotificationId); + Marshal.FreeHGlobal(pchTextUtf8); return result; } - public EVROverlayError GetOverlayAutoCurveDistanceRangeInMeters(ulong ulOverlayHandle,ref float pfMinDistanceInMeters,ref float pfMaxDistanceInMeters) + public EVRNotificationError RemoveNotification(uint notificationId) { - pfMinDistanceInMeters = 0; - pfMaxDistanceInMeters = 0; - EVROverlayError result = FnTable.GetOverlayAutoCurveDistanceRangeInMeters(ulOverlayHandle,ref pfMinDistanceInMeters,ref pfMaxDistanceInMeters); + EVRNotificationError result = FnTable.RemoveNotification(notificationId); return result; } - public EVROverlayError SetOverlayTextureColorSpace(ulong ulOverlayHandle,EColorSpace eTextureColorSpace) +} + + +public class CVRSettings +{ + IVRSettings FnTable; + internal CVRSettings(IntPtr pInterface) { - EVROverlayError result = FnTable.SetOverlayTextureColorSpace(ulOverlayHandle,eTextureColorSpace); - return result; + FnTable = (IVRSettings)Marshal.PtrToStructure(pInterface, typeof(IVRSettings)); } - public EVROverlayError GetOverlayTextureColorSpace(ulong ulOverlayHandle,ref EColorSpace peTextureColorSpace) + public string GetSettingsErrorNameFromEnum(EVRSettingsError eError) { - EVROverlayError result = FnTable.GetOverlayTextureColorSpace(ulOverlayHandle,ref peTextureColorSpace); - return result; + IntPtr result = FnTable.GetSettingsErrorNameFromEnum(eError); + return Marshal.PtrToStringAnsi(result); } - public EVROverlayError SetOverlayTextureBounds(ulong ulOverlayHandle,ref VRTextureBounds_t pOverlayTextureBounds) + public void SetBool(string pchSection,string pchSettingsKey,bool bValue,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.SetOverlayTextureBounds(ulOverlayHandle,ref pOverlayTextureBounds); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + FnTable.SetBool(pchSectionUtf8,pchSettingsKeyUtf8,bValue,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); } - public EVROverlayError GetOverlayTextureBounds(ulong ulOverlayHandle,ref VRTextureBounds_t pOverlayTextureBounds) + public void SetInt32(string pchSection,string pchSettingsKey,int nValue,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.GetOverlayTextureBounds(ulOverlayHandle,ref pOverlayTextureBounds); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + FnTable.SetInt32(pchSectionUtf8,pchSettingsKeyUtf8,nValue,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); } - public EVROverlayError GetOverlayTransformType(ulong ulOverlayHandle,ref VROverlayTransformType peTransformType) + public void SetFloat(string pchSection,string pchSettingsKey,float flValue,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.GetOverlayTransformType(ulOverlayHandle,ref peTransformType); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + FnTable.SetFloat(pchSectionUtf8,pchSettingsKeyUtf8,flValue,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); } - public EVROverlayError SetOverlayTransformAbsolute(ulong ulOverlayHandle,ETrackingUniverseOrigin eTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform) + public void SetString(string pchSection,string pchSettingsKey,string pchValue,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.SetOverlayTransformAbsolute(ulOverlayHandle,eTrackingOrigin,ref pmatTrackingOriginToOverlayTransform); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + IntPtr pchValueUtf8 = Utils.ToUtf8(pchValue); + FnTable.SetString(pchSectionUtf8,pchSettingsKeyUtf8,pchValueUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); + Marshal.FreeHGlobal(pchValueUtf8); } - public EVROverlayError GetOverlayTransformAbsolute(ulong ulOverlayHandle,ref ETrackingUniverseOrigin peTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform) + public bool GetBool(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.GetOverlayTransformAbsolute(ulOverlayHandle,ref peTrackingOrigin,ref pmatTrackingOriginToOverlayTransform); + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + bool result = FnTable.GetBool(pchSectionUtf8,pchSettingsKeyUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); return result; } - public EVROverlayError SetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle,uint unTrackedDevice,ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform) + public int GetInt32(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.SetOverlayTransformTrackedDeviceRelative(ulOverlayHandle,unTrackedDevice,ref pmatTrackedDeviceToOverlayTransform); + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + int result = FnTable.GetInt32(pchSectionUtf8,pchSettingsKeyUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); return result; } - public EVROverlayError GetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle,ref uint punTrackedDevice,ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform) + public float GetFloat(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) { - punTrackedDevice = 0; - EVROverlayError result = FnTable.GetOverlayTransformTrackedDeviceRelative(ulOverlayHandle,ref punTrackedDevice,ref pmatTrackedDeviceToOverlayTransform); + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + float result = FnTable.GetFloat(pchSectionUtf8,pchSettingsKeyUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); return result; } - public EVROverlayError SetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle,uint unDeviceIndex,string pchComponentName) + public void GetString(string pchSection,string pchSettingsKey,System.Text.StringBuilder pchValue,uint unValueLen,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.SetOverlayTransformTrackedDeviceComponent(ulOverlayHandle,unDeviceIndex,pchComponentName); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + FnTable.GetString(pchSectionUtf8,pchSettingsKeyUtf8,pchValue,unValueLen,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); } - public EVROverlayError GetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle,ref uint punDeviceIndex,string pchComponentName,uint unComponentNameSize) + public void RemoveSection(string pchSection,ref EVRSettingsError peError) { - punDeviceIndex = 0; - EVROverlayError result = FnTable.GetOverlayTransformTrackedDeviceComponent(ulOverlayHandle,ref punDeviceIndex,pchComponentName,unComponentNameSize); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + FnTable.RemoveSection(pchSectionUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); } - public EVROverlayError ShowOverlay(ulong ulOverlayHandle) + public void RemoveKeyInSection(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) { - EVROverlayError result = FnTable.ShowOverlay(ulOverlayHandle); - return result; + IntPtr pchSectionUtf8 = Utils.ToUtf8(pchSection); + IntPtr pchSettingsKeyUtf8 = Utils.ToUtf8(pchSettingsKey); + FnTable.RemoveKeyInSection(pchSectionUtf8,pchSettingsKeyUtf8,ref peError); + Marshal.FreeHGlobal(pchSectionUtf8); + Marshal.FreeHGlobal(pchSettingsKeyUtf8); } - public EVROverlayError HideOverlay(ulong ulOverlayHandle) +} + + +public class CVRScreenshots +{ + IVRScreenshots FnTable; + internal CVRScreenshots(IntPtr pInterface) { - EVROverlayError result = FnTable.HideOverlay(ulOverlayHandle); - return result; + FnTable = (IVRScreenshots)Marshal.PtrToStructure(pInterface, typeof(IVRScreenshots)); } - public bool IsOverlayVisible(ulong ulOverlayHandle) + public EVRScreenshotError RequestScreenshot(ref uint pOutScreenshotHandle,EVRScreenshotType type,string pchPreviewFilename,string pchVRFilename) { - bool result = FnTable.IsOverlayVisible(ulOverlayHandle); + pOutScreenshotHandle = 0; + IntPtr pchPreviewFilenameUtf8 = Utils.ToUtf8(pchPreviewFilename); + IntPtr pchVRFilenameUtf8 = Utils.ToUtf8(pchVRFilename); + EVRScreenshotError result = FnTable.RequestScreenshot(ref pOutScreenshotHandle,type,pchPreviewFilenameUtf8,pchVRFilenameUtf8); + Marshal.FreeHGlobal(pchPreviewFilenameUtf8); + Marshal.FreeHGlobal(pchVRFilenameUtf8); return result; } - public EVROverlayError GetTransformForOverlayCoordinates(ulong ulOverlayHandle,ETrackingUniverseOrigin eTrackingOrigin,HmdVector2_t coordinatesInOverlay,ref HmdMatrix34_t pmatTransform) + public EVRScreenshotError HookScreenshot(EVRScreenshotType [] pSupportedTypes) { - EVROverlayError result = FnTable.GetTransformForOverlayCoordinates(ulOverlayHandle,eTrackingOrigin,coordinatesInOverlay,ref pmatTransform); + EVRScreenshotError result = FnTable.HookScreenshot(pSupportedTypes,(int) pSupportedTypes.Length); return result; } - public bool PollNextOverlayEvent(ulong ulOverlayHandle,ref VREvent_t pEvent,uint uncbVREvent) + public EVRScreenshotType GetScreenshotPropertyType(uint screenshotHandle,ref EVRScreenshotError pError) { - bool result = FnTable.PollNextOverlayEvent(ulOverlayHandle,ref pEvent,uncbVREvent); + EVRScreenshotType result = FnTable.GetScreenshotPropertyType(screenshotHandle,ref pError); return result; } - public EVROverlayError GetOverlayInputMethod(ulong ulOverlayHandle,ref VROverlayInputMethod peInputMethod) + public uint GetScreenshotPropertyFilename(uint screenshotHandle,EVRScreenshotPropertyFilenames filenameType,System.Text.StringBuilder pchFilename,uint cchFilename,ref EVRScreenshotError pError) { - EVROverlayError result = FnTable.GetOverlayInputMethod(ulOverlayHandle,ref peInputMethod); + uint result = FnTable.GetScreenshotPropertyFilename(screenshotHandle,filenameType,pchFilename,cchFilename,ref pError); return result; } - public EVROverlayError SetOverlayInputMethod(ulong ulOverlayHandle,VROverlayInputMethod eInputMethod) + public EVRScreenshotError UpdateScreenshotProgress(uint screenshotHandle,float flProgress) { - EVROverlayError result = FnTable.SetOverlayInputMethod(ulOverlayHandle,eInputMethod); + EVRScreenshotError result = FnTable.UpdateScreenshotProgress(screenshotHandle,flProgress); return result; } - public EVROverlayError GetOverlayMouseScale(ulong ulOverlayHandle,ref HmdVector2_t pvecMouseScale) + public EVRScreenshotError TakeStereoScreenshot(ref uint pOutScreenshotHandle,string pchPreviewFilename,string pchVRFilename) { - EVROverlayError result = FnTable.GetOverlayMouseScale(ulOverlayHandle,ref pvecMouseScale); + pOutScreenshotHandle = 0; + IntPtr pchPreviewFilenameUtf8 = Utils.ToUtf8(pchPreviewFilename); + IntPtr pchVRFilenameUtf8 = Utils.ToUtf8(pchVRFilename); + EVRScreenshotError result = FnTable.TakeStereoScreenshot(ref pOutScreenshotHandle,pchPreviewFilenameUtf8,pchVRFilenameUtf8); + Marshal.FreeHGlobal(pchPreviewFilenameUtf8); + Marshal.FreeHGlobal(pchVRFilenameUtf8); return result; } - public EVROverlayError SetOverlayMouseScale(ulong ulOverlayHandle,ref HmdVector2_t pvecMouseScale) + public EVRScreenshotError SubmitScreenshot(uint screenshotHandle,EVRScreenshotType type,string pchSourcePreviewFilename,string pchSourceVRFilename) { - EVROverlayError result = FnTable.SetOverlayMouseScale(ulOverlayHandle,ref pvecMouseScale); + IntPtr pchSourcePreviewFilenameUtf8 = Utils.ToUtf8(pchSourcePreviewFilename); + IntPtr pchSourceVRFilenameUtf8 = Utils.ToUtf8(pchSourceVRFilename); + EVRScreenshotError result = FnTable.SubmitScreenshot(screenshotHandle,type,pchSourcePreviewFilenameUtf8,pchSourceVRFilenameUtf8); + Marshal.FreeHGlobal(pchSourcePreviewFilenameUtf8); + Marshal.FreeHGlobal(pchSourceVRFilenameUtf8); return result; } - public bool ComputeOverlayIntersection(ulong ulOverlayHandle,ref VROverlayIntersectionParams_t pParams,ref VROverlayIntersectionResults_t pResults) +} + + +public class CVRResources +{ + IVRResources FnTable; + internal CVRResources(IntPtr pInterface) { - bool result = FnTable.ComputeOverlayIntersection(ulOverlayHandle,ref pParams,ref pResults); - return result; + FnTable = (IVRResources)Marshal.PtrToStructure(pInterface, typeof(IVRResources)); } - public bool HandleControllerOverlayInteractionAsMouse(ulong ulOverlayHandle,uint unControllerDeviceIndex) + public uint LoadSharedResource(string pchResourceName,string pchBuffer,uint unBufferLen) { - bool result = FnTable.HandleControllerOverlayInteractionAsMouse(ulOverlayHandle,unControllerDeviceIndex); + IntPtr pchResourceNameUtf8 = Utils.ToUtf8(pchResourceName); + uint result = FnTable.LoadSharedResource(pchResourceNameUtf8,pchBuffer,unBufferLen); + Marshal.FreeHGlobal(pchResourceNameUtf8); return result; } - public bool IsHoverTargetOverlay(ulong ulOverlayHandle) + public uint GetResourceFullPath(string pchResourceName,string pchResourceTypeDirectory,System.Text.StringBuilder pchPathBuffer,uint unBufferLen) { - bool result = FnTable.IsHoverTargetOverlay(ulOverlayHandle); + IntPtr pchResourceNameUtf8 = Utils.ToUtf8(pchResourceName); + IntPtr pchResourceTypeDirectoryUtf8 = Utils.ToUtf8(pchResourceTypeDirectory); + uint result = FnTable.GetResourceFullPath(pchResourceNameUtf8,pchResourceTypeDirectoryUtf8,pchPathBuffer,unBufferLen); + Marshal.FreeHGlobal(pchResourceNameUtf8); + Marshal.FreeHGlobal(pchResourceTypeDirectoryUtf8); return result; } - public ulong GetGamepadFocusOverlay() +} + + +public class CVRDriverManager +{ + IVRDriverManager FnTable; + internal CVRDriverManager(IntPtr pInterface) { - ulong result = FnTable.GetGamepadFocusOverlay(); - return result; + FnTable = (IVRDriverManager)Marshal.PtrToStructure(pInterface, typeof(IVRDriverManager)); } - public EVROverlayError SetGamepadFocusOverlay(ulong ulNewFocusOverlay) + public uint GetDriverCount() { - EVROverlayError result = FnTable.SetGamepadFocusOverlay(ulNewFocusOverlay); + uint result = FnTable.GetDriverCount(); return result; } - public EVROverlayError SetOverlayNeighbor(EOverlayDirection eDirection,ulong ulFrom,ulong ulTo) + public uint GetDriverName(uint nDriver,System.Text.StringBuilder pchValue,uint unBufferSize) { - EVROverlayError result = FnTable.SetOverlayNeighbor(eDirection,ulFrom,ulTo); + uint result = FnTable.GetDriverName(nDriver,pchValue,unBufferSize); return result; } - public EVROverlayError MoveGamepadFocusToNeighbor(EOverlayDirection eDirection,ulong ulFrom) + public ulong GetDriverHandle(string pchDriverName) { - EVROverlayError result = FnTable.MoveGamepadFocusToNeighbor(eDirection,ulFrom); + IntPtr pchDriverNameUtf8 = Utils.ToUtf8(pchDriverName); + ulong result = FnTable.GetDriverHandle(pchDriverNameUtf8); + Marshal.FreeHGlobal(pchDriverNameUtf8); return result; } - public EVROverlayError SetOverlayTexture(ulong ulOverlayHandle,ref Texture_t pTexture) + public bool IsEnabled(uint nDriver) { - EVROverlayError result = FnTable.SetOverlayTexture(ulOverlayHandle,ref pTexture); + bool result = FnTable.IsEnabled(nDriver); return result; } - public EVROverlayError ClearOverlayTexture(ulong ulOverlayHandle) +} + + +public class CVRInput +{ + IVRInput FnTable; + internal CVRInput(IntPtr pInterface) { - EVROverlayError result = FnTable.ClearOverlayTexture(ulOverlayHandle); + FnTable = (IVRInput)Marshal.PtrToStructure(pInterface, typeof(IVRInput)); + } + public EVRInputError SetActionManifestPath(string pchActionManifestPath) + { + IntPtr pchActionManifestPathUtf8 = Utils.ToUtf8(pchActionManifestPath); + EVRInputError result = FnTable.SetActionManifestPath(pchActionManifestPathUtf8); + Marshal.FreeHGlobal(pchActionManifestPathUtf8); return result; } - public EVROverlayError SetOverlayRaw(ulong ulOverlayHandle,IntPtr pvBuffer,uint unWidth,uint unHeight,uint unDepth) + public EVRInputError GetActionSetHandle(string pchActionSetName,ref ulong pHandle) { - EVROverlayError result = FnTable.SetOverlayRaw(ulOverlayHandle,pvBuffer,unWidth,unHeight,unDepth); + IntPtr pchActionSetNameUtf8 = Utils.ToUtf8(pchActionSetName); + pHandle = 0; + EVRInputError result = FnTable.GetActionSetHandle(pchActionSetNameUtf8,ref pHandle); + Marshal.FreeHGlobal(pchActionSetNameUtf8); return result; } - public EVROverlayError SetOverlayFromFile(ulong ulOverlayHandle,string pchFilePath) + public EVRInputError GetActionHandle(string pchActionName,ref ulong pHandle) { - EVROverlayError result = FnTable.SetOverlayFromFile(ulOverlayHandle,pchFilePath); + IntPtr pchActionNameUtf8 = Utils.ToUtf8(pchActionName); + pHandle = 0; + EVRInputError result = FnTable.GetActionHandle(pchActionNameUtf8,ref pHandle); + Marshal.FreeHGlobal(pchActionNameUtf8); return result; } - public EVROverlayError GetOverlayTexture(ulong ulOverlayHandle,ref IntPtr pNativeTextureHandle,IntPtr pNativeTextureRef,ref uint pWidth,ref uint pHeight,ref uint pNativeFormat,ref EGraphicsAPIConvention pAPI,ref EColorSpace pColorSpace) + public EVRInputError GetInputSourceHandle(string pchInputSourcePath,ref ulong pHandle) { - pWidth = 0; - pHeight = 0; - pNativeFormat = 0; - EVROverlayError result = FnTable.GetOverlayTexture(ulOverlayHandle,ref pNativeTextureHandle,pNativeTextureRef,ref pWidth,ref pHeight,ref pNativeFormat,ref pAPI,ref pColorSpace); + IntPtr pchInputSourcePathUtf8 = Utils.ToUtf8(pchInputSourcePath); + pHandle = 0; + EVRInputError result = FnTable.GetInputSourceHandle(pchInputSourcePathUtf8,ref pHandle); + Marshal.FreeHGlobal(pchInputSourcePathUtf8); return result; } - public EVROverlayError ReleaseNativeOverlayHandle(ulong ulOverlayHandle,IntPtr pNativeTextureHandle) + public EVRInputError UpdateActionState(VRActiveActionSet_t [] pSets,uint unSizeOfVRSelectedActionSet_t) { - EVROverlayError result = FnTable.ReleaseNativeOverlayHandle(ulOverlayHandle,pNativeTextureHandle); + EVRInputError result = FnTable.UpdateActionState(pSets,unSizeOfVRSelectedActionSet_t,(uint) pSets.Length); return result; } - public EVROverlayError GetOverlayTextureSize(ulong ulOverlayHandle,ref uint pWidth,ref uint pHeight) + public EVRInputError GetDigitalActionData(ulong action,ref InputDigitalActionData_t pActionData,uint unActionDataSize,ulong ulRestrictToDevice) { - pWidth = 0; - pHeight = 0; - EVROverlayError result = FnTable.GetOverlayTextureSize(ulOverlayHandle,ref pWidth,ref pHeight); + EVRInputError result = FnTable.GetDigitalActionData(action,ref pActionData,unActionDataSize,ulRestrictToDevice); return result; } - public EVROverlayError CreateDashboardOverlay(string pchOverlayKey,string pchOverlayFriendlyName,ref ulong pMainHandle,ref ulong pThumbnailHandle) + public EVRInputError GetAnalogActionData(ulong action,ref InputAnalogActionData_t pActionData,uint unActionDataSize,ulong ulRestrictToDevice) { - pMainHandle = 0; - pThumbnailHandle = 0; - EVROverlayError result = FnTable.CreateDashboardOverlay(pchOverlayKey,pchOverlayFriendlyName,ref pMainHandle,ref pThumbnailHandle); + EVRInputError result = FnTable.GetAnalogActionData(action,ref pActionData,unActionDataSize,ulRestrictToDevice); return result; } - public bool IsDashboardVisible() + public EVRInputError GetPoseActionDataRelativeToNow(ulong action,ETrackingUniverseOrigin eOrigin,float fPredictedSecondsFromNow,ref InputPoseActionData_t pActionData,uint unActionDataSize,ulong ulRestrictToDevice) { - bool result = FnTable.IsDashboardVisible(); + EVRInputError result = FnTable.GetPoseActionDataRelativeToNow(action,eOrigin,fPredictedSecondsFromNow,ref pActionData,unActionDataSize,ulRestrictToDevice); return result; } - public bool IsActiveDashboardOverlay(ulong ulOverlayHandle) + public EVRInputError GetPoseActionDataForNextFrame(ulong action,ETrackingUniverseOrigin eOrigin,ref InputPoseActionData_t pActionData,uint unActionDataSize,ulong ulRestrictToDevice) { - bool result = FnTable.IsActiveDashboardOverlay(ulOverlayHandle); + EVRInputError result = FnTable.GetPoseActionDataForNextFrame(action,eOrigin,ref pActionData,unActionDataSize,ulRestrictToDevice); return result; } - public EVROverlayError SetDashboardOverlaySceneProcess(ulong ulOverlayHandle,uint unProcessId) + public EVRInputError GetSkeletalActionData(ulong action,ref InputSkeletalActionData_t pActionData,uint unActionDataSize) { - EVROverlayError result = FnTable.SetDashboardOverlaySceneProcess(ulOverlayHandle,unProcessId); + EVRInputError result = FnTable.GetSkeletalActionData(action,ref pActionData,unActionDataSize); return result; } - public EVROverlayError GetDashboardOverlaySceneProcess(ulong ulOverlayHandle,ref uint punProcessId) + public EVRInputError GetDominantHand(ref ETrackedControllerRole peDominantHand) { - punProcessId = 0; - EVROverlayError result = FnTable.GetDashboardOverlaySceneProcess(ulOverlayHandle,ref punProcessId); + EVRInputError result = FnTable.GetDominantHand(ref peDominantHand); return result; } - public void ShowDashboard(string pchOverlayToShow) + public EVRInputError SetDominantHand(ETrackedControllerRole eDominantHand) { - FnTable.ShowDashboard(pchOverlayToShow); + EVRInputError result = FnTable.SetDominantHand(eDominantHand); + return result; } - public uint GetPrimaryDashboardDevice() + public EVRInputError GetBoneCount(ulong action,ref uint pBoneCount) { - uint result = FnTable.GetPrimaryDashboardDevice(); + pBoneCount = 0; + EVRInputError result = FnTable.GetBoneCount(action,ref pBoneCount); return result; } - public EVROverlayError ShowKeyboard(int eInputMode,int eLineInputMode,string pchDescription,uint unCharMax,string pchExistingText,bool bUseMinimalMode,ulong uUserValue) + public EVRInputError GetBoneHierarchy(ulong action,int [] pParentIndices) { - EVROverlayError result = FnTable.ShowKeyboard(eInputMode,eLineInputMode,pchDescription,unCharMax,pchExistingText,bUseMinimalMode,uUserValue); + EVRInputError result = FnTable.GetBoneHierarchy(action,pParentIndices,(uint) pParentIndices.Length); return result; } - public EVROverlayError ShowKeyboardForOverlay(ulong ulOverlayHandle,int eInputMode,int eLineInputMode,string pchDescription,uint unCharMax,string pchExistingText,bool bUseMinimalMode,ulong uUserValue) + public EVRInputError GetBoneName(ulong action,int nBoneIndex,System.Text.StringBuilder pchBoneName,uint unNameBufferSize) { - EVROverlayError result = FnTable.ShowKeyboardForOverlay(ulOverlayHandle,eInputMode,eLineInputMode,pchDescription,unCharMax,pchExistingText,bUseMinimalMode,uUserValue); + EVRInputError result = FnTable.GetBoneName(action,nBoneIndex,pchBoneName,unNameBufferSize); return result; } - public uint GetKeyboardText(System.Text.StringBuilder pchText,uint cchText) + public EVRInputError GetSkeletalReferenceTransforms(ulong action,EVRSkeletalTransformSpace eTransformSpace,EVRSkeletalReferencePose eReferencePose,VRBoneTransform_t [] pTransformArray) { - uint result = FnTable.GetKeyboardText(pchText,cchText); + EVRInputError result = FnTable.GetSkeletalReferenceTransforms(action,eTransformSpace,eReferencePose,pTransformArray,(uint) pTransformArray.Length); return result; } - public void HideKeyboard() + public EVRInputError GetSkeletalTrackingLevel(ulong action,ref EVRSkeletalTrackingLevel pSkeletalTrackingLevel) { - FnTable.HideKeyboard(); + EVRInputError result = FnTable.GetSkeletalTrackingLevel(action,ref pSkeletalTrackingLevel); + return result; } - public void SetKeyboardTransformAbsolute(ETrackingUniverseOrigin eTrackingOrigin,ref HmdMatrix34_t pmatTrackingOriginToKeyboardTransform) + public EVRInputError GetSkeletalBoneData(ulong action,EVRSkeletalTransformSpace eTransformSpace,EVRSkeletalMotionRange eMotionRange,VRBoneTransform_t [] pTransformArray) { - FnTable.SetKeyboardTransformAbsolute(eTrackingOrigin,ref pmatTrackingOriginToKeyboardTransform); + EVRInputError result = FnTable.GetSkeletalBoneData(action,eTransformSpace,eMotionRange,pTransformArray,(uint) pTransformArray.Length); + return result; } - public void SetKeyboardPositionForOverlay(ulong ulOverlayHandle,HmdRect2_t avoidRect) + public EVRInputError GetSkeletalSummaryData(ulong action,EVRSummaryType eSummaryType,ref VRSkeletalSummaryData_t pSkeletalSummaryData) { - FnTable.SetKeyboardPositionForOverlay(ulOverlayHandle,avoidRect); + EVRInputError result = FnTable.GetSkeletalSummaryData(action,eSummaryType,ref pSkeletalSummaryData); + return result; } -} - - -public class CVRRenderModels -{ - IVRRenderModels FnTable; - internal CVRRenderModels(IntPtr pInterface) + public EVRInputError GetSkeletalBoneDataCompressed(ulong action,EVRSkeletalMotionRange eMotionRange,IntPtr pvCompressedData,uint unCompressedSize,ref uint punRequiredCompressedSize) { - FnTable = (IVRRenderModels)Marshal.PtrToStructure(pInterface, typeof(IVRRenderModels)); + punRequiredCompressedSize = 0; + EVRInputError result = FnTable.GetSkeletalBoneDataCompressed(action,eMotionRange,pvCompressedData,unCompressedSize,ref punRequiredCompressedSize); + return result; } - public EVRRenderModelError LoadRenderModel_Async(string pchRenderModelName,ref IntPtr ppRenderModel) + public EVRInputError DecompressSkeletalBoneData(IntPtr pvCompressedBuffer,uint unCompressedBufferSize,EVRSkeletalTransformSpace eTransformSpace,VRBoneTransform_t [] pTransformArray) { - EVRRenderModelError result = FnTable.LoadRenderModel_Async(pchRenderModelName,ref ppRenderModel); + EVRInputError result = FnTable.DecompressSkeletalBoneData(pvCompressedBuffer,unCompressedBufferSize,eTransformSpace,pTransformArray,(uint) pTransformArray.Length); return result; } - public void FreeRenderModel(IntPtr pRenderModel) + public EVRInputError TriggerHapticVibrationAction(ulong action,float fStartSecondsFromNow,float fDurationSeconds,float fFrequency,float fAmplitude,ulong ulRestrictToDevice) { - FnTable.FreeRenderModel(pRenderModel); + EVRInputError result = FnTable.TriggerHapticVibrationAction(action,fStartSecondsFromNow,fDurationSeconds,fFrequency,fAmplitude,ulRestrictToDevice); + return result; } - public EVRRenderModelError LoadTexture_Async(int textureId,ref IntPtr ppTexture) + public EVRInputError GetActionOrigins(ulong actionSetHandle,ulong digitalActionHandle,ulong [] originsOut) { - EVRRenderModelError result = FnTable.LoadTexture_Async(textureId,ref ppTexture); + EVRInputError result = FnTable.GetActionOrigins(actionSetHandle,digitalActionHandle,originsOut,(uint) originsOut.Length); return result; } - public void FreeTexture(IntPtr pTexture) + public EVRInputError GetOriginLocalizedName(ulong origin,System.Text.StringBuilder pchNameArray,uint unNameArraySize,int unStringSectionsToInclude) { - FnTable.FreeTexture(pTexture); + EVRInputError result = FnTable.GetOriginLocalizedName(origin,pchNameArray,unNameArraySize,unStringSectionsToInclude); + return result; } - public EVRRenderModelError LoadTextureD3D11_Async(int textureId,IntPtr pD3D11Device,ref IntPtr ppD3D11Texture2D) + public EVRInputError GetOriginTrackedDeviceInfo(ulong origin,ref InputOriginInfo_t pOriginInfo,uint unOriginInfoSize) { - EVRRenderModelError result = FnTable.LoadTextureD3D11_Async(textureId,pD3D11Device,ref ppD3D11Texture2D); + EVRInputError result = FnTable.GetOriginTrackedDeviceInfo(origin,ref pOriginInfo,unOriginInfoSize); return result; } - public EVRRenderModelError LoadIntoTextureD3D11_Async(int textureId,IntPtr pDstTexture) + public EVRInputError GetActionBindingInfo(ulong action,ref InputBindingInfo_t pOriginInfo,uint unBindingInfoSize,uint unBindingInfoCount,ref uint punReturnedBindingInfoCount) { - EVRRenderModelError result = FnTable.LoadIntoTextureD3D11_Async(textureId,pDstTexture); + punReturnedBindingInfoCount = 0; + EVRInputError result = FnTable.GetActionBindingInfo(action,ref pOriginInfo,unBindingInfoSize,unBindingInfoCount,ref punReturnedBindingInfoCount); return result; } - public void FreeTextureD3D11(IntPtr pD3D11Texture2D) + public EVRInputError ShowActionOrigins(ulong actionSetHandle,ulong ulActionHandle) { - FnTable.FreeTextureD3D11(pD3D11Texture2D); + EVRInputError result = FnTable.ShowActionOrigins(actionSetHandle,ulActionHandle); + return result; } - public uint GetRenderModelName(uint unRenderModelIndex,System.Text.StringBuilder pchRenderModelName,uint unRenderModelNameLen) + public EVRInputError ShowBindingsForActionSet(VRActiveActionSet_t [] pSets,uint unSizeOfVRSelectedActionSet_t,ulong originToHighlight) { - uint result = FnTable.GetRenderModelName(unRenderModelIndex,pchRenderModelName,unRenderModelNameLen); + EVRInputError result = FnTable.ShowBindingsForActionSet(pSets,unSizeOfVRSelectedActionSet_t,(uint) pSets.Length,originToHighlight); return result; } - public uint GetRenderModelCount() + public EVRInputError GetComponentStateForBinding(string pchRenderModelName,string pchComponentName,ref InputBindingInfo_t pOriginInfo,uint unBindingInfoSize,uint unBindingInfoCount,ref RenderModel_ComponentState_t pComponentState) { - uint result = FnTable.GetRenderModelCount(); + IntPtr pchRenderModelNameUtf8 = Utils.ToUtf8(pchRenderModelName); + IntPtr pchComponentNameUtf8 = Utils.ToUtf8(pchComponentName); + EVRInputError result = FnTable.GetComponentStateForBinding(pchRenderModelNameUtf8,pchComponentNameUtf8,ref pOriginInfo,unBindingInfoSize,unBindingInfoCount,ref pComponentState); + Marshal.FreeHGlobal(pchRenderModelNameUtf8); + Marshal.FreeHGlobal(pchComponentNameUtf8); return result; } - public uint GetComponentCount(string pchRenderModelName) + public bool IsUsingLegacyInput() { - uint result = FnTable.GetComponentCount(pchRenderModelName); + bool result = FnTable.IsUsingLegacyInput(); return result; } - public uint GetComponentName(string pchRenderModelName,uint unComponentIndex,System.Text.StringBuilder pchComponentName,uint unComponentNameLen) + public EVRInputError OpenBindingUI(string pchAppKey,ulong ulActionSetHandle,ulong ulDeviceHandle,bool bShowOnDesktop) { - uint result = FnTable.GetComponentName(pchRenderModelName,unComponentIndex,pchComponentName,unComponentNameLen); + IntPtr pchAppKeyUtf8 = Utils.ToUtf8(pchAppKey); + EVRInputError result = FnTable.OpenBindingUI(pchAppKeyUtf8,ulActionSetHandle,ulDeviceHandle,bShowOnDesktop); + Marshal.FreeHGlobal(pchAppKeyUtf8); return result; } - public ulong GetComponentButtonMask(string pchRenderModelName,string pchComponentName) + public EVRInputError GetBindingVariant(ulong ulDevicePath,System.Text.StringBuilder pchVariantArray,uint unVariantArraySize) { - ulong result = FnTable.GetComponentButtonMask(pchRenderModelName,pchComponentName); + EVRInputError result = FnTable.GetBindingVariant(ulDevicePath,pchVariantArray,unVariantArraySize); return result; } - public uint GetComponentRenderModelName(string pchRenderModelName,string pchComponentName,System.Text.StringBuilder pchComponentRenderModelName,uint unComponentRenderModelNameLen) +} + + +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) { - uint result = FnTable.GetComponentRenderModelName(pchRenderModelName,pchComponentName,pchComponentRenderModelName,unComponentRenderModelNameLen); + IntPtr pchPathUtf8 = Utils.ToUtf8(pchPath); + pulBuffer = 0; + EIOBufferError result = FnTable.Open(pchPathUtf8,mode,unElementSize,unElements,ref pulBuffer); + Marshal.FreeHGlobal(pchPathUtf8); return result; } - public bool GetComponentState(string pchRenderModelName,string pchComponentName,ref VRControllerState_t pControllerState,ref RenderModel_ControllerMode_State_t pState,ref RenderModel_ComponentState_t pComponentState) + public EIOBufferError Close(ulong ulBuffer) { - bool result = FnTable.GetComponentState(pchRenderModelName,pchComponentName,ref pControllerState,ref pState,ref pComponentState); + EIOBufferError result = FnTable.Close(ulBuffer); return result; } - public bool RenderModelHasComponent(string pchRenderModelName,string pchComponentName) + public EIOBufferError Read(ulong ulBuffer,IntPtr pDst,uint unBytes,ref uint punRead) { - bool result = FnTable.RenderModelHasComponent(pchRenderModelName,pchComponentName); + punRead = 0; + EIOBufferError result = FnTable.Read(ulBuffer,pDst,unBytes,ref punRead); return result; } - public uint GetRenderModelThumbnailURL(string pchRenderModelName,System.Text.StringBuilder pchThumbnailURL,uint unThumbnailURLLen,ref EVRRenderModelError peError) + public EIOBufferError Write(ulong ulBuffer,IntPtr pSrc,uint unBytes) { - uint result = FnTable.GetRenderModelThumbnailURL(pchRenderModelName,pchThumbnailURL,unThumbnailURLLen,ref peError); + EIOBufferError result = FnTable.Write(ulBuffer,pSrc,unBytes); return result; } - public uint GetRenderModelOriginalPath(string pchRenderModelName,System.Text.StringBuilder pchOriginalPath,uint unOriginalPathLen,ref EVRRenderModelError peError) + public ulong PropertyContainer(ulong ulBuffer) { - uint result = FnTable.GetRenderModelOriginalPath(pchRenderModelName,pchOriginalPath,unOriginalPathLen,ref peError); + ulong result = FnTable.PropertyContainer(ulBuffer); return result; } - public string GetRenderModelErrorNameFromEnum(EVRRenderModelError error) + public bool HasReaders(ulong ulBuffer) { - IntPtr result = FnTable.GetRenderModelErrorNameFromEnum(error); - return Marshal.PtrToStringAnsi(result); + bool result = FnTable.HasReaders(ulBuffer); + return result; } } -public class CVRNotifications +public class CVRSpatialAnchors { - IVRNotifications FnTable; - internal CVRNotifications(IntPtr pInterface) + IVRSpatialAnchors FnTable; + internal CVRSpatialAnchors(IntPtr pInterface) { - FnTable = (IVRNotifications)Marshal.PtrToStructure(pInterface, typeof(IVRNotifications)); + FnTable = (IVRSpatialAnchors)Marshal.PtrToStructure(pInterface, typeof(IVRSpatialAnchors)); } - public EVRNotificationError CreateNotification(ulong ulOverlayHandle,ulong ulUserValue,EVRNotificationType type,string pchText,EVRNotificationStyle style,ref NotificationBitmap_t pImage,ref uint pNotificationId) + public EVRSpatialAnchorError CreateSpatialAnchorFromDescriptor(string pchDescriptor,ref uint pHandleOut) { - pNotificationId = 0; - EVRNotificationError result = FnTable.CreateNotification(ulOverlayHandle,ulUserValue,type,pchText,style,ref pImage,ref pNotificationId); + IntPtr pchDescriptorUtf8 = Utils.ToUtf8(pchDescriptor); + pHandleOut = 0; + EVRSpatialAnchorError result = FnTable.CreateSpatialAnchorFromDescriptor(pchDescriptorUtf8,ref pHandleOut); + Marshal.FreeHGlobal(pchDescriptorUtf8); return result; } - public EVRNotificationError RemoveNotification(uint notificationId) + public EVRSpatialAnchorError CreateSpatialAnchorFromPose(uint unDeviceIndex,ETrackingUniverseOrigin eOrigin,ref SpatialAnchorPose_t pPose,ref uint pHandleOut) { - EVRNotificationError result = FnTable.RemoveNotification(notificationId); + pHandleOut = 0; + EVRSpatialAnchorError result = FnTable.CreateSpatialAnchorFromPose(unDeviceIndex,eOrigin,ref pPose,ref pHandleOut); + return result; + } + public EVRSpatialAnchorError GetSpatialAnchorPose(uint unHandle,ETrackingUniverseOrigin eOrigin,ref SpatialAnchorPose_t pPoseOut) + { + EVRSpatialAnchorError result = FnTable.GetSpatialAnchorPose(unHandle,eOrigin,ref pPoseOut); + return result; + } + public EVRSpatialAnchorError GetSpatialAnchorDescriptor(uint unHandle,System.Text.StringBuilder pchDescriptorOut,ref uint punDescriptorBufferLenInOut) + { + punDescriptorBufferLenInOut = 0; + EVRSpatialAnchorError result = FnTable.GetSpatialAnchorDescriptor(unHandle,pchDescriptorOut,ref punDescriptorBufferLenInOut); return result; } } -public class CVRSettings +public class CVRDebug { - IVRSettings FnTable; - internal CVRSettings(IntPtr pInterface) + IVRDebug FnTable; + internal CVRDebug(IntPtr pInterface) { - FnTable = (IVRSettings)Marshal.PtrToStructure(pInterface, typeof(IVRSettings)); + FnTable = (IVRDebug)Marshal.PtrToStructure(pInterface, typeof(IVRDebug)); } - public string GetSettingsErrorNameFromEnum(EVRSettingsError eError) + public EVRDebugError EmitVrProfilerEvent(string pchMessage) { - IntPtr result = FnTable.GetSettingsErrorNameFromEnum(eError); - return Marshal.PtrToStringAnsi(result); + IntPtr pchMessageUtf8 = Utils.ToUtf8(pchMessage); + EVRDebugError result = FnTable.EmitVrProfilerEvent(pchMessageUtf8); + Marshal.FreeHGlobal(pchMessageUtf8); + return result; } - public bool Sync(bool bForce,ref EVRSettingsError peError) + public EVRDebugError BeginVrProfilerEvent(ref ulong pHandleOut) { - bool result = FnTable.Sync(bForce,ref peError); + pHandleOut = 0; + EVRDebugError result = FnTable.BeginVrProfilerEvent(ref pHandleOut); return result; } - public bool GetBool(string pchSection,string pchSettingsKey,bool bDefaultValue,ref EVRSettingsError peError) + public EVRDebugError FinishVrProfilerEvent(ulong hHandle,string pchMessage) { - bool result = FnTable.GetBool(pchSection,pchSettingsKey,bDefaultValue,ref peError); + IntPtr pchMessageUtf8 = Utils.ToUtf8(pchMessage); + EVRDebugError result = FnTable.FinishVrProfilerEvent(hHandle,pchMessageUtf8); + Marshal.FreeHGlobal(pchMessageUtf8); return result; } - public void SetBool(string pchSection,string pchSettingsKey,bool bValue,ref EVRSettingsError peError) + public uint DriverDebugRequest(uint unDeviceIndex,string pchRequest,System.Text.StringBuilder pchResponseBuffer,uint unResponseBufferSize) + { + IntPtr pchRequestUtf8 = Utils.ToUtf8(pchRequest); + uint result = FnTable.DriverDebugRequest(unDeviceIndex,pchRequestUtf8,pchResponseBuffer,unResponseBufferSize); + Marshal.FreeHGlobal(pchRequestUtf8); + return result; + } +} + + +public class CVRProperties +{ + IVRProperties FnTable; + internal CVRProperties(IntPtr pInterface) { - FnTable.SetBool(pchSection,pchSettingsKey,bValue,ref peError); + FnTable = (IVRProperties)Marshal.PtrToStructure(pInterface, typeof(IVRProperties)); } - public int GetInt32(string pchSection,string pchSettingsKey,int nDefaultValue,ref EVRSettingsError peError) + public ETrackedPropertyError ReadPropertyBatch(ulong ulContainerHandle,ref PropertyRead_t pBatch,uint unBatchEntryCount) { - int result = FnTable.GetInt32(pchSection,pchSettingsKey,nDefaultValue,ref peError); + ETrackedPropertyError result = FnTable.ReadPropertyBatch(ulContainerHandle,ref pBatch,unBatchEntryCount); return result; } - public void SetInt32(string pchSection,string pchSettingsKey,int nValue,ref EVRSettingsError peError) + public ETrackedPropertyError WritePropertyBatch(ulong ulContainerHandle,ref PropertyWrite_t pBatch,uint unBatchEntryCount) + { + ETrackedPropertyError result = FnTable.WritePropertyBatch(ulContainerHandle,ref pBatch,unBatchEntryCount); + return result; + } + public string GetPropErrorNameFromEnum(ETrackedPropertyError error) { - FnTable.SetInt32(pchSection,pchSettingsKey,nValue,ref peError); + IntPtr result = FnTable.GetPropErrorNameFromEnum(error); + return Marshal.PtrToStringAnsi(result); } - public float GetFloat(string pchSection,string pchSettingsKey,float flDefaultValue,ref EVRSettingsError peError) + public ulong TrackedDeviceToPropertyContainer(uint nDevice) { - float result = FnTable.GetFloat(pchSection,pchSettingsKey,flDefaultValue,ref peError); + ulong result = FnTable.TrackedDeviceToPropertyContainer(nDevice); return result; } - public void SetFloat(string pchSection,string pchSettingsKey,float flValue,ref EVRSettingsError peError) +} + + +public class CVRPaths +{ + IVRPaths FnTable; + internal CVRPaths(IntPtr pInterface) { - FnTable.SetFloat(pchSection,pchSettingsKey,flValue,ref peError); + FnTable = (IVRPaths)Marshal.PtrToStructure(pInterface, typeof(IVRPaths)); } - public void GetString(string pchSection,string pchSettingsKey,System.Text.StringBuilder pchValue,uint unValueLen,string pchDefaultValue,ref EVRSettingsError peError) + public ETrackedPropertyError ReadPathBatch(ulong ulRootHandle,ref PathRead_t pBatch,uint unBatchEntryCount) { - FnTable.GetString(pchSection,pchSettingsKey,pchValue,unValueLen,pchDefaultValue,ref peError); + ETrackedPropertyError result = FnTable.ReadPathBatch(ulRootHandle,ref pBatch,unBatchEntryCount); + return result; } - public void SetString(string pchSection,string pchSettingsKey,string pchValue,ref EVRSettingsError peError) + public ETrackedPropertyError WritePathBatch(ulong ulRootHandle,ref PathWrite_t pBatch,uint unBatchEntryCount) { - FnTable.SetString(pchSection,pchSettingsKey,pchValue,ref peError); + ETrackedPropertyError result = FnTable.WritePathBatch(ulRootHandle,ref pBatch,unBatchEntryCount); + return result; } - public void RemoveSection(string pchSection,ref EVRSettingsError peError) + public ETrackedPropertyError StringToHandle(ref ulong pHandle,string pchPath) { - FnTable.RemoveSection(pchSection,ref peError); + pHandle = 0; + IntPtr pchPathUtf8 = Utils.ToUtf8(pchPath); + ETrackedPropertyError result = FnTable.StringToHandle(ref pHandle,pchPathUtf8); + Marshal.FreeHGlobal(pchPathUtf8); + return result; } - public void RemoveKeyInSection(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) + public ETrackedPropertyError HandleToString(ulong pHandle,string pchBuffer,uint unBufferSize,ref uint punBufferSizeUsed) { - FnTable.RemoveKeyInSection(pchSection,pchSettingsKey,ref peError); + punBufferSizeUsed = 0; + ETrackedPropertyError result = FnTable.HandleToString(pHandle,pchBuffer,unBufferSize,ref punBufferSizeUsed); + return result; } } -public class CVRScreenshots +public class CVRBlockQueue { - IVRScreenshots FnTable; - internal CVRScreenshots(IntPtr pInterface) + IVRBlockQueue FnTable; + internal CVRBlockQueue(IntPtr pInterface) { - FnTable = (IVRScreenshots)Marshal.PtrToStructure(pInterface, typeof(IVRScreenshots)); + FnTable = (IVRBlockQueue)Marshal.PtrToStructure(pInterface, typeof(IVRBlockQueue)); } - public EVRScreenshotError RequestScreenshot(ref uint pOutScreenshotHandle,EVRScreenshotType type,string pchPreviewFilename,string pchVRFilename) + public EBlockQueueError Create(ref ulong pulQueueHandle,string pchPath,uint unBlockDataSize,uint unBlockHeaderSize,uint unBlockCount) { - pOutScreenshotHandle = 0; - EVRScreenshotError result = FnTable.RequestScreenshot(ref pOutScreenshotHandle,type,pchPreviewFilename,pchVRFilename); + pulQueueHandle = 0; + IntPtr pchPathUtf8 = Utils.ToUtf8(pchPath); + EBlockQueueError result = FnTable.Create(ref pulQueueHandle,pchPathUtf8,unBlockDataSize,unBlockHeaderSize,unBlockCount); + Marshal.FreeHGlobal(pchPathUtf8); return result; } - public EVRScreenshotError HookScreenshot(EVRScreenshotType [] pSupportedTypes) + public EBlockQueueError Connect(ref ulong pulQueueHandle,string pchPath) { - EVRScreenshotError result = FnTable.HookScreenshot(pSupportedTypes,(int) pSupportedTypes.Length); + pulQueueHandle = 0; + IntPtr pchPathUtf8 = Utils.ToUtf8(pchPath); + EBlockQueueError result = FnTable.Connect(ref pulQueueHandle,pchPathUtf8); + Marshal.FreeHGlobal(pchPathUtf8); return result; } - public EVRScreenshotType GetScreenshotPropertyType(uint screenshotHandle,ref EVRScreenshotError pError) + public EBlockQueueError Destroy(ulong ulQueueHandle) { - EVRScreenshotType result = FnTable.GetScreenshotPropertyType(screenshotHandle,ref pError); + EBlockQueueError result = FnTable.Destroy(ulQueueHandle); return result; } - public uint GetScreenshotPropertyFilename(uint screenshotHandle,EVRScreenshotPropertyFilenames filenameType,System.Text.StringBuilder pchFilename,uint cchFilename,ref EVRScreenshotError pError) + public EBlockQueueError AcquireWriteOnlyBlock(ulong ulQueueHandle,ref ulong pulBlockHandle,ref IntPtr ppvBuffer) { - uint result = FnTable.GetScreenshotPropertyFilename(screenshotHandle,filenameType,pchFilename,cchFilename,ref pError); + pulBlockHandle = 0; + EBlockQueueError result = FnTable.AcquireWriteOnlyBlock(ulQueueHandle,ref pulBlockHandle,ref ppvBuffer); return result; } - public EVRScreenshotError UpdateScreenshotProgress(uint screenshotHandle,float flProgress) + public EBlockQueueError ReleaseWriteOnlyBlock(ulong ulQueueHandle,ulong ulBlockHandle) { - EVRScreenshotError result = FnTable.UpdateScreenshotProgress(screenshotHandle,flProgress); + EBlockQueueError result = FnTable.ReleaseWriteOnlyBlock(ulQueueHandle,ulBlockHandle); return result; } - public EVRScreenshotError TakeStereoScreenshot(ref uint pOutScreenshotHandle,string pchPreviewFilename,string pchVRFilename) + public EBlockQueueError WaitAndAcquireReadOnlyBlock(ulong ulQueueHandle,ref ulong pulBlockHandle,ref IntPtr ppvBuffer,EBlockQueueReadType eReadType,uint unTimeoutMs) { - pOutScreenshotHandle = 0; - EVRScreenshotError result = FnTable.TakeStereoScreenshot(ref pOutScreenshotHandle,pchPreviewFilename,pchVRFilename); + pulBlockHandle = 0; + EBlockQueueError result = FnTable.WaitAndAcquireReadOnlyBlock(ulQueueHandle,ref pulBlockHandle,ref ppvBuffer,eReadType,unTimeoutMs); return result; } - public EVRScreenshotError SubmitScreenshot(uint screenshotHandle,EVRScreenshotType type,string pchSourcePreviewFilename,string pchSourceVRFilename) + public EBlockQueueError AcquireReadOnlyBlock(ulong ulQueueHandle,ref ulong pulBlockHandle,ref IntPtr ppvBuffer,EBlockQueueReadType eReadType) { - EVRScreenshotError result = FnTable.SubmitScreenshot(screenshotHandle,type,pchSourcePreviewFilename,pchSourceVRFilename); + pulBlockHandle = 0; + EBlockQueueError result = FnTable.AcquireReadOnlyBlock(ulQueueHandle,ref pulBlockHandle,ref ppvBuffer,eReadType); return result; } -} - - -public class CVRResources -{ - IVRResources FnTable; - internal CVRResources(IntPtr pInterface) - { - FnTable = (IVRResources)Marshal.PtrToStructure(pInterface, typeof(IVRResources)); - } - public uint LoadSharedResource(string pchResourceName,string pchBuffer,uint unBufferLen) + public EBlockQueueError ReleaseReadOnlyBlock(ulong ulQueueHandle,ulong ulBlockHandle) { - uint result = FnTable.LoadSharedResource(pchResourceName,pchBuffer,unBufferLen); + EBlockQueueError result = FnTable.ReleaseReadOnlyBlock(ulQueueHandle,ulBlockHandle); return result; } - public uint GetResourceFullPath(string pchResourceName,string pchResourceTypeDirectory,string pchPathBuffer,uint unBufferLen) + public EBlockQueueError QueueHasReader(ulong ulQueueHandle,ref bool pbHasReaders) { - uint result = FnTable.GetResourceFullPath(pchResourceName,pchResourceTypeDirectory,pchPathBuffer,unBufferLen); + pbHasReaders = false; + EBlockQueueError result = FnTable.QueueHasReader(ulQueueHandle,ref pbHasReaders); return result; } } @@ -2876,21 +4469,27 @@ public uint GetResourceFullPath(string pchResourceName,string pchResourceTypeDir public class OpenVRInterop { - [DllImportAttribute("openvr_api", EntryPoint = "VR_InitInternal")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_InitInternal", CallingConvention = CallingConvention.Cdecl)] internal static extern uint InitInternal(ref EVRInitError peError, EVRApplicationType eApplicationType); - [DllImportAttribute("openvr_api", EntryPoint = "VR_ShutdownInternal")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_InitInternal2", CallingConvention = CallingConvention.Cdecl)] + internal static extern uint InitInternal2(ref EVRInitError peError, EVRApplicationType eApplicationType,[In, MarshalAs(UnmanagedType.LPStr)] string pStartupInfo); + [DllImportAttribute("openvr_api", EntryPoint = "VR_ShutdownInternal", CallingConvention = CallingConvention.Cdecl)] internal static extern void ShutdownInternal(); - [DllImportAttribute("openvr_api", EntryPoint = "VR_IsHmdPresent")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_IsHmdPresent", CallingConvention = CallingConvention.Cdecl)] internal static extern bool IsHmdPresent(); - [DllImportAttribute("openvr_api", EntryPoint = "VR_IsRuntimeInstalled")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_IsRuntimeInstalled", CallingConvention = CallingConvention.Cdecl)] internal static extern bool IsRuntimeInstalled(); - [DllImportAttribute("openvr_api", EntryPoint = "VR_GetStringForHmdError")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_RuntimePath", CallingConvention = CallingConvention.Cdecl)] + internal static extern string RuntimePath(); + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetRuntimePath", CallingConvention = CallingConvention.Cdecl)] + internal static extern bool GetRuntimePath(System.Text.StringBuilder pchPathBuffer, uint unBufferSize, ref uint punRequiredBufferSize); + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetStringForHmdError", CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr GetStringForHmdError(EVRInitError error); - [DllImportAttribute("openvr_api", EntryPoint = "VR_GetGenericInterface")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetGenericInterface", CallingConvention = CallingConvention.Cdecl)] internal static extern IntPtr GetGenericInterface([In, MarshalAs(UnmanagedType.LPStr)] string pchInterfaceVersion, ref EVRInitError peError); - [DllImportAttribute("openvr_api", EntryPoint = "VR_IsInterfaceVersionValid")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_IsInterfaceVersionValid", CallingConvention = CallingConvention.Cdecl)] internal static extern bool IsInterfaceVersionValid([In, MarshalAs(UnmanagedType.LPStr)] string pchInterfaceVersion); - [DllImportAttribute("openvr_api", EntryPoint = "VR_GetInitToken")] + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetInitToken", CallingConvention = CallingConvention.Cdecl)] internal static extern uint GetInitToken(); } @@ -2900,10 +4499,16 @@ public enum EVREye Eye_Left = 0, Eye_Right = 1, } -public enum EGraphicsAPIConvention +public enum ETextureType { - API_DirectX = 0, - API_OpenGL = 1, + Invalid = -1, + DirectX = 0, + OpenGL = 1, + Vulkan = 2, + IOSurface = 3, + DirectX12 = 4, + DXGISharedHandle = 5, + Metal = 6, } public enum EColorSpace { @@ -2918,20 +4523,27 @@ public enum ETrackingResult Calibrating_OutOfRange = 101, Running_OK = 200, Running_OutOfRange = 201, + Fallback_RotationOnly = 300, } public enum ETrackedDeviceClass { Invalid = 0, HMD = 1, Controller = 2, + GenericTracker = 3, TrackingReference = 4, - Other = 1000, + DisplayRedirect = 5, + Max = 6, } public enum ETrackedControllerRole { Invalid = 0, LeftHand = 1, RightHand = 2, + OptOut = 3, + Treadmill = 4, + Stylus = 5, + Max = 5, } public enum ETrackingUniverseOrigin { @@ -2939,8 +4551,16 @@ public enum ETrackingUniverseOrigin TrackingUniverseStanding = 1, TrackingUniverseRawAndUncalibrated = 2, } +public enum EAdditionalRadioFeatures +{ + None = 0, + HTCLinkBox = 1, + InternalDongle = 2, + ExternalDongle = 4, +} public enum ETrackedDeviceProperty { + Prop_Invalid = 0, Prop_TrackingSystemName_String = 1000, Prop_ModelNumber_String = 1001, Prop_SerialNumber_String = 1002, @@ -2974,6 +4594,25 @@ public enum ETrackedDeviceProperty Prop_HasCamera_Bool = 1030, Prop_DriverVersion_String = 1031, Prop_Firmware_ForceUpdateRequired_Bool = 1032, + Prop_ViveSystemButtonFixRequired_Bool = 1033, + Prop_ParentDriver_Uint64 = 1034, + Prop_ResourceRoot_String = 1035, + Prop_RegisteredDeviceType_String = 1036, + Prop_InputProfilePath_String = 1037, + Prop_NeverTracked_Bool = 1038, + Prop_NumCameras_Int32 = 1039, + Prop_CameraFrameLayout_Int32 = 1040, + Prop_CameraStreamFormat_Int32 = 1041, + Prop_AdditionalDeviceSettingsPath_String = 1042, + Prop_Identifiable_Bool = 1043, + Prop_BootloaderVersion_Uint64 = 1044, + Prop_AdditionalSystemReportData_String = 1045, + Prop_CompositeFirmwareVersion_String = 1046, + Prop_Firmware_RemindUpdate_Bool = 1047, + Prop_PeripheralApplicationVersion_Uint64 = 1048, + Prop_ManufacturerSerialNumber_String = 1049, + Prop_ComputedSerialNumber_String = 1050, + Prop_EstimatedDeviceFirstUseTime_Int32 = 1051, Prop_ReportsTimeSinceVSync_Bool = 2000, Prop_SecondsFromVsyncToPhotons_Float = 2001, Prop_DisplayFrequency_Float = 2002, @@ -3011,6 +4650,68 @@ public enum ETrackedDeviceProperty Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, Prop_DisplaySuppressed_Bool = 2036, + Prop_DisplayAllowNightMode_Bool = 2037, + Prop_DisplayMCImageWidth_Int32 = 2038, + Prop_DisplayMCImageHeight_Int32 = 2039, + Prop_DisplayMCImageNumChannels_Int32 = 2040, + Prop_DisplayMCImageData_Binary = 2041, + Prop_SecondsFromPhotonsToVblank_Float = 2042, + Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, + Prop_DisplayDebugMode_Bool = 2044, + Prop_GraphicsAdapterLuid_Uint64 = 2045, + Prop_DriverProvidedChaperonePath_String = 2048, + Prop_ExpectedTrackingReferenceCount_Int32 = 2049, + Prop_ExpectedControllerCount_Int32 = 2050, + Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, + Prop_NamedIconPathControllerRightDeviceOff_String = 2052, + Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, + Prop_DoNotApplyPrediction_Bool = 2054, + Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + Prop_DistortionMeshResolution_Int32 = 2056, + Prop_DriverIsDrawingControllers_Bool = 2057, + Prop_DriverRequestsApplicationPause_Bool = 2058, + Prop_DriverRequestsReducedRendering_Bool = 2059, + 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_ConfigurationIncludesLighthouse20Features_Bool = 2069, + Prop_AdditionalRadioFeatures_Uint64 = 2070, + Prop_CameraWhiteBalance_Vector4_Array = 2071, + Prop_CameraDistortionFunction_Int32_Array = 2072, + Prop_CameraDistortionCoefficients_Float_Array = 2073, + Prop_ExpectedControllerType_String = 2074, + Prop_HmdTrackingStyle_Int32 = 2075, + Prop_DriverProvidedChaperoneVisibility_Bool = 2076, + Prop_HmdColumnCorrectionSettingPrefix_String = 2077, + Prop_CameraSupportsCompatibilityModes_Bool = 2078, + Prop_DisplayAvailableFrameRates_Float_Array = 2080, + Prop_DisplaySupportsMultipleFramerates_Bool = 2081, + Prop_DisplayColorMultLeft_Vector3 = 2082, + Prop_DisplayColorMultRight_Vector3 = 2083, + Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084, + Prop_DisplaySupportsAnalogGain_Bool = 2085, + Prop_DisplayMinAnalogGain_Float = 2086, + Prop_DisplayMaxAnalogGain_Float = 2087, + Prop_DashboardScale_Float = 2091, + Prop_IpdUIRangeMinMeters_Float = 2100, + Prop_IpdUIRangeMaxMeters_Float = 2101, + Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, + Prop_Audio_DefaultPlaybackDeviceId_String = 2300, + Prop_Audio_DefaultRecordingDeviceId_String = 2301, + Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302, Prop_AttachedDeviceId_String = 3000, Prop_SupportedButtons_Uint64 = 3001, Prop_Axis0Type_Int32 = 3002, @@ -3026,8 +4727,35 @@ public enum ETrackedDeviceProperty Prop_TrackingRangeMinimumMeters_Float = 4004, Prop_TrackingRangeMaximumMeters_Float = 4005, Prop_ModeLabel_String = 4006, + Prop_CanWirelessIdentify_Bool = 4007, + Prop_Nonce_Int32 = 4008, + Prop_IconPathName_String = 5000, + Prop_NamedIconPathDeviceOff_String = 5001, + Prop_NamedIconPathDeviceSearching_String = 5002, + Prop_NamedIconPathDeviceSearchingAlert_String = 5003, + Prop_NamedIconPathDeviceReady_String = 5004, + Prop_NamedIconPathDeviceReadyAlert_String = 5005, + Prop_NamedIconPathDeviceNotReady_String = 5006, + Prop_NamedIconPathDeviceStandby_String = 5007, + Prop_NamedIconPathDeviceAlertLow_String = 5008, + Prop_NamedIconPathDeviceStandbyAlert_String = 5009, + Prop_DisplayHiddenArea_Binary_Start = 5100, + Prop_DisplayHiddenArea_Binary_End = 5150, + Prop_ParentContainer = 5151, + Prop_OverrideContainer_Uint64 = 5152, + Prop_UserConfigPath_String = 6000, + Prop_InstallPath_String = 6001, + Prop_HasDisplayComponent_Bool = 6002, + Prop_HasControllerComponent_Bool = 6003, + Prop_HasCameraComponent_Bool = 6004, + Prop_HasDriverDirectModeComponent_Bool = 6005, + Prop_HasVirtualDisplayComponent_Bool = 6006, + Prop_HasSpatialAnchorsSupport_Bool = 6007, + Prop_ControllerType_String = 7000, + Prop_ControllerHandSelectionPriority_Int32 = 7002, Prop_VendorSpecific_Reserved_Start = 10000, Prop_VendorSpecific_Reserved_End = 10999, + Prop_TrackedDeviceProperty_Max = 1000000, } public enum ETrackedPropertyError { @@ -3041,12 +4769,30 @@ public enum ETrackedPropertyError TrackedProp_ValueNotProvidedByDevice = 7, TrackedProp_StringExceedsMaximumLength = 8, TrackedProp_NotYetAvailable = 9, + TrackedProp_PermissionDenied = 10, + TrackedProp_InvalidOperation = 11, + TrackedProp_CannotWriteToWildcards = 12, + TrackedProp_IPCReadFailure = 13, + TrackedProp_OutOfMemory = 14, + TrackedProp_InvalidContainer = 15, +} +public enum EHmdTrackingStyle +{ + Unknown = 0, + Lighthouse = 1, + OutsideInCameras = 2, + InsideOutCameras = 3, } public enum EVRSubmitFlags { Submit_Default = 0, Submit_LensDistortionAlreadyApplied = 1, Submit_GlRenderBuffer = 2, + Submit_Reserved = 4, + Submit_TextureWithPose = 8, + Submit_TextureWithDepth = 16, + Submit_FrameDiscontinuty = 32, + Submit_VulkanTextureWithArrayData = 64, } public enum EVRState { @@ -3073,94 +4819,153 @@ public enum EVREventType VREvent_LeaveStandbyMode = 107, VREvent_TrackedDeviceRoleChanged = 108, VREvent_WatchdogWakeUpRequested = 109, + VREvent_LensDistortionChanged = 110, + VREvent_PropertyChanged = 111, + VREvent_WirelessDisconnect = 112, + VREvent_WirelessReconnect = 113, VREvent_ButtonPress = 200, VREvent_ButtonUnpress = 201, VREvent_ButtonTouch = 202, VREvent_ButtonUntouch = 203, + VREvent_Modal_Cancel = 257, VREvent_MouseMove = 300, VREvent_MouseButtonDown = 301, VREvent_MouseButtonUp = 302, VREvent_FocusEnter = 303, VREvent_FocusLeave = 304, - VREvent_Scroll = 305, + VREvent_ScrollDiscrete = 305, VREvent_TouchPadMove = 306, VREvent_OverlayFocusChanged = 307, + VREvent_ReloadOverlays = 308, + VREvent_ScrollSmooth = 309, + VREvent_LockMousePosition = 310, + VREvent_UnlockMousePosition = 311, VREvent_InputFocusCaptured = 400, VREvent_InputFocusReleased = 401, - VREvent_SceneFocusLost = 402, - VREvent_SceneFocusGained = 403, VREvent_SceneApplicationChanged = 404, VREvent_SceneFocusChanged = 405, VREvent_InputFocusChanged = 406, - VREvent_SceneApplicationSecondaryRenderingStarted = 407, + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, + VREvent_ActionBindingReloaded = 409, VREvent_HideRenderModels = 410, VREvent_ShowRenderModels = 411, + VREvent_SceneApplicationStateChanged = 412, + VREvent_ConsoleOpened = 420, + VREvent_ConsoleClosed = 421, VREvent_OverlayShown = 500, VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, VREvent_DashboardDeactivated = 503, - VREvent_DashboardThumbSelected = 504, VREvent_DashboardRequested = 505, VREvent_ResetDashboard = 506, - VREvent_RenderToast = 507, VREvent_ImageLoaded = 508, VREvent_ShowKeyboard = 509, VREvent_HideKeyboard = 510, VREvent_OverlayGamepadFocusGained = 511, VREvent_OverlayGamepadFocusLost = 512, VREvent_OverlaySharedTextureChanged = 513, - VREvent_DashboardGuideButtonDown = 514, - VREvent_DashboardGuideButtonUp = 515, VREvent_ScreenshotTriggered = 516, VREvent_ImageFailed = 517, + VREvent_DashboardOverlayCreated = 518, + VREvent_SwitchGamepadFocus = 519, VREvent_RequestScreenshot = 520, VREvent_ScreenshotTaken = 521, VREvent_ScreenshotFailed = 522, VREvent_SubmitScreenshotToDashboard = 523, VREvent_ScreenshotProgressToDashboard = 524, + VREvent_PrimaryDashboardDeviceChanged = 525, + VREvent_RoomViewShown = 526, + VREvent_RoomViewHidden = 527, + VREvent_ShowUI = 528, + VREvent_ShowDevTools = 529, VREvent_Notification_Shown = 600, VREvent_Notification_Hidden = 601, VREvent_Notification_BeginInteraction = 602, VREvent_Notification_Destroyed = 603, VREvent_Quit = 700, VREvent_ProcessQuit = 701, - VREvent_QuitAborted_UserPrompt = 702, VREvent_QuitAcknowledged = 703, VREvent_DriverRequestedQuit = 704, + VREvent_RestartRequested = 705, VREvent_ChaperoneDataHasChanged = 800, VREvent_ChaperoneUniverseHasChanged = 801, VREvent_ChaperoneTempDataHasChanged = 802, VREvent_ChaperoneSettingsHaveChanged = 803, VREvent_SeatedZeroPoseReset = 804, + VREvent_ChaperoneFlushCache = 805, + VREvent_ChaperoneRoomSetupStarting = 806, + VREvent_ChaperoneRoomSetupFinished = 807, VREvent_AudioSettingsHaveChanged = 820, VREvent_BackgroundSettingHasChanged = 850, VREvent_CameraSettingsHaveChanged = 851, VREvent_ReprojectionSettingHasChanged = 852, VREvent_ModelSkinSettingsHaveChanged = 853, VREvent_EnvironmentSettingsHaveChanged = 854, + VREvent_PowerSettingsHaveChanged = 855, + VREvent_EnableHomeAppSettingsHaveChanged = 856, + VREvent_SteamVRSectionSettingChanged = 857, + VREvent_LighthouseSectionSettingChanged = 858, + VREvent_NullSectionSettingChanged = 859, + VREvent_UserInterfaceSectionSettingChanged = 860, + VREvent_NotificationsSectionSettingChanged = 861, + VREvent_KeyboardSectionSettingChanged = 862, + VREvent_PerfSectionSettingChanged = 863, + VREvent_DashboardSectionSettingChanged = 864, + VREvent_WebInterfaceSectionSettingChanged = 865, + VREvent_TrackersSectionSettingChanged = 866, + VREvent_LastKnownSectionSettingChanged = 867, + VREvent_DismissedWarningsSectionSettingChanged = 868, + VREvent_GpuSpeedSectionSettingChanged = 869, + VREvent_WindowsMRSectionSettingChanged = 870, + VREvent_OtherSectionSettingChanged = 871, VREvent_StatusUpdate = 900, + VREvent_WebInterface_InstallDriverCompleted = 950, VREvent_MCImageUpdated = 1000, VREvent_FirmwareUpdateStarted = 1100, VREvent_FirmwareUpdateFinished = 1101, VREvent_KeyboardClosed = 1200, VREvent_KeyboardCharInput = 1201, VREvent_KeyboardDone = 1202, - VREvent_ApplicationTransitionStarted = 1300, - VREvent_ApplicationTransitionAborted = 1301, - VREvent_ApplicationTransitionNewAppStarted = 1302, VREvent_ApplicationListUpdated = 1303, VREvent_ApplicationMimeTypeLoad = 1304, - VREvent_Compositor_MirrorWindowShown = 1400, - VREvent_Compositor_MirrorWindowHidden = 1401, + VREvent_ProcessConnected = 1306, + VREvent_ProcessDisconnected = 1307, VREvent_Compositor_ChaperoneBoundsShown = 1410, VREvent_Compositor_ChaperoneBoundsHidden = 1411, + VREvent_Compositor_DisplayDisconnected = 1412, + VREvent_Compositor_DisplayReconnected = 1413, + VREvent_Compositor_HDCPError = 1414, + VREvent_Compositor_ApplicationNotResponding = 1415, + VREvent_Compositor_ApplicationResumed = 1416, + VREvent_Compositor_OutOfVideoMemory = 1417, + VREvent_Compositor_DisplayModeNotSupported = 1418, + VREvent_Compositor_StageOverrideReady = 1419, VREvent_TrackedCamera_StartVideoStream = 1500, VREvent_TrackedCamera_StopVideoStream = 1501, VREvent_TrackedCamera_PauseVideoStream = 1502, VREvent_TrackedCamera_ResumeVideoStream = 1503, + VREvent_TrackedCamera_EditingSurface = 1550, VREvent_PerformanceTest_EnableCapture = 1600, VREvent_PerformanceTest_DisableCapture = 1601, VREvent_PerformanceTest_FidelityLevel = 1602, + VREvent_MessageOverlay_Closed = 1650, + VREvent_MessageOverlayCloseRequested = 1651, + VREvent_Input_HapticVibration = 1700, + VREvent_Input_BindingLoadFailed = 1701, + VREvent_Input_BindingLoadSuccessful = 1702, + VREvent_Input_ActionManifestReloaded = 1703, + VREvent_Input_ActionManifestLoadFailed = 1704, + VREvent_Input_ProgressUpdate = 1705, + VREvent_Input_TrackerActivated = 1706, + VREvent_Input_BindingsUpdated = 1707, + VREvent_Input_BindingSubscriptionChanged = 1708, + VREvent_SpatialAnchors_PoseUpdated = 1800, + VREvent_SpatialAnchors_DescriptorUpdated = 1801, + VREvent_SpatialAnchors_RequestPoseUpdate = 1802, + VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, + VREvent_SystemReport_Started = 1900, + VREvent_Monitor_ShowHeadsetView = 2000, + VREvent_Monitor_HideHeadsetView = 2001, VREvent_VendorSpecific_Reserved_Start = 10000, VREvent_VendorSpecific_Reserved_End = 19999, } @@ -3171,6 +4976,7 @@ public enum EDeviceActivityLevel k_EDeviceActivityLevel_UserInteraction = 1, k_EDeviceActivityLevel_UserInteraction_Timeout = 2, k_EDeviceActivityLevel_Standby = 3, + k_EDeviceActivityLevel_Idle_Timeout = 4, } public enum EVRButtonId { @@ -3182,6 +4988,7 @@ public enum EVRButtonId k_EButton_DPad_Right = 5, k_EButton_DPad_Down = 6, k_EButton_A = 7, + k_EButton_ProximitySensor = 31, k_EButton_Axis0 = 32, k_EButton_Axis1 = 33, k_EButton_Axis2 = 34, @@ -3190,6 +4997,9 @@ public enum EVRButtonId k_EButton_SteamVR_Touchpad = 32, k_EButton_SteamVR_Trigger = 33, k_EButton_Dashboard_Back = 2, + k_EButton_IndexController_A = 2, + k_EButton_IndexController_B = 1, + k_EButton_IndexController_JoyStick = 35, k_EButton_Max = 64, } public enum EVRMouseButton @@ -3198,6 +5008,81 @@ public enum EVRMouseButton Right = 2, Middle = 4, } +public enum EShowUIType +{ + ShowUI_ControllerBinding = 0, + ShowUI_ManageTrackers = 1, + ShowUI_Pairing = 3, + ShowUI_Settings = 4, + ShowUI_DebugCommands = 5, + ShowUI_FullControllerBinding = 6, + ShowUI_ManageDrivers = 7, +} +public enum EHDCPError +{ + None = 0, + LinkLost = 1, + Tampered = 2, + DeviceRevoked = 3, + Unknown = 4, +} +public enum EVRComponentProperty +{ + IsStatic = 1, + IsVisible = 2, + IsTouched = 4, + IsPressed = 8, + IsScrolled = 16, + IsHighlighted = 32, +} +public enum EVRInputError +{ + None = 0, + NameNotFound = 1, + WrongType = 2, + InvalidHandle = 3, + InvalidParam = 4, + NoSteam = 5, + MaxCapacityReached = 6, + IPCError = 7, + NoActiveActionSet = 8, + InvalidDevice = 9, + InvalidSkeleton = 10, + InvalidBoneCount = 11, + InvalidCompressedData = 12, + NoData = 13, + BufferTooSmall = 14, + MismatchedActionManifest = 15, + MissingSkeletonData = 16, + InvalidBoneIndex = 17, + InvalidPriority = 18, + PermissionDenied = 19, + InvalidRenderModel = 20, +} +public enum EVRSpatialAnchorError +{ + Success = 0, + Internal = 1, + UnknownHandle = 2, + ArrayTooSmall = 3, + InvalidDescriptorChar = 4, + NotYetAvailable = 5, + NotAvailableInThisUniverse = 6, + PermanentlyUnavailable = 7, + WrongDriver = 8, + DescriptorTooLong = 9, + Unknown = 10, + NoRoomCalibration = 11, + InvalidArgument = 12, + UnknownDriver = 13, +} +public enum EHiddenAreaMeshType +{ + k_eHiddenAreaMesh_Standard = 0, + k_eHiddenAreaMesh_Inverse = 1, + k_eHiddenAreaMesh_LineLoop = 2, + k_eHiddenAreaMesh_Max = 3, +} public enum EVRControllerAxisType { k_eControllerAxis_None = 0, @@ -3238,8 +5123,13 @@ public enum EVROverlayError RequestFailed = 23, InvalidTexture = 24, UnableToLoadFile = 25, - VROVerlayError_KeyboardAlreadyInUse = 26, + KeyboardAlreadyInUse = 26, NoNeighbor = 27, + TooManyMaskPrimitives = 29, + BadMaskPrimitive = 30, + TextureAlreadyLocked = 31, + TextureLockCapacityReached = 32, + TextureNotLocked = 33, } public enum EVRApplicationType { @@ -3250,7 +5140,9 @@ public enum EVRApplicationType VRApplication_Utility = 4, VRApplication_VRMonitor = 5, VRApplication_SteamWatchdog = 6, - VRApplication_Max = 7, + VRApplication_Bootstrapper = 7, + VRApplication_WebHelper = 8, + VRApplication_Max = 9, } public enum EVRFirmwareError { @@ -3266,6 +5158,19 @@ public enum EVRNotificationError InvalidOverlayHandle = 102, SystemWithUserValueAlreadyExists = 103, } +public enum EVRSkeletalMotionRange +{ + WithController = 0, + WithoutController = 1, +} +public enum EVRSkeletalTrackingLevel +{ + VRSkeletalTracking_Estimated = 0, + VRSkeletalTracking_Partial = 1, + VRSkeletalTracking_Full = 2, + Count = 3, + Max = 2, +} public enum EVRInitError { None = 0, @@ -3303,6 +5208,20 @@ public enum EVRInitError Init_InvalidApplicationType = 130, Init_NotAvailableToWatchdogApps = 131, Init_WatchdogDisabledInSettings = 132, + Init_VRDashboardNotFound = 133, + Init_VRDashboardStartupFailed = 134, + Init_VRHomeNotFound = 135, + Init_VRHomeStartupFailed = 136, + Init_RebootingBusy = 137, + Init_FirmwareUpdateBusy = 138, + Init_FirmwareRecoveryBusy = 139, + Init_USBServiceBusy = 140, + Init_VRWebHelperStartupFailed = 141, + Init_TrackerManagerInitFailed = 142, + Init_AlreadyRunning = 143, + Init_FailedForVrMonitor = 144, + Init_PropertyManagerInitFailed = 145, + Init_WebServerFailed = 146, Driver_Failed = 200, Driver_Unknown = 201, Driver_HmdUnknown = 202, @@ -3315,6 +5234,7 @@ public enum EVRInitError Driver_TrackedDeviceInterfaceUnknown = 209, Driver_HmdDriverIdOutOfBounds = 211, Driver_HmdDisplayMirrored = 212, + Driver_HmdDisplayNotFoundLaptop = 213, IPC_ServerInitFailed = 300, IPC_ConnectFailed = 301, IPC_SharedStateInitFailed = 302, @@ -3324,12 +5244,101 @@ public enum EVRInitError IPC_CompositorConnectFailed = 306, IPC_CompositorInvalidConnectResponse = 307, IPC_ConnectFailedAfterMultipleAttempts = 308, + IPC_ConnectFailedAfterTargetExited = 309, + IPC_NamespaceUnavailable = 310, Compositor_Failed = 400, Compositor_D3D11HardwareRequired = 401, Compositor_FirmwareRequiresUpdate = 402, Compositor_OverlayInitFailed = 403, Compositor_ScreenshotsInitFailed = 404, + Compositor_UnableToCreateDevice = 405, + Compositor_SharedStateIsNull = 406, + Compositor_NotificationManagerIsNull = 407, + Compositor_ResourceManagerClientIsNull = 408, + Compositor_MessageOverlaySharedStateInitFailure = 409, + Compositor_PropertiesInterfaceIsNull = 410, + Compositor_CreateFullscreenWindowFailed = 411, + Compositor_SettingsInterfaceIsNull = 412, + Compositor_FailedToShowWindow = 413, + Compositor_DistortInterfaceIsNull = 414, + Compositor_DisplayFrequencyFailure = 415, + Compositor_RendererInitializationFailed = 416, + Compositor_DXGIFactoryInterfaceIsNull = 417, + Compositor_DXGIFactoryCreateFailed = 418, + Compositor_DXGIFactoryQueryFailed = 419, + Compositor_InvalidAdapterDesktop = 420, + Compositor_InvalidHmdAttachment = 421, + Compositor_InvalidOutputDesktop = 422, + Compositor_InvalidDeviceProvided = 423, + Compositor_D3D11RendererInitializationFailed = 424, + Compositor_FailedToFindDisplayMode = 425, + Compositor_FailedToCreateSwapChain = 426, + Compositor_FailedToGetBackBuffer = 427, + Compositor_FailedToCreateRenderTarget = 428, + Compositor_FailedToCreateDXGI2SwapChain = 429, + Compositor_FailedtoGetDXGI2BackBuffer = 430, + Compositor_FailedToCreateDXGI2RenderTarget = 431, + Compositor_FailedToGetDXGIDeviceInterface = 432, + Compositor_SelectDisplayMode = 433, + Compositor_FailedToCreateNvAPIRenderTargets = 434, + Compositor_NvAPISetDisplayMode = 435, + Compositor_FailedToCreateDirectModeDisplay = 436, + Compositor_InvalidHmdPropertyContainer = 437, + Compositor_UpdateDisplayFrequency = 438, + Compositor_CreateRasterizerState = 439, + Compositor_CreateWireframeRasterizerState = 440, + Compositor_CreateSamplerState = 441, + Compositor_CreateClampToBorderSamplerState = 442, + Compositor_CreateAnisoSamplerState = 443, + Compositor_CreateOverlaySamplerState = 444, + Compositor_CreatePanoramaSamplerState = 445, + Compositor_CreateFontSamplerState = 446, + Compositor_CreateNoBlendState = 447, + Compositor_CreateBlendState = 448, + Compositor_CreateAlphaBlendState = 449, + Compositor_CreateBlendStateMaskR = 450, + Compositor_CreateBlendStateMaskG = 451, + Compositor_CreateBlendStateMaskB = 452, + Compositor_CreateDepthStencilState = 453, + Compositor_CreateDepthStencilStateNoWrite = 454, + Compositor_CreateDepthStencilStateNoDepth = 455, + Compositor_CreateFlushTexture = 456, + Compositor_CreateDistortionSurfaces = 457, + Compositor_CreateConstantBuffer = 458, + Compositor_CreateHmdPoseConstantBuffer = 459, + Compositor_CreateHmdPoseStagingConstantBuffer = 460, + Compositor_CreateSharedFrameInfoConstantBuffer = 461, + Compositor_CreateOverlayConstantBuffer = 462, + Compositor_CreateSceneTextureIndexConstantBuffer = 463, + Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464, + Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465, + Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466, + Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467, + Compositor_CreateComputeHmdPoseConstantBuffer = 468, + Compositor_CreateGeomConstantBuffer = 469, + Compositor_CreatePanelMaskConstantBuffer = 470, + Compositor_CreatePixelSimUBO = 471, + Compositor_CreateMSAARenderTextures = 472, + Compositor_CreateResolveRenderTextures = 473, + Compositor_CreateComputeResolveRenderTextures = 474, + Compositor_CreateDriverDirectModeResolveTextures = 475, + Compositor_OpenDriverDirectModeResolveTextures = 476, + Compositor_CreateFallbackSyncTexture = 477, + Compositor_ShareFallbackSyncTexture = 478, + Compositor_CreateOverlayIndexBuffer = 479, + Compositor_CreateOverlayVertexBuffer = 480, + Compositor_CreateTextVertexBuffer = 481, + Compositor_CreateTextIndexBuffer = 482, + Compositor_CreateMirrorTextures = 483, + Compositor_CreateLastFrameRenderTexture = 484, + Compositor_CreateMirrorOverlay = 485, + Compositor_FailedToCreateVirtualDisplayBackbuffer = 486, + Compositor_DisplayModeNotSupported = 487, + Compositor_CreateOverlayInvalidCall = 488, + Compositor_CreateOverlayAlreadyInitialized = 489, + Compositor_FailedToCreateMailbox = 490, VendorSpecific_UnableToConnectToOculusRuntime = 1000, + VendorSpecific_WindowsNotInDevMode = 1001, VendorSpecific_HmdFound_CantOpenDevice = 1101, VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, VendorSpecific_HmdFound_NoStoredConfig = 1103, @@ -3343,7 +5352,9 @@ public enum EVRInitError VendorSpecific_HmdFound_UserDataAddressRange = 1111, VendorSpecific_HmdFound_UserDataError = 1112, VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, + VendorSpecific_OculusRuntimeBadInstall = 1114, Steam_SteamInstallationNotFound = 2000, + LastError = 2001, } public enum EVRScreenshotType { @@ -3379,6 +5390,13 @@ public enum EVRTrackedCameraError InvalidArgument = 114, InvalidFrameBufferSize = 115, } +public enum EVRTrackedCameraFrameLayout +{ + Mono = 1, + Stereo = 2, + VerticalLayout = 16, + HorizontalLayout = 32, +} public enum EVRTrackedCameraFrameType { Distorted = 0, @@ -3386,6 +5404,33 @@ public enum EVRTrackedCameraFrameType MaximumUndistorted = 2, MAX_CAMERA_FRAME_TYPES = 3, } +public enum EVRDistortionFunctionType +{ + None = 0, + FTheta = 1, + Extended_FTheta = 2, + MAX_DISTORTION_FUNCTION_TYPES = 3, +} +public enum EVSync +{ + None = 0, + WaitRender = 1, + NoWaitRender = 2, +} +public enum EVRMuraCorrectionMode +{ + Default = 0, + NoCorrection = 1, +} +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, @@ -3404,6 +5449,7 @@ public enum EVRApplicationError OldApplicationQuitting = 112, TransitionAborted = 113, IsTemplate = 114, + SteamVRIsExiting = 115, BufferTooSmall = 200, PropertyNotSet = 201, UnknownProperty = 202, @@ -3421,17 +5467,22 @@ public enum EVRApplicationProperty NewsURL_String = 51, ImagePath_String = 52, Source_String = 53, + ActionManifestURL_String = 54, IsDashboardOverlay_Bool = 60, IsTemplate_Bool = 61, IsInstanced_Bool = 62, + IsInternal_Bool = 63, + WantsCompositorPauseInStandby_Bool = 64, + IsHidden_Bool = 65, LastLaunchTime_Uint64 = 70, } -public enum EVRApplicationTransitionState +public enum EVRSceneApplicationState { - VRApplicationTransition_None = 0, - VRApplicationTransition_OldAppQuitSent = 10, - VRApplicationTransition_WaitingForExternalLaunch = 11, - VRApplicationTransition_NewAppLaunched = 20, + None = 0, + Starting = 1, + Quitting = 2, + Running = 3, + Waiting = 4, } public enum ChaperoneCalibrationState { @@ -3441,7 +5492,7 @@ public enum ChaperoneCalibrationState Warning_BaseStationRemoved = 102, Warning_SeatedBoundsInvalid = 103, Error = 200, - Error_BaseStationUninitalized = 201, + Error_BaseStationUninitialized = 201, Error_BaseStationConflict = 202, Error_PlayAreaInvalid = 203, Error_CollisionBoundsInvalid = 204, @@ -3467,6 +5518,15 @@ public enum EVRCompositorError TextureUsesUnsupportedFormat = 105, SharedTexturesNotSupported = 106, IndexOutOfRange = 107, + AlreadySubmitted = 108, + InvalidBounds = 109, + AlreadySet = 110, +} +public enum EVRCompositorTimingMode +{ + Implicit = 0, + Explicit_RuntimePerformsPostPresentHandoff = 1, + Explicit_ApplicationPerformsPostPresentHandoff = 2, } public enum VROverlayInputMethod { @@ -3475,28 +5535,45 @@ public enum VROverlayInputMethod } public enum VROverlayTransformType { + VROverlayTransform_Invalid = -1, VROverlayTransform_Absolute = 0, VROverlayTransform_TrackedDeviceRelative = 1, VROverlayTransform_SystemOverlay = 2, VROverlayTransform_TrackedComponent = 3, + VROverlayTransform_Cursor = 4, + VROverlayTransform_DashboardTab = 5, + VROverlayTransform_DashboardThumb = 6, + VROverlayTransform_Mountable = 7, } public enum VROverlayFlags { - None = 0, - Curved = 1, - RGSS4X = 2, - NoDashboardTab = 3, - AcceptsGamepadEvents = 4, - ShowGamepadFocus = 5, - SendVRScrollEvents = 6, - SendVRTouchpadEvents = 7, - ShowTouchPadScrollWheel = 8, - TransferOwnershipToInternalProcess = 9, - SideBySide_Parallel = 10, - SideBySide_Crossed = 11, - Panorama = 12, - StereoPanorama = 13, - SortWithNonSceneOverlays = 14, + NoDashboardTab = 8, + SendVRDiscreteScrollEvents = 64, + SendVRTouchpadEvents = 128, + ShowTouchPadScrollWheel = 256, + TransferOwnershipToInternalProcess = 512, + SideBySide_Parallel = 1024, + SideBySide_Crossed = 2048, + Panorama = 4096, + StereoPanorama = 8192, + SortWithNonSceneOverlays = 16384, + VisibleInDashboard = 32768, + MakeOverlaysInteractiveIfVisible = 65536, + SendVRSmoothScrollEvents = 131072, + ProtectedContent = 262144, + HideLaserIntersection = 524288, + WantsModalBehavior = 1048576, + IsPremultiplied = 2097152, +} +public enum VRMessageOverlayResponse +{ + ButtonPress_0 = 0, + ButtonPress_1 = 1, + ButtonPress_2 = 2, + ButtonPress_3 = 3, + CouldntFindSystemOverlay = 4, + CouldntFindOrCreateClientOverlay = 5, + ApplicationQuit = 6, } public enum EGamepadTextInputMode { @@ -3509,13 +5586,27 @@ public enum EGamepadTextInputLineMode k_EGamepadTextInputLineModeSingleLine = 0, k_EGamepadTextInputLineModeMultipleLines = 1, } -public enum EOverlayDirection +public enum EVROverlayIntersectionMaskPrimitiveType { - Up = 0, - Down = 1, - Left = 2, - Right = 3, - Count = 4, + OverlayIntersectionPrimitiveType_Rectangle = 0, + OverlayIntersectionPrimitiveType_Circle = 1, +} +public enum EKeyboardFlags +{ + KeyboardFlag_Minimal = 1, + KeyboardFlag_Modal = 2, +} +public enum EDeviceType +{ + Invalid = -1, + DirectX11 = 0, + Vulkan = 1, +} +public enum HeadsetViewMode_t +{ + HeadsetViewMode_Left = 0, + HeadsetViewMode_Right = 1, + HeadsetViewMode_Both = 2, } public enum EVRRenderModelError { @@ -3533,13 +5624,13 @@ public enum EVRRenderModelError NotEnoughTexCoords = 308, InvalidTexture = 400, } -public enum EVRComponentProperty +public enum EVRRenderModelTextureFormat { - IsStatic = 1, - IsVisible = 2, - IsTouched = 4, - IsPressed = 8, - IsScrolled = 16, + RGBA8_SRGB = 0, + BC2 = 1, + BC4 = 2, + BC7 = 3, + BC7_SRGB = 4, } public enum EVRNotificationType { @@ -3561,6 +5652,8 @@ public enum EVRSettingsError IPCFailed = 1, WriteFailed = 2, ReadFailed = 3, + JsonParseFailed = 4, + UnsetSettingHasNoDefault = 5, } public enum EVRScreenshotError { @@ -3571,6 +5664,99 @@ public enum EVRScreenshotError BufferTooSmall = 102, ScreenshotAlreadyInProgress = 108, } +public enum EVRSkeletalTransformSpace +{ + Model = 0, + Parent = 1, +} +public enum EVRSkeletalReferencePose +{ + BindPose = 0, + OpenHand = 1, + Fist = 2, + GripLimit = 3, +} +public enum EVRFinger +{ + Thumb = 0, + Index = 1, + Middle = 2, + Ring = 3, + Pinky = 4, + Count = 5, +} +public enum EVRFingerSplay +{ + Thumb_Index = 0, + Index_Middle = 1, + Middle_Ring = 2, + Ring_Pinky = 3, + Count = 4, +} +public enum EVRSummaryType +{ + FromAnimation = 0, + FromDevice = 1, +} +public enum EVRInputFilterCancelType +{ + VRInputFilterCancel_Timers = 0, + VRInputFilterCancel_Momentum = 1, +} +public enum EVRInputStringBits +{ + VRInputString_Hand = 1, + VRInputString_ControllerType = 2, + VRInputString_InputSource = 4, + VRInputString_All = -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, +} +public enum EVRDebugError +{ + Success = 0, + BadParameter = 1, +} +public enum EPropertyWriteType +{ + PropertyWrite_Set = 0, + PropertyWrite_Erase = 1, + PropertyWrite_SetError = 2, +} +public enum EBlockQueueError +{ + None = 0, + QueueAlreadyExists = 1, + QueueNotFound = 2, + BlockNotAvailable = 3, + InvalidHandle = 4, + InvalidParam = 5, + ParamMismatch = 6, + InternalError = 7, + AlreadyInitialized = 8, + OperationIsServerOnly = 9, + TooManyConnections = 10, +} +public enum EBlockQueueReadType +{ + BlockQueueRead_Latest = 0, + BlockQueueRead_New = 1, + BlockQueueRead_Next = 2, +} [StructLayout(LayoutKind.Explicit)] public struct VREvent_Data_t { @@ -3588,9 +5774,30 @@ public enum EVRScreenshotError [FieldOffset(0)] public VREvent_TouchPadMove_t touchPadMove; [FieldOffset(0)] public VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; [FieldOffset(0)] public VREvent_Screenshot_t screenshot; + [FieldOffset(0)] public VREvent_ScreenshotProgress_t screenshotProgress; + [FieldOffset(0)] public VREvent_ApplicationLaunch_t applicationLaunch; + [FieldOffset(0)] public VREvent_EditingCameraSurface_t cameraSurface; + [FieldOffset(0)] public VREvent_MessageOverlay_t messageOverlay; + [FieldOffset(0)] public VREvent_Property_t property; + [FieldOffset(0)] public VREvent_HapticVibration_t hapticVibration; + [FieldOffset(0)] public VREvent_WebConsole_t webConsole; + [FieldOffset(0)] public VREvent_InputBindingLoad_t inputBinding; + [FieldOffset(0)] public VREvent_SpatialAnchor_t spatialAnchor; + [FieldOffset(0)] public VREvent_InputActionManifestLoad_t actionManifest; + [FieldOffset(0)] public VREvent_ProgressUpdate_t progressUpdate; + [FieldOffset(0)] public VREvent_ShowUI_t showUi; + [FieldOffset(0)] public VREvent_ShowDevTools_t showDevTools; + [FieldOffset(0)] public VREvent_HDCPError_t hdcpError; [FieldOffset(0)] public VREvent_Keyboard_t keyboard; // This has to be at the end due to a mono bug } + +[StructLayout(LayoutKind.Explicit)] public struct VROverlayIntersectionMaskPrimitive_Data_t +{ + [FieldOffset(0)] public IntersectionMaskRectangle_t m_Rectangle; + [FieldOffset(0)] public IntersectionMaskCircle_t m_Circle; +} + [StructLayout(LayoutKind.Sequential)] public struct HmdMatrix34_t { public float m0; //float[3][4] @@ -3605,6 +5812,54 @@ public enum EVRScreenshotError public float m9; public float m10; public float m11; +#if UNITY_5_3_OR_NEWER + + public Vector3 GetPosition() + { + return new Vector3(m3, m7, -m11); + } + + public bool IsRotationValid() + { + return ((m2 != 0 || m6 != 0 || m10 != 0) && (m1 != 0 || m5 != 0 || m9 != 0)); + } + + public Quaternion GetRotation() + { + if (IsRotationValid()) + { + float w = Mathf.Sqrt(Mathf.Max(0, 1 + m0 + m5 + m10)) / 2; + float x = Mathf.Sqrt(Mathf.Max(0, 1 + m0 - m5 - m10)) / 2; + float y = Mathf.Sqrt(Mathf.Max(0, 1 - m0 + m5 - m10)) / 2; + float z = Mathf.Sqrt(Mathf.Max(0, 1 - m0 - m5 + m10)) / 2; + + _copysign(ref x, -m9 - -m6); + _copysign(ref y, -m2 - -m8); + _copysign(ref z, m4 - m1); + + return new Quaternion(x, y, z, w); + } + return Quaternion.identity; + } + + private static void _copysign(ref float sizeval, float signval) + { + if (signval > 0 != sizeval > 0) + sizeval = -sizeval; + } +#endif +} +[StructLayout(LayoutKind.Sequential)] public struct HmdMatrix33_t +{ + public float m0; //float[3][3] + public float m1; + public float m2; + public float m3; + public float m4; + public float m5; + public float m6; + public float m7; + public float m8; } [StructLayout(LayoutKind.Sequential)] public struct HmdMatrix44_t { @@ -3656,6 +5911,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; @@ -3687,7 +5949,7 @@ public enum EVRScreenshotError [StructLayout(LayoutKind.Sequential)] public struct Texture_t { public IntPtr handle; // void * - public EGraphicsAPIConvention eType; + public ETextureType eType; public EColorSpace eColorSpace; } [StructLayout(LayoutKind.Sequential)] public struct TrackedDevicePose_t @@ -3708,6 +5970,48 @@ public enum EVRScreenshotError public float uMax; public float vMax; } +[StructLayout(LayoutKind.Sequential)] public struct VRTextureWithPose_t +{ + public HmdMatrix34_t mDeviceToAbsoluteTracking; +} +[StructLayout(LayoutKind.Sequential)] public struct VRTextureDepthInfo_t +{ + public IntPtr handle; // void * + public HmdMatrix44_t mProjection; + public HmdVector2_t vRange; +} +[StructLayout(LayoutKind.Sequential)] public struct VRTextureWithDepth_t +{ + public VRTextureDepthInfo_t depth; +} +[StructLayout(LayoutKind.Sequential)] public struct VRTextureWithPoseAndDepth_t +{ + public VRTextureDepthInfo_t depth; +} +[StructLayout(LayoutKind.Sequential)] public struct VRVulkanTextureData_t +{ + public ulong m_nImage; + public IntPtr m_pDevice; // struct VkDevice_T * + public IntPtr m_pPhysicalDevice; // struct VkPhysicalDevice_T * + public IntPtr m_pInstance; // struct VkInstance_T * + public IntPtr m_pQueue; // struct VkQueue_T * + public uint m_nQueueFamilyIndex; + public uint m_nWidth; + public uint m_nHeight; + public uint m_nFormat; + public uint m_nSampleCount; +} +[StructLayout(LayoutKind.Sequential)] public struct VRVulkanTextureArrayData_t +{ + public uint m_unArrayIndex; + public uint m_unArraySize; +} +[StructLayout(LayoutKind.Sequential)] public struct D3D12TextureData_t +{ + public IntPtr m_pResource; // struct ID3D12Resource * + public IntPtr m_pCommandQueue; // struct ID3D12CommandQueue * + public uint m_nNodeMask; +} [StructLayout(LayoutKind.Sequential)] public struct VREvent_Controller_t { public uint button; @@ -3722,7 +6026,8 @@ public enum EVRScreenshotError { public float xdelta; public float ydelta; - public uint repeatCount; + public uint unused; + public float viewportscale; } [StructLayout(LayoutKind.Sequential)] public struct VREvent_TouchPadMove_t { @@ -3745,10 +6050,13 @@ public enum EVRScreenshotError public uint oldPid; [MarshalAs(UnmanagedType.I1)] public bool bForced; + [MarshalAs(UnmanagedType.I1)] + public bool bConnectionLost; } [StructLayout(LayoutKind.Sequential)] public struct VREvent_Overlay_t { public ulong overlayHandle; + public ulong devicePath; } [StructLayout(LayoutKind.Sequential)] public struct VREvent_Status_t { @@ -3757,6 +6065,22 @@ public enum EVRScreenshotError [StructLayout(LayoutKind.Sequential)] public struct VREvent_Keyboard_t { public byte cNewInput0,cNewInput1,cNewInput2,cNewInput3,cNewInput4,cNewInput5,cNewInput6,cNewInput7; + public string cNewInput + { + get + { + return new string(new char[] { + (char)cNewInput0, + (char)cNewInput1, + (char)cNewInput2, + (char)cNewInput3, + (char)cNewInput4, + (char)cNewInput5, + (char)cNewInput6, + (char)cNewInput7 + }).TrimEnd('\0'); + } + } public ulong uUserValue; } [StructLayout(LayoutKind.Sequential)] public struct VREvent_Ipd_t @@ -3772,6 +6096,10 @@ public enum EVRScreenshotError { public ulong reserved0; public ulong reserved1; + public ulong reserved2; + public ulong reserved3; + public ulong reserved4; + public ulong reserved5; } [StructLayout(LayoutKind.Sequential)] public struct VREvent_PerformanceTest_t { @@ -3796,6 +6124,71 @@ public enum EVRScreenshotError public uint pid; public uint unArgsHandle; } +[StructLayout(LayoutKind.Sequential)] public struct VREvent_EditingCameraSurface_t +{ + public ulong overlayHandle; + public uint nVisualMode; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_MessageOverlay_t +{ + public uint unVRMessageOverlayResponse; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_Property_t +{ + public ulong container; + public ETrackedDeviceProperty prop; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_HapticVibration_t +{ + public ulong containerHandle; + public ulong componentHandle; + public float fDurationSeconds; + public float fFrequency; + public float fAmplitude; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_WebConsole_t +{ + public ulong webConsoleHandle; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_InputBindingLoad_t +{ + public ulong ulAppContainer; + public ulong pathMessage; + public ulong pathUrl; + public ulong pathControllerType; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_InputActionManifestLoad_t +{ + public ulong pathAppKey; + public ulong pathMessage; + public ulong pathMessageParam; + public ulong pathManifestPath; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_SpatialAnchor_t +{ + public uint unHandle; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_ProgressUpdate_t +{ + public ulong ulApplicationPropertyContainer; + public ulong pathDevice; + public ulong pathInputSource; + public ulong pathProgressAction; + public ulong pathIcon; + public float fProgress; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_ShowUI_t +{ + public EShowUIType eType; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_ShowDevTools_t +{ + public int nBrowserIdentifier; +} +[StructLayout(LayoutKind.Sequential)] public struct VREvent_HDCPError_t +{ + public EHDCPError eCode; +} [StructLayout(LayoutKind.Sequential)] public struct VREvent_t { public uint eventType; @@ -3803,6 +6196,34 @@ public enum EVRScreenshotError public float eventAgeSeconds; public VREvent_Data_t data; } +// This structure is for backwards binary compatibility on Linux and OSX only +[StructLayout(LayoutKind.Sequential, Pack = 4)] public struct VREvent_t_Packed +{ + public uint eventType; + public uint trackedDeviceIndex; + public float eventAgeSeconds; + public VREvent_Data_t data; + public VREvent_t_Packed(VREvent_t unpacked) + { + this.eventType = unpacked.eventType; + this.trackedDeviceIndex = unpacked.trackedDeviceIndex; + this.eventAgeSeconds = unpacked.eventAgeSeconds; + this.data = unpacked.data; + } + public void Unpack(ref VREvent_t unpacked) + { + unpacked.eventType = this.eventType; + unpacked.trackedDeviceIndex = this.trackedDeviceIndex; + unpacked.eventAgeSeconds = this.eventAgeSeconds; + unpacked.data = this.data; + } +} +[StructLayout(LayoutKind.Sequential)] public struct RenderModel_ComponentState_t +{ + public HmdMatrix34_t mTrackingToComponentRenderModel; + public HmdMatrix34_t mTrackingToComponentLocal; + public uint uProperties; +} [StructLayout(LayoutKind.Sequential)] public struct HiddenAreaMesh_t { public IntPtr pVertexData; // const struct vr::HmdVector2_t * @@ -3824,24 +6245,44 @@ public enum EVRScreenshotError public VRControllerAxis_t rAxis3; public VRControllerAxis_t rAxis4; } -[StructLayout(LayoutKind.Sequential)] public struct Compositor_OverlaySettings +// This structure is for backwards binary compatibility on Linux and OSX only +[StructLayout(LayoutKind.Sequential, Pack = 4)] public struct VRControllerState_t_Packed { - public uint size; - [MarshalAs(UnmanagedType.I1)] - public bool curved; - [MarshalAs(UnmanagedType.I1)] - public bool antialias; - public float scale; - public float distance; - public float alpha; - public float uOffset; - public float vOffset; - public float uScale; - public float vScale; - public float gridDivs; - public float gridWidth; - public float gridScale; - public HmdMatrix44_t transform; + public uint unPacketNum; + public ulong ulButtonPressed; + public ulong ulButtonTouched; + public VRControllerAxis_t rAxis0; //VRControllerAxis_t[5] + public VRControllerAxis_t rAxis1; + public VRControllerAxis_t rAxis2; + public VRControllerAxis_t rAxis3; + public VRControllerAxis_t rAxis4; + public VRControllerState_t_Packed(VRControllerState_t unpacked) + { + this.unPacketNum = unpacked.unPacketNum; + this.ulButtonPressed = unpacked.ulButtonPressed; + this.ulButtonTouched = unpacked.ulButtonTouched; + this.rAxis0 = unpacked.rAxis0; + this.rAxis1 = unpacked.rAxis1; + this.rAxis2 = unpacked.rAxis2; + this.rAxis3 = unpacked.rAxis3; + this.rAxis4 = unpacked.rAxis4; + } + public void Unpack(ref VRControllerState_t unpacked) + { + unpacked.unPacketNum = this.unPacketNum; + unpacked.ulButtonPressed = this.ulButtonPressed; + unpacked.ulButtonTouched = this.ulButtonTouched; + unpacked.rAxis0 = this.rAxis0; + unpacked.rAxis1 = this.rAxis1; + unpacked.rAxis2 = this.rAxis2; + unpacked.rAxis3 = this.rAxis3; + unpacked.rAxis4 = this.rAxis4; + } +} +[StructLayout(LayoutKind.Sequential)] public struct VRBoneTransform_t +{ + public HmdVector4_t position; + public HmdQuaternionf_t orientation; } [StructLayout(LayoutKind.Sequential)] public struct CameraVideoStreamFrameHeader_t { @@ -3850,18 +6291,15 @@ public enum EVRScreenshotError public uint nHeight; public uint nBytesPerPixel; public uint nFrameSequence; - public TrackedDevicePose_t standingTrackedDevicePose; -} -[StructLayout(LayoutKind.Sequential)] public struct AppOverrideKeys_t -{ - public IntPtr pchKey; // const char * - public IntPtr pchValue; // const char * + public TrackedDevicePose_t trackedDevicePose; + public ulong ulFrameExposureTime; } [StructLayout(LayoutKind.Sequential)] public struct Compositor_FrameTiming { public uint m_nSize; public uint m_nFrameIndex; public uint m_nNumFramePresents; + public uint m_nNumMisPresented; public uint m_nNumDroppedFrames; public uint m_nReprojectionFlags; public double m_flSystemTimeInSeconds; @@ -3882,6 +6320,33 @@ public enum EVRScreenshotError public float m_flCompositorUpdateEndMs; public float m_flCompositorRenderStartMs; public TrackedDevicePose_t m_HmdPose; + public uint m_nNumVSyncsReadyForUse; + public uint m_nNumVSyncsToFirstView; +} +[StructLayout(LayoutKind.Sequential)] public struct Compositor_BenchmarkResults +{ + public float m_flMegaPixelsPerSecond; + public float m_flHmdRecommendedMegaPixelsPerSecond; +} +[StructLayout(LayoutKind.Sequential)] public struct DriverDirectMode_FrameTiming +{ + public uint m_nSize; + public uint m_nNumFramePresents; + public uint m_nNumMisPresented; + 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 * + public IntPtr pchValue; // const char * } [StructLayout(LayoutKind.Sequential)] public struct Compositor_CumulativeStats { @@ -3901,6 +6366,20 @@ public enum EVRScreenshotError public uint m_nNumDroppedFramesTimedOut; public uint m_nNumReprojectedFramesTimedOut; } +[StructLayout(LayoutKind.Sequential)] public struct Compositor_StageRenderSettings +{ + public HmdColor_t m_PrimaryColor; + public HmdColor_t m_SecondaryColor; + public float m_flVignetteInnerRadius; + public float m_flVignetteOuterRadius; + public float m_flFresnelStrength; + [MarshalAs(UnmanagedType.I1)] + public bool m_bBackfaceCulling; + [MarshalAs(UnmanagedType.I1)] + public bool m_bGreyscale; + [MarshalAs(UnmanagedType.I1)] + public bool m_bWireframe; +} [StructLayout(LayoutKind.Sequential)] public struct VROverlayIntersectionParams_t { public HmdVector3_t vSource; @@ -3914,11 +6393,42 @@ public enum EVRScreenshotError public HmdVector2_t vUVs; public float fDistance; } -[StructLayout(LayoutKind.Sequential)] public struct RenderModel_ComponentState_t +[StructLayout(LayoutKind.Sequential)] public struct IntersectionMaskRectangle_t { - public HmdMatrix34_t mTrackingToComponentRenderModel; - public HmdMatrix34_t mTrackingToComponentLocal; - public uint uProperties; + public float m_flTopLeftX; + public float m_flTopLeftY; + public float m_flWidth; + public float m_flHeight; +} +[StructLayout(LayoutKind.Sequential)] public struct IntersectionMaskCircle_t +{ + public float m_flCenterX; + public float m_flCenterY; + public float m_flRadius; +} +[StructLayout(LayoutKind.Sequential)] public struct VROverlayIntersectionMaskPrimitive_t +{ + public EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType; + public VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; +} +[StructLayout(LayoutKind.Sequential)] public struct VROverlayView_t +{ + public ulong overlayHandle; + public Texture_t texture; + public VRTextureBounds_t textureBounds; +} +[StructLayout(LayoutKind.Sequential)] public struct VRVulkanDevice_t +{ + public IntPtr m_pInstance; // struct VkInstance_T * + public IntPtr m_pDevice; // struct VkDevice_T * + public IntPtr m_pPhysicalDevice; // struct VkPhysicalDevice_T * + public IntPtr m_pQueue; // struct VkQueue_T * + public uint m_uQueueFamilyIndex; +} +[StructLayout(LayoutKind.Sequential)] public struct VRNativeDevice_t +{ + public IntPtr handle; // void * + public EDeviceType eType; } [StructLayout(LayoutKind.Sequential)] public struct RenderModel_Vertex_t { @@ -3929,9 +6439,32 @@ public enum EVRScreenshotError } [StructLayout(LayoutKind.Sequential)] public struct RenderModel_TextureMap_t { - public char unWidth; - public char unHeight; + public ushort unWidth; + public ushort unHeight; + public IntPtr rubTextureMapData; // const uint8_t * + public EVRRenderModelTextureFormat format; +} +// This structure is for backwards binary compatibility on Linux and OSX only +[StructLayout(LayoutKind.Sequential, Pack = 4)] public struct RenderModel_TextureMap_t_Packed +{ + public ushort unWidth; + public ushort unHeight; public IntPtr rubTextureMapData; // const uint8_t * + public EVRRenderModelTextureFormat format; + public RenderModel_TextureMap_t_Packed(RenderModel_TextureMap_t unpacked) + { + this.unWidth = unpacked.unWidth; + this.unHeight = unpacked.unHeight; + this.rubTextureMapData = unpacked.rubTextureMapData; + this.format = unpacked.format; + } + public void Unpack(ref RenderModel_TextureMap_t unpacked) + { + unpacked.unWidth = this.unWidth; + unpacked.unHeight = this.unHeight; + unpacked.rubTextureMapData = this.rubTextureMapData; + unpacked.format = this.format; + } } [StructLayout(LayoutKind.Sequential)] public struct RenderModel_t { @@ -3941,6 +6474,31 @@ public enum EVRScreenshotError public uint unTriangleCount; public int diffuseTextureId; } +// This structure is for backwards binary compatibility on Linux and OSX only +[StructLayout(LayoutKind.Sequential, Pack = 4)] public struct RenderModel_t_Packed +{ + public IntPtr rVertexData; // const struct vr::RenderModel_Vertex_t * + public uint unVertexCount; + public IntPtr rIndexData; // const uint16_t * + public uint unTriangleCount; + public int diffuseTextureId; + public RenderModel_t_Packed(RenderModel_t unpacked) + { + this.rVertexData = unpacked.rVertexData; + this.unVertexCount = unpacked.unVertexCount; + this.rIndexData = unpacked.rIndexData; + this.unTriangleCount = unpacked.unTriangleCount; + this.diffuseTextureId = unpacked.diffuseTextureId; + } + public void Unpack(ref RenderModel_t unpacked) + { + unpacked.rVertexData = this.rVertexData; + unpacked.unVertexCount = this.unVertexCount; + unpacked.rIndexData = this.rIndexData; + unpacked.unTriangleCount = this.unTriangleCount; + unpacked.diffuseTextureId = this.diffuseTextureId; + } +} [StructLayout(LayoutKind.Sequential)] public struct RenderModel_ControllerMode_State_t { [MarshalAs(UnmanagedType.I1)] @@ -3953,13 +6511,814 @@ public enum EVRScreenshotError public int m_nHeight; public int m_nBytesPerPixel; } +[StructLayout(LayoutKind.Sequential)] public struct CVRSettingHelper +{ + public IntPtr m_pSettings; // class vr::IVRSettings * +} +[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 InputSkeletalActionData_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; + public string rchRenderModelComponentName + { + get + { + return new string(new char[] { + (char)rchRenderModelComponentName0, + (char)rchRenderModelComponentName1, + (char)rchRenderModelComponentName2, + (char)rchRenderModelComponentName3, + (char)rchRenderModelComponentName4, + (char)rchRenderModelComponentName5, + (char)rchRenderModelComponentName6, + (char)rchRenderModelComponentName7, + (char)rchRenderModelComponentName8, + (char)rchRenderModelComponentName9, + (char)rchRenderModelComponentName10, + (char)rchRenderModelComponentName11, + (char)rchRenderModelComponentName12, + (char)rchRenderModelComponentName13, + (char)rchRenderModelComponentName14, + (char)rchRenderModelComponentName15, + (char)rchRenderModelComponentName16, + (char)rchRenderModelComponentName17, + (char)rchRenderModelComponentName18, + (char)rchRenderModelComponentName19, + (char)rchRenderModelComponentName20, + (char)rchRenderModelComponentName21, + (char)rchRenderModelComponentName22, + (char)rchRenderModelComponentName23, + (char)rchRenderModelComponentName24, + (char)rchRenderModelComponentName25, + (char)rchRenderModelComponentName26, + (char)rchRenderModelComponentName27, + (char)rchRenderModelComponentName28, + (char)rchRenderModelComponentName29, + (char)rchRenderModelComponentName30, + (char)rchRenderModelComponentName31, + (char)rchRenderModelComponentName32, + (char)rchRenderModelComponentName33, + (char)rchRenderModelComponentName34, + (char)rchRenderModelComponentName35, + (char)rchRenderModelComponentName36, + (char)rchRenderModelComponentName37, + (char)rchRenderModelComponentName38, + (char)rchRenderModelComponentName39, + (char)rchRenderModelComponentName40, + (char)rchRenderModelComponentName41, + (char)rchRenderModelComponentName42, + (char)rchRenderModelComponentName43, + (char)rchRenderModelComponentName44, + (char)rchRenderModelComponentName45, + (char)rchRenderModelComponentName46, + (char)rchRenderModelComponentName47, + (char)rchRenderModelComponentName48, + (char)rchRenderModelComponentName49, + (char)rchRenderModelComponentName50, + (char)rchRenderModelComponentName51, + (char)rchRenderModelComponentName52, + (char)rchRenderModelComponentName53, + (char)rchRenderModelComponentName54, + (char)rchRenderModelComponentName55, + (char)rchRenderModelComponentName56, + (char)rchRenderModelComponentName57, + (char)rchRenderModelComponentName58, + (char)rchRenderModelComponentName59, + (char)rchRenderModelComponentName60, + (char)rchRenderModelComponentName61, + (char)rchRenderModelComponentName62, + (char)rchRenderModelComponentName63, + (char)rchRenderModelComponentName64, + (char)rchRenderModelComponentName65, + (char)rchRenderModelComponentName66, + (char)rchRenderModelComponentName67, + (char)rchRenderModelComponentName68, + (char)rchRenderModelComponentName69, + (char)rchRenderModelComponentName70, + (char)rchRenderModelComponentName71, + (char)rchRenderModelComponentName72, + (char)rchRenderModelComponentName73, + (char)rchRenderModelComponentName74, + (char)rchRenderModelComponentName75, + (char)rchRenderModelComponentName76, + (char)rchRenderModelComponentName77, + (char)rchRenderModelComponentName78, + (char)rchRenderModelComponentName79, + (char)rchRenderModelComponentName80, + (char)rchRenderModelComponentName81, + (char)rchRenderModelComponentName82, + (char)rchRenderModelComponentName83, + (char)rchRenderModelComponentName84, + (char)rchRenderModelComponentName85, + (char)rchRenderModelComponentName86, + (char)rchRenderModelComponentName87, + (char)rchRenderModelComponentName88, + (char)rchRenderModelComponentName89, + (char)rchRenderModelComponentName90, + (char)rchRenderModelComponentName91, + (char)rchRenderModelComponentName92, + (char)rchRenderModelComponentName93, + (char)rchRenderModelComponentName94, + (char)rchRenderModelComponentName95, + (char)rchRenderModelComponentName96, + (char)rchRenderModelComponentName97, + (char)rchRenderModelComponentName98, + (char)rchRenderModelComponentName99, + (char)rchRenderModelComponentName100, + (char)rchRenderModelComponentName101, + (char)rchRenderModelComponentName102, + (char)rchRenderModelComponentName103, + (char)rchRenderModelComponentName104, + (char)rchRenderModelComponentName105, + (char)rchRenderModelComponentName106, + (char)rchRenderModelComponentName107, + (char)rchRenderModelComponentName108, + (char)rchRenderModelComponentName109, + (char)rchRenderModelComponentName110, + (char)rchRenderModelComponentName111, + (char)rchRenderModelComponentName112, + (char)rchRenderModelComponentName113, + (char)rchRenderModelComponentName114, + (char)rchRenderModelComponentName115, + (char)rchRenderModelComponentName116, + (char)rchRenderModelComponentName117, + (char)rchRenderModelComponentName118, + (char)rchRenderModelComponentName119, + (char)rchRenderModelComponentName120, + (char)rchRenderModelComponentName121, + (char)rchRenderModelComponentName122, + (char)rchRenderModelComponentName123, + (char)rchRenderModelComponentName124, + (char)rchRenderModelComponentName125, + (char)rchRenderModelComponentName126, + (char)rchRenderModelComponentName127 + }).TrimEnd('\0'); + } + } +} +[StructLayout(LayoutKind.Sequential)] public struct InputBindingInfo_t +{ + public byte rchDevicePathName0,rchDevicePathName1,rchDevicePathName2,rchDevicePathName3,rchDevicePathName4,rchDevicePathName5,rchDevicePathName6,rchDevicePathName7,rchDevicePathName8,rchDevicePathName9,rchDevicePathName10,rchDevicePathName11,rchDevicePathName12,rchDevicePathName13,rchDevicePathName14,rchDevicePathName15,rchDevicePathName16,rchDevicePathName17,rchDevicePathName18,rchDevicePathName19,rchDevicePathName20,rchDevicePathName21,rchDevicePathName22,rchDevicePathName23,rchDevicePathName24,rchDevicePathName25,rchDevicePathName26,rchDevicePathName27,rchDevicePathName28,rchDevicePathName29,rchDevicePathName30,rchDevicePathName31,rchDevicePathName32,rchDevicePathName33,rchDevicePathName34,rchDevicePathName35,rchDevicePathName36,rchDevicePathName37,rchDevicePathName38,rchDevicePathName39,rchDevicePathName40,rchDevicePathName41,rchDevicePathName42,rchDevicePathName43,rchDevicePathName44,rchDevicePathName45,rchDevicePathName46,rchDevicePathName47,rchDevicePathName48,rchDevicePathName49,rchDevicePathName50,rchDevicePathName51,rchDevicePathName52,rchDevicePathName53,rchDevicePathName54,rchDevicePathName55,rchDevicePathName56,rchDevicePathName57,rchDevicePathName58,rchDevicePathName59,rchDevicePathName60,rchDevicePathName61,rchDevicePathName62,rchDevicePathName63,rchDevicePathName64,rchDevicePathName65,rchDevicePathName66,rchDevicePathName67,rchDevicePathName68,rchDevicePathName69,rchDevicePathName70,rchDevicePathName71,rchDevicePathName72,rchDevicePathName73,rchDevicePathName74,rchDevicePathName75,rchDevicePathName76,rchDevicePathName77,rchDevicePathName78,rchDevicePathName79,rchDevicePathName80,rchDevicePathName81,rchDevicePathName82,rchDevicePathName83,rchDevicePathName84,rchDevicePathName85,rchDevicePathName86,rchDevicePathName87,rchDevicePathName88,rchDevicePathName89,rchDevicePathName90,rchDevicePathName91,rchDevicePathName92,rchDevicePathName93,rchDevicePathName94,rchDevicePathName95,rchDevicePathName96,rchDevicePathName97,rchDevicePathName98,rchDevicePathName99,rchDevicePathName100,rchDevicePathName101,rchDevicePathName102,rchDevicePathName103,rchDevicePathName104,rchDevicePathName105,rchDevicePathName106,rchDevicePathName107,rchDevicePathName108,rchDevicePathName109,rchDevicePathName110,rchDevicePathName111,rchDevicePathName112,rchDevicePathName113,rchDevicePathName114,rchDevicePathName115,rchDevicePathName116,rchDevicePathName117,rchDevicePathName118,rchDevicePathName119,rchDevicePathName120,rchDevicePathName121,rchDevicePathName122,rchDevicePathName123,rchDevicePathName124,rchDevicePathName125,rchDevicePathName126,rchDevicePathName127; + public string rchDevicePathName + { + get + { + return new string(new char[] { + (char)rchDevicePathName0, + (char)rchDevicePathName1, + (char)rchDevicePathName2, + (char)rchDevicePathName3, + (char)rchDevicePathName4, + (char)rchDevicePathName5, + (char)rchDevicePathName6, + (char)rchDevicePathName7, + (char)rchDevicePathName8, + (char)rchDevicePathName9, + (char)rchDevicePathName10, + (char)rchDevicePathName11, + (char)rchDevicePathName12, + (char)rchDevicePathName13, + (char)rchDevicePathName14, + (char)rchDevicePathName15, + (char)rchDevicePathName16, + (char)rchDevicePathName17, + (char)rchDevicePathName18, + (char)rchDevicePathName19, + (char)rchDevicePathName20, + (char)rchDevicePathName21, + (char)rchDevicePathName22, + (char)rchDevicePathName23, + (char)rchDevicePathName24, + (char)rchDevicePathName25, + (char)rchDevicePathName26, + (char)rchDevicePathName27, + (char)rchDevicePathName28, + (char)rchDevicePathName29, + (char)rchDevicePathName30, + (char)rchDevicePathName31, + (char)rchDevicePathName32, + (char)rchDevicePathName33, + (char)rchDevicePathName34, + (char)rchDevicePathName35, + (char)rchDevicePathName36, + (char)rchDevicePathName37, + (char)rchDevicePathName38, + (char)rchDevicePathName39, + (char)rchDevicePathName40, + (char)rchDevicePathName41, + (char)rchDevicePathName42, + (char)rchDevicePathName43, + (char)rchDevicePathName44, + (char)rchDevicePathName45, + (char)rchDevicePathName46, + (char)rchDevicePathName47, + (char)rchDevicePathName48, + (char)rchDevicePathName49, + (char)rchDevicePathName50, + (char)rchDevicePathName51, + (char)rchDevicePathName52, + (char)rchDevicePathName53, + (char)rchDevicePathName54, + (char)rchDevicePathName55, + (char)rchDevicePathName56, + (char)rchDevicePathName57, + (char)rchDevicePathName58, + (char)rchDevicePathName59, + (char)rchDevicePathName60, + (char)rchDevicePathName61, + (char)rchDevicePathName62, + (char)rchDevicePathName63, + (char)rchDevicePathName64, + (char)rchDevicePathName65, + (char)rchDevicePathName66, + (char)rchDevicePathName67, + (char)rchDevicePathName68, + (char)rchDevicePathName69, + (char)rchDevicePathName70, + (char)rchDevicePathName71, + (char)rchDevicePathName72, + (char)rchDevicePathName73, + (char)rchDevicePathName74, + (char)rchDevicePathName75, + (char)rchDevicePathName76, + (char)rchDevicePathName77, + (char)rchDevicePathName78, + (char)rchDevicePathName79, + (char)rchDevicePathName80, + (char)rchDevicePathName81, + (char)rchDevicePathName82, + (char)rchDevicePathName83, + (char)rchDevicePathName84, + (char)rchDevicePathName85, + (char)rchDevicePathName86, + (char)rchDevicePathName87, + (char)rchDevicePathName88, + (char)rchDevicePathName89, + (char)rchDevicePathName90, + (char)rchDevicePathName91, + (char)rchDevicePathName92, + (char)rchDevicePathName93, + (char)rchDevicePathName94, + (char)rchDevicePathName95, + (char)rchDevicePathName96, + (char)rchDevicePathName97, + (char)rchDevicePathName98, + (char)rchDevicePathName99, + (char)rchDevicePathName100, + (char)rchDevicePathName101, + (char)rchDevicePathName102, + (char)rchDevicePathName103, + (char)rchDevicePathName104, + (char)rchDevicePathName105, + (char)rchDevicePathName106, + (char)rchDevicePathName107, + (char)rchDevicePathName108, + (char)rchDevicePathName109, + (char)rchDevicePathName110, + (char)rchDevicePathName111, + (char)rchDevicePathName112, + (char)rchDevicePathName113, + (char)rchDevicePathName114, + (char)rchDevicePathName115, + (char)rchDevicePathName116, + (char)rchDevicePathName117, + (char)rchDevicePathName118, + (char)rchDevicePathName119, + (char)rchDevicePathName120, + (char)rchDevicePathName121, + (char)rchDevicePathName122, + (char)rchDevicePathName123, + (char)rchDevicePathName124, + (char)rchDevicePathName125, + (char)rchDevicePathName126, + (char)rchDevicePathName127 + }).TrimEnd('\0'); + } + } + public byte rchInputPathName0,rchInputPathName1,rchInputPathName2,rchInputPathName3,rchInputPathName4,rchInputPathName5,rchInputPathName6,rchInputPathName7,rchInputPathName8,rchInputPathName9,rchInputPathName10,rchInputPathName11,rchInputPathName12,rchInputPathName13,rchInputPathName14,rchInputPathName15,rchInputPathName16,rchInputPathName17,rchInputPathName18,rchInputPathName19,rchInputPathName20,rchInputPathName21,rchInputPathName22,rchInputPathName23,rchInputPathName24,rchInputPathName25,rchInputPathName26,rchInputPathName27,rchInputPathName28,rchInputPathName29,rchInputPathName30,rchInputPathName31,rchInputPathName32,rchInputPathName33,rchInputPathName34,rchInputPathName35,rchInputPathName36,rchInputPathName37,rchInputPathName38,rchInputPathName39,rchInputPathName40,rchInputPathName41,rchInputPathName42,rchInputPathName43,rchInputPathName44,rchInputPathName45,rchInputPathName46,rchInputPathName47,rchInputPathName48,rchInputPathName49,rchInputPathName50,rchInputPathName51,rchInputPathName52,rchInputPathName53,rchInputPathName54,rchInputPathName55,rchInputPathName56,rchInputPathName57,rchInputPathName58,rchInputPathName59,rchInputPathName60,rchInputPathName61,rchInputPathName62,rchInputPathName63,rchInputPathName64,rchInputPathName65,rchInputPathName66,rchInputPathName67,rchInputPathName68,rchInputPathName69,rchInputPathName70,rchInputPathName71,rchInputPathName72,rchInputPathName73,rchInputPathName74,rchInputPathName75,rchInputPathName76,rchInputPathName77,rchInputPathName78,rchInputPathName79,rchInputPathName80,rchInputPathName81,rchInputPathName82,rchInputPathName83,rchInputPathName84,rchInputPathName85,rchInputPathName86,rchInputPathName87,rchInputPathName88,rchInputPathName89,rchInputPathName90,rchInputPathName91,rchInputPathName92,rchInputPathName93,rchInputPathName94,rchInputPathName95,rchInputPathName96,rchInputPathName97,rchInputPathName98,rchInputPathName99,rchInputPathName100,rchInputPathName101,rchInputPathName102,rchInputPathName103,rchInputPathName104,rchInputPathName105,rchInputPathName106,rchInputPathName107,rchInputPathName108,rchInputPathName109,rchInputPathName110,rchInputPathName111,rchInputPathName112,rchInputPathName113,rchInputPathName114,rchInputPathName115,rchInputPathName116,rchInputPathName117,rchInputPathName118,rchInputPathName119,rchInputPathName120,rchInputPathName121,rchInputPathName122,rchInputPathName123,rchInputPathName124,rchInputPathName125,rchInputPathName126,rchInputPathName127; + public string rchInputPathName + { + get + { + return new string(new char[] { + (char)rchInputPathName0, + (char)rchInputPathName1, + (char)rchInputPathName2, + (char)rchInputPathName3, + (char)rchInputPathName4, + (char)rchInputPathName5, + (char)rchInputPathName6, + (char)rchInputPathName7, + (char)rchInputPathName8, + (char)rchInputPathName9, + (char)rchInputPathName10, + (char)rchInputPathName11, + (char)rchInputPathName12, + (char)rchInputPathName13, + (char)rchInputPathName14, + (char)rchInputPathName15, + (char)rchInputPathName16, + (char)rchInputPathName17, + (char)rchInputPathName18, + (char)rchInputPathName19, + (char)rchInputPathName20, + (char)rchInputPathName21, + (char)rchInputPathName22, + (char)rchInputPathName23, + (char)rchInputPathName24, + (char)rchInputPathName25, + (char)rchInputPathName26, + (char)rchInputPathName27, + (char)rchInputPathName28, + (char)rchInputPathName29, + (char)rchInputPathName30, + (char)rchInputPathName31, + (char)rchInputPathName32, + (char)rchInputPathName33, + (char)rchInputPathName34, + (char)rchInputPathName35, + (char)rchInputPathName36, + (char)rchInputPathName37, + (char)rchInputPathName38, + (char)rchInputPathName39, + (char)rchInputPathName40, + (char)rchInputPathName41, + (char)rchInputPathName42, + (char)rchInputPathName43, + (char)rchInputPathName44, + (char)rchInputPathName45, + (char)rchInputPathName46, + (char)rchInputPathName47, + (char)rchInputPathName48, + (char)rchInputPathName49, + (char)rchInputPathName50, + (char)rchInputPathName51, + (char)rchInputPathName52, + (char)rchInputPathName53, + (char)rchInputPathName54, + (char)rchInputPathName55, + (char)rchInputPathName56, + (char)rchInputPathName57, + (char)rchInputPathName58, + (char)rchInputPathName59, + (char)rchInputPathName60, + (char)rchInputPathName61, + (char)rchInputPathName62, + (char)rchInputPathName63, + (char)rchInputPathName64, + (char)rchInputPathName65, + (char)rchInputPathName66, + (char)rchInputPathName67, + (char)rchInputPathName68, + (char)rchInputPathName69, + (char)rchInputPathName70, + (char)rchInputPathName71, + (char)rchInputPathName72, + (char)rchInputPathName73, + (char)rchInputPathName74, + (char)rchInputPathName75, + (char)rchInputPathName76, + (char)rchInputPathName77, + (char)rchInputPathName78, + (char)rchInputPathName79, + (char)rchInputPathName80, + (char)rchInputPathName81, + (char)rchInputPathName82, + (char)rchInputPathName83, + (char)rchInputPathName84, + (char)rchInputPathName85, + (char)rchInputPathName86, + (char)rchInputPathName87, + (char)rchInputPathName88, + (char)rchInputPathName89, + (char)rchInputPathName90, + (char)rchInputPathName91, + (char)rchInputPathName92, + (char)rchInputPathName93, + (char)rchInputPathName94, + (char)rchInputPathName95, + (char)rchInputPathName96, + (char)rchInputPathName97, + (char)rchInputPathName98, + (char)rchInputPathName99, + (char)rchInputPathName100, + (char)rchInputPathName101, + (char)rchInputPathName102, + (char)rchInputPathName103, + (char)rchInputPathName104, + (char)rchInputPathName105, + (char)rchInputPathName106, + (char)rchInputPathName107, + (char)rchInputPathName108, + (char)rchInputPathName109, + (char)rchInputPathName110, + (char)rchInputPathName111, + (char)rchInputPathName112, + (char)rchInputPathName113, + (char)rchInputPathName114, + (char)rchInputPathName115, + (char)rchInputPathName116, + (char)rchInputPathName117, + (char)rchInputPathName118, + (char)rchInputPathName119, + (char)rchInputPathName120, + (char)rchInputPathName121, + (char)rchInputPathName122, + (char)rchInputPathName123, + (char)rchInputPathName124, + (char)rchInputPathName125, + (char)rchInputPathName126, + (char)rchInputPathName127 + }).TrimEnd('\0'); + } + } + public byte rchModeName0,rchModeName1,rchModeName2,rchModeName3,rchModeName4,rchModeName5,rchModeName6,rchModeName7,rchModeName8,rchModeName9,rchModeName10,rchModeName11,rchModeName12,rchModeName13,rchModeName14,rchModeName15,rchModeName16,rchModeName17,rchModeName18,rchModeName19,rchModeName20,rchModeName21,rchModeName22,rchModeName23,rchModeName24,rchModeName25,rchModeName26,rchModeName27,rchModeName28,rchModeName29,rchModeName30,rchModeName31,rchModeName32,rchModeName33,rchModeName34,rchModeName35,rchModeName36,rchModeName37,rchModeName38,rchModeName39,rchModeName40,rchModeName41,rchModeName42,rchModeName43,rchModeName44,rchModeName45,rchModeName46,rchModeName47,rchModeName48,rchModeName49,rchModeName50,rchModeName51,rchModeName52,rchModeName53,rchModeName54,rchModeName55,rchModeName56,rchModeName57,rchModeName58,rchModeName59,rchModeName60,rchModeName61,rchModeName62,rchModeName63,rchModeName64,rchModeName65,rchModeName66,rchModeName67,rchModeName68,rchModeName69,rchModeName70,rchModeName71,rchModeName72,rchModeName73,rchModeName74,rchModeName75,rchModeName76,rchModeName77,rchModeName78,rchModeName79,rchModeName80,rchModeName81,rchModeName82,rchModeName83,rchModeName84,rchModeName85,rchModeName86,rchModeName87,rchModeName88,rchModeName89,rchModeName90,rchModeName91,rchModeName92,rchModeName93,rchModeName94,rchModeName95,rchModeName96,rchModeName97,rchModeName98,rchModeName99,rchModeName100,rchModeName101,rchModeName102,rchModeName103,rchModeName104,rchModeName105,rchModeName106,rchModeName107,rchModeName108,rchModeName109,rchModeName110,rchModeName111,rchModeName112,rchModeName113,rchModeName114,rchModeName115,rchModeName116,rchModeName117,rchModeName118,rchModeName119,rchModeName120,rchModeName121,rchModeName122,rchModeName123,rchModeName124,rchModeName125,rchModeName126,rchModeName127; + public string rchModeName + { + get + { + return new string(new char[] { + (char)rchModeName0, + (char)rchModeName1, + (char)rchModeName2, + (char)rchModeName3, + (char)rchModeName4, + (char)rchModeName5, + (char)rchModeName6, + (char)rchModeName7, + (char)rchModeName8, + (char)rchModeName9, + (char)rchModeName10, + (char)rchModeName11, + (char)rchModeName12, + (char)rchModeName13, + (char)rchModeName14, + (char)rchModeName15, + (char)rchModeName16, + (char)rchModeName17, + (char)rchModeName18, + (char)rchModeName19, + (char)rchModeName20, + (char)rchModeName21, + (char)rchModeName22, + (char)rchModeName23, + (char)rchModeName24, + (char)rchModeName25, + (char)rchModeName26, + (char)rchModeName27, + (char)rchModeName28, + (char)rchModeName29, + (char)rchModeName30, + (char)rchModeName31, + (char)rchModeName32, + (char)rchModeName33, + (char)rchModeName34, + (char)rchModeName35, + (char)rchModeName36, + (char)rchModeName37, + (char)rchModeName38, + (char)rchModeName39, + (char)rchModeName40, + (char)rchModeName41, + (char)rchModeName42, + (char)rchModeName43, + (char)rchModeName44, + (char)rchModeName45, + (char)rchModeName46, + (char)rchModeName47, + (char)rchModeName48, + (char)rchModeName49, + (char)rchModeName50, + (char)rchModeName51, + (char)rchModeName52, + (char)rchModeName53, + (char)rchModeName54, + (char)rchModeName55, + (char)rchModeName56, + (char)rchModeName57, + (char)rchModeName58, + (char)rchModeName59, + (char)rchModeName60, + (char)rchModeName61, + (char)rchModeName62, + (char)rchModeName63, + (char)rchModeName64, + (char)rchModeName65, + (char)rchModeName66, + (char)rchModeName67, + (char)rchModeName68, + (char)rchModeName69, + (char)rchModeName70, + (char)rchModeName71, + (char)rchModeName72, + (char)rchModeName73, + (char)rchModeName74, + (char)rchModeName75, + (char)rchModeName76, + (char)rchModeName77, + (char)rchModeName78, + (char)rchModeName79, + (char)rchModeName80, + (char)rchModeName81, + (char)rchModeName82, + (char)rchModeName83, + (char)rchModeName84, + (char)rchModeName85, + (char)rchModeName86, + (char)rchModeName87, + (char)rchModeName88, + (char)rchModeName89, + (char)rchModeName90, + (char)rchModeName91, + (char)rchModeName92, + (char)rchModeName93, + (char)rchModeName94, + (char)rchModeName95, + (char)rchModeName96, + (char)rchModeName97, + (char)rchModeName98, + (char)rchModeName99, + (char)rchModeName100, + (char)rchModeName101, + (char)rchModeName102, + (char)rchModeName103, + (char)rchModeName104, + (char)rchModeName105, + (char)rchModeName106, + (char)rchModeName107, + (char)rchModeName108, + (char)rchModeName109, + (char)rchModeName110, + (char)rchModeName111, + (char)rchModeName112, + (char)rchModeName113, + (char)rchModeName114, + (char)rchModeName115, + (char)rchModeName116, + (char)rchModeName117, + (char)rchModeName118, + (char)rchModeName119, + (char)rchModeName120, + (char)rchModeName121, + (char)rchModeName122, + (char)rchModeName123, + (char)rchModeName124, + (char)rchModeName125, + (char)rchModeName126, + (char)rchModeName127 + }).TrimEnd('\0'); + } + } + public byte rchSlotName0,rchSlotName1,rchSlotName2,rchSlotName3,rchSlotName4,rchSlotName5,rchSlotName6,rchSlotName7,rchSlotName8,rchSlotName9,rchSlotName10,rchSlotName11,rchSlotName12,rchSlotName13,rchSlotName14,rchSlotName15,rchSlotName16,rchSlotName17,rchSlotName18,rchSlotName19,rchSlotName20,rchSlotName21,rchSlotName22,rchSlotName23,rchSlotName24,rchSlotName25,rchSlotName26,rchSlotName27,rchSlotName28,rchSlotName29,rchSlotName30,rchSlotName31,rchSlotName32,rchSlotName33,rchSlotName34,rchSlotName35,rchSlotName36,rchSlotName37,rchSlotName38,rchSlotName39,rchSlotName40,rchSlotName41,rchSlotName42,rchSlotName43,rchSlotName44,rchSlotName45,rchSlotName46,rchSlotName47,rchSlotName48,rchSlotName49,rchSlotName50,rchSlotName51,rchSlotName52,rchSlotName53,rchSlotName54,rchSlotName55,rchSlotName56,rchSlotName57,rchSlotName58,rchSlotName59,rchSlotName60,rchSlotName61,rchSlotName62,rchSlotName63,rchSlotName64,rchSlotName65,rchSlotName66,rchSlotName67,rchSlotName68,rchSlotName69,rchSlotName70,rchSlotName71,rchSlotName72,rchSlotName73,rchSlotName74,rchSlotName75,rchSlotName76,rchSlotName77,rchSlotName78,rchSlotName79,rchSlotName80,rchSlotName81,rchSlotName82,rchSlotName83,rchSlotName84,rchSlotName85,rchSlotName86,rchSlotName87,rchSlotName88,rchSlotName89,rchSlotName90,rchSlotName91,rchSlotName92,rchSlotName93,rchSlotName94,rchSlotName95,rchSlotName96,rchSlotName97,rchSlotName98,rchSlotName99,rchSlotName100,rchSlotName101,rchSlotName102,rchSlotName103,rchSlotName104,rchSlotName105,rchSlotName106,rchSlotName107,rchSlotName108,rchSlotName109,rchSlotName110,rchSlotName111,rchSlotName112,rchSlotName113,rchSlotName114,rchSlotName115,rchSlotName116,rchSlotName117,rchSlotName118,rchSlotName119,rchSlotName120,rchSlotName121,rchSlotName122,rchSlotName123,rchSlotName124,rchSlotName125,rchSlotName126,rchSlotName127; + public string rchSlotName + { + get + { + return new string(new char[] { + (char)rchSlotName0, + (char)rchSlotName1, + (char)rchSlotName2, + (char)rchSlotName3, + (char)rchSlotName4, + (char)rchSlotName5, + (char)rchSlotName6, + (char)rchSlotName7, + (char)rchSlotName8, + (char)rchSlotName9, + (char)rchSlotName10, + (char)rchSlotName11, + (char)rchSlotName12, + (char)rchSlotName13, + (char)rchSlotName14, + (char)rchSlotName15, + (char)rchSlotName16, + (char)rchSlotName17, + (char)rchSlotName18, + (char)rchSlotName19, + (char)rchSlotName20, + (char)rchSlotName21, + (char)rchSlotName22, + (char)rchSlotName23, + (char)rchSlotName24, + (char)rchSlotName25, + (char)rchSlotName26, + (char)rchSlotName27, + (char)rchSlotName28, + (char)rchSlotName29, + (char)rchSlotName30, + (char)rchSlotName31, + (char)rchSlotName32, + (char)rchSlotName33, + (char)rchSlotName34, + (char)rchSlotName35, + (char)rchSlotName36, + (char)rchSlotName37, + (char)rchSlotName38, + (char)rchSlotName39, + (char)rchSlotName40, + (char)rchSlotName41, + (char)rchSlotName42, + (char)rchSlotName43, + (char)rchSlotName44, + (char)rchSlotName45, + (char)rchSlotName46, + (char)rchSlotName47, + (char)rchSlotName48, + (char)rchSlotName49, + (char)rchSlotName50, + (char)rchSlotName51, + (char)rchSlotName52, + (char)rchSlotName53, + (char)rchSlotName54, + (char)rchSlotName55, + (char)rchSlotName56, + (char)rchSlotName57, + (char)rchSlotName58, + (char)rchSlotName59, + (char)rchSlotName60, + (char)rchSlotName61, + (char)rchSlotName62, + (char)rchSlotName63, + (char)rchSlotName64, + (char)rchSlotName65, + (char)rchSlotName66, + (char)rchSlotName67, + (char)rchSlotName68, + (char)rchSlotName69, + (char)rchSlotName70, + (char)rchSlotName71, + (char)rchSlotName72, + (char)rchSlotName73, + (char)rchSlotName74, + (char)rchSlotName75, + (char)rchSlotName76, + (char)rchSlotName77, + (char)rchSlotName78, + (char)rchSlotName79, + (char)rchSlotName80, + (char)rchSlotName81, + (char)rchSlotName82, + (char)rchSlotName83, + (char)rchSlotName84, + (char)rchSlotName85, + (char)rchSlotName86, + (char)rchSlotName87, + (char)rchSlotName88, + (char)rchSlotName89, + (char)rchSlotName90, + (char)rchSlotName91, + (char)rchSlotName92, + (char)rchSlotName93, + (char)rchSlotName94, + (char)rchSlotName95, + (char)rchSlotName96, + (char)rchSlotName97, + (char)rchSlotName98, + (char)rchSlotName99, + (char)rchSlotName100, + (char)rchSlotName101, + (char)rchSlotName102, + (char)rchSlotName103, + (char)rchSlotName104, + (char)rchSlotName105, + (char)rchSlotName106, + (char)rchSlotName107, + (char)rchSlotName108, + (char)rchSlotName109, + (char)rchSlotName110, + (char)rchSlotName111, + (char)rchSlotName112, + (char)rchSlotName113, + (char)rchSlotName114, + (char)rchSlotName115, + (char)rchSlotName116, + (char)rchSlotName117, + (char)rchSlotName118, + (char)rchSlotName119, + (char)rchSlotName120, + (char)rchSlotName121, + (char)rchSlotName122, + (char)rchSlotName123, + (char)rchSlotName124, + (char)rchSlotName125, + (char)rchSlotName126, + (char)rchSlotName127 + }).TrimEnd('\0'); + } + } + public byte rchInputSourceType0,rchInputSourceType1,rchInputSourceType2,rchInputSourceType3,rchInputSourceType4,rchInputSourceType5,rchInputSourceType6,rchInputSourceType7,rchInputSourceType8,rchInputSourceType9,rchInputSourceType10,rchInputSourceType11,rchInputSourceType12,rchInputSourceType13,rchInputSourceType14,rchInputSourceType15,rchInputSourceType16,rchInputSourceType17,rchInputSourceType18,rchInputSourceType19,rchInputSourceType20,rchInputSourceType21,rchInputSourceType22,rchInputSourceType23,rchInputSourceType24,rchInputSourceType25,rchInputSourceType26,rchInputSourceType27,rchInputSourceType28,rchInputSourceType29,rchInputSourceType30,rchInputSourceType31; + public string rchInputSourceType + { + get + { + return new string(new char[] { + (char)rchInputSourceType0, + (char)rchInputSourceType1, + (char)rchInputSourceType2, + (char)rchInputSourceType3, + (char)rchInputSourceType4, + (char)rchInputSourceType5, + (char)rchInputSourceType6, + (char)rchInputSourceType7, + (char)rchInputSourceType8, + (char)rchInputSourceType9, + (char)rchInputSourceType10, + (char)rchInputSourceType11, + (char)rchInputSourceType12, + (char)rchInputSourceType13, + (char)rchInputSourceType14, + (char)rchInputSourceType15, + (char)rchInputSourceType16, + (char)rchInputSourceType17, + (char)rchInputSourceType18, + (char)rchInputSourceType19, + (char)rchInputSourceType20, + (char)rchInputSourceType21, + (char)rchInputSourceType22, + (char)rchInputSourceType23, + (char)rchInputSourceType24, + (char)rchInputSourceType25, + (char)rchInputSourceType26, + (char)rchInputSourceType27, + (char)rchInputSourceType28, + (char)rchInputSourceType29, + (char)rchInputSourceType30, + (char)rchInputSourceType31 + }).TrimEnd('\0'); + } + } +} +[StructLayout(LayoutKind.Sequential)] public struct VRActiveActionSet_t +{ + public ulong ulActionSet; + public ulong ulRestrictedToDevice; + public ulong ulSecondaryActionSet; + public uint unPadding; + public int nPriority; +} +[StructLayout(LayoutKind.Sequential)] public struct VRSkeletalSummaryData_t +{ + public float flFingerCurl0; //float[5] + public float flFingerCurl1; + public float flFingerCurl2; + public float flFingerCurl3; + public float flFingerCurl4; + public float flFingerSplay0; //float[4] + public float flFingerSplay1; + public float flFingerSplay2; + public float flFingerSplay3; +} +[StructLayout(LayoutKind.Sequential)] public struct SpatialAnchorPose_t +{ + public HmdMatrix34_t mAnchorToAbsoluteTracking; +} [StructLayout(LayoutKind.Sequential)] public struct COpenVRContext { public IntPtr m_pVRSystem; // class vr::IVRSystem * public IntPtr m_pVRChaperone; // class vr::IVRChaperone * public IntPtr m_pVRChaperoneSetup; // class vr::IVRChaperoneSetup * public IntPtr m_pVRCompositor; // class vr::IVRCompositor * + public IntPtr m_pVRHeadsetView; // class vr::IVRHeadsetView * public IntPtr m_pVROverlay; // class vr::IVROverlay * + public IntPtr m_pVROverlayView; // class vr::IVROverlayView * public IntPtr m_pVRResources; // class vr::IVRResources * public IntPtr m_pVRRenderModels; // class vr::IVRRenderModels * public IntPtr m_pVRExtendedDisplay; // class vr::IVRExtendedDisplay * @@ -3967,6 +7326,56 @@ public enum EVRScreenshotError public IntPtr m_pVRApplications; // class vr::IVRApplications * 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 IntPtr m_pVRSpatialAnchors; // class vr::IVRSpatialAnchors * + public IntPtr m_pVRDebug; // class vr::IVRDebug * + public IntPtr m_pVRNotifications; // class vr::IVRNotifications * +} +[StructLayout(LayoutKind.Sequential)] public struct PropertyWrite_t +{ + public ETrackedDeviceProperty prop; + public EPropertyWriteType writeType; + public ETrackedPropertyError eSetError; + public IntPtr pvBuffer; // void * + public uint unBufferSize; + public uint unTag; + public ETrackedPropertyError eError; +} +[StructLayout(LayoutKind.Sequential)] public struct PropertyRead_t +{ + public ETrackedDeviceProperty prop; + public IntPtr pvBuffer; // void * + public uint unBufferSize; + public uint unTag; + public uint unRequiredBufferSize; + public ETrackedPropertyError eError; +} +[StructLayout(LayoutKind.Sequential)] public struct CVRPropertyHelpers +{ + public IntPtr m_pProperties; // class vr::IVRProperties * +} +[StructLayout(LayoutKind.Sequential)] public struct PathWrite_t +{ + public ulong ulPath; + public EPropertyWriteType writeType; + public ETrackedPropertyError eSetError; + public IntPtr pvBuffer; // void * + public uint unBufferSize; + public uint unTag; + public ETrackedPropertyError eError; + public IntPtr pszPath; // const char * +} +[StructLayout(LayoutKind.Sequential)] public struct PathRead_t +{ + public ulong ulPath; + public IntPtr pvBuffer; // void * + public uint unBufferSize; + public uint unTag; + public uint unRequiredBufferSize; + public ETrackedPropertyError eError; + public IntPtr pszPath; // const char * } public class OpenVR @@ -3977,6 +7386,11 @@ public static uint InitInternal(ref EVRInitError peError, EVRApplicationType eAp return OpenVRInterop.InitInternal(ref peError, eApplicationType); } + public static uint InitInternal2(ref EVRInitError peError, EVRApplicationType eApplicationType, string pchStartupInfo) + { + return OpenVRInterop.InitInternal2(ref peError, eApplicationType, pchStartupInfo); + } + public static void ShutdownInternal() { OpenVRInterop.ShutdownInternal(); @@ -3992,6 +7406,26 @@ public static bool IsRuntimeInstalled() return OpenVRInterop.IsRuntimeInstalled(); } + public static string RuntimePath() + { + try + { + uint pathSize = 512; + uint requiredPathSize = 512; + System.Text.StringBuilder path = new System.Text.StringBuilder((int)pathSize); + bool success = OpenVRInterop.GetRuntimePath(path, pathSize, ref requiredPathSize); + if (success == false) + { + return null; + } + + return path.ToString(); + } catch + { + return OpenVRInterop.RuntimePath(); //this api is deprecated but here to support older unity versions + } + } + public static string GetStringForHmdError(EVRInitError error) { return Marshal.PtrToStringAnsi(OpenVRInterop.GetStringForHmdError(error)); @@ -4012,88 +7446,167 @@ public static uint GetInitToken() return OpenVRInterop.GetInitToken(); } - public const uint k_unTrackingStringSize = 32; + public const uint k_nDriverNone = 4294967295; public const uint k_unMaxDriverDebugResponseSize = 32768; public const uint k_unTrackedDeviceIndex_Hmd = 0; - public const uint k_unMaxTrackedDeviceCount = 16; + public const uint k_unMaxTrackedDeviceCount = 64; public const uint k_unTrackedDeviceIndexOther = 4294967294; public const uint k_unTrackedDeviceIndexInvalid = 4294967295; + public const ulong k_ulInvalidPropertyContainer = 0; + public const uint k_unInvalidPropertyTag = 0; + public const ulong k_ulInvalidDriverHandle = 0; + public const uint k_unFloatPropertyTag = 1; + public const uint k_unInt32PropertyTag = 2; + public const uint k_unUint64PropertyTag = 3; + public const uint k_unBoolPropertyTag = 4; + public const uint k_unStringPropertyTag = 5; + public const uint k_unErrorPropertyTag = 6; + public const uint k_unDoublePropertyTag = 7; + public const uint k_unHmdMatrix34PropertyTag = 20; + public const uint k_unHmdMatrix44PropertyTag = 21; + public const uint k_unHmdVector3PropertyTag = 22; + public const uint k_unHmdVector4PropertyTag = 23; + public const uint k_unHmdVector2PropertyTag = 24; + public const uint k_unHmdQuadPropertyTag = 25; + public const uint k_unHiddenAreaPropertyTag = 30; + public const uint k_unPathHandleInfoTag = 31; + public const uint k_unActionPropertyTag = 32; + 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_unSpatialAnchorPosePropertyTag = 40; + public const uint k_unJsonPropertyTag = 41; + public const uint k_unActiveActionSetPropertyTag = 42; + public const uint k_unOpenVRInternalReserved_Start = 1000; + public const uint k_unOpenVRInternalReserved_End = 10000; public const uint k_unMaxPropertyStringSize = 32768; + public const ulong k_ulInvalidActionHandle = 0; + public const ulong k_ulInvalidActionSetHandle = 0; + public const ulong k_ulInvalidInputValueHandle = 0; public const uint k_unControllerStateAxisCount = 5; public const ulong k_ulOverlayHandleInvalid = 0; + public const uint k_unMaxDistortionFunctionParameters = 8; public const uint k_unScreenshotHandleInvalid = 0; - public const string IVRSystem_Version = "IVRSystem_012"; + public const string IVRSystem_Version = "IVRSystem_021"; public const string IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; - public const string IVRTrackedCamera_Version = "IVRTrackedCamera_003"; + public const string IVRTrackedCamera_Version = "IVRTrackedCamera_006"; public const uint k_unMaxApplicationKeyLength = 128; - public const string IVRApplications_Version = "IVRApplications_006"; + public const string k_pch_MimeType_HomeApp = "vr/home"; + public const string k_pch_MimeType_GameTheater = "vr/game_theater"; + public const string IVRApplications_Version = "IVRApplications_007"; public const string IVRChaperone_Version = "IVRChaperone_003"; - public const string IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; - public const string IVRCompositor_Version = "IVRCompositor_016"; + public const string IVRChaperoneSetup_Version = "IVRChaperoneSetup_006"; + public const string IVRCompositor_Version = "IVRCompositor_026"; public const uint k_unVROverlayMaxKeyLength = 128; public const uint k_unVROverlayMaxNameLength = 128; - public const uint k_unMaxOverlayCount = 64; - public const string IVROverlay_Version = "IVROverlay_013"; + public const uint k_unMaxOverlayCount = 128; + public const uint k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; + public const string IVROverlay_Version = "IVROverlay_024"; + public const string IVROverlayView_Version = "IVROverlayView_003"; + public const uint k_unHeadsetViewMaxWidth = 3840; + public const uint k_unHeadsetViewMaxHeight = 2160; + public const string k_pchHeadsetViewOverlayKey = "system.HeadsetView"; + public const string IVRHeadsetView_Version = "IVRHeadsetView_001"; public const string k_pch_Controller_Component_GDC2015 = "gdc2015"; public const string k_pch_Controller_Component_Base = "base"; public const string k_pch_Controller_Component_Tip = "tip"; public const string k_pch_Controller_Component_HandGrip = "handgrip"; public const string k_pch_Controller_Component_Status = "status"; - public const string IVRRenderModels_Version = "IVRRenderModels_005"; + public const string IVRRenderModels_Version = "IVRRenderModels_006"; public const uint k_unNotificationTextMaxSize = 256; public const string IVRNotifications_Version = "IVRNotifications_002"; public const uint k_unMaxSettingsKeyLength = 128; - public const string IVRSettings_Version = "IVRSettings_001"; + public const string IVRSettings_Version = "IVRSettings_003"; public const string k_pch_SteamVR_Section = "steamvr"; public const string k_pch_SteamVR_RequireHmd_String = "requireHmd"; public const string k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; public const string k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; public const string k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; public const string k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; - public const string k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; public const string k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; public const string k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; public const string k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; public const string k_pch_SteamVR_LogLevel_Int32 = "loglevel"; public const string k_pch_SteamVR_IPD_Float = "ipd"; public const string k_pch_SteamVR_Background_String = "background"; + public const string k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; public const string k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; public const string k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; - public const string k_pch_SteamVR_Environment_String = "environment"; public const string k_pch_SteamVR_GridColor_String = "gridColor"; public const string k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; + public const string k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor"; public const string k_pch_SteamVR_ShowStage_Bool = "showStage"; public const string k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; - public const string k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit"; - public const string k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout"; - public const string k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout"; - public const string k_pch_SteamVR_DirectMode_Bool = "directMode"; - public const string k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; - public const string k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; public const string k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; public const string k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; - public const string k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; + public const string k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement"; + public const string k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip"; public const string k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; - public const string k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier"; - public const string k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection"; - public const string k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + public const string k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; + public const string k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; + public const string k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; + public const string k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; + public const string k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync"; public const string k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; - public const string k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; - public const string k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; + public const string k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; + public const string k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView"; + public const string k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView"; + public const string k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode"; + public const string k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye"; + public const string k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; + public const string k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; + public const string k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph"; public const string k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; - public const string k_pch_SteamVR_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; - public const string k_pch_SteamVR_UseGenericGraphcisDevice_Bool = "useGenericGraphicsDevice"; + public const string k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; + public const string k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; + public const string k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; + public const string k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; + public const string k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; + public const string k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; + public const string k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; + public const string k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; + public const string k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; + public const string k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; + public const string k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; + public const string k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; + public const string k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; + public const string k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; + public const string k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid"; + public const string k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; + public const string k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; + public const string k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; + public const string k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; + public const string k_pch_SteamVR_LastVersionNotice = "lastVersionNotice"; + public const string k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate"; + public const string k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR"; + public const string k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG"; + public const string k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB"; + public const string k_pch_SteamVR_CustomIconStyle_String = "customIconStyle"; + public const string k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle"; + public const string k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate"; + public const string k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority"; + public const string k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2"; + public const string k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption"; + public const string k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches"; + public const string k_pch_DirectMode_Section = "direct_mode"; + public const string k_pch_DirectMode_Enable_Bool = "enable"; + public const string k_pch_DirectMode_Count_Int32 = "count"; + public const string k_pch_DirectMode_EdidVid_Int32 = "edidVid"; + public const string k_pch_DirectMode_EdidPid_Int32 = "edidPid"; 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"; public const string k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; public const string k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; public const string k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; - public const string k_pch_Lighthouse_LighthouseName_String = "lighthousename"; - public const string k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; - public const string k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; public const string k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; + public const string k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; + public const string k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; + public const string k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; + public const string k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations"; + public const string k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; public const string k_pch_Null_Section = "driver_null"; - public const string k_pch_Null_EnableNullDriver_Bool = "enable"; public const string k_pch_Null_SerialNumber_String = "serialNumber"; public const string k_pch_Null_ModelNumber_String = "modelNumber"; public const string k_pch_Null_WindowX_Int32 = "windowX"; @@ -4104,8 +7617,11 @@ public static uint GetInitToken() public const string k_pch_Null_RenderHeight_Int32 = "renderHeight"; public const string k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; public const string k_pch_Null_DisplayFrequency_Float = "displayFrequency"; + public const string k_pch_WindowsMR_Section = "driver_holographic"; public const string k_pch_UserInterface_Section = "userinterface"; public const string k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; + public const string k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; + public const string k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; public const string k_pch_UserInterface_Screenshots_Bool = "screenshots"; public const string k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; public const string k_pch_Notifications_Section = "notifications"; @@ -4119,22 +7635,23 @@ public static uint GetInitToken() public const string k_pch_Keyboard_OffsetY = "OffsetY"; public const string k_pch_Keyboard_Smoothing = "Smoothing"; public const string k_pch_Perf_Section = "perfcheck"; - public const string k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; - public const string k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; - public const string k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; + public const string k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; public const string k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; public const string k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; public const string k_pch_Perf_TestData_Float = "perfTestData"; + public const string k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; public const string k_pch_CollisionBounds_Section = "collisionBounds"; public const string k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; public const string k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; public const string k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; public const string k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; public const string k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; + public const string k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight"; public const string k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; public const string k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; public const string k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; public const string k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; + public const string k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport"; public const string k_pch_Camera_Section = "camera"; public const string k_pch_Camera_EnableCamera_Bool = "enableCamera"; public const string k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard"; @@ -4144,16 +7661,124 @@ public static uint GetInitToken() public const string k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; public const string k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; public const string k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; + public const string k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; + public const string k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; public const string k_pch_audio_Section = "audio"; - public const string k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; - public const string k_pch_audio_OnRecordDevice_String = "onRecordDevice"; - public const string k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; - public const string k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; - public const string k_pch_audio_OffRecordDevice_String = "offRecordDevice"; + public const string k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice"; + public const string k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride"; + public const string k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride"; + public const string k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName"; + public const string k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice"; + public const string k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride"; + public const string k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride"; + public const string k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName"; + public const string k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror"; + public const string k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice"; + public const string k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName"; + public const string k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; + public const string k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice"; + public const string k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume"; + public const string k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; public const string k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; + public const string k_pch_Power_Section = "power"; + public const string k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; + public const string k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; + public const string k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; + public const string k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; + public const string k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; + public const string k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; + public const string k_pch_Dashboard_Section = "dashboard"; + public const string k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; + public const string k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; + public const string k_pch_Dashboard_Position = "position"; + public const string k_pch_Dashboard_DesktopScale = "desktopScale"; + public const string k_pch_Dashboard_DashboardScale = "dashboardScale"; public const string k_pch_modelskin_Section = "modelskins"; + public const string k_pch_Driver_Enable_Bool = "enable"; + public const string k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode"; + public const string k_pch_Driver_LoadPriority_Int32 = "loadPriority"; + public const string k_pch_WebInterface_Section = "WebInterface"; + public const string k_pch_VRWebHelper_Section = "VRWebHelper"; + public const string k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; + public const string k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; + public const string k_pch_TrackingOverride_Section = "TrackingOverrides"; + public const string k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; + public const string k_pch_App_BindingLegacyAPISuffix_String = "_legacy"; + public const string k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput"; + public const string k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + public const string k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL"; + public const string k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + public const string k_pch_App_DominantHand_Int32 = "DominantHand"; + public const string k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK"; + public const string k_pch_Trackers_Section = "trackers"; + public const string k_pch_DesktopUI_Section = "DesktopUI"; + public const string k_pch_LastKnown_Section = "LastKnown"; + public const string k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; + public const string k_pch_LastKnown_HMDModel_String = "HMDModel"; + public const string k_pch_DismissedWarnings_Section = "DismissedWarnings"; + public const string k_pch_Input_Section = "input"; + public const string k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation"; + public const string k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation"; + public const string k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone"; + public const string k_pch_GpuSpeed_Section = "GpuSpeed"; public const string IVRScreenshots_Version = "IVRScreenshots_001"; public const string IVRResources_Version = "IVRResources_001"; + public const string IVRDriverManager_Version = "IVRDriverManager_001"; + public const uint k_unMaxActionNameLength = 64; + public const uint k_unMaxActionSetNameLength = 64; + public const uint k_unMaxActionOriginCount = 16; + public const uint k_unMaxBoneNameLength = 32; + public const int k_nActionSetOverlayGlobalPriorityMin = 16777216; + public const int k_nActionSetOverlayGlobalPriorityMax = 33554431; + public const int k_nActionSetPriorityReservedMin = 33554432; + public const string IVRInput_Version = "IVRInput_010"; + public const ulong k_ulInvalidIOBufferHandle = 0; + public const string IVRIOBuffer_Version = "IVRIOBuffer_002"; + public const uint k_ulInvalidSpatialAnchorHandle = 0; + public const string IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; + public const string IVRDebug_Version = "IVRDebug_001"; + public const ulong k_ulDisplayRedirectContainer = 25769803779; + public const string IVRProperties_Version = "IVRProperties_001"; + public const string k_pchPathUserHandRight = "/user/hand/right"; + public const string k_pchPathUserHandLeft = "/user/hand/left"; + public const string k_pchPathUserHandPrimary = "/user/hand/primary"; + public const string k_pchPathUserHandSecondary = "/user/hand/secondary"; + public const string k_pchPathUserHead = "/user/head"; + public const string k_pchPathUserGamepad = "/user/gamepad"; + public const string k_pchPathUserTreadmill = "/user/treadmill"; + public const string k_pchPathUserStylus = "/user/stylus"; + public const string k_pchPathDevices = "/devices"; + public const string k_pchPathDevicePath = "/device_path"; + public const string k_pchPathBestAliasPath = "/best_alias_path"; + public const string k_pchPathBoundTrackerAliasPath = "/bound_tracker_path"; + public const string k_pchPathBoundTrackerRole = "/bound_tracker_role"; + public const string k_pchPathPoseRaw = "/pose/raw"; + public const string k_pchPathPoseTip = "/pose/tip"; + public const string k_pchPathSystemButtonClick = "/input/system/click"; + public const string k_pchPathProximity = "/proximity"; + public const string k_pchPathControllerTypePrefix = "/controller_type/"; + public const string k_pchPathInputProfileSuffix = "/input_profile"; + public const string k_pchPathBindingNameSuffix = "/binding_name"; + public const string k_pchPathBindingUrlSuffix = "/binding_url"; + public const string k_pchPathBindingErrorSuffix = "/binding_error"; + public const string k_pchPathActiveActionSets = "/active_action_sets"; + public const string k_pchPathComponentUpdates = "/total_component_updates"; + public const string k_pchPathUserFootLeft = "/user/foot/left"; + public const string k_pchPathUserFootRight = "/user/foot/right"; + public const string k_pchPathUserShoulderLeft = "/user/shoulder/left"; + public const string k_pchPathUserShoulderRight = "/user/shoulder/right"; + public const string k_pchPathUserElbowLeft = "/user/elbow/left"; + public const string k_pchPathUserElbowRight = "/user/elbow/right"; + public const string k_pchPathUserKneeLeft = "/user/knee/left"; + public const string k_pchPathUserKneeRight = "/user/knee/right"; + public const string k_pchPathUserWaist = "/user/waist"; + public const string k_pchPathUserChest = "/user/chest"; + public const string k_pchPathUserCamera = "/user/camera"; + public const string k_pchPathUserKeyboard = "/user/keyboard"; + public const string k_pchPathClientAppKey = "/client_info/app_key"; + public const ulong k_ulInvalidPathHandle = 0; + public const string IVRPaths_Version = "IVRPaths_001"; + public const string IVRBlockQueue_Version = "IVRBlockQueue_004"; static uint VRToken { get; set; } @@ -4169,13 +7794,20 @@ public void Clear() m_pVRChaperone = null; m_pVRChaperoneSetup = null; m_pVRCompositor = null; + m_pVRHeadsetView = null; m_pVROverlay = null; + m_pVROverlayView = null; m_pVRRenderModels = null; m_pVRExtendedDisplay = null; m_pVRSettings = null; m_pVRApplications = null; m_pVRScreenshots = null; m_pVRTrackedCamera = null; + m_pVRInput = null; + m_pVRIOBuffer = null; + m_pVRSpatialAnchors = null; + m_pVRNotifications = null; + m_pVRDebug = null; } void CheckClear() @@ -4239,6 +7871,19 @@ public CVRCompositor VRCompositor() return m_pVRCompositor; } + public CVRHeadsetView VRHeadsetView() + { + CheckClear(); + if (m_pVRHeadsetView == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix+IVRHeadsetView_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRHeadsetView = new CVRHeadsetView(pInterface); + } + return m_pVRHeadsetView; + } + public CVROverlay VROverlay() { CheckClear(); @@ -4252,6 +7897,19 @@ public CVROverlay VROverlay() return m_pVROverlay; } + public CVROverlayView VROverlayView() + { + CheckClear(); + if (m_pVROverlayView == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix+IVROverlayView_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVROverlayView = new CVROverlayView(pInterface); + } + return m_pVROverlayView; + } + public CVRRenderModels VRRenderModels() { CheckClear(); @@ -4330,17 +7988,89 @@ public CVRTrackedCamera VRTrackedCamera() 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; + } + + public CVRIOBuffer VRIOBuffer() + { + CheckClear(); + if (m_pVRIOBuffer == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix + IVRIOBuffer_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRIOBuffer = new CVRIOBuffer(pInterface); + } + return m_pVRIOBuffer; + } + + public CVRSpatialAnchors VRSpatialAnchors() + { + CheckClear(); + if (m_pVRSpatialAnchors == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix + IVRSpatialAnchors_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRSpatialAnchors = new CVRSpatialAnchors(pInterface); + } + return m_pVRSpatialAnchors; + } + + public CVRDebug VRDebug() + { + CheckClear(); + if (m_pVRDebug == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix + IVRDebug_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRDebug = new CVRDebug(pInterface); + } + return m_pVRDebug; + } + + public CVRNotifications VRNotifications() + { + CheckClear(); + if (m_pVRNotifications == null) + { + var eError = EVRInitError.None; + var pInterface = OpenVRInterop.GetGenericInterface(FnTable_Prefix + IVRNotifications_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRNotifications = new CVRNotifications(pInterface); + } + return m_pVRNotifications; + } + private CVRSystem m_pVRSystem; private CVRChaperone m_pVRChaperone; private CVRChaperoneSetup m_pVRChaperoneSetup; private CVRCompositor m_pVRCompositor; + private CVRHeadsetView m_pVRHeadsetView; private CVROverlay m_pVROverlay; + private CVROverlayView m_pVROverlayView; private CVRRenderModels m_pVRRenderModels; private CVRExtendedDisplay m_pVRExtendedDisplay; private CVRSettings m_pVRSettings; private CVRApplications m_pVRApplications; private CVRScreenshots m_pVRScreenshots; private CVRTrackedCamera m_pVRTrackedCamera; + private CVRInput m_pVRInput; + private CVRIOBuffer m_pVRIOBuffer; + private CVRSpatialAnchors m_pVRSpatialAnchors; + private CVRNotifications m_pVRNotifications; + private CVRDebug m_pVRDebug; }; private static COpenVRContext _OpenVRInternal_ModuleContext = null; @@ -4358,18 +8088,34 @@ static COpenVRContext OpenVRInternal_ModuleContext public static CVRChaperone Chaperone { get { return OpenVRInternal_ModuleContext.VRChaperone(); } } public static CVRChaperoneSetup ChaperoneSetup { get { return OpenVRInternal_ModuleContext.VRChaperoneSetup(); } } public static CVRCompositor Compositor { get { return OpenVRInternal_ModuleContext.VRCompositor(); } } + public static CVRHeadsetView HeadsetView { get { return OpenVRInternal_ModuleContext.VRHeadsetView(); } } public static CVROverlay Overlay { get { return OpenVRInternal_ModuleContext.VROverlay(); } } + public static CVROverlayView OverlayView { get { return OpenVRInternal_ModuleContext.VROverlayView(); } } public static CVRRenderModels RenderModels { get { return OpenVRInternal_ModuleContext.VRRenderModels(); } } public static CVRExtendedDisplay ExtendedDisplay { get { return OpenVRInternal_ModuleContext.VRExtendedDisplay(); } } public static CVRSettings Settings { get { return OpenVRInternal_ModuleContext.VRSettings(); } } 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(); } } + public static CVRIOBuffer IOBuffer { get { return OpenVRInternal_ModuleContext.VRIOBuffer(); } } + public static CVRSpatialAnchors SpatialAnchors { get { return OpenVRInternal_ModuleContext.VRSpatialAnchors(); } } + public static CVRNotifications Notifications { get { return OpenVRInternal_ModuleContext.VRNotifications(); } } + public static CVRDebug Debug { get { return OpenVRInternal_ModuleContext.VRDebug(); } } + /** Finds the active installation of vrclient.dll and initializes it */ - public static CVRSystem Init(ref EVRInitError peError, EVRApplicationType eApplicationType = EVRApplicationType.VRApplication_Scene) + public static CVRSystem Init(ref EVRInitError peError, EVRApplicationType eApplicationType = EVRApplicationType.VRApplication_Scene, string pchStartupInfo= "") { - VRToken = InitInternal(ref peError, eApplicationType); + try + { + VRToken = InitInternal2(ref peError, eApplicationType, pchStartupInfo); + } + catch (EntryPointNotFoundException) + { + VRToken = InitInternal(ref peError, eApplicationType); + } + OpenVRInternal_ModuleContext.Clear(); if (peError != EVRInitError.None) diff --git a/ext/OpenVR/headers/openvr_api.json b/ext/OpenVR/headers/openvr_api.json index 98f0497..3cc3ef4 100644 --- a/ext/OpenVR/headers/openvr_api.json +++ b/ext/OpenVR/headers/openvr_api.json @@ -1,18 +1,31 @@ -{"typedefs":[{"typedef": "vr::glSharedTextureHandle_t","type": "void *"} +{"typedefs":[{"typedef": "vr::SpatialAnchorHandle_t","type": "uint32_t"} +,{"typedef": "vr::glSharedTextureHandle_t","type": "void *"} ,{"typedef": "vr::glInt_t","type": "int32_t"} ,{"typedef": "vr::glUInt_t","type": "uint32_t"} +,{"typedef": "vr::SharedTextureHandle_t","type": "uint64_t"} +,{"typedef": "vr::DriverId_t","type": "uint32_t"} ,{"typedef": "vr::TrackedDeviceIndex_t","type": "uint32_t"} +,{"typedef": "vr::WebConsoleHandle_t","type": "uint64_t"} +,{"typedef": "vr::PropertyContainerHandle_t","type": "uint64_t"} +,{"typedef": "vr::PropertyTypeTag_t","type": "uint32_t"} +,{"typedef": "vr::DriverHandle_t","type": "PropertyContainerHandle_t"} +,{"typedef": "vr::VRActionHandle_t","type": "uint64_t"} +,{"typedef": "vr::VRActionSetHandle_t","type": "uint64_t"} +,{"typedef": "vr::VRInputValueHandle_t","type": "uint64_t"} ,{"typedef": "vr::VREvent_Data_t","type": "union VREvent_Data_t"} +,{"typedef": "vr::VRComponentProperties","type": "uint32_t"} ,{"typedef": "vr::VRControllerState_t","type": "struct vr::VRControllerState001_t"} ,{"typedef": "vr::VROverlayHandle_t","type": "uint64_t"} +,{"typedef": "vr::BoneIndex_t","type": "int32_t"} ,{"typedef": "vr::TrackedCameraHandle_t","type": "uint64_t"} ,{"typedef": "vr::ScreenshotHandle_t","type": "uint32_t"} -,{"typedef": "vr::VRComponentProperties","type": "uint32_t"} +,{"typedef": "vr::VROverlayIntersectionMaskPrimitive_Data_t","type": "union VROverlayIntersectionMaskPrimitive_Data_t"} ,{"typedef": "vr::TextureID_t","type": "int32_t"} ,{"typedef": "vr::VRNotificationId","type": "uint32_t"} +,{"typedef": "vr::IOBufferHandle_t","type": "uint64_t"} +,{"typedef": "vr::VrProfilerEventHandle_t","type": "uint64_t"} ,{"typedef": "vr::HmdError","type": "enum vr::EVRInitError"} ,{"typedef": "vr::Hmd_Eye","type": "enum vr::EVREye"} -,{"typedef": "vr::GraphicsAPIConvention","type": "enum vr::EGraphicsAPIConvention"} ,{"typedef": "vr::ColorSpace","type": "enum vr::EColorSpace"} ,{"typedef": "vr::HmdTrackingResult","type": "enum vr::ETrackingResult"} ,{"typedef": "vr::TrackedDeviceClass","type": "enum vr::ETrackedDeviceClass"} @@ -26,15 +39,22 @@ ,{"typedef": "vr::VRFirmwareError","type": "enum vr::EVRFirmwareError"} ,{"typedef": "vr::VRCompositorError","type": "enum vr::EVRCompositorError"} ,{"typedef": "vr::VRScreenshotsError","type": "enum vr::EVRScreenshotError"} +,{"typedef": "vr::PathHandle_t","type": "uint64_t"} ], "enums":[ {"enumname": "vr::EVREye","values": [ {"name": "Eye_Left","value": "0"} ,{"name": "Eye_Right","value": "1"} ]} -, {"enumname": "vr::EGraphicsAPIConvention","values": [ - {"name": "API_DirectX","value": "0"} - ,{"name": "API_OpenGL","value": "1"} +, {"enumname": "vr::ETextureType","values": [ + {"name": "TextureType_Invalid","value": "-1"} + ,{"name": "TextureType_DirectX","value": "0"} + ,{"name": "TextureType_OpenGL","value": "1"} + ,{"name": "TextureType_Vulkan","value": "2"} + ,{"name": "TextureType_IOSurface","value": "3"} + ,{"name": "TextureType_DirectX12","value": "4"} + ,{"name": "TextureType_DXGISharedHandle","value": "5"} + ,{"name": "TextureType_Metal","value": "6"} ]} , {"enumname": "vr::EColorSpace","values": [ {"name": "ColorSpace_Auto","value": "0"} @@ -47,26 +67,40 @@ ,{"name": "TrackingResult_Calibrating_OutOfRange","value": "101"} ,{"name": "TrackingResult_Running_OK","value": "200"} ,{"name": "TrackingResult_Running_OutOfRange","value": "201"} + ,{"name": "TrackingResult_Fallback_RotationOnly","value": "300"} ]} , {"enumname": "vr::ETrackedDeviceClass","values": [ {"name": "TrackedDeviceClass_Invalid","value": "0"} ,{"name": "TrackedDeviceClass_HMD","value": "1"} ,{"name": "TrackedDeviceClass_Controller","value": "2"} + ,{"name": "TrackedDeviceClass_GenericTracker","value": "3"} ,{"name": "TrackedDeviceClass_TrackingReference","value": "4"} - ,{"name": "TrackedDeviceClass_Other","value": "1000"} + ,{"name": "TrackedDeviceClass_DisplayRedirect","value": "5"} + ,{"name": "TrackedDeviceClass_Max","value": "6"} ]} , {"enumname": "vr::ETrackedControllerRole","values": [ {"name": "TrackedControllerRole_Invalid","value": "0"} ,{"name": "TrackedControllerRole_LeftHand","value": "1"} ,{"name": "TrackedControllerRole_RightHand","value": "2"} + ,{"name": "TrackedControllerRole_OptOut","value": "3"} + ,{"name": "TrackedControllerRole_Treadmill","value": "4"} + ,{"name": "TrackedControllerRole_Stylus","value": "5"} + ,{"name": "TrackedControllerRole_Max","value": "5"} ]} , {"enumname": "vr::ETrackingUniverseOrigin","values": [ {"name": "TrackingUniverseSeated","value": "0"} ,{"name": "TrackingUniverseStanding","value": "1"} ,{"name": "TrackingUniverseRawAndUncalibrated","value": "2"} ]} +, {"enumname": "vr::EAdditionalRadioFeatures","values": [ + {"name": "AdditionalRadioFeatures_None","value": "0"} + ,{"name": "AdditionalRadioFeatures_HTCLinkBox","value": "1"} + ,{"name": "AdditionalRadioFeatures_InternalDongle","value": "2"} + ,{"name": "AdditionalRadioFeatures_ExternalDongle","value": "4"} +]} , {"enumname": "vr::ETrackedDeviceProperty","values": [ - {"name": "Prop_TrackingSystemName_String","value": "1000"} + {"name": "Prop_Invalid","value": "0"} + ,{"name": "Prop_TrackingSystemName_String","value": "1000"} ,{"name": "Prop_ModelNumber_String","value": "1001"} ,{"name": "Prop_SerialNumber_String","value": "1002"} ,{"name": "Prop_RenderModelName_String","value": "1003"} @@ -99,6 +133,25 @@ ,{"name": "Prop_HasCamera_Bool","value": "1030"} ,{"name": "Prop_DriverVersion_String","value": "1031"} ,{"name": "Prop_Firmware_ForceUpdateRequired_Bool","value": "1032"} + ,{"name": "Prop_ViveSystemButtonFixRequired_Bool","value": "1033"} + ,{"name": "Prop_ParentDriver_Uint64","value": "1034"} + ,{"name": "Prop_ResourceRoot_String","value": "1035"} + ,{"name": "Prop_RegisteredDeviceType_String","value": "1036"} + ,{"name": "Prop_InputProfilePath_String","value": "1037"} + ,{"name": "Prop_NeverTracked_Bool","value": "1038"} + ,{"name": "Prop_NumCameras_Int32","value": "1039"} + ,{"name": "Prop_CameraFrameLayout_Int32","value": "1040"} + ,{"name": "Prop_CameraStreamFormat_Int32","value": "1041"} + ,{"name": "Prop_AdditionalDeviceSettingsPath_String","value": "1042"} + ,{"name": "Prop_Identifiable_Bool","value": "1043"} + ,{"name": "Prop_BootloaderVersion_Uint64","value": "1044"} + ,{"name": "Prop_AdditionalSystemReportData_String","value": "1045"} + ,{"name": "Prop_CompositeFirmwareVersion_String","value": "1046"} + ,{"name": "Prop_Firmware_RemindUpdate_Bool","value": "1047"} + ,{"name": "Prop_PeripheralApplicationVersion_Uint64","value": "1048"} + ,{"name": "Prop_ManufacturerSerialNumber_String","value": "1049"} + ,{"name": "Prop_ComputedSerialNumber_String","value": "1050"} + ,{"name": "Prop_EstimatedDeviceFirstUseTime_Int32","value": "1051"} ,{"name": "Prop_ReportsTimeSinceVSync_Bool","value": "2000"} ,{"name": "Prop_SecondsFromVsyncToPhotons_Float","value": "2001"} ,{"name": "Prop_DisplayFrequency_Float","value": "2002"} @@ -136,6 +189,68 @@ ,{"name": "Prop_ScreenshotHorizontalFieldOfViewDegrees_Float","value": "2034"} ,{"name": "Prop_ScreenshotVerticalFieldOfViewDegrees_Float","value": "2035"} ,{"name": "Prop_DisplaySuppressed_Bool","value": "2036"} + ,{"name": "Prop_DisplayAllowNightMode_Bool","value": "2037"} + ,{"name": "Prop_DisplayMCImageWidth_Int32","value": "2038"} + ,{"name": "Prop_DisplayMCImageHeight_Int32","value": "2039"} + ,{"name": "Prop_DisplayMCImageNumChannels_Int32","value": "2040"} + ,{"name": "Prop_DisplayMCImageData_Binary","value": "2041"} + ,{"name": "Prop_SecondsFromPhotonsToVblank_Float","value": "2042"} + ,{"name": "Prop_DriverDirectModeSendsVsyncEvents_Bool","value": "2043"} + ,{"name": "Prop_DisplayDebugMode_Bool","value": "2044"} + ,{"name": "Prop_GraphicsAdapterLuid_Uint64","value": "2045"} + ,{"name": "Prop_DriverProvidedChaperonePath_String","value": "2048"} + ,{"name": "Prop_ExpectedTrackingReferenceCount_Int32","value": "2049"} + ,{"name": "Prop_ExpectedControllerCount_Int32","value": "2050"} + ,{"name": "Prop_NamedIconPathControllerLeftDeviceOff_String","value": "2051"} + ,{"name": "Prop_NamedIconPathControllerRightDeviceOff_String","value": "2052"} + ,{"name": "Prop_NamedIconPathTrackingReferenceDeviceOff_String","value": "2053"} + ,{"name": "Prop_DoNotApplyPrediction_Bool","value": "2054"} + ,{"name": "Prop_CameraToHeadTransforms_Matrix34_Array","value": "2055"} + ,{"name": "Prop_DistortionMeshResolution_Int32","value": "2056"} + ,{"name": "Prop_DriverIsDrawingControllers_Bool","value": "2057"} + ,{"name": "Prop_DriverRequestsApplicationPause_Bool","value": "2058"} + ,{"name": "Prop_DriverRequestsReducedRendering_Bool","value": "2059"} + ,{"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_ConfigurationIncludesLighthouse20Features_Bool","value": "2069"} + ,{"name": "Prop_AdditionalRadioFeatures_Uint64","value": "2070"} + ,{"name": "Prop_CameraWhiteBalance_Vector4_Array","value": "2071"} + ,{"name": "Prop_CameraDistortionFunction_Int32_Array","value": "2072"} + ,{"name": "Prop_CameraDistortionCoefficients_Float_Array","value": "2073"} + ,{"name": "Prop_ExpectedControllerType_String","value": "2074"} + ,{"name": "Prop_HmdTrackingStyle_Int32","value": "2075"} + ,{"name": "Prop_DriverProvidedChaperoneVisibility_Bool","value": "2076"} + ,{"name": "Prop_HmdColumnCorrectionSettingPrefix_String","value": "2077"} + ,{"name": "Prop_CameraSupportsCompatibilityModes_Bool","value": "2078"} + ,{"name": "Prop_DisplayAvailableFrameRates_Float_Array","value": "2080"} + ,{"name": "Prop_DisplaySupportsMultipleFramerates_Bool","value": "2081"} + ,{"name": "Prop_DisplayColorMultLeft_Vector3","value": "2082"} + ,{"name": "Prop_DisplayColorMultRight_Vector3","value": "2083"} + ,{"name": "Prop_DisplaySupportsRuntimeFramerateChange_Bool","value": "2084"} + ,{"name": "Prop_DisplaySupportsAnalogGain_Bool","value": "2085"} + ,{"name": "Prop_DisplayMinAnalogGain_Float","value": "2086"} + ,{"name": "Prop_DisplayMaxAnalogGain_Float","value": "2087"} + ,{"name": "Prop_DashboardScale_Float","value": "2091"} + ,{"name": "Prop_IpdUIRangeMinMeters_Float","value": "2100"} + ,{"name": "Prop_IpdUIRangeMaxMeters_Float","value": "2101"} + ,{"name": "Prop_DriverRequestedMuraCorrectionMode_Int32","value": "2200"} + ,{"name": "Prop_DriverRequestedMuraFeather_InnerLeft_Int32","value": "2201"} + ,{"name": "Prop_DriverRequestedMuraFeather_InnerRight_Int32","value": "2202"} + ,{"name": "Prop_DriverRequestedMuraFeather_InnerTop_Int32","value": "2203"} + ,{"name": "Prop_DriverRequestedMuraFeather_InnerBottom_Int32","value": "2204"} + ,{"name": "Prop_DriverRequestedMuraFeather_OuterLeft_Int32","value": "2205"} + ,{"name": "Prop_DriverRequestedMuraFeather_OuterRight_Int32","value": "2206"} + ,{"name": "Prop_DriverRequestedMuraFeather_OuterTop_Int32","value": "2207"} + ,{"name": "Prop_DriverRequestedMuraFeather_OuterBottom_Int32","value": "2208"} + ,{"name": "Prop_Audio_DefaultPlaybackDeviceId_String","value": "2300"} + ,{"name": "Prop_Audio_DefaultRecordingDeviceId_String","value": "2301"} + ,{"name": "Prop_Audio_DefaultPlaybackDeviceVolume_Float","value": "2302"} ,{"name": "Prop_AttachedDeviceId_String","value": "3000"} ,{"name": "Prop_SupportedButtons_Uint64","value": "3001"} ,{"name": "Prop_Axis0Type_Int32","value": "3002"} @@ -151,8 +266,35 @@ ,{"name": "Prop_TrackingRangeMinimumMeters_Float","value": "4004"} ,{"name": "Prop_TrackingRangeMaximumMeters_Float","value": "4005"} ,{"name": "Prop_ModeLabel_String","value": "4006"} + ,{"name": "Prop_CanWirelessIdentify_Bool","value": "4007"} + ,{"name": "Prop_Nonce_Int32","value": "4008"} + ,{"name": "Prop_IconPathName_String","value": "5000"} + ,{"name": "Prop_NamedIconPathDeviceOff_String","value": "5001"} + ,{"name": "Prop_NamedIconPathDeviceSearching_String","value": "5002"} + ,{"name": "Prop_NamedIconPathDeviceSearchingAlert_String","value": "5003"} + ,{"name": "Prop_NamedIconPathDeviceReady_String","value": "5004"} + ,{"name": "Prop_NamedIconPathDeviceReadyAlert_String","value": "5005"} + ,{"name": "Prop_NamedIconPathDeviceNotReady_String","value": "5006"} + ,{"name": "Prop_NamedIconPathDeviceStandby_String","value": "5007"} + ,{"name": "Prop_NamedIconPathDeviceAlertLow_String","value": "5008"} + ,{"name": "Prop_NamedIconPathDeviceStandbyAlert_String","value": "5009"} + ,{"name": "Prop_DisplayHiddenArea_Binary_Start","value": "5100"} + ,{"name": "Prop_DisplayHiddenArea_Binary_End","value": "5150"} + ,{"name": "Prop_ParentContainer","value": "5151"} + ,{"name": "Prop_OverrideContainer_Uint64","value": "5152"} + ,{"name": "Prop_UserConfigPath_String","value": "6000"} + ,{"name": "Prop_InstallPath_String","value": "6001"} + ,{"name": "Prop_HasDisplayComponent_Bool","value": "6002"} + ,{"name": "Prop_HasControllerComponent_Bool","value": "6003"} + ,{"name": "Prop_HasCameraComponent_Bool","value": "6004"} + ,{"name": "Prop_HasDriverDirectModeComponent_Bool","value": "6005"} + ,{"name": "Prop_HasVirtualDisplayComponent_Bool","value": "6006"} + ,{"name": "Prop_HasSpatialAnchorsSupport_Bool","value": "6007"} + ,{"name": "Prop_ControllerType_String","value": "7000"} + ,{"name": "Prop_ControllerHandSelectionPriority_Int32","value": "7002"} ,{"name": "Prop_VendorSpecific_Reserved_Start","value": "10000"} ,{"name": "Prop_VendorSpecific_Reserved_End","value": "10999"} + ,{"name": "Prop_TrackedDeviceProperty_Max","value": "1000000"} ]} , {"enumname": "vr::ETrackedPropertyError","values": [ {"name": "TrackedProp_Success","value": "0"} @@ -165,11 +307,28 @@ ,{"name": "TrackedProp_ValueNotProvidedByDevice","value": "7"} ,{"name": "TrackedProp_StringExceedsMaximumLength","value": "8"} ,{"name": "TrackedProp_NotYetAvailable","value": "9"} + ,{"name": "TrackedProp_PermissionDenied","value": "10"} + ,{"name": "TrackedProp_InvalidOperation","value": "11"} + ,{"name": "TrackedProp_CannotWriteToWildcards","value": "12"} + ,{"name": "TrackedProp_IPCReadFailure","value": "13"} + ,{"name": "TrackedProp_OutOfMemory","value": "14"} + ,{"name": "TrackedProp_InvalidContainer","value": "15"} +]} +, {"enumname": "vr::EHmdTrackingStyle","values": [ + {"name": "HmdTrackingStyle_Unknown","value": "0"} + ,{"name": "HmdTrackingStyle_Lighthouse","value": "1"} + ,{"name": "HmdTrackingStyle_OutsideInCameras","value": "2"} + ,{"name": "HmdTrackingStyle_InsideOutCameras","value": "3"} ]} , {"enumname": "vr::EVRSubmitFlags","values": [ {"name": "Submit_Default","value": "0"} ,{"name": "Submit_LensDistortionAlreadyApplied","value": "1"} ,{"name": "Submit_GlRenderBuffer","value": "2"} + ,{"name": "Submit_Reserved","value": "4"} + ,{"name": "Submit_TextureWithPose","value": "8"} + ,{"name": "Submit_TextureWithDepth","value": "16"} + ,{"name": "Submit_FrameDiscontinuty","value": "32"} + ,{"name": "Submit_VulkanTextureWithArrayData","value": "64"} ]} , {"enumname": "vr::EVRState","values": [ {"name": "VRState_Undefined","value": "-1"} @@ -194,94 +353,153 @@ ,{"name": "VREvent_LeaveStandbyMode","value": "107"} ,{"name": "VREvent_TrackedDeviceRoleChanged","value": "108"} ,{"name": "VREvent_WatchdogWakeUpRequested","value": "109"} + ,{"name": "VREvent_LensDistortionChanged","value": "110"} + ,{"name": "VREvent_PropertyChanged","value": "111"} + ,{"name": "VREvent_WirelessDisconnect","value": "112"} + ,{"name": "VREvent_WirelessReconnect","value": "113"} ,{"name": "VREvent_ButtonPress","value": "200"} ,{"name": "VREvent_ButtonUnpress","value": "201"} ,{"name": "VREvent_ButtonTouch","value": "202"} ,{"name": "VREvent_ButtonUntouch","value": "203"} + ,{"name": "VREvent_Modal_Cancel","value": "257"} ,{"name": "VREvent_MouseMove","value": "300"} ,{"name": "VREvent_MouseButtonDown","value": "301"} ,{"name": "VREvent_MouseButtonUp","value": "302"} ,{"name": "VREvent_FocusEnter","value": "303"} ,{"name": "VREvent_FocusLeave","value": "304"} - ,{"name": "VREvent_Scroll","value": "305"} + ,{"name": "VREvent_ScrollDiscrete","value": "305"} ,{"name": "VREvent_TouchPadMove","value": "306"} ,{"name": "VREvent_OverlayFocusChanged","value": "307"} + ,{"name": "VREvent_ReloadOverlays","value": "308"} + ,{"name": "VREvent_ScrollSmooth","value": "309"} + ,{"name": "VREvent_LockMousePosition","value": "310"} + ,{"name": "VREvent_UnlockMousePosition","value": "311"} ,{"name": "VREvent_InputFocusCaptured","value": "400"} ,{"name": "VREvent_InputFocusReleased","value": "401"} - ,{"name": "VREvent_SceneFocusLost","value": "402"} - ,{"name": "VREvent_SceneFocusGained","value": "403"} ,{"name": "VREvent_SceneApplicationChanged","value": "404"} ,{"name": "VREvent_SceneFocusChanged","value": "405"} ,{"name": "VREvent_InputFocusChanged","value": "406"} - ,{"name": "VREvent_SceneApplicationSecondaryRenderingStarted","value": "407"} + ,{"name": "VREvent_SceneApplicationUsingWrongGraphicsAdapter","value": "408"} + ,{"name": "VREvent_ActionBindingReloaded","value": "409"} ,{"name": "VREvent_HideRenderModels","value": "410"} ,{"name": "VREvent_ShowRenderModels","value": "411"} + ,{"name": "VREvent_SceneApplicationStateChanged","value": "412"} + ,{"name": "VREvent_ConsoleOpened","value": "420"} + ,{"name": "VREvent_ConsoleClosed","value": "421"} ,{"name": "VREvent_OverlayShown","value": "500"} ,{"name": "VREvent_OverlayHidden","value": "501"} ,{"name": "VREvent_DashboardActivated","value": "502"} ,{"name": "VREvent_DashboardDeactivated","value": "503"} - ,{"name": "VREvent_DashboardThumbSelected","value": "504"} ,{"name": "VREvent_DashboardRequested","value": "505"} ,{"name": "VREvent_ResetDashboard","value": "506"} - ,{"name": "VREvent_RenderToast","value": "507"} ,{"name": "VREvent_ImageLoaded","value": "508"} ,{"name": "VREvent_ShowKeyboard","value": "509"} ,{"name": "VREvent_HideKeyboard","value": "510"} ,{"name": "VREvent_OverlayGamepadFocusGained","value": "511"} ,{"name": "VREvent_OverlayGamepadFocusLost","value": "512"} ,{"name": "VREvent_OverlaySharedTextureChanged","value": "513"} - ,{"name": "VREvent_DashboardGuideButtonDown","value": "514"} - ,{"name": "VREvent_DashboardGuideButtonUp","value": "515"} ,{"name": "VREvent_ScreenshotTriggered","value": "516"} ,{"name": "VREvent_ImageFailed","value": "517"} + ,{"name": "VREvent_DashboardOverlayCreated","value": "518"} + ,{"name": "VREvent_SwitchGamepadFocus","value": "519"} ,{"name": "VREvent_RequestScreenshot","value": "520"} ,{"name": "VREvent_ScreenshotTaken","value": "521"} ,{"name": "VREvent_ScreenshotFailed","value": "522"} ,{"name": "VREvent_SubmitScreenshotToDashboard","value": "523"} ,{"name": "VREvent_ScreenshotProgressToDashboard","value": "524"} + ,{"name": "VREvent_PrimaryDashboardDeviceChanged","value": "525"} + ,{"name": "VREvent_RoomViewShown","value": "526"} + ,{"name": "VREvent_RoomViewHidden","value": "527"} + ,{"name": "VREvent_ShowUI","value": "528"} + ,{"name": "VREvent_ShowDevTools","value": "529"} ,{"name": "VREvent_Notification_Shown","value": "600"} ,{"name": "VREvent_Notification_Hidden","value": "601"} ,{"name": "VREvent_Notification_BeginInteraction","value": "602"} ,{"name": "VREvent_Notification_Destroyed","value": "603"} ,{"name": "VREvent_Quit","value": "700"} ,{"name": "VREvent_ProcessQuit","value": "701"} - ,{"name": "VREvent_QuitAborted_UserPrompt","value": "702"} ,{"name": "VREvent_QuitAcknowledged","value": "703"} ,{"name": "VREvent_DriverRequestedQuit","value": "704"} + ,{"name": "VREvent_RestartRequested","value": "705"} ,{"name": "VREvent_ChaperoneDataHasChanged","value": "800"} ,{"name": "VREvent_ChaperoneUniverseHasChanged","value": "801"} ,{"name": "VREvent_ChaperoneTempDataHasChanged","value": "802"} ,{"name": "VREvent_ChaperoneSettingsHaveChanged","value": "803"} ,{"name": "VREvent_SeatedZeroPoseReset","value": "804"} + ,{"name": "VREvent_ChaperoneFlushCache","value": "805"} + ,{"name": "VREvent_ChaperoneRoomSetupStarting","value": "806"} + ,{"name": "VREvent_ChaperoneRoomSetupFinished","value": "807"} ,{"name": "VREvent_AudioSettingsHaveChanged","value": "820"} ,{"name": "VREvent_BackgroundSettingHasChanged","value": "850"} ,{"name": "VREvent_CameraSettingsHaveChanged","value": "851"} ,{"name": "VREvent_ReprojectionSettingHasChanged","value": "852"} ,{"name": "VREvent_ModelSkinSettingsHaveChanged","value": "853"} ,{"name": "VREvent_EnvironmentSettingsHaveChanged","value": "854"} + ,{"name": "VREvent_PowerSettingsHaveChanged","value": "855"} + ,{"name": "VREvent_EnableHomeAppSettingsHaveChanged","value": "856"} + ,{"name": "VREvent_SteamVRSectionSettingChanged","value": "857"} + ,{"name": "VREvent_LighthouseSectionSettingChanged","value": "858"} + ,{"name": "VREvent_NullSectionSettingChanged","value": "859"} + ,{"name": "VREvent_UserInterfaceSectionSettingChanged","value": "860"} + ,{"name": "VREvent_NotificationsSectionSettingChanged","value": "861"} + ,{"name": "VREvent_KeyboardSectionSettingChanged","value": "862"} + ,{"name": "VREvent_PerfSectionSettingChanged","value": "863"} + ,{"name": "VREvent_DashboardSectionSettingChanged","value": "864"} + ,{"name": "VREvent_WebInterfaceSectionSettingChanged","value": "865"} + ,{"name": "VREvent_TrackersSectionSettingChanged","value": "866"} + ,{"name": "VREvent_LastKnownSectionSettingChanged","value": "867"} + ,{"name": "VREvent_DismissedWarningsSectionSettingChanged","value": "868"} + ,{"name": "VREvent_GpuSpeedSectionSettingChanged","value": "869"} + ,{"name": "VREvent_WindowsMRSectionSettingChanged","value": "870"} + ,{"name": "VREvent_OtherSectionSettingChanged","value": "871"} ,{"name": "VREvent_StatusUpdate","value": "900"} + ,{"name": "VREvent_WebInterface_InstallDriverCompleted","value": "950"} ,{"name": "VREvent_MCImageUpdated","value": "1000"} ,{"name": "VREvent_FirmwareUpdateStarted","value": "1100"} ,{"name": "VREvent_FirmwareUpdateFinished","value": "1101"} ,{"name": "VREvent_KeyboardClosed","value": "1200"} ,{"name": "VREvent_KeyboardCharInput","value": "1201"} ,{"name": "VREvent_KeyboardDone","value": "1202"} - ,{"name": "VREvent_ApplicationTransitionStarted","value": "1300"} - ,{"name": "VREvent_ApplicationTransitionAborted","value": "1301"} - ,{"name": "VREvent_ApplicationTransitionNewAppStarted","value": "1302"} ,{"name": "VREvent_ApplicationListUpdated","value": "1303"} ,{"name": "VREvent_ApplicationMimeTypeLoad","value": "1304"} - ,{"name": "VREvent_Compositor_MirrorWindowShown","value": "1400"} - ,{"name": "VREvent_Compositor_MirrorWindowHidden","value": "1401"} + ,{"name": "VREvent_ProcessConnected","value": "1306"} + ,{"name": "VREvent_ProcessDisconnected","value": "1307"} ,{"name": "VREvent_Compositor_ChaperoneBoundsShown","value": "1410"} ,{"name": "VREvent_Compositor_ChaperoneBoundsHidden","value": "1411"} + ,{"name": "VREvent_Compositor_DisplayDisconnected","value": "1412"} + ,{"name": "VREvent_Compositor_DisplayReconnected","value": "1413"} + ,{"name": "VREvent_Compositor_HDCPError","value": "1414"} + ,{"name": "VREvent_Compositor_ApplicationNotResponding","value": "1415"} + ,{"name": "VREvent_Compositor_ApplicationResumed","value": "1416"} + ,{"name": "VREvent_Compositor_OutOfVideoMemory","value": "1417"} + ,{"name": "VREvent_Compositor_DisplayModeNotSupported","value": "1418"} + ,{"name": "VREvent_Compositor_StageOverrideReady","value": "1419"} ,{"name": "VREvent_TrackedCamera_StartVideoStream","value": "1500"} ,{"name": "VREvent_TrackedCamera_StopVideoStream","value": "1501"} ,{"name": "VREvent_TrackedCamera_PauseVideoStream","value": "1502"} ,{"name": "VREvent_TrackedCamera_ResumeVideoStream","value": "1503"} + ,{"name": "VREvent_TrackedCamera_EditingSurface","value": "1550"} ,{"name": "VREvent_PerformanceTest_EnableCapture","value": "1600"} ,{"name": "VREvent_PerformanceTest_DisableCapture","value": "1601"} ,{"name": "VREvent_PerformanceTest_FidelityLevel","value": "1602"} + ,{"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_Input_ActionManifestReloaded","value": "1703"} + ,{"name": "VREvent_Input_ActionManifestLoadFailed","value": "1704"} + ,{"name": "VREvent_Input_ProgressUpdate","value": "1705"} + ,{"name": "VREvent_Input_TrackerActivated","value": "1706"} + ,{"name": "VREvent_Input_BindingsUpdated","value": "1707"} + ,{"name": "VREvent_Input_BindingSubscriptionChanged","value": "1708"} + ,{"name": "VREvent_SpatialAnchors_PoseUpdated","value": "1800"} + ,{"name": "VREvent_SpatialAnchors_DescriptorUpdated","value": "1801"} + ,{"name": "VREvent_SpatialAnchors_RequestPoseUpdate","value": "1802"} + ,{"name": "VREvent_SpatialAnchors_RequestDescriptorUpdate","value": "1803"} + ,{"name": "VREvent_SystemReport_Started","value": "1900"} + ,{"name": "VREvent_Monitor_ShowHeadsetView","value": "2000"} + ,{"name": "VREvent_Monitor_HideHeadsetView","value": "2001"} ,{"name": "VREvent_VendorSpecific_Reserved_Start","value": "10000"} ,{"name": "VREvent_VendorSpecific_Reserved_End","value": "19999"} ]} @@ -291,6 +509,7 @@ ,{"name": "k_EDeviceActivityLevel_UserInteraction","value": "1"} ,{"name": "k_EDeviceActivityLevel_UserInteraction_Timeout","value": "2"} ,{"name": "k_EDeviceActivityLevel_Standby","value": "3"} + ,{"name": "k_EDeviceActivityLevel_Idle_Timeout","value": "4"} ]} , {"enumname": "vr::EVRButtonId","values": [ {"name": "k_EButton_System","value": "0"} @@ -301,6 +520,7 @@ ,{"name": "k_EButton_DPad_Right","value": "5"} ,{"name": "k_EButton_DPad_Down","value": "6"} ,{"name": "k_EButton_A","value": "7"} + ,{"name": "k_EButton_ProximitySensor","value": "31"} ,{"name": "k_EButton_Axis0","value": "32"} ,{"name": "k_EButton_Axis1","value": "33"} ,{"name": "k_EButton_Axis2","value": "34"} @@ -309,6 +529,9 @@ ,{"name": "k_EButton_SteamVR_Touchpad","value": "32"} ,{"name": "k_EButton_SteamVR_Trigger","value": "33"} ,{"name": "k_EButton_Dashboard_Back","value": "2"} + ,{"name": "k_EButton_IndexController_A","value": "2"} + ,{"name": "k_EButton_IndexController_B","value": "1"} + ,{"name": "k_EButton_IndexController_JoyStick","value": "35"} ,{"name": "k_EButton_Max","value": "64"} ]} , {"enumname": "vr::EVRMouseButton","values": [ @@ -316,6 +539,75 @@ ,{"name": "VRMouseButton_Right","value": "2"} ,{"name": "VRMouseButton_Middle","value": "4"} ]} +, {"enumname": "vr::EShowUIType","values": [ + {"name": "ShowUI_ControllerBinding","value": "0"} + ,{"name": "ShowUI_ManageTrackers","value": "1"} + ,{"name": "ShowUI_Pairing","value": "3"} + ,{"name": "ShowUI_Settings","value": "4"} + ,{"name": "ShowUI_DebugCommands","value": "5"} + ,{"name": "ShowUI_FullControllerBinding","value": "6"} + ,{"name": "ShowUI_ManageDrivers","value": "7"} +]} +, {"enumname": "vr::EHDCPError","values": [ + {"name": "HDCPError_None","value": "0"} + ,{"name": "HDCPError_LinkLost","value": "1"} + ,{"name": "HDCPError_Tampered","value": "2"} + ,{"name": "HDCPError_DeviceRevoked","value": "3"} + ,{"name": "HDCPError_Unknown","value": "4"} +]} +, {"enumname": "vr::EVRComponentProperty","values": [ + {"name": "VRComponentProperty_IsStatic","value": "1"} + ,{"name": "VRComponentProperty_IsVisible","value": "2"} + ,{"name": "VRComponentProperty_IsTouched","value": "4"} + ,{"name": "VRComponentProperty_IsPressed","value": "8"} + ,{"name": "VRComponentProperty_IsScrolled","value": "16"} + ,{"name": "VRComponentProperty_IsHighlighted","value": "32"} +]} +, {"enumname": "vr::EVRInputError","values": [ + {"name": "VRInputError_None","value": "0"} + ,{"name": "VRInputError_NameNotFound","value": "1"} + ,{"name": "VRInputError_WrongType","value": "2"} + ,{"name": "VRInputError_InvalidHandle","value": "3"} + ,{"name": "VRInputError_InvalidParam","value": "4"} + ,{"name": "VRInputError_NoSteam","value": "5"} + ,{"name": "VRInputError_MaxCapacityReached","value": "6"} + ,{"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"} + ,{"name": "VRInputError_MissingSkeletonData","value": "16"} + ,{"name": "VRInputError_InvalidBoneIndex","value": "17"} + ,{"name": "VRInputError_InvalidPriority","value": "18"} + ,{"name": "VRInputError_PermissionDenied","value": "19"} + ,{"name": "VRInputError_InvalidRenderModel","value": "20"} +]} +, {"enumname": "vr::EVRSpatialAnchorError","values": [ + {"name": "VRSpatialAnchorError_Success","value": "0"} + ,{"name": "VRSpatialAnchorError_Internal","value": "1"} + ,{"name": "VRSpatialAnchorError_UnknownHandle","value": "2"} + ,{"name": "VRSpatialAnchorError_ArrayTooSmall","value": "3"} + ,{"name": "VRSpatialAnchorError_InvalidDescriptorChar","value": "4"} + ,{"name": "VRSpatialAnchorError_NotYetAvailable","value": "5"} + ,{"name": "VRSpatialAnchorError_NotAvailableInThisUniverse","value": "6"} + ,{"name": "VRSpatialAnchorError_PermanentlyUnavailable","value": "7"} + ,{"name": "VRSpatialAnchorError_WrongDriver","value": "8"} + ,{"name": "VRSpatialAnchorError_DescriptorTooLong","value": "9"} + ,{"name": "VRSpatialAnchorError_Unknown","value": "10"} + ,{"name": "VRSpatialAnchorError_NoRoomCalibration","value": "11"} + ,{"name": "VRSpatialAnchorError_InvalidArgument","value": "12"} + ,{"name": "VRSpatialAnchorError_UnknownDriver","value": "13"} +]} +, {"enumname": "vr::EHiddenAreaMeshType","values": [ + {"name": "k_eHiddenAreaMesh_Standard","value": "0"} + ,{"name": "k_eHiddenAreaMesh_Inverse","value": "1"} + ,{"name": "k_eHiddenAreaMesh_LineLoop","value": "2"} + ,{"name": "k_eHiddenAreaMesh_Max","value": "3"} +]} , {"enumname": "vr::EVRControllerAxisType","values": [ {"name": "k_eControllerAxis_None","value": "0"} ,{"name": "k_eControllerAxis_TrackPad","value": "1"} @@ -352,8 +644,13 @@ ,{"name": "VROverlayError_RequestFailed","value": "23"} ,{"name": "VROverlayError_InvalidTexture","value": "24"} ,{"name": "VROverlayError_UnableToLoadFile","value": "25"} - ,{"name": "VROVerlayError_KeyboardAlreadyInUse","value": "26"} + ,{"name": "VROverlayError_KeyboardAlreadyInUse","value": "26"} ,{"name": "VROverlayError_NoNeighbor","value": "27"} + ,{"name": "VROverlayError_TooManyMaskPrimitives","value": "29"} + ,{"name": "VROverlayError_BadMaskPrimitive","value": "30"} + ,{"name": "VROverlayError_TextureAlreadyLocked","value": "31"} + ,{"name": "VROverlayError_TextureLockCapacityReached","value": "32"} + ,{"name": "VROverlayError_TextureNotLocked","value": "33"} ]} , {"enumname": "vr::EVRApplicationType","values": [ {"name": "VRApplication_Other","value": "0"} @@ -363,7 +660,9 @@ ,{"name": "VRApplication_Utility","value": "4"} ,{"name": "VRApplication_VRMonitor","value": "5"} ,{"name": "VRApplication_SteamWatchdog","value": "6"} - ,{"name": "VRApplication_Max","value": "7"} + ,{"name": "VRApplication_Bootstrapper","value": "7"} + ,{"name": "VRApplication_WebHelper","value": "8"} + ,{"name": "VRApplication_Max","value": "9"} ]} , {"enumname": "vr::EVRFirmwareError","values": [ {"name": "VRFirmwareError_None","value": "0"} @@ -377,6 +676,17 @@ ,{"name": "VRNotificationError_InvalidOverlayHandle","value": "102"} ,{"name": "VRNotificationError_SystemWithUserValueAlreadyExists","value": "103"} ]} +, {"enumname": "vr::EVRSkeletalMotionRange","values": [ + {"name": "VRSkeletalMotionRange_WithController","value": "0"} + ,{"name": "VRSkeletalMotionRange_WithoutController","value": "1"} +]} +, {"enumname": "vr::EVRSkeletalTrackingLevel","values": [ + {"name": "VRSkeletalTracking_Estimated","value": "0"} + ,{"name": "VRSkeletalTracking_Partial","value": "1"} + ,{"name": "VRSkeletalTracking_Full","value": "2"} + ,{"name": "VRSkeletalTrackingLevel_Count","value": "3"} + ,{"name": "VRSkeletalTrackingLevel_Max","value": "2"} +]} , {"enumname": "vr::EVRInitError","values": [ {"name": "VRInitError_None","value": "0"} ,{"name": "VRInitError_Unknown","value": "1"} @@ -413,6 +723,20 @@ ,{"name": "VRInitError_Init_InvalidApplicationType","value": "130"} ,{"name": "VRInitError_Init_NotAvailableToWatchdogApps","value": "131"} ,{"name": "VRInitError_Init_WatchdogDisabledInSettings","value": "132"} + ,{"name": "VRInitError_Init_VRDashboardNotFound","value": "133"} + ,{"name": "VRInitError_Init_VRDashboardStartupFailed","value": "134"} + ,{"name": "VRInitError_Init_VRHomeNotFound","value": "135"} + ,{"name": "VRInitError_Init_VRHomeStartupFailed","value": "136"} + ,{"name": "VRInitError_Init_RebootingBusy","value": "137"} + ,{"name": "VRInitError_Init_FirmwareUpdateBusy","value": "138"} + ,{"name": "VRInitError_Init_FirmwareRecoveryBusy","value": "139"} + ,{"name": "VRInitError_Init_USBServiceBusy","value": "140"} + ,{"name": "VRInitError_Init_VRWebHelperStartupFailed","value": "141"} + ,{"name": "VRInitError_Init_TrackerManagerInitFailed","value": "142"} + ,{"name": "VRInitError_Init_AlreadyRunning","value": "143"} + ,{"name": "VRInitError_Init_FailedForVrMonitor","value": "144"} + ,{"name": "VRInitError_Init_PropertyManagerInitFailed","value": "145"} + ,{"name": "VRInitError_Init_WebServerFailed","value": "146"} ,{"name": "VRInitError_Driver_Failed","value": "200"} ,{"name": "VRInitError_Driver_Unknown","value": "201"} ,{"name": "VRInitError_Driver_HmdUnknown","value": "202"} @@ -425,6 +749,7 @@ ,{"name": "VRInitError_Driver_TrackedDeviceInterfaceUnknown","value": "209"} ,{"name": "VRInitError_Driver_HmdDriverIdOutOfBounds","value": "211"} ,{"name": "VRInitError_Driver_HmdDisplayMirrored","value": "212"} + ,{"name": "VRInitError_Driver_HmdDisplayNotFoundLaptop","value": "213"} ,{"name": "VRInitError_IPC_ServerInitFailed","value": "300"} ,{"name": "VRInitError_IPC_ConnectFailed","value": "301"} ,{"name": "VRInitError_IPC_SharedStateInitFailed","value": "302"} @@ -434,12 +759,101 @@ ,{"name": "VRInitError_IPC_CompositorConnectFailed","value": "306"} ,{"name": "VRInitError_IPC_CompositorInvalidConnectResponse","value": "307"} ,{"name": "VRInitError_IPC_ConnectFailedAfterMultipleAttempts","value": "308"} + ,{"name": "VRInitError_IPC_ConnectFailedAfterTargetExited","value": "309"} + ,{"name": "VRInitError_IPC_NamespaceUnavailable","value": "310"} ,{"name": "VRInitError_Compositor_Failed","value": "400"} ,{"name": "VRInitError_Compositor_D3D11HardwareRequired","value": "401"} ,{"name": "VRInitError_Compositor_FirmwareRequiresUpdate","value": "402"} ,{"name": "VRInitError_Compositor_OverlayInitFailed","value": "403"} ,{"name": "VRInitError_Compositor_ScreenshotsInitFailed","value": "404"} + ,{"name": "VRInitError_Compositor_UnableToCreateDevice","value": "405"} + ,{"name": "VRInitError_Compositor_SharedStateIsNull","value": "406"} + ,{"name": "VRInitError_Compositor_NotificationManagerIsNull","value": "407"} + ,{"name": "VRInitError_Compositor_ResourceManagerClientIsNull","value": "408"} + ,{"name": "VRInitError_Compositor_MessageOverlaySharedStateInitFailure","value": "409"} + ,{"name": "VRInitError_Compositor_PropertiesInterfaceIsNull","value": "410"} + ,{"name": "VRInitError_Compositor_CreateFullscreenWindowFailed","value": "411"} + ,{"name": "VRInitError_Compositor_SettingsInterfaceIsNull","value": "412"} + ,{"name": "VRInitError_Compositor_FailedToShowWindow","value": "413"} + ,{"name": "VRInitError_Compositor_DistortInterfaceIsNull","value": "414"} + ,{"name": "VRInitError_Compositor_DisplayFrequencyFailure","value": "415"} + ,{"name": "VRInitError_Compositor_RendererInitializationFailed","value": "416"} + ,{"name": "VRInitError_Compositor_DXGIFactoryInterfaceIsNull","value": "417"} + ,{"name": "VRInitError_Compositor_DXGIFactoryCreateFailed","value": "418"} + ,{"name": "VRInitError_Compositor_DXGIFactoryQueryFailed","value": "419"} + ,{"name": "VRInitError_Compositor_InvalidAdapterDesktop","value": "420"} + ,{"name": "VRInitError_Compositor_InvalidHmdAttachment","value": "421"} + ,{"name": "VRInitError_Compositor_InvalidOutputDesktop","value": "422"} + ,{"name": "VRInitError_Compositor_InvalidDeviceProvided","value": "423"} + ,{"name": "VRInitError_Compositor_D3D11RendererInitializationFailed","value": "424"} + ,{"name": "VRInitError_Compositor_FailedToFindDisplayMode","value": "425"} + ,{"name": "VRInitError_Compositor_FailedToCreateSwapChain","value": "426"} + ,{"name": "VRInitError_Compositor_FailedToGetBackBuffer","value": "427"} + ,{"name": "VRInitError_Compositor_FailedToCreateRenderTarget","value": "428"} + ,{"name": "VRInitError_Compositor_FailedToCreateDXGI2SwapChain","value": "429"} + ,{"name": "VRInitError_Compositor_FailedtoGetDXGI2BackBuffer","value": "430"} + ,{"name": "VRInitError_Compositor_FailedToCreateDXGI2RenderTarget","value": "431"} + ,{"name": "VRInitError_Compositor_FailedToGetDXGIDeviceInterface","value": "432"} + ,{"name": "VRInitError_Compositor_SelectDisplayMode","value": "433"} + ,{"name": "VRInitError_Compositor_FailedToCreateNvAPIRenderTargets","value": "434"} + ,{"name": "VRInitError_Compositor_NvAPISetDisplayMode","value": "435"} + ,{"name": "VRInitError_Compositor_FailedToCreateDirectModeDisplay","value": "436"} + ,{"name": "VRInitError_Compositor_InvalidHmdPropertyContainer","value": "437"} + ,{"name": "VRInitError_Compositor_UpdateDisplayFrequency","value": "438"} + ,{"name": "VRInitError_Compositor_CreateRasterizerState","value": "439"} + ,{"name": "VRInitError_Compositor_CreateWireframeRasterizerState","value": "440"} + ,{"name": "VRInitError_Compositor_CreateSamplerState","value": "441"} + ,{"name": "VRInitError_Compositor_CreateClampToBorderSamplerState","value": "442"} + ,{"name": "VRInitError_Compositor_CreateAnisoSamplerState","value": "443"} + ,{"name": "VRInitError_Compositor_CreateOverlaySamplerState","value": "444"} + ,{"name": "VRInitError_Compositor_CreatePanoramaSamplerState","value": "445"} + ,{"name": "VRInitError_Compositor_CreateFontSamplerState","value": "446"} + ,{"name": "VRInitError_Compositor_CreateNoBlendState","value": "447"} + ,{"name": "VRInitError_Compositor_CreateBlendState","value": "448"} + ,{"name": "VRInitError_Compositor_CreateAlphaBlendState","value": "449"} + ,{"name": "VRInitError_Compositor_CreateBlendStateMaskR","value": "450"} + ,{"name": "VRInitError_Compositor_CreateBlendStateMaskG","value": "451"} + ,{"name": "VRInitError_Compositor_CreateBlendStateMaskB","value": "452"} + ,{"name": "VRInitError_Compositor_CreateDepthStencilState","value": "453"} + ,{"name": "VRInitError_Compositor_CreateDepthStencilStateNoWrite","value": "454"} + ,{"name": "VRInitError_Compositor_CreateDepthStencilStateNoDepth","value": "455"} + ,{"name": "VRInitError_Compositor_CreateFlushTexture","value": "456"} + ,{"name": "VRInitError_Compositor_CreateDistortionSurfaces","value": "457"} + ,{"name": "VRInitError_Compositor_CreateConstantBuffer","value": "458"} + ,{"name": "VRInitError_Compositor_CreateHmdPoseConstantBuffer","value": "459"} + ,{"name": "VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer","value": "460"} + ,{"name": "VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer","value": "461"} + ,{"name": "VRInitError_Compositor_CreateOverlayConstantBuffer","value": "462"} + ,{"name": "VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer","value": "463"} + ,{"name": "VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer","value": "464"} + ,{"name": "VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer","value": "465"} + ,{"name": "VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer","value": "466"} + ,{"name": "VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer","value": "467"} + ,{"name": "VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer","value": "468"} + ,{"name": "VRInitError_Compositor_CreateGeomConstantBuffer","value": "469"} + ,{"name": "VRInitError_Compositor_CreatePanelMaskConstantBuffer","value": "470"} + ,{"name": "VRInitError_Compositor_CreatePixelSimUBO","value": "471"} + ,{"name": "VRInitError_Compositor_CreateMSAARenderTextures","value": "472"} + ,{"name": "VRInitError_Compositor_CreateResolveRenderTextures","value": "473"} + ,{"name": "VRInitError_Compositor_CreateComputeResolveRenderTextures","value": "474"} + ,{"name": "VRInitError_Compositor_CreateDriverDirectModeResolveTextures","value": "475"} + ,{"name": "VRInitError_Compositor_OpenDriverDirectModeResolveTextures","value": "476"} + ,{"name": "VRInitError_Compositor_CreateFallbackSyncTexture","value": "477"} + ,{"name": "VRInitError_Compositor_ShareFallbackSyncTexture","value": "478"} + ,{"name": "VRInitError_Compositor_CreateOverlayIndexBuffer","value": "479"} + ,{"name": "VRInitError_Compositor_CreateOverlayVertexBuffer","value": "480"} + ,{"name": "VRInitError_Compositor_CreateTextVertexBuffer","value": "481"} + ,{"name": "VRInitError_Compositor_CreateTextIndexBuffer","value": "482"} + ,{"name": "VRInitError_Compositor_CreateMirrorTextures","value": "483"} + ,{"name": "VRInitError_Compositor_CreateLastFrameRenderTexture","value": "484"} + ,{"name": "VRInitError_Compositor_CreateMirrorOverlay","value": "485"} + ,{"name": "VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer","value": "486"} + ,{"name": "VRInitError_Compositor_DisplayModeNotSupported","value": "487"} + ,{"name": "VRInitError_Compositor_CreateOverlayInvalidCall","value": "488"} + ,{"name": "VRInitError_Compositor_CreateOverlayAlreadyInitialized","value": "489"} + ,{"name": "VRInitError_Compositor_FailedToCreateMailbox","value": "490"} ,{"name": "VRInitError_VendorSpecific_UnableToConnectToOculusRuntime","value": "1000"} + ,{"name": "VRInitError_VendorSpecific_WindowsNotInDevMode","value": "1001"} ,{"name": "VRInitError_VendorSpecific_HmdFound_CantOpenDevice","value": "1101"} ,{"name": "VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart","value": "1102"} ,{"name": "VRInitError_VendorSpecific_HmdFound_NoStoredConfig","value": "1103"} @@ -453,7 +867,9 @@ ,{"name": "VRInitError_VendorSpecific_HmdFound_UserDataAddressRange","value": "1111"} ,{"name": "VRInitError_VendorSpecific_HmdFound_UserDataError","value": "1112"} ,{"name": "VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck","value": "1113"} + ,{"name": "VRInitError_VendorSpecific_OculusRuntimeBadInstall","value": "1114"} ,{"name": "VRInitError_Steam_SteamInstallationNotFound","value": "2000"} + ,{"name": "VRInitError_LastError","value": "2001"} ]} , {"enumname": "vr::EVRScreenshotType","values": [ {"name": "VRScreenshotType_None","value": "0"} @@ -486,12 +902,41 @@ ,{"name": "VRTrackedCameraError_InvalidArgument","value": "114"} ,{"name": "VRTrackedCameraError_InvalidFrameBufferSize","value": "115"} ]} +, {"enumname": "vr::EVRTrackedCameraFrameLayout","values": [ + {"name": "EVRTrackedCameraFrameLayout_Mono","value": "1"} + ,{"name": "EVRTrackedCameraFrameLayout_Stereo","value": "2"} + ,{"name": "EVRTrackedCameraFrameLayout_VerticalLayout","value": "16"} + ,{"name": "EVRTrackedCameraFrameLayout_HorizontalLayout","value": "32"} +]} , {"enumname": "vr::EVRTrackedCameraFrameType","values": [ {"name": "VRTrackedCameraFrameType_Distorted","value": "0"} ,{"name": "VRTrackedCameraFrameType_Undistorted","value": "1"} ,{"name": "VRTrackedCameraFrameType_MaximumUndistorted","value": "2"} ,{"name": "MAX_CAMERA_FRAME_TYPES","value": "3"} ]} +, {"enumname": "vr::EVRDistortionFunctionType","values": [ + {"name": "VRDistortionFunctionType_None","value": "0"} + ,{"name": "VRDistortionFunctionType_FTheta","value": "1"} + ,{"name": "VRDistortionFunctionType_Extended_FTheta","value": "2"} + ,{"name": "MAX_DISTORTION_FUNCTION_TYPES","value": "3"} +]} +, {"enumname": "vr::EVSync","values": [ + {"name": "VSync_None","value": "0"} + ,{"name": "VSync_WaitRender","value": "1"} + ,{"name": "VSync_NoWaitRender","value": "2"} +]} +, {"enumname": "vr::EVRMuraCorrectionMode","values": [ + {"name": "EVRMuraCorrectionMode_Default","value": "0"} + ,{"name": "EVRMuraCorrectionMode_NoCorrection","value": "1"} +]} +, {"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"} @@ -509,6 +954,7 @@ ,{"name": "VRApplicationError_OldApplicationQuitting","value": "112"} ,{"name": "VRApplicationError_TransitionAborted","value": "113"} ,{"name": "VRApplicationError_IsTemplate","value": "114"} + ,{"name": "VRApplicationError_SteamVRIsExiting","value": "115"} ,{"name": "VRApplicationError_BufferTooSmall","value": "200"} ,{"name": "VRApplicationError_PropertyNotSet","value": "201"} ,{"name": "VRApplicationError_UnknownProperty","value": "202"} @@ -525,16 +971,21 @@ ,{"name": "VRApplicationProperty_NewsURL_String","value": "51"} ,{"name": "VRApplicationProperty_ImagePath_String","value": "52"} ,{"name": "VRApplicationProperty_Source_String","value": "53"} + ,{"name": "VRApplicationProperty_ActionManifestURL_String","value": "54"} ,{"name": "VRApplicationProperty_IsDashboardOverlay_Bool","value": "60"} ,{"name": "VRApplicationProperty_IsTemplate_Bool","value": "61"} ,{"name": "VRApplicationProperty_IsInstanced_Bool","value": "62"} + ,{"name": "VRApplicationProperty_IsInternal_Bool","value": "63"} + ,{"name": "VRApplicationProperty_WantsCompositorPauseInStandby_Bool","value": "64"} + ,{"name": "VRApplicationProperty_IsHidden_Bool","value": "65"} ,{"name": "VRApplicationProperty_LastLaunchTime_Uint64","value": "70"} ]} -, {"enumname": "vr::EVRApplicationTransitionState","values": [ - {"name": "VRApplicationTransition_None","value": "0"} - ,{"name": "VRApplicationTransition_OldAppQuitSent","value": "10"} - ,{"name": "VRApplicationTransition_WaitingForExternalLaunch","value": "11"} - ,{"name": "VRApplicationTransition_NewAppLaunched","value": "20"} +, {"enumname": "vr::EVRSceneApplicationState","values": [ + {"name": "EVRSceneApplicationState_None","value": "0"} + ,{"name": "EVRSceneApplicationState_Starting","value": "1"} + ,{"name": "EVRSceneApplicationState_Quitting","value": "2"} + ,{"name": "EVRSceneApplicationState_Running","value": "3"} + ,{"name": "EVRSceneApplicationState_Waiting","value": "4"} ]} , {"enumname": "vr::ChaperoneCalibrationState","values": [ {"name": "ChaperoneCalibrationState_OK","value": "1"} @@ -543,7 +994,7 @@ ,{"name": "ChaperoneCalibrationState_Warning_BaseStationRemoved","value": "102"} ,{"name": "ChaperoneCalibrationState_Warning_SeatedBoundsInvalid","value": "103"} ,{"name": "ChaperoneCalibrationState_Error","value": "200"} - ,{"name": "ChaperoneCalibrationState_Error_BaseStationUninitalized","value": "201"} + ,{"name": "ChaperoneCalibrationState_Error_BaseStationUninitialized","value": "201"} ,{"name": "ChaperoneCalibrationState_Error_BaseStationConflict","value": "202"} ,{"name": "ChaperoneCalibrationState_Error_PlayAreaInvalid","value": "203"} ,{"name": "ChaperoneCalibrationState_Error_CollisionBoundsInvalid","value": "204"} @@ -566,33 +1017,57 @@ ,{"name": "VRCompositorError_TextureUsesUnsupportedFormat","value": "105"} ,{"name": "VRCompositorError_SharedTexturesNotSupported","value": "106"} ,{"name": "VRCompositorError_IndexOutOfRange","value": "107"} + ,{"name": "VRCompositorError_AlreadySubmitted","value": "108"} + ,{"name": "VRCompositorError_InvalidBounds","value": "109"} + ,{"name": "VRCompositorError_AlreadySet","value": "110"} +]} +, {"enumname": "vr::EVRCompositorTimingMode","values": [ + {"name": "VRCompositorTimingMode_Implicit","value": "0"} + ,{"name": "VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff","value": "1"} + ,{"name": "VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff","value": "2"} ]} , {"enumname": "vr::VROverlayInputMethod","values": [ {"name": "VROverlayInputMethod_None","value": "0"} ,{"name": "VROverlayInputMethod_Mouse","value": "1"} ]} , {"enumname": "vr::VROverlayTransformType","values": [ - {"name": "VROverlayTransform_Absolute","value": "0"} + {"name": "VROverlayTransform_Invalid","value": "-1"} + ,{"name": "VROverlayTransform_Absolute","value": "0"} ,{"name": "VROverlayTransform_TrackedDeviceRelative","value": "1"} ,{"name": "VROverlayTransform_SystemOverlay","value": "2"} ,{"name": "VROverlayTransform_TrackedComponent","value": "3"} + ,{"name": "VROverlayTransform_Cursor","value": "4"} + ,{"name": "VROverlayTransform_DashboardTab","value": "5"} + ,{"name": "VROverlayTransform_DashboardThumb","value": "6"} + ,{"name": "VROverlayTransform_Mountable","value": "7"} ]} , {"enumname": "vr::VROverlayFlags","values": [ - {"name": "VROverlayFlags_None","value": "0"} - ,{"name": "VROverlayFlags_Curved","value": "1"} - ,{"name": "VROverlayFlags_RGSS4X","value": "2"} - ,{"name": "VROverlayFlags_NoDashboardTab","value": "3"} - ,{"name": "VROverlayFlags_AcceptsGamepadEvents","value": "4"} - ,{"name": "VROverlayFlags_ShowGamepadFocus","value": "5"} - ,{"name": "VROverlayFlags_SendVRScrollEvents","value": "6"} - ,{"name": "VROverlayFlags_SendVRTouchpadEvents","value": "7"} - ,{"name": "VROverlayFlags_ShowTouchPadScrollWheel","value": "8"} - ,{"name": "VROverlayFlags_TransferOwnershipToInternalProcess","value": "9"} - ,{"name": "VROverlayFlags_SideBySide_Parallel","value": "10"} - ,{"name": "VROverlayFlags_SideBySide_Crossed","value": "11"} - ,{"name": "VROverlayFlags_Panorama","value": "12"} - ,{"name": "VROverlayFlags_StereoPanorama","value": "13"} - ,{"name": "VROverlayFlags_SortWithNonSceneOverlays","value": "14"} + {"name": "VROverlayFlags_NoDashboardTab","value": "8"} + ,{"name": "VROverlayFlags_SendVRDiscreteScrollEvents","value": "64"} + ,{"name": "VROverlayFlags_SendVRTouchpadEvents","value": "128"} + ,{"name": "VROverlayFlags_ShowTouchPadScrollWheel","value": "256"} + ,{"name": "VROverlayFlags_TransferOwnershipToInternalProcess","value": "512"} + ,{"name": "VROverlayFlags_SideBySide_Parallel","value": "1024"} + ,{"name": "VROverlayFlags_SideBySide_Crossed","value": "2048"} + ,{"name": "VROverlayFlags_Panorama","value": "4096"} + ,{"name": "VROverlayFlags_StereoPanorama","value": "8192"} + ,{"name": "VROverlayFlags_SortWithNonSceneOverlays","value": "16384"} + ,{"name": "VROverlayFlags_VisibleInDashboard","value": "32768"} + ,{"name": "VROverlayFlags_MakeOverlaysInteractiveIfVisible","value": "65536"} + ,{"name": "VROverlayFlags_SendVRSmoothScrollEvents","value": "131072"} + ,{"name": "VROverlayFlags_ProtectedContent","value": "262144"} + ,{"name": "VROverlayFlags_HideLaserIntersection","value": "524288"} + ,{"name": "VROverlayFlags_WantsModalBehavior","value": "1048576"} + ,{"name": "VROverlayFlags_IsPremultiplied","value": "2097152"} +]} +, {"enumname": "vr::VRMessageOverlayResponse","values": [ + {"name": "VRMessageOverlayResponse_ButtonPress_0","value": "0"} + ,{"name": "VRMessageOverlayResponse_ButtonPress_1","value": "1"} + ,{"name": "VRMessageOverlayResponse_ButtonPress_2","value": "2"} + ,{"name": "VRMessageOverlayResponse_ButtonPress_3","value": "3"} + ,{"name": "VRMessageOverlayResponse_CouldntFindSystemOverlay","value": "4"} + ,{"name": "VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay","value": "5"} + ,{"name": "VRMessageOverlayResponse_ApplicationQuit","value": "6"} ]} , {"enumname": "vr::EGamepadTextInputMode","values": [ {"name": "k_EGamepadTextInputModeNormal","value": "0"} @@ -603,12 +1078,23 @@ {"name": "k_EGamepadTextInputLineModeSingleLine","value": "0"} ,{"name": "k_EGamepadTextInputLineModeMultipleLines","value": "1"} ]} -, {"enumname": "vr::EOverlayDirection","values": [ - {"name": "OverlayDirection_Up","value": "0"} - ,{"name": "OverlayDirection_Down","value": "1"} - ,{"name": "OverlayDirection_Left","value": "2"} - ,{"name": "OverlayDirection_Right","value": "3"} - ,{"name": "OverlayDirection_Count","value": "4"} +, {"enumname": "vr::EVROverlayIntersectionMaskPrimitiveType","values": [ + {"name": "OverlayIntersectionPrimitiveType_Rectangle","value": "0"} + ,{"name": "OverlayIntersectionPrimitiveType_Circle","value": "1"} +]} +, {"enumname": "vr::EKeyboardFlags","values": [ + {"name": "KeyboardFlag_Minimal","value": "1"} + ,{"name": "KeyboardFlag_Modal","value": "2"} +]} +, {"enumname": "vr::EDeviceType","values": [ + {"name": "DeviceType_Invalid","value": "-1"} + ,{"name": "DeviceType_DirectX11","value": "0"} + ,{"name": "DeviceType_Vulkan","value": "1"} +]} +, {"enumname": "vr::HeadsetViewMode_t","values": [ + {"name": "HeadsetViewMode_Left","value": "0"} + ,{"name": "HeadsetViewMode_Right","value": "1"} + ,{"name": "HeadsetViewMode_Both","value": "2"} ]} , {"enumname": "vr::EVRRenderModelError","values": [ {"name": "VRRenderModelError_None","value": "0"} @@ -625,12 +1111,12 @@ ,{"name": "VRRenderModelError_NotEnoughTexCoords","value": "308"} ,{"name": "VRRenderModelError_InvalidTexture","value": "400"} ]} -, {"enumname": "vr::EVRComponentProperty","values": [ - {"name": "VRComponentProperty_IsStatic","value": "1"} - ,{"name": "VRComponentProperty_IsVisible","value": "2"} - ,{"name": "VRComponentProperty_IsTouched","value": "4"} - ,{"name": "VRComponentProperty_IsPressed","value": "8"} - ,{"name": "VRComponentProperty_IsScrolled","value": "16"} +, {"enumname": "vr::EVRRenderModelTextureFormat","values": [ + {"name": "VRRenderModelTextureFormat_RGBA8_SRGB","value": "0"} + ,{"name": "VRRenderModelTextureFormat_BC2","value": "1"} + ,{"name": "VRRenderModelTextureFormat_BC4","value": "2"} + ,{"name": "VRRenderModelTextureFormat_BC7","value": "3"} + ,{"name": "VRRenderModelTextureFormat_BC7_SRGB","value": "4"} ]} , {"enumname": "vr::EVRNotificationType","values": [ {"name": "EVRNotificationType_Transient","value": "0"} @@ -649,6 +1135,8 @@ ,{"name": "VRSettingsError_IPCFailed","value": "1"} ,{"name": "VRSettingsError_WriteFailed","value": "2"} ,{"name": "VRSettingsError_ReadFailed","value": "3"} + ,{"name": "VRSettingsError_JsonParseFailed","value": "4"} + ,{"name": "VRSettingsError_UnsetSettingHasNoDefault","value": "5"} ]} , {"enumname": "vr::EVRScreenshotError","values": [ {"name": "VRScreenshotError_None","value": "0"} @@ -658,51 +1146,211 @@ ,{"name": "VRScreenshotError_BufferTooSmall","value": "102"} ,{"name": "VRScreenshotError_ScreenshotAlreadyInProgress","value": "108"} ]} +, {"enumname": "vr::EVRSkeletalTransformSpace","values": [ + {"name": "VRSkeletalTransformSpace_Model","value": "0"} + ,{"name": "VRSkeletalTransformSpace_Parent","value": "1"} +]} +, {"enumname": "vr::EVRSkeletalReferencePose","values": [ + {"name": "VRSkeletalReferencePose_BindPose","value": "0"} + ,{"name": "VRSkeletalReferencePose_OpenHand","value": "1"} + ,{"name": "VRSkeletalReferencePose_Fist","value": "2"} + ,{"name": "VRSkeletalReferencePose_GripLimit","value": "3"} +]} +, {"enumname": "vr::EVRFinger","values": [ + {"name": "VRFinger_Thumb","value": "0"} + ,{"name": "VRFinger_Index","value": "1"} + ,{"name": "VRFinger_Middle","value": "2"} + ,{"name": "VRFinger_Ring","value": "3"} + ,{"name": "VRFinger_Pinky","value": "4"} + ,{"name": "VRFinger_Count","value": "5"} +]} +, {"enumname": "vr::EVRFingerSplay","values": [ + {"name": "VRFingerSplay_Thumb_Index","value": "0"} + ,{"name": "VRFingerSplay_Index_Middle","value": "1"} + ,{"name": "VRFingerSplay_Middle_Ring","value": "2"} + ,{"name": "VRFingerSplay_Ring_Pinky","value": "3"} + ,{"name": "VRFingerSplay_Count","value": "4"} +]} +, {"enumname": "vr::EVRSummaryType","values": [ + {"name": "VRSummaryType_FromAnimation","value": "0"} + ,{"name": "VRSummaryType_FromDevice","value": "1"} +]} +, {"enumname": "vr::EVRInputFilterCancelType","values": [ + {"name": "VRInputFilterCancel_Timers","value": "0"} + ,{"name": "VRInputFilterCancel_Momentum","value": "1"} +]} +, {"enumname": "vr::EVRInputStringBits","values": [ + {"name": "VRInputString_Hand","value": "1"} + ,{"name": "VRInputString_ControllerType","value": "2"} + ,{"name": "VRInputString_InputSource","value": "4"} + ,{"name": "VRInputString_All","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"} +]} +, {"enumname": "vr::EVRDebugError","values": [ + {"name": "VRDebugError_Success","value": "0"} + ,{"name": "VRDebugError_BadParameter","value": "1"} +]} +, {"enumname": "vr::EPropertyWriteType","values": [ + {"name": "PropertyWrite_Set","value": "0"} + ,{"name": "PropertyWrite_Erase","value": "1"} + ,{"name": "PropertyWrite_SetError","value": "2"} +]} +, {"enumname": "vr::EBlockQueueError","values": [ + {"name": "BlockQueueError_None","value": "0"} + ,{"name": "BlockQueueError_QueueAlreadyExists","value": "1"} + ,{"name": "BlockQueueError_QueueNotFound","value": "2"} + ,{"name": "BlockQueueError_BlockNotAvailable","value": "3"} + ,{"name": "BlockQueueError_InvalidHandle","value": "4"} + ,{"name": "BlockQueueError_InvalidParam","value": "5"} + ,{"name": "BlockQueueError_ParamMismatch","value": "6"} + ,{"name": "BlockQueueError_InternalError","value": "7"} + ,{"name": "BlockQueueError_AlreadyInitialized","value": "8"} + ,{"name": "BlockQueueError_OperationIsServerOnly","value": "9"} + ,{"name": "BlockQueueError_TooManyConnections","value": "10"} +]} +, {"enumname": "vr::EBlockQueueReadType","values": [ + {"name": "BlockQueueRead_Latest","value": "0"} + ,{"name": "BlockQueueRead_New","value": "1"} + ,{"name": "BlockQueueRead_Next","value": "2"} +]} ], "consts":[{ - "constname": "k_unTrackingStringSize","consttype": "const uint32_t", "constval": "32"} + "constname": "k_nDriverNone","consttype": "const uint32_t", "constval": "4294967295"} ,{ "constname": "k_unMaxDriverDebugResponseSize","consttype": "const uint32_t", "constval": "32768"} ,{ "constname": "k_unTrackedDeviceIndex_Hmd","consttype": "const uint32_t", "constval": "0"} ,{ - "constname": "k_unMaxTrackedDeviceCount","consttype": "const uint32_t", "constval": "16"} + "constname": "k_unMaxTrackedDeviceCount","consttype": "const uint32_t", "constval": "64"} ,{ "constname": "k_unTrackedDeviceIndexOther","consttype": "const uint32_t", "constval": "4294967294"} ,{ "constname": "k_unTrackedDeviceIndexInvalid","consttype": "const uint32_t", "constval": "4294967295"} +,{ + "constname": "k_ulInvalidPropertyContainer","consttype": "const PropertyContainerHandle_t", "constval": "0"} +,{ + "constname": "k_unInvalidPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "0"} +,{ + "constname": "k_ulInvalidDriverHandle","consttype": "const PropertyContainerHandle_t", "constval": "0"} +,{ + "constname": "k_unFloatPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "1"} +,{ + "constname": "k_unInt32PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "2"} +,{ + "constname": "k_unUint64PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "3"} +,{ + "constname": "k_unBoolPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "4"} +,{ + "constname": "k_unStringPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "5"} +,{ + "constname": "k_unErrorPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "6"} +,{ + "constname": "k_unDoublePropertyTag","consttype": "const PropertyTypeTag_t", "constval": "7"} +,{ + "constname": "k_unHmdMatrix34PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "20"} +,{ + "constname": "k_unHmdMatrix44PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "21"} +,{ + "constname": "k_unHmdVector3PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "22"} +,{ + "constname": "k_unHmdVector4PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "23"} +,{ + "constname": "k_unHmdVector2PropertyTag","consttype": "const PropertyTypeTag_t", "constval": "24"} +,{ + "constname": "k_unHmdQuadPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "25"} +,{ + "constname": "k_unHiddenAreaPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "30"} +,{ + "constname": "k_unPathHandleInfoTag","consttype": "const PropertyTypeTag_t", "constval": "31"} +,{ + "constname": "k_unActionPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "32"} +,{ + "constname": "k_unInputValuePropertyTag","consttype": "const PropertyTypeTag_t", "constval": "33"} +,{ + "constname": "k_unWildcardPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "34"} +,{ + "constname": "k_unHapticVibrationPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "35"} +,{ + "constname": "k_unSkeletonPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "36"} +,{ + "constname": "k_unSpatialAnchorPosePropertyTag","consttype": "const PropertyTypeTag_t", "constval": "40"} +,{ + "constname": "k_unJsonPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "41"} +,{ + "constname": "k_unActiveActionSetPropertyTag","consttype": "const PropertyTypeTag_t", "constval": "42"} +,{ + "constname": "k_unOpenVRInternalReserved_Start","consttype": "const PropertyTypeTag_t", "constval": "1000"} +,{ + "constname": "k_unOpenVRInternalReserved_End","consttype": "const PropertyTypeTag_t", "constval": "10000"} ,{ "constname": "k_unMaxPropertyStringSize","consttype": "const uint32_t", "constval": "32768"} +,{ + "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_unControllerStateAxisCount","consttype": "const uint32_t", "constval": "5"} ,{ "constname": "k_ulOverlayHandleInvalid","consttype": "const VROverlayHandle_t", "constval": "0"} +,{ + "constname": "k_unMaxDistortionFunctionParameters","consttype": "const uint32_t", "constval": "8"} ,{ "constname": "k_unScreenshotHandleInvalid","consttype": "const uint32_t", "constval": "0"} ,{ - "constname": "IVRSystem_Version","consttype": "const char *const", "constval": "IVRSystem_012"} + "constname": "IVRSystem_Version","consttype": "const char *const", "constval": "IVRSystem_021"} ,{ "constname": "IVRExtendedDisplay_Version","consttype": "const char *const", "constval": "IVRExtendedDisplay_001"} ,{ - "constname": "IVRTrackedCamera_Version","consttype": "const char *const", "constval": "IVRTrackedCamera_003"} + "constname": "IVRTrackedCamera_Version","consttype": "const char *const", "constval": "IVRTrackedCamera_006"} ,{ "constname": "k_unMaxApplicationKeyLength","consttype": "const uint32_t", "constval": "128"} ,{ - "constname": "IVRApplications_Version","consttype": "const char *const", "constval": "IVRApplications_006"} + "constname": "k_pch_MimeType_HomeApp","consttype": "const char *const", "constval": "vr/home"} +,{ + "constname": "k_pch_MimeType_GameTheater","consttype": "const char *const", "constval": "vr/game_theater"} +,{ + "constname": "IVRApplications_Version","consttype": "const char *const", "constval": "IVRApplications_007"} ,{ "constname": "IVRChaperone_Version","consttype": "const char *const", "constval": "IVRChaperone_003"} ,{ - "constname": "IVRChaperoneSetup_Version","consttype": "const char *const", "constval": "IVRChaperoneSetup_005"} + "constname": "IVRChaperoneSetup_Version","consttype": "const char *const", "constval": "IVRChaperoneSetup_006"} ,{ - "constname": "IVRCompositor_Version","consttype": "const char *const", "constval": "IVRCompositor_016"} + "constname": "IVRCompositor_Version","consttype": "const char *const", "constval": "IVRCompositor_026"} ,{ "constname": "k_unVROverlayMaxKeyLength","consttype": "const uint32_t", "constval": "128"} ,{ "constname": "k_unVROverlayMaxNameLength","consttype": "const uint32_t", "constval": "128"} ,{ - "constname": "k_unMaxOverlayCount","consttype": "const uint32_t", "constval": "64"} + "constname": "k_unMaxOverlayCount","consttype": "const uint32_t", "constval": "128"} +,{ + "constname": "k_unMaxOverlayIntersectionMaskPrimitivesCount","consttype": "const uint32_t", "constval": "32"} +,{ + "constname": "IVROverlay_Version","consttype": "const char *const", "constval": "IVROverlay_024"} +,{ + "constname": "IVROverlayView_Version","consttype": "const char *const", "constval": "IVROverlayView_003"} ,{ - "constname": "IVROverlay_Version","consttype": "const char *const", "constval": "IVROverlay_013"} + "constname": "k_unHeadsetViewMaxWidth","consttype": "const uint32_t", "constval": "3840"} +,{ + "constname": "k_unHeadsetViewMaxHeight","consttype": "const uint32_t", "constval": "2160"} +,{ + "constname": "k_pchHeadsetViewOverlayKey","consttype": "const char *const", "constval": "system.HeadsetView"} +,{ + "constname": "IVRHeadsetView_Version","consttype": "const char *const", "constval": "IVRHeadsetView_001"} ,{ "constname": "k_pch_Controller_Component_GDC2015","consttype": "const char *const", "constval": "gdc2015"} ,{ @@ -714,7 +1362,7 @@ ,{ "constname": "k_pch_Controller_Component_Status","consttype": "const char *const", "constval": "status"} ,{ - "constname": "IVRRenderModels_Version","consttype": "const char *const", "constval": "IVRRenderModels_005"} + "constname": "IVRRenderModels_Version","consttype": "const char *const", "constval": "IVRRenderModels_006"} ,{ "constname": "k_unNotificationTextMaxSize","consttype": "const uint32_t", "constval": "256"} ,{ @@ -722,7 +1370,7 @@ ,{ "constname": "k_unMaxSettingsKeyLength","consttype": "const uint32_t", "constval": "128"} ,{ - "constname": "IVRSettings_Version","consttype": "const char *const", "constval": "IVRSettings_001"} + "constname": "IVRSettings_Version","consttype": "const char *const", "constval": "IVRSettings_003"} ,{ "constname": "k_pch_SteamVR_Section","consttype": "const char *const", "constval": "steamvr"} ,{ @@ -735,8 +1383,6 @@ "constname": "k_pch_SteamVR_DisplayDebug_Bool","consttype": "const char *const", "constval": "displayDebug"} ,{ "constname": "k_pch_SteamVR_DebugProcessPipe_String","consttype": "const char *const", "constval": "debugProcessPipe"} -,{ - "constname": "k_pch_SteamVR_EnableDistortion_Bool","consttype": "const char *const", "constval": "enableDistortion"} ,{ "constname": "k_pch_SteamVR_DisplayDebugX_Int32","consttype": "const char *const", "constval": "displayDebugX"} ,{ @@ -749,62 +1395,140 @@ "constname": "k_pch_SteamVR_IPD_Float","consttype": "const char *const", "constval": "ipd"} ,{ "constname": "k_pch_SteamVR_Background_String","consttype": "const char *const", "constval": "background"} +,{ + "constname": "k_pch_SteamVR_BackgroundUseDomeProjection_Bool","consttype": "const char *const", "constval": "backgroundUseDomeProjection"} ,{ "constname": "k_pch_SteamVR_BackgroundCameraHeight_Float","consttype": "const char *const", "constval": "backgroundCameraHeight"} ,{ "constname": "k_pch_SteamVR_BackgroundDomeRadius_Float","consttype": "const char *const", "constval": "backgroundDomeRadius"} -,{ - "constname": "k_pch_SteamVR_Environment_String","consttype": "const char *const", "constval": "environment"} ,{ "constname": "k_pch_SteamVR_GridColor_String","consttype": "const char *const", "constval": "gridColor"} ,{ "constname": "k_pch_SteamVR_PlayAreaColor_String","consttype": "const char *const", "constval": "playAreaColor"} +,{ + "constname": "k_pch_SteamVR_TrackingLossColor_String","consttype": "const char *const", "constval": "trackingLossColor"} ,{ "constname": "k_pch_SteamVR_ShowStage_Bool","consttype": "const char *const", "constval": "showStage"} ,{ "constname": "k_pch_SteamVR_ActivateMultipleDrivers_Bool","consttype": "const char *const", "constval": "activateMultipleDrivers"} ,{ - "constname": "k_pch_SteamVR_PowerOffOnExit_Bool","consttype": "const char *const", "constval": "powerOffOnExit"} + "constname": "k_pch_SteamVR_UsingSpeakers_Bool","consttype": "const char *const", "constval": "usingSpeakers"} ,{ - "constname": "k_pch_SteamVR_StandbyAppRunningTimeout_Float","consttype": "const char *const", "constval": "standbyAppRunningTimeout"} + "constname": "k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float","consttype": "const char *const", "constval": "speakersForwardYawOffsetDegrees"} ,{ - "constname": "k_pch_SteamVR_StandbyNoAppTimeout_Float","consttype": "const char *const", "constval": "standbyNoAppTimeout"} + "constname": "k_pch_SteamVR_BaseStationPowerManagement_Int32","consttype": "const char *const", "constval": "basestationPowerManagement"} ,{ - "constname": "k_pch_SteamVR_DirectMode_Bool","consttype": "const char *const", "constval": "directMode"} + "constname": "k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32","consttype": "const char *const", "constval": "ShowBaseStationPowerManagementTip"} ,{ - "constname": "k_pch_SteamVR_DirectModeEdidVid_Int32","consttype": "const char *const", "constval": "directModeEdidVid"} + "constname": "k_pch_SteamVR_NeverKillProcesses_Bool","consttype": "const char *const", "constval": "neverKillProcesses"} ,{ - "constname": "k_pch_SteamVR_DirectModeEdidPid_Int32","consttype": "const char *const", "constval": "directModeEdidPid"} + "constname": "k_pch_SteamVR_SupersampleScale_Float","consttype": "const char *const", "constval": "supersampleScale"} ,{ - "constname": "k_pch_SteamVR_UsingSpeakers_Bool","consttype": "const char *const", "constval": "usingSpeakers"} + "constname": "k_pch_SteamVR_MaxRecommendedResolution_Int32","consttype": "const char *const", "constval": "maxRecommendedResolution"} ,{ - "constname": "k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float","consttype": "const char *const", "constval": "speakersForwardYawOffsetDegrees"} + "constname": "k_pch_SteamVR_MotionSmoothing_Bool","consttype": "const char *const", "constval": "motionSmoothing"} ,{ - "constname": "k_pch_SteamVR_BaseStationPowerManagement_Bool","consttype": "const char *const", "constval": "basestationPowerManagement"} + "constname": "k_pch_SteamVR_MotionSmoothingOverride_Int32","consttype": "const char *const", "constval": "motionSmoothingOverride"} ,{ - "constname": "k_pch_SteamVR_NeverKillProcesses_Bool","consttype": "const char *const", "constval": "neverKillProcesses"} + "constname": "k_pch_SteamVR_DisableAsyncReprojection_Bool","consttype": "const char *const", "constval": "disableAsync"} +,{ + "constname": "k_pch_SteamVR_ForceFadeOnBadTracking_Bool","consttype": "const char *const", "constval": "forceFadeOnBadTracking"} ,{ - "constname": "k_pch_SteamVR_RenderTargetMultiplier_Float","consttype": "const char *const", "constval": "renderTargetMultiplier"} + "constname": "k_pch_SteamVR_DefaultMirrorView_Int32","consttype": "const char *const", "constval": "mirrorView"} ,{ - "constname": "k_pch_SteamVR_AllowReprojection_Bool","consttype": "const char *const", "constval": "allowReprojection"} + "constname": "k_pch_SteamVR_ShowLegacyMirrorView_Bool","consttype": "const char *const", "constval": "showLegacyMirrorView"} ,{ - "constname": "k_pch_SteamVR_ForceReprojection_Bool","consttype": "const char *const", "constval": "forceReprojection"} + "constname": "k_pch_SteamVR_MirrorViewVisibility_Bool","consttype": "const char *const", "constval": "showMirrorView"} ,{ - "constname": "k_pch_SteamVR_ForceFadeOnBadTracking_Bool","consttype": "const char *const", "constval": "forceFadeOnBadTracking"} + "constname": "k_pch_SteamVR_MirrorViewDisplayMode_Int32","consttype": "const char *const", "constval": "mirrorViewDisplayMode"} ,{ - "constname": "k_pch_SteamVR_DefaultMirrorView_Int32","consttype": "const char *const", "constval": "defaultMirrorView"} + "constname": "k_pch_SteamVR_MirrorViewEye_Int32","consttype": "const char *const", "constval": "mirrorViewEye"} ,{ - "constname": "k_pch_SteamVR_ShowMirrorView_Bool","consttype": "const char *const", "constval": "showMirrorView"} + "constname": "k_pch_SteamVR_MirrorViewGeometry_String","consttype": "const char *const", "constval": "mirrorViewGeometry"} +,{ + "constname": "k_pch_SteamVR_MirrorViewGeometryMaximized_String","consttype": "const char *const", "constval": "mirrorViewGeometryMaximized"} +,{ + "constname": "k_pch_SteamVR_PerfGraphVisibility_Bool","consttype": "const char *const", "constval": "showPerfGraph"} ,{ "constname": "k_pch_SteamVR_StartMonitorFromAppLaunch","consttype": "const char *const", "constval": "startMonitorFromAppLaunch"} ,{ - "constname": "k_pch_SteamVR_AutoLaunchSteamVROnButtonPress","consttype": "const char *const", "constval": "autoLaunchSteamVROnButtonPress"} + "constname": "k_pch_SteamVR_StartCompositorFromAppLaunch_Bool","consttype": "const char *const", "constval": "startCompositorFromAppLaunch"} +,{ + "constname": "k_pch_SteamVR_StartDashboardFromAppLaunch_Bool","consttype": "const char *const", "constval": "startDashboardFromAppLaunch"} +,{ + "constname": "k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool","consttype": "const char *const", "constval": "startOverlayAppsFromDashboard"} +,{ + "constname": "k_pch_SteamVR_EnableHomeApp","consttype": "const char *const", "constval": "enableHomeApp"} +,{ + "constname": "k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32","consttype": "const char *const", "constval": "CycleBackgroundImageTimeSec"} +,{ + "constname": "k_pch_SteamVR_RetailDemo_Bool","consttype": "const char *const", "constval": "retailDemo"} +,{ + "constname": "k_pch_SteamVR_IpdOffset_Float","consttype": "const char *const", "constval": "ipdOffset"} +,{ + "constname": "k_pch_SteamVR_AllowSupersampleFiltering_Bool","consttype": "const char *const", "constval": "allowSupersampleFiltering"} +,{ + "constname": "k_pch_SteamVR_SupersampleManualOverride_Bool","consttype": "const char *const", "constval": "supersampleManualOverride"} +,{ + "constname": "k_pch_SteamVR_EnableLinuxVulkanAsync_Bool","consttype": "const char *const", "constval": "enableLinuxVulkanAsync"} +,{ + "constname": "k_pch_SteamVR_AllowDisplayLockedMode_Bool","consttype": "const char *const", "constval": "allowDisplayLockedMode"} +,{ + "constname": "k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool","consttype": "const char *const", "constval": "haveStartedTutorialForNativeChaperoneDriver"} +,{ + "constname": "k_pch_SteamVR_ForceWindows32bitVRMonitor","consttype": "const char *const", "constval": "forceWindows32BitVRMonitor"} +,{ + "constname": "k_pch_SteamVR_DebugInputBinding","consttype": "const char *const", "constval": "debugInputBinding"} +,{ + "constname": "k_pch_SteamVR_DoNotFadeToGrid","consttype": "const char *const", "constval": "doNotFadeToGrid"} +,{ + "constname": "k_pch_SteamVR_RenderCameraMode","consttype": "const char *const", "constval": "renderCameraMode"} +,{ + "constname": "k_pch_SteamVR_EnableSharedResourceJournaling","consttype": "const char *const", "constval": "enableSharedResourceJournaling"} +,{ + "constname": "k_pch_SteamVR_EnableSafeMode","consttype": "const char *const", "constval": "enableSafeMode"} +,{ + "constname": "k_pch_SteamVR_PreferredRefreshRate","consttype": "const char *const", "constval": "preferredRefreshRate"} +,{ + "constname": "k_pch_SteamVR_LastVersionNotice","consttype": "const char *const", "constval": "lastVersionNotice"} +,{ + "constname": "k_pch_SteamVR_LastVersionNoticeDate","consttype": "const char *const", "constval": "lastVersionNoticeDate"} +,{ + "constname": "k_pch_SteamVR_HmdDisplayColorGainR_Float","consttype": "const char *const", "constval": "hmdDisplayColorGainR"} +,{ + "constname": "k_pch_SteamVR_HmdDisplayColorGainG_Float","consttype": "const char *const", "constval": "hmdDisplayColorGainG"} +,{ + "constname": "k_pch_SteamVR_HmdDisplayColorGainB_Float","consttype": "const char *const", "constval": "hmdDisplayColorGainB"} +,{ + "constname": "k_pch_SteamVR_CustomIconStyle_String","consttype": "const char *const", "constval": "customIconStyle"} +,{ + "constname": "k_pch_SteamVR_CustomOffIconStyle_String","consttype": "const char *const", "constval": "customOffIconStyle"} +,{ + "constname": "k_pch_SteamVR_CustomIconForceUpdate_String","consttype": "const char *const", "constval": "customIconForceUpdate"} ,{ - "constname": "k_pch_SteamVR_UseGenericGraphcisDevice_Bool","consttype": "const char *const", "constval": "useGenericGraphicsDevice"} + "constname": "k_pch_SteamVR_AllowGlobalActionSetPriority","consttype": "const char *const", "constval": "globalActionSetPriority"} +,{ + "constname": "k_pch_SteamVR_OverlayRenderQuality","consttype": "const char *const", "constval": "overlayRenderQuality_2"} +,{ + "constname": "k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool","consttype": "const char *const", "constval": "blockOculusSDKOnOpenVRLaunchOption"} +,{ + "constname": "k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool","consttype": "const char *const", "constval": "blockOculusSDKOnAllLaunches"} +,{ + "constname": "k_pch_DirectMode_Section","consttype": "const char *const", "constval": "direct_mode"} +,{ + "constname": "k_pch_DirectMode_Enable_Bool","consttype": "const char *const", "constval": "enable"} +,{ + "constname": "k_pch_DirectMode_Count_Int32","consttype": "const char *const", "constval": "count"} +,{ + "constname": "k_pch_DirectMode_EdidVid_Int32","consttype": "const char *const", "constval": "edidVid"} +,{ + "constname": "k_pch_DirectMode_EdidPid_Int32","consttype": "const char *const", "constval": "edidPid"} ,{ "constname": "k_pch_Lighthouse_Section","consttype": "const char *const", "constval": "driver_lighthouse"} ,{ "constname": "k_pch_Lighthouse_DisableIMU_Bool","consttype": "const char *const", "constval": "disableimu"} +,{ + "constname": "k_pch_Lighthouse_DisableIMUExceptHMD_Bool","consttype": "const char *const", "constval": "disableimuexcepthmd"} ,{ "constname": "k_pch_Lighthouse_UseDisambiguation_String","consttype": "const char *const", "constval": "usedisambiguation"} ,{ @@ -812,17 +1536,19 @@ ,{ "constname": "k_pch_Lighthouse_PrimaryBasestation_Int32","consttype": "const char *const", "constval": "primarybasestation"} ,{ - "constname": "k_pch_Lighthouse_LighthouseName_String","consttype": "const char *const", "constval": "lighthousename"} + "constname": "k_pch_Lighthouse_DBHistory_Bool","consttype": "const char *const", "constval": "dbhistory"} ,{ - "constname": "k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float","consttype": "const char *const", "constval": "maxincidenceangledegrees"} + "constname": "k_pch_Lighthouse_EnableBluetooth_Bool","consttype": "const char *const", "constval": "enableBluetooth"} ,{ - "constname": "k_pch_Lighthouse_UseLighthouseDirect_Bool","consttype": "const char *const", "constval": "uselighthousedirect"} + "constname": "k_pch_Lighthouse_PowerManagedBaseStations_String","consttype": "const char *const", "constval": "PowerManagedBaseStations"} ,{ - "constname": "k_pch_Lighthouse_DBHistory_Bool","consttype": "const char *const", "constval": "dbhistory"} + "constname": "k_pch_Lighthouse_PowerManagedBaseStations2_String","consttype": "const char *const", "constval": "PowerManagedBaseStations2"} ,{ - "constname": "k_pch_Null_Section","consttype": "const char *const", "constval": "driver_null"} + "constname": "k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32","consttype": "const char *const", "constval": "InactivityTimeoutForBaseStations"} ,{ - "constname": "k_pch_Null_EnableNullDriver_Bool","consttype": "const char *const", "constval": "enable"} + "constname": "k_pch_Lighthouse_EnableImuFallback_Bool","consttype": "const char *const", "constval": "enableImuFallback"} +,{ + "constname": "k_pch_Null_Section","consttype": "const char *const", "constval": "driver_null"} ,{ "constname": "k_pch_Null_SerialNumber_String","consttype": "const char *const", "constval": "serialNumber"} ,{ @@ -843,10 +1569,16 @@ "constname": "k_pch_Null_SecondsFromVsyncToPhotons_Float","consttype": "const char *const", "constval": "secondsFromVsyncToPhotons"} ,{ "constname": "k_pch_Null_DisplayFrequency_Float","consttype": "const char *const", "constval": "displayFrequency"} +,{ + "constname": "k_pch_WindowsMR_Section","consttype": "const char *const", "constval": "driver_holographic"} ,{ "constname": "k_pch_UserInterface_Section","consttype": "const char *const", "constval": "userinterface"} ,{ "constname": "k_pch_UserInterface_StatusAlwaysOnTop_Bool","consttype": "const char *const", "constval": "StatusAlwaysOnTop"} +,{ + "constname": "k_pch_UserInterface_MinimizeToTray_Bool","consttype": "const char *const", "constval": "MinimizeToTray"} +,{ + "constname": "k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool","consttype": "const char *const", "constval": "HidePopupsWhenStatusMinimized"} ,{ "constname": "k_pch_UserInterface_Screenshots_Bool","consttype": "const char *const", "constval": "screenshots"} ,{ @@ -874,17 +1606,15 @@ ,{ "constname": "k_pch_Perf_Section","consttype": "const char *const", "constval": "perfcheck"} ,{ - "constname": "k_pch_Perf_HeuristicActive_Bool","consttype": "const char *const", "constval": "heuristicActive"} -,{ - "constname": "k_pch_Perf_NotifyInHMD_Bool","consttype": "const char *const", "constval": "warnInHMD"} -,{ - "constname": "k_pch_Perf_NotifyOnlyOnce_Bool","consttype": "const char *const", "constval": "warnOnlyOnce"} + "constname": "k_pch_Perf_PerfGraphInHMD_Bool","consttype": "const char *const", "constval": "perfGraphInHMD"} ,{ "constname": "k_pch_Perf_AllowTimingStore_Bool","consttype": "const char *const", "constval": "allowTimingStore"} ,{ "constname": "k_pch_Perf_SaveTimingsOnExit_Bool","consttype": "const char *const", "constval": "saveTimingsOnExit"} ,{ "constname": "k_pch_Perf_TestData_Float","consttype": "const char *const", "constval": "perfTestData"} +,{ + "constname": "k_pch_Perf_GPUProfiling_Bool","consttype": "const char *const", "constval": "GPUProfiling"} ,{ "constname": "k_pch_CollisionBounds_Section","consttype": "const char *const", "constval": "collisionBounds"} ,{ @@ -897,6 +1627,8 @@ "constname": "k_pch_CollisionBounds_PlaySpaceOn_Bool","consttype": "const char *const", "constval": "CollisionBoundsPlaySpaceOn"} ,{ "constname": "k_pch_CollisionBounds_FadeDistance_Float","consttype": "const char *const", "constval": "CollisionBoundsFadeDistance"} +,{ + "constname": "k_pch_CollisionBounds_WallHeight_Float","consttype": "const char *const", "constval": "CollisionBoundsWallHeight"} ,{ "constname": "k_pch_CollisionBounds_ColorGammaR_Int32","consttype": "const char *const", "constval": "CollisionBoundsColorGammaR"} ,{ @@ -905,6 +1637,8 @@ "constname": "k_pch_CollisionBounds_ColorGammaB_Int32","consttype": "const char *const", "constval": "CollisionBoundsColorGammaB"} ,{ "constname": "k_pch_CollisionBounds_ColorGammaA_Int32","consttype": "const char *const", "constval": "CollisionBoundsColorGammaA"} +,{ + "constname": "k_pch_CollisionBounds_EnableDriverImport","consttype": "const char *const", "constval": "enableDriverBoundsImport"} ,{ "constname": "k_pch_Camera_Section","consttype": "const char *const", "constval": "camera"} ,{ @@ -923,84 +1657,336 @@ "constname": "k_pch_Camera_BoundsColorGammaB_Int32","consttype": "const char *const", "constval": "cameraBoundsColorGammaB"} ,{ "constname": "k_pch_Camera_BoundsColorGammaA_Int32","consttype": "const char *const", "constval": "cameraBoundsColorGammaA"} +,{ + "constname": "k_pch_Camera_BoundsStrength_Int32","consttype": "const char *const", "constval": "cameraBoundsStrength"} +,{ + "constname": "k_pch_Camera_RoomViewMode_Int32","consttype": "const char *const", "constval": "cameraRoomViewMode"} ,{ "constname": "k_pch_audio_Section","consttype": "const char *const", "constval": "audio"} ,{ - "constname": "k_pch_audio_OnPlaybackDevice_String","consttype": "const char *const", "constval": "onPlaybackDevice"} + "constname": "k_pch_audio_SetOsDefaultPlaybackDevice_Bool","consttype": "const char *const", "constval": "setOsDefaultPlaybackDevice"} +,{ + "constname": "k_pch_audio_EnablePlaybackDeviceOverride_Bool","consttype": "const char *const", "constval": "enablePlaybackDeviceOverride"} +,{ + "constname": "k_pch_audio_PlaybackDeviceOverride_String","consttype": "const char *const", "constval": "playbackDeviceOverride"} +,{ + "constname": "k_pch_audio_PlaybackDeviceOverrideName_String","consttype": "const char *const", "constval": "playbackDeviceOverrideName"} +,{ + "constname": "k_pch_audio_SetOsDefaultRecordingDevice_Bool","consttype": "const char *const", "constval": "setOsDefaultRecordingDevice"} +,{ + "constname": "k_pch_audio_EnableRecordingDeviceOverride_Bool","consttype": "const char *const", "constval": "enableRecordingDeviceOverride"} +,{ + "constname": "k_pch_audio_RecordingDeviceOverride_String","consttype": "const char *const", "constval": "recordingDeviceOverride"} +,{ + "constname": "k_pch_audio_RecordingDeviceOverrideName_String","consttype": "const char *const", "constval": "recordingDeviceOverrideName"} +,{ + "constname": "k_pch_audio_EnablePlaybackMirror_Bool","consttype": "const char *const", "constval": "enablePlaybackMirror"} ,{ - "constname": "k_pch_audio_OnRecordDevice_String","consttype": "const char *const", "constval": "onRecordDevice"} + "constname": "k_pch_audio_PlaybackMirrorDevice_String","consttype": "const char *const", "constval": "playbackMirrorDevice"} ,{ - "constname": "k_pch_audio_OnPlaybackMirrorDevice_String","consttype": "const char *const", "constval": "onPlaybackMirrorDevice"} + "constname": "k_pch_audio_PlaybackMirrorDeviceName_String","consttype": "const char *const", "constval": "playbackMirrorDeviceName"} ,{ - "constname": "k_pch_audio_OffPlaybackDevice_String","consttype": "const char *const", "constval": "offPlaybackDevice"} + "constname": "k_pch_audio_OldPlaybackMirrorDevice_String","consttype": "const char *const", "constval": "onPlaybackMirrorDevice"} ,{ - "constname": "k_pch_audio_OffRecordDevice_String","consttype": "const char *const", "constval": "offRecordDevice"} + "constname": "k_pch_audio_ActiveMirrorDevice_String","consttype": "const char *const", "constval": "activePlaybackMirrorDevice"} +,{ + "constname": "k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool","consttype": "const char *const", "constval": "enablePlaybackMirrorIndependentVolume"} +,{ + "constname": "k_pch_audio_LastHmdPlaybackDeviceId_String","consttype": "const char *const", "constval": "lastHmdPlaybackDeviceId"} ,{ "constname": "k_pch_audio_VIVEHDMIGain","consttype": "const char *const", "constval": "viveHDMIGain"} +,{ + "constname": "k_pch_Power_Section","consttype": "const char *const", "constval": "power"} +,{ + "constname": "k_pch_Power_PowerOffOnExit_Bool","consttype": "const char *const", "constval": "powerOffOnExit"} +,{ + "constname": "k_pch_Power_TurnOffScreensTimeout_Float","consttype": "const char *const", "constval": "turnOffScreensTimeout"} +,{ + "constname": "k_pch_Power_TurnOffControllersTimeout_Float","consttype": "const char *const", "constval": "turnOffControllersTimeout"} +,{ + "constname": "k_pch_Power_ReturnToWatchdogTimeout_Float","consttype": "const char *const", "constval": "returnToWatchdogTimeout"} +,{ + "constname": "k_pch_Power_AutoLaunchSteamVROnButtonPress","consttype": "const char *const", "constval": "autoLaunchSteamVROnButtonPress"} +,{ + "constname": "k_pch_Power_PauseCompositorOnStandby_Bool","consttype": "const char *const", "constval": "pauseCompositorOnStandby"} +,{ + "constname": "k_pch_Dashboard_Section","consttype": "const char *const", "constval": "dashboard"} +,{ + "constname": "k_pch_Dashboard_EnableDashboard_Bool","consttype": "const char *const", "constval": "enableDashboard"} +,{ + "constname": "k_pch_Dashboard_ArcadeMode_Bool","consttype": "const char *const", "constval": "arcadeMode"} +,{ + "constname": "k_pch_Dashboard_Position","consttype": "const char *const", "constval": "position"} +,{ + "constname": "k_pch_Dashboard_DesktopScale","consttype": "const char *const", "constval": "desktopScale"} +,{ + "constname": "k_pch_Dashboard_DashboardScale","consttype": "const char *const", "constval": "dashboardScale"} ,{ "constname": "k_pch_modelskin_Section","consttype": "const char *const", "constval": "modelskins"} +,{ + "constname": "k_pch_Driver_Enable_Bool","consttype": "const char *const", "constval": "enable"} +,{ + "constname": "k_pch_Driver_BlockedBySafemode_Bool","consttype": "const char *const", "constval": "blocked_by_safe_mode"} +,{ + "constname": "k_pch_Driver_LoadPriority_Int32","consttype": "const char *const", "constval": "loadPriority"} +,{ + "constname": "k_pch_WebInterface_Section","consttype": "const char *const", "constval": "WebInterface"} +,{ + "constname": "k_pch_VRWebHelper_Section","consttype": "const char *const", "constval": "VRWebHelper"} +,{ + "constname": "k_pch_VRWebHelper_DebuggerEnabled_Bool","consttype": "const char *const", "constval": "DebuggerEnabled"} +,{ + "constname": "k_pch_VRWebHelper_DebuggerPort_Int32","consttype": "const char *const", "constval": "DebuggerPort"} +,{ + "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_BindingLegacyAPISuffix_String","consttype": "const char *const", "constval": "_legacy"} +,{ + "constname": "k_pch_App_BindingSteamVRInputAPISuffix_String","consttype": "const char *const", "constval": "_steamvrinput"} +,{ + "constname": "k_pch_App_BindingCurrentURLSuffix_String","consttype": "const char *const", "constval": "CurrentURL"} +,{ + "constname": "k_pch_App_BindingPreviousURLSuffix_String","consttype": "const char *const", "constval": "PreviousURL"} +,{ + "constname": "k_pch_App_NeedToUpdateAutosaveSuffix_Bool","consttype": "const char *const", "constval": "NeedToUpdateAutosave"} +,{ + "constname": "k_pch_App_DominantHand_Int32","consttype": "const char *const", "constval": "DominantHand"} +,{ + "constname": "k_pch_App_BlockOculusSDK_Bool","consttype": "const char *const", "constval": "blockOculusSDK"} +,{ + "constname": "k_pch_Trackers_Section","consttype": "const char *const", "constval": "trackers"} +,{ + "constname": "k_pch_DesktopUI_Section","consttype": "const char *const", "constval": "DesktopUI"} +,{ + "constname": "k_pch_LastKnown_Section","consttype": "const char *const", "constval": "LastKnown"} +,{ + "constname": "k_pch_LastKnown_HMDManufacturer_String","consttype": "const char *const", "constval": "HMDManufacturer"} +,{ + "constname": "k_pch_LastKnown_HMDModel_String","consttype": "const char *const", "constval": "HMDModel"} +,{ + "constname": "k_pch_DismissedWarnings_Section","consttype": "const char *const", "constval": "DismissedWarnings"} +,{ + "constname": "k_pch_Input_Section","consttype": "const char *const", "constval": "input"} +,{ + "constname": "k_pch_Input_LeftThumbstickRotation_Float","consttype": "const char *const", "constval": "leftThumbstickRotation"} +,{ + "constname": "k_pch_Input_RightThumbstickRotation_Float","consttype": "const char *const", "constval": "rightThumbstickRotation"} +,{ + "constname": "k_pch_Input_ThumbstickDeadzone_Float","consttype": "const char *const", "constval": "thumbstickDeadzone"} +,{ + "constname": "k_pch_GpuSpeed_Section","consttype": "const char *const", "constval": "GpuSpeed"} ,{ "constname": "IVRScreenshots_Version","consttype": "const char *const", "constval": "IVRScreenshots_001"} ,{ "constname": "IVRResources_Version","consttype": "const char *const", "constval": "IVRResources_001"} -], -"structs":[{"struct": "vr::HmdMatrix34_t","fields": [ -{ "fieldname": "m", "fieldtype": "float [3][4]"}]} -,{"struct": "vr::HmdMatrix44_t","fields": [ -{ "fieldname": "m", "fieldtype": "float [4][4]"}]} -,{"struct": "vr::HmdVector3_t","fields": [ -{ "fieldname": "v", "fieldtype": "float [3]"}]} -,{"struct": "vr::HmdVector4_t","fields": [ -{ "fieldname": "v", "fieldtype": "float [4]"}]} -,{"struct": "vr::HmdVector3d_t","fields": [ -{ "fieldname": "v", "fieldtype": "double [3]"}]} -,{"struct": "vr::HmdVector2_t","fields": [ -{ "fieldname": "v", "fieldtype": "float [2]"}]} -,{"struct": "vr::HmdQuaternion_t","fields": [ -{ "fieldname": "w", "fieldtype": "double"}, -{ "fieldname": "x", "fieldtype": "double"}, -{ "fieldname": "y", "fieldtype": "double"}, -{ "fieldname": "z", "fieldtype": "double"}]} -,{"struct": "vr::HmdColor_t","fields": [ -{ "fieldname": "r", "fieldtype": "float"}, -{ "fieldname": "g", "fieldtype": "float"}, -{ "fieldname": "b", "fieldtype": "float"}, -{ "fieldname": "a", "fieldtype": "float"}]} -,{"struct": "vr::HmdQuad_t","fields": [ -{ "fieldname": "vCorners", "fieldtype": "struct vr::HmdVector3_t [4]"}]} -,{"struct": "vr::HmdRect2_t","fields": [ -{ "fieldname": "vTopLeft", "fieldtype": "struct vr::HmdVector2_t"}, -{ "fieldname": "vBottomRight", "fieldtype": "struct vr::HmdVector2_t"}]} -,{"struct": "vr::DistortionCoordinates_t","fields": [ -{ "fieldname": "rfRed", "fieldtype": "float [2]"}, -{ "fieldname": "rfGreen", "fieldtype": "float [2]"}, -{ "fieldname": "rfBlue", "fieldtype": "float [2]"}]} -,{"struct": "vr::Texture_t","fields": [ -{ "fieldname": "handle", "fieldtype": "void *"}, -{ "fieldname": "eType", "fieldtype": "enum vr::EGraphicsAPIConvention"}, -{ "fieldname": "eColorSpace", "fieldtype": "enum vr::EColorSpace"}]} -,{"struct": "vr::TrackedDevicePose_t","fields": [ -{ "fieldname": "mDeviceToAbsoluteTracking", "fieldtype": "struct vr::HmdMatrix34_t"}, -{ "fieldname": "vVelocity", "fieldtype": "struct vr::HmdVector3_t"}, -{ "fieldname": "vAngularVelocity", "fieldtype": "struct vr::HmdVector3_t"}, -{ "fieldname": "eTrackingResult", "fieldtype": "enum vr::ETrackingResult"}, -{ "fieldname": "bPoseIsValid", "fieldtype": "_Bool"}, -{ "fieldname": "bDeviceIsConnected", "fieldtype": "_Bool"}]} -,{"struct": "vr::VRTextureBounds_t","fields": [ -{ "fieldname": "uMin", "fieldtype": "float"}, -{ "fieldname": "vMin", "fieldtype": "float"}, -{ "fieldname": "uMax", "fieldtype": "float"}, -{ "fieldname": "vMax", "fieldtype": "float"}]} -,{"struct": "vr::VREvent_Controller_t","fields": [ -{ "fieldname": "button", "fieldtype": "uint32_t"}]} -,{"struct": "vr::VREvent_Mouse_t","fields": [ -{ "fieldname": "x", "fieldtype": "float"}, -{ "fieldname": "y", "fieldtype": "float"}, -{ "fieldname": "button", "fieldtype": "uint32_t"}]} -,{"struct": "vr::VREvent_Scroll_t","fields": [ +,{ + "constname": "IVRDriverManager_Version","consttype": "const char *const", "constval": "IVRDriverManager_001"} +,{ + "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": "k_unMaxBoneNameLength","consttype": "const uint32_t", "constval": "32"} +,{ + "constname": "k_nActionSetOverlayGlobalPriorityMin","consttype": "const int32_t", "constval": "16777216"} +,{ + "constname": "k_nActionSetOverlayGlobalPriorityMax","consttype": "const int32_t", "constval": "33554431"} +,{ + "constname": "k_nActionSetPriorityReservedMin","consttype": "const int32_t", "constval": "33554432"} +,{ + "constname": "IVRInput_Version","consttype": "const char *const", "constval": "IVRInput_010"} +,{ + "constname": "k_ulInvalidIOBufferHandle","consttype": "const uint64_t", "constval": "0"} +,{ + "constname": "IVRIOBuffer_Version","consttype": "const char *", "constval": "IVRIOBuffer_002"} +,{ + "constname": "k_ulInvalidSpatialAnchorHandle","consttype": "const SpatialAnchorHandle_t", "constval": "0"} +,{ + "constname": "IVRSpatialAnchors_Version","consttype": "const char *const", "constval": "IVRSpatialAnchors_001"} +,{ + "constname": "IVRDebug_Version","consttype": "const char *const", "constval": "IVRDebug_001"} +,{ + "constname": "k_ulDisplayRedirectContainer","consttype": "const PropertyContainerHandle_t", "constval": "25769803779"} +,{ + "constname": "IVRProperties_Version","consttype": "const char *const", "constval": "IVRProperties_001"} +,{ + "constname": "k_pchPathUserHandRight","consttype": "const char *", "constval": "/user/hand/right"} +,{ + "constname": "k_pchPathUserHandLeft","consttype": "const char *", "constval": "/user/hand/left"} +,{ + "constname": "k_pchPathUserHandPrimary","consttype": "const char *", "constval": "/user/hand/primary"} +,{ + "constname": "k_pchPathUserHandSecondary","consttype": "const char *", "constval": "/user/hand/secondary"} +,{ + "constname": "k_pchPathUserHead","consttype": "const char *", "constval": "/user/head"} +,{ + "constname": "k_pchPathUserGamepad","consttype": "const char *", "constval": "/user/gamepad"} +,{ + "constname": "k_pchPathUserTreadmill","consttype": "const char *", "constval": "/user/treadmill"} +,{ + "constname": "k_pchPathUserStylus","consttype": "const char *", "constval": "/user/stylus"} +,{ + "constname": "k_pchPathDevices","consttype": "const char *", "constval": "/devices"} +,{ + "constname": "k_pchPathDevicePath","consttype": "const char *", "constval": "/device_path"} +,{ + "constname": "k_pchPathBestAliasPath","consttype": "const char *", "constval": "/best_alias_path"} +,{ + "constname": "k_pchPathBoundTrackerAliasPath","consttype": "const char *", "constval": "/bound_tracker_path"} +,{ + "constname": "k_pchPathBoundTrackerRole","consttype": "const char *", "constval": "/bound_tracker_role"} +,{ + "constname": "k_pchPathPoseRaw","consttype": "const char *", "constval": "/pose/raw"} +,{ + "constname": "k_pchPathPoseTip","consttype": "const char *", "constval": "/pose/tip"} +,{ + "constname": "k_pchPathSystemButtonClick","consttype": "const char *", "constval": "/input/system/click"} +,{ + "constname": "k_pchPathProximity","consttype": "const char *", "constval": "/proximity"} +,{ + "constname": "k_pchPathControllerTypePrefix","consttype": "const char *", "constval": "/controller_type/"} +,{ + "constname": "k_pchPathInputProfileSuffix","consttype": "const char *", "constval": "/input_profile"} +,{ + "constname": "k_pchPathBindingNameSuffix","consttype": "const char *", "constval": "/binding_name"} +,{ + "constname": "k_pchPathBindingUrlSuffix","consttype": "const char *", "constval": "/binding_url"} +,{ + "constname": "k_pchPathBindingErrorSuffix","consttype": "const char *", "constval": "/binding_error"} +,{ + "constname": "k_pchPathActiveActionSets","consttype": "const char *", "constval": "/active_action_sets"} +,{ + "constname": "k_pchPathComponentUpdates","consttype": "const char *", "constval": "/total_component_updates"} +,{ + "constname": "k_pchPathUserFootLeft","consttype": "const char *", "constval": "/user/foot/left"} +,{ + "constname": "k_pchPathUserFootRight","consttype": "const char *", "constval": "/user/foot/right"} +,{ + "constname": "k_pchPathUserShoulderLeft","consttype": "const char *", "constval": "/user/shoulder/left"} +,{ + "constname": "k_pchPathUserShoulderRight","consttype": "const char *", "constval": "/user/shoulder/right"} +,{ + "constname": "k_pchPathUserElbowLeft","consttype": "const char *", "constval": "/user/elbow/left"} +,{ + "constname": "k_pchPathUserElbowRight","consttype": "const char *", "constval": "/user/elbow/right"} +,{ + "constname": "k_pchPathUserKneeLeft","consttype": "const char *", "constval": "/user/knee/left"} +,{ + "constname": "k_pchPathUserKneeRight","consttype": "const char *", "constval": "/user/knee/right"} +,{ + "constname": "k_pchPathUserWaist","consttype": "const char *", "constval": "/user/waist"} +,{ + "constname": "k_pchPathUserChest","consttype": "const char *", "constval": "/user/chest"} +,{ + "constname": "k_pchPathUserCamera","consttype": "const char *", "constval": "/user/camera"} +,{ + "constname": "k_pchPathUserKeyboard","consttype": "const char *", "constval": "/user/keyboard"} +,{ + "constname": "k_pchPathClientAppKey","consttype": "const char *", "constval": "/client_info/app_key"} +,{ + "constname": "k_ulInvalidPathHandle","consttype": "const PathHandle_t", "constval": "0"} +,{ + "constname": "IVRPaths_Version","consttype": "const char *const", "constval": "IVRPaths_001"} +,{ + "constname": "IVRBlockQueue_Version","consttype": "const char *", "constval": "IVRBlockQueue_004"} +], +"structs":[{"struct": "vr::HmdMatrix34_t","fields": [ +{ "fieldname": "m", "fieldtype": "float [3][4]"}]} +,{"struct": "vr::HmdMatrix33_t","fields": [ +{ "fieldname": "m", "fieldtype": "float [3][3]"}]} +,{"struct": "vr::HmdMatrix44_t","fields": [ +{ "fieldname": "m", "fieldtype": "float [4][4]"}]} +,{"struct": "vr::HmdVector3_t","fields": [ +{ "fieldname": "v", "fieldtype": "float [3]"}]} +,{"struct": "vr::HmdVector4_t","fields": [ +{ "fieldname": "v", "fieldtype": "float [4]"}]} +,{"struct": "vr::HmdVector3d_t","fields": [ +{ "fieldname": "v", "fieldtype": "double [3]"}]} +,{"struct": "vr::HmdVector2_t","fields": [ +{ "fieldname": "v", "fieldtype": "float [2]"}]} +,{"struct": "vr::HmdQuaternion_t","fields": [ +{ "fieldname": "w", "fieldtype": "double"}, +{ "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"}, +{ "fieldname": "b", "fieldtype": "float"}, +{ "fieldname": "a", "fieldtype": "float"}]} +,{"struct": "vr::HmdQuad_t","fields": [ +{ "fieldname": "vCorners", "fieldtype": "struct vr::HmdVector3_t [4]"}]} +,{"struct": "vr::HmdRect2_t","fields": [ +{ "fieldname": "vTopLeft", "fieldtype": "struct vr::HmdVector2_t"}, +{ "fieldname": "vBottomRight", "fieldtype": "struct vr::HmdVector2_t"}]} +,{"struct": "vr::DistortionCoordinates_t","fields": [ +{ "fieldname": "rfRed", "fieldtype": "float [2]"}, +{ "fieldname": "rfGreen", "fieldtype": "float [2]"}, +{ "fieldname": "rfBlue", "fieldtype": "float [2]"}]} +,{"struct": "vr::Texture_t","fields": [ +{ "fieldname": "handle", "fieldtype": "void *"}, +{ "fieldname": "eType", "fieldtype": "enum vr::ETextureType"}, +{ "fieldname": "eColorSpace", "fieldtype": "enum vr::EColorSpace"}]} +,{"struct": "vr::TrackedDevicePose_t","fields": [ +{ "fieldname": "mDeviceToAbsoluteTracking", "fieldtype": "struct vr::HmdMatrix34_t"}, +{ "fieldname": "vVelocity", "fieldtype": "struct vr::HmdVector3_t"}, +{ "fieldname": "vAngularVelocity", "fieldtype": "struct vr::HmdVector3_t"}, +{ "fieldname": "eTrackingResult", "fieldtype": "enum vr::ETrackingResult"}, +{ "fieldname": "bPoseIsValid", "fieldtype": "_Bool"}, +{ "fieldname": "bDeviceIsConnected", "fieldtype": "_Bool"}]} +,{"struct": "vr::VRTextureBounds_t","fields": [ +{ "fieldname": "uMin", "fieldtype": "float"}, +{ "fieldname": "vMin", "fieldtype": "float"}, +{ "fieldname": "uMax", "fieldtype": "float"}, +{ "fieldname": "vMax", "fieldtype": "float"}]} +,{"struct": "vr::VRTextureWithPose_t","fields": [ +{ "fieldname": "mDeviceToAbsoluteTracking", "fieldtype": "struct vr::HmdMatrix34_t"}]} +,{"struct": "vr::VRTextureDepthInfo_t","fields": [ +{ "fieldname": "handle", "fieldtype": "void *"}, +{ "fieldname": "mProjection", "fieldtype": "struct vr::HmdMatrix44_t"}, +{ "fieldname": "vRange", "fieldtype": "struct vr::HmdVector2_t"}]} +,{"struct": "vr::VRTextureWithDepth_t","fields": [ +{ "fieldname": "depth", "fieldtype": "struct vr::VRTextureDepthInfo_t"}]} +,{"struct": "vr::VRTextureWithPoseAndDepth_t","fields": [ +{ "fieldname": "depth", "fieldtype": "struct vr::VRTextureDepthInfo_t"}]} +,{"struct": "vr::VRVulkanTextureData_t","fields": [ +{ "fieldname": "m_nImage", "fieldtype": "uint64_t"}, +{ "fieldname": "m_pDevice", "fieldtype": "struct VkDevice_T *"}, +{ "fieldname": "m_pPhysicalDevice", "fieldtype": "struct VkPhysicalDevice_T *"}, +{ "fieldname": "m_pInstance", "fieldtype": "struct VkInstance_T *"}, +{ "fieldname": "m_pQueue", "fieldtype": "struct VkQueue_T *"}, +{ "fieldname": "m_nQueueFamilyIndex", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nWidth", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nHeight", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nFormat", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nSampleCount", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VRVulkanTextureArrayData_t","fields": [ +{ "fieldname": "m_unArrayIndex", "fieldtype": "uint32_t"}, +{ "fieldname": "m_unArraySize", "fieldtype": "uint32_t"}]} +,{"struct": "vr::D3D12TextureData_t","fields": [ +{ "fieldname": "m_pResource", "fieldtype": "struct ID3D12Resource *"}, +{ "fieldname": "m_pCommandQueue", "fieldtype": "struct ID3D12CommandQueue *"}, +{ "fieldname": "m_nNodeMask", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_Controller_t","fields": [ +{ "fieldname": "button", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_Mouse_t","fields": [ +{ "fieldname": "x", "fieldtype": "float"}, +{ "fieldname": "y", "fieldtype": "float"}, +{ "fieldname": "button", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_Scroll_t","fields": [ { "fieldname": "xdelta", "fieldtype": "float"}, { "fieldname": "ydelta", "fieldtype": "float"}, -{ "fieldname": "repeatCount", "fieldtype": "uint32_t"}]} +{ "fieldname": "unused", "fieldtype": "uint32_t"}, +{ "fieldname": "viewportscale", "fieldtype": "float"}]} ,{"struct": "vr::VREvent_TouchPadMove_t","fields": [ { "fieldname": "bFingerDown", "fieldtype": "_Bool"}, { "fieldname": "flSecondsFingerDown", "fieldtype": "float"}, @@ -1014,9 +2000,11 @@ ,{"struct": "vr::VREvent_Process_t","fields": [ { "fieldname": "pid", "fieldtype": "uint32_t"}, { "fieldname": "oldPid", "fieldtype": "uint32_t"}, -{ "fieldname": "bForced", "fieldtype": "_Bool"}]} +{ "fieldname": "bForced", "fieldtype": "_Bool"}, +{ "fieldname": "bConnectionLost", "fieldtype": "_Bool"}]} ,{"struct": "vr::VREvent_Overlay_t","fields": [ -{ "fieldname": "overlayHandle", "fieldtype": "uint64_t"}]} +{ "fieldname": "overlayHandle", "fieldtype": "uint64_t"}, +{ "fieldname": "devicePath", "fieldtype": "uint64_t"}]} ,{"struct": "vr::VREvent_Status_t","fields": [ { "fieldname": "statusState", "fieldtype": "uint32_t"}]} ,{"struct": "vr::VREvent_Keyboard_t","fields": [ @@ -1029,7 +2017,11 @@ { "fieldname": "m_nCurrentUniverse", "fieldtype": "uint64_t"}]} ,{"struct": "vr::VREvent_Reserved_t","fields": [ { "fieldname": "reserved0", "fieldtype": "uint64_t"}, -{ "fieldname": "reserved1", "fieldtype": "uint64_t"}]} +{ "fieldname": "reserved1", "fieldtype": "uint64_t"}, +{ "fieldname": "reserved2", "fieldtype": "uint64_t"}, +{ "fieldname": "reserved3", "fieldtype": "uint64_t"}, +{ "fieldname": "reserved4", "fieldtype": "uint64_t"}, +{ "fieldname": "reserved5", "fieldtype": "uint64_t"}]} ,{"struct": "vr::VREvent_PerformanceTest_t","fields": [ { "fieldname": "m_nFidelityLevel", "fieldtype": "uint32_t"}]} ,{"struct": "vr::VREvent_SeatedZeroPoseReset_t","fields": [ @@ -1042,6 +2034,47 @@ ,{"struct": "vr::VREvent_ApplicationLaunch_t","fields": [ { "fieldname": "pid", "fieldtype": "uint32_t"}, { "fieldname": "unArgsHandle", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_EditingCameraSurface_t","fields": [ +{ "fieldname": "overlayHandle", "fieldtype": "uint64_t"}, +{ "fieldname": "nVisualMode", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_MessageOverlay_t","fields": [ +{ "fieldname": "unVRMessageOverlayResponse", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VREvent_Property_t","fields": [ +{ "fieldname": "container", "fieldtype": "PropertyContainerHandle_t"}, +{ "fieldname": "prop", "fieldtype": "enum vr::ETrackedDeviceProperty"}]} +,{"struct": "vr::VREvent_HapticVibration_t","fields": [ +{ "fieldname": "containerHandle", "fieldtype": "uint64_t"}, +{ "fieldname": "componentHandle", "fieldtype": "uint64_t"}, +{ "fieldname": "fDurationSeconds", "fieldtype": "float"}, +{ "fieldname": "fFrequency", "fieldtype": "float"}, +{ "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"}, +{ "fieldname": "pathControllerType", "fieldtype": "uint64_t"}]} +,{"struct": "vr::VREvent_InputActionManifestLoad_t","fields": [ +{ "fieldname": "pathAppKey", "fieldtype": "uint64_t"}, +{ "fieldname": "pathMessage", "fieldtype": "uint64_t"}, +{ "fieldname": "pathMessageParam", "fieldtype": "uint64_t"}, +{ "fieldname": "pathManifestPath", "fieldtype": "uint64_t"}]} +,{"struct": "vr::VREvent_SpatialAnchor_t","fields": [ +{ "fieldname": "unHandle", "fieldtype": "SpatialAnchorHandle_t"}]} +,{"struct": "vr::VREvent_ProgressUpdate_t","fields": [ +{ "fieldname": "ulApplicationPropertyContainer", "fieldtype": "uint64_t"}, +{ "fieldname": "pathDevice", "fieldtype": "uint64_t"}, +{ "fieldname": "pathInputSource", "fieldtype": "uint64_t"}, +{ "fieldname": "pathProgressAction", "fieldtype": "uint64_t"}, +{ "fieldname": "pathIcon", "fieldtype": "uint64_t"}, +{ "fieldname": "fProgress", "fieldtype": "float"}]} +,{"struct": "vr::VREvent_ShowUI_t","fields": [ +{ "fieldname": "eType", "fieldtype": "enum vr::EShowUIType"}]} +,{"struct": "vr::VREvent_ShowDevTools_t","fields": [ +{ "fieldname": "nBrowserIdentifier", "fieldtype": "int32_t"}]} +,{"struct": "vr::VREvent_HDCPError_t","fields": [ +{ "fieldname": "eCode", "fieldtype": "enum vr::EHDCPError"}]} ,{"struct": "vr::(anonymous)","fields": [ { "fieldname": "reserved", "fieldtype": "struct vr::VREvent_Reserved_t"}, { "fieldname": "controller", "fieldtype": "struct vr::VREvent_Controller_t"}, @@ -1059,12 +2092,28 @@ { "fieldname": "seatedZeroPoseReset", "fieldtype": "struct vr::VREvent_SeatedZeroPoseReset_t"}, { "fieldname": "screenshot", "fieldtype": "struct vr::VREvent_Screenshot_t"}, { "fieldname": "screenshotProgress", "fieldtype": "struct vr::VREvent_ScreenshotProgress_t"}, -{ "fieldname": "applicationLaunch", "fieldtype": "struct vr::VREvent_ApplicationLaunch_t"}]} +{ "fieldname": "applicationLaunch", "fieldtype": "struct vr::VREvent_ApplicationLaunch_t"}, +{ "fieldname": "cameraSurface", "fieldtype": "struct vr::VREvent_EditingCameraSurface_t"}, +{ "fieldname": "messageOverlay", "fieldtype": "struct vr::VREvent_MessageOverlay_t"}, +{ "fieldname": "property", "fieldtype": "struct vr::VREvent_Property_t"}, +{ "fieldname": "hapticVibration", "fieldtype": "struct vr::VREvent_HapticVibration_t"}, +{ "fieldname": "webConsole", "fieldtype": "struct vr::VREvent_WebConsole_t"}, +{ "fieldname": "inputBinding", "fieldtype": "struct vr::VREvent_InputBindingLoad_t"}, +{ "fieldname": "actionManifest", "fieldtype": "struct vr::VREvent_InputActionManifestLoad_t"}, +{ "fieldname": "spatialAnchor", "fieldtype": "struct vr::VREvent_SpatialAnchor_t"}, +{ "fieldname": "progressUpdate", "fieldtype": "struct vr::VREvent_ProgressUpdate_t"}, +{ "fieldname": "showUi", "fieldtype": "struct vr::VREvent_ShowUI_t"}, +{ "fieldname": "showDevTools", "fieldtype": "struct vr::VREvent_ShowDevTools_t"}, +{ "fieldname": "hdcpError", "fieldtype": "struct vr::VREvent_HDCPError_t"}]} ,{"struct": "vr::VREvent_t","fields": [ { "fieldname": "eventType", "fieldtype": "uint32_t"}, { "fieldname": "trackedDeviceIndex", "fieldtype": "TrackedDeviceIndex_t"}, { "fieldname": "eventAgeSeconds", "fieldtype": "float"}, { "fieldname": "data", "fieldtype": "VREvent_Data_t"}]} +,{"struct": "vr::RenderModel_ComponentState_t","fields": [ +{ "fieldname": "mTrackingToComponentRenderModel", "fieldtype": "struct vr::HmdMatrix34_t"}, +{ "fieldname": "mTrackingToComponentLocal", "fieldtype": "struct vr::HmdMatrix34_t"}, +{ "fieldname": "uProperties", "fieldtype": "VRComponentProperties"}]} ,{"struct": "vr::HiddenAreaMesh_t","fields": [ { "fieldname": "pVertexData", "fieldtype": "const struct vr::HmdVector2_t *"}, { "fieldname": "unTriangleCount", "fieldtype": "uint32_t"}]} @@ -1076,35 +2125,22 @@ { "fieldname": "ulButtonPressed", "fieldtype": "uint64_t"}, { "fieldname": "ulButtonTouched", "fieldtype": "uint64_t"}, { "fieldname": "rAxis", "fieldtype": "struct vr::VRControllerAxis_t [5]"}]} -,{"struct": "vr::Compositor_OverlaySettings","fields": [ -{ "fieldname": "size", "fieldtype": "uint32_t"}, -{ "fieldname": "curved", "fieldtype": "_Bool"}, -{ "fieldname": "antialias", "fieldtype": "_Bool"}, -{ "fieldname": "scale", "fieldtype": "float"}, -{ "fieldname": "distance", "fieldtype": "float"}, -{ "fieldname": "alpha", "fieldtype": "float"}, -{ "fieldname": "uOffset", "fieldtype": "float"}, -{ "fieldname": "vOffset", "fieldtype": "float"}, -{ "fieldname": "uScale", "fieldtype": "float"}, -{ "fieldname": "vScale", "fieldtype": "float"}, -{ "fieldname": "gridDivs", "fieldtype": "float"}, -{ "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"}, { "fieldname": "nHeight", "fieldtype": "uint32_t"}, { "fieldname": "nBytesPerPixel", "fieldtype": "uint32_t"}, { "fieldname": "nFrameSequence", "fieldtype": "uint32_t"}, -{ "fieldname": "standingTrackedDevicePose", "fieldtype": "struct vr::TrackedDevicePose_t"}]} -,{"struct": "vr::AppOverrideKeys_t","fields": [ -{ "fieldname": "pchKey", "fieldtype": "const char *"}, -{ "fieldname": "pchValue", "fieldtype": "const char *"}]} +{ "fieldname": "trackedDevicePose", "fieldtype": "struct vr::TrackedDevicePose_t"}, +{ "fieldname": "ulFrameExposureTime", "fieldtype": "uint64_t"}]} ,{"struct": "vr::Compositor_FrameTiming","fields": [ { "fieldname": "m_nSize", "fieldtype": "uint32_t"}, { "fieldname": "m_nFrameIndex", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumFramePresents", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nNumMisPresented", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumDroppedFrames", "fieldtype": "uint32_t"}, { "fieldname": "m_nReprojectionFlags", "fieldtype": "uint32_t"}, { "fieldname": "m_flSystemTimeInSeconds", "fieldtype": "double"}, @@ -1124,7 +2160,26 @@ { "fieldname": "m_flCompositorUpdateStartMs", "fieldtype": "float"}, { "fieldname": "m_flCompositorUpdateEndMs", "fieldtype": "float"}, { "fieldname": "m_flCompositorRenderStartMs", "fieldtype": "float"}, -{ "fieldname": "m_HmdPose", "fieldtype": "vr::TrackedDevicePose_t"}]} +{ "fieldname": "m_HmdPose", "fieldtype": "vr::TrackedDevicePose_t"}, +{ "fieldname": "m_nNumVSyncsReadyForUse", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nNumVSyncsToFirstView", "fieldtype": "uint32_t"}]} +,{"struct": "vr::Compositor_BenchmarkResults","fields": [ +{ "fieldname": "m_flMegaPixelsPerSecond", "fieldtype": "float"}, +{ "fieldname": "m_flHmdRecommendedMegaPixelsPerSecond", "fieldtype": "float"}]} +,{"struct": "vr::DriverDirectMode_FrameTiming","fields": [ +{ "fieldname": "m_nSize", "fieldtype": "uint32_t"}, +{ "fieldname": "m_nNumFramePresents", "fieldtype": "uint32_t"}, +{ "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 *"}]} ,{"struct": "vr::Compositor_CumulativeStats","fields": [ { "fieldname": "m_nPid", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumFramePresents", "fieldtype": "uint32_t"}, @@ -1141,6 +2196,15 @@ { "fieldname": "m_nNumFramePresentsTimedOut", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumDroppedFramesTimedOut", "fieldtype": "uint32_t"}, { "fieldname": "m_nNumReprojectedFramesTimedOut", "fieldtype": "uint32_t"}]} +,{"struct": "vr::Compositor_StageRenderSettings","fields": [ +{ "fieldname": "m_PrimaryColor", "fieldtype": "struct vr::HmdColor_t"}, +{ "fieldname": "m_SecondaryColor", "fieldtype": "struct vr::HmdColor_t"}, +{ "fieldname": "m_flVignetteInnerRadius", "fieldtype": "float"}, +{ "fieldname": "m_flVignetteOuterRadius", "fieldtype": "float"}, +{ "fieldname": "m_flFresnelStrength", "fieldtype": "float"}, +{ "fieldname": "m_bBackfaceCulling", "fieldtype": "_Bool"}, +{ "fieldname": "m_bGreyscale", "fieldtype": "_Bool"}, +{ "fieldname": "m_bWireframe", "fieldtype": "_Bool"}]} ,{"struct": "vr::VROverlayIntersectionParams_t","fields": [ { "fieldname": "vSource", "fieldtype": "struct vr::HmdVector3_t"}, { "fieldname": "vDirection", "fieldtype": "struct vr::HmdVector3_t"}, @@ -1150,10 +2214,34 @@ { "fieldname": "vNormal", "fieldtype": "struct vr::HmdVector3_t"}, { "fieldname": "vUVs", "fieldtype": "struct vr::HmdVector2_t"}, { "fieldname": "fDistance", "fieldtype": "float"}]} -,{"struct": "vr::RenderModel_ComponentState_t","fields": [ -{ "fieldname": "mTrackingToComponentRenderModel", "fieldtype": "struct vr::HmdMatrix34_t"}, -{ "fieldname": "mTrackingToComponentLocal", "fieldtype": "struct vr::HmdMatrix34_t"}, -{ "fieldname": "uProperties", "fieldtype": "VRComponentProperties"}]} +,{"struct": "vr::IntersectionMaskRectangle_t","fields": [ +{ "fieldname": "m_flTopLeftX", "fieldtype": "float"}, +{ "fieldname": "m_flTopLeftY", "fieldtype": "float"}, +{ "fieldname": "m_flWidth", "fieldtype": "float"}, +{ "fieldname": "m_flHeight", "fieldtype": "float"}]} +,{"struct": "vr::IntersectionMaskCircle_t","fields": [ +{ "fieldname": "m_flCenterX", "fieldtype": "float"}, +{ "fieldname": "m_flCenterY", "fieldtype": "float"}, +{ "fieldname": "m_flRadius", "fieldtype": "float"}]} +,{"struct": "vr::(anonymous)","fields": [ +{ "fieldname": "m_Rectangle", "fieldtype": "struct vr::IntersectionMaskRectangle_t"}, +{ "fieldname": "m_Circle", "fieldtype": "struct vr::IntersectionMaskCircle_t"}]} +,{"struct": "vr::VROverlayIntersectionMaskPrimitive_t","fields": [ +{ "fieldname": "m_nPrimitiveType", "fieldtype": "enum vr::EVROverlayIntersectionMaskPrimitiveType"}, +{ "fieldname": "m_Primitive", "fieldtype": "VROverlayIntersectionMaskPrimitive_Data_t"}]} +,{"struct": "vr::VROverlayView_t","fields": [ +{ "fieldname": "overlayHandle", "fieldtype": "VROverlayHandle_t"}, +{ "fieldname": "texture", "fieldtype": "struct vr::Texture_t"}, +{ "fieldname": "textureBounds", "fieldtype": "struct vr::VRTextureBounds_t"}]} +,{"struct": "vr::VRVulkanDevice_t","fields": [ +{ "fieldname": "m_pInstance", "fieldtype": "struct VkInstance_T *"}, +{ "fieldname": "m_pDevice", "fieldtype": "struct VkDevice_T *"}, +{ "fieldname": "m_pPhysicalDevice", "fieldtype": "struct VkPhysicalDevice_T *"}, +{ "fieldname": "m_pQueue", "fieldtype": "struct VkQueue_T *"}, +{ "fieldname": "m_uQueueFamilyIndex", "fieldtype": "uint32_t"}]} +,{"struct": "vr::VRNativeDevice_t","fields": [ +{ "fieldname": "handle", "fieldtype": "void *"}, +{ "fieldname": "eType", "fieldtype": "enum vr::EDeviceType"}]} ,{"struct": "vr::RenderModel_Vertex_t","fields": [ { "fieldname": "vPosition", "fieldtype": "struct vr::HmdVector3_t"}, { "fieldname": "vNormal", "fieldtype": "struct vr::HmdVector3_t"}, @@ -1161,7 +2249,8 @@ ,{"struct": "vr::RenderModel_TextureMap_t","fields": [ { "fieldname": "unWidth", "fieldtype": "uint16_t"}, { "fieldname": "unHeight", "fieldtype": "uint16_t"}, -{ "fieldname": "rubTextureMapData", "fieldtype": "const uint8_t *"}]} +{ "fieldname": "rubTextureMapData", "fieldtype": "const uint8_t *"}, +{ "fieldname": "format", "fieldtype": "enum vr::EVRRenderModelTextureFormat"}]} ,{"struct": "vr::RenderModel_t","fields": [ { "fieldname": "rVertexData", "fieldtype": "const struct vr::RenderModel_Vertex_t *"}, { "fieldname": "unVertexCount", "fieldtype": "uint32_t"}, @@ -1175,19 +2264,107 @@ { "fieldname": "m_nWidth", "fieldtype": "int32_t"}, { "fieldname": "m_nHeight", "fieldtype": "int32_t"}, { "fieldname": "m_nBytesPerPixel", "fieldtype": "int32_t"}]} +,{"struct": "vr::CVRSettingHelper","fields": [ +{ "fieldname": "m_pSettings", "fieldtype": "class vr::IVRSettings *"}]} +,{"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::InputSkeletalActionData_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::InputBindingInfo_t","fields": [ +{ "fieldname": "rchDevicePathName", "fieldtype": "char [128]"}, +{ "fieldname": "rchInputPathName", "fieldtype": "char [128]"}, +{ "fieldname": "rchModeName", "fieldtype": "char [128]"}, +{ "fieldname": "rchSlotName", "fieldtype": "char [128]"}, +{ "fieldname": "rchInputSourceType", "fieldtype": "char [32]"}]} +,{"struct": "vr::VRActiveActionSet_t","fields": [ +{ "fieldname": "ulActionSet", "fieldtype": "VRActionSetHandle_t"}, +{ "fieldname": "ulRestrictedToDevice", "fieldtype": "VRInputValueHandle_t"}, +{ "fieldname": "ulSecondaryActionSet", "fieldtype": "VRActionSetHandle_t"}, +{ "fieldname": "unPadding", "fieldtype": "uint32_t"}, +{ "fieldname": "nPriority", "fieldtype": "int32_t"}]} +,{"struct": "vr::VRSkeletalSummaryData_t","fields": [ +{ "fieldname": "flFingerCurl", "fieldtype": "float [5]"}, +{ "fieldname": "flFingerSplay", "fieldtype": "float [4]"}]} +,{"struct": "vr::SpatialAnchorPose_t","fields": [ +{ "fieldname": "mAnchorToAbsoluteTracking", "fieldtype": "struct vr::HmdMatrix34_t"}]} ,{"struct": "vr::COpenVRContext","fields": [ { "fieldname": "m_pVRSystem", "fieldtype": "class vr::IVRSystem *"}, { "fieldname": "m_pVRChaperone", "fieldtype": "class vr::IVRChaperone *"}, { "fieldname": "m_pVRChaperoneSetup", "fieldtype": "class vr::IVRChaperoneSetup *"}, { "fieldname": "m_pVRCompositor", "fieldtype": "class vr::IVRCompositor *"}, +{ "fieldname": "m_pVRHeadsetView", "fieldtype": "class vr::IVRHeadsetView *"}, { "fieldname": "m_pVROverlay", "fieldtype": "class vr::IVROverlay *"}, +{ "fieldname": "m_pVROverlayView", "fieldtype": "class vr::IVROverlayView *"}, { "fieldname": "m_pVRResources", "fieldtype": "class vr::IVRResources *"}, { "fieldname": "m_pVRRenderModels", "fieldtype": "class vr::IVRRenderModels *"}, { "fieldname": "m_pVRExtendedDisplay", "fieldtype": "class vr::IVRExtendedDisplay *"}, { "fieldname": "m_pVRSettings", "fieldtype": "class vr::IVRSettings *"}, { "fieldname": "m_pVRApplications", "fieldtype": "class vr::IVRApplications *"}, { "fieldname": "m_pVRTrackedCamera", "fieldtype": "class vr::IVRTrackedCamera *"}, -{ "fieldname": "m_pVRScreenshots", "fieldtype": "class vr::IVRScreenshots *"}]} +{ "fieldname": "m_pVRScreenshots", "fieldtype": "class vr::IVRScreenshots *"}, +{ "fieldname": "m_pVRDriverManager", "fieldtype": "class vr::IVRDriverManager *"}, +{ "fieldname": "m_pVRInput", "fieldtype": "class vr::IVRInput *"}, +{ "fieldname": "m_pVRIOBuffer", "fieldtype": "class vr::IVRIOBuffer *"}, +{ "fieldname": "m_pVRSpatialAnchors", "fieldtype": "class vr::IVRSpatialAnchors *"}, +{ "fieldname": "m_pVRDebug", "fieldtype": "class vr::IVRDebug *"}, +{ "fieldname": "m_pVRNotifications", "fieldtype": "class vr::IVRNotifications *"}]} +,{"struct": "vr::PropertyWrite_t","fields": [ +{ "fieldname": "prop", "fieldtype": "enum vr::ETrackedDeviceProperty"}, +{ "fieldname": "writeType", "fieldtype": "enum vr::EPropertyWriteType"}, +{ "fieldname": "eSetError", "fieldtype": "enum vr::ETrackedPropertyError"}, +{ "fieldname": "pvBuffer", "fieldtype": "void *"}, +{ "fieldname": "unBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "unTag", "fieldtype": "PropertyTypeTag_t"}, +{ "fieldname": "eError", "fieldtype": "enum vr::ETrackedPropertyError"}]} +,{"struct": "vr::PropertyRead_t","fields": [ +{ "fieldname": "prop", "fieldtype": "enum vr::ETrackedDeviceProperty"}, +{ "fieldname": "pvBuffer", "fieldtype": "void *"}, +{ "fieldname": "unBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "unTag", "fieldtype": "PropertyTypeTag_t"}, +{ "fieldname": "unRequiredBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "eError", "fieldtype": "enum vr::ETrackedPropertyError"}]} +,{"struct": "vr::CVRPropertyHelpers","fields": [ +{ "fieldname": "m_pProperties", "fieldtype": "class vr::IVRProperties *"}]} +,{"struct": "vr::PathWrite_t","fields": [ +{ "fieldname": "ulPath", "fieldtype": "PathHandle_t"}, +{ "fieldname": "writeType", "fieldtype": "enum vr::EPropertyWriteType"}, +{ "fieldname": "eSetError", "fieldtype": "enum vr::ETrackedPropertyError"}, +{ "fieldname": "pvBuffer", "fieldtype": "void *"}, +{ "fieldname": "unBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "unTag", "fieldtype": "PropertyTypeTag_t"}, +{ "fieldname": "eError", "fieldtype": "enum vr::ETrackedPropertyError"}, +{ "fieldname": "pszPath", "fieldtype": "const char *"}]} +,{"struct": "vr::PathRead_t","fields": [ +{ "fieldname": "ulPath", "fieldtype": "PathHandle_t"}, +{ "fieldname": "pvBuffer", "fieldtype": "void *"}, +{ "fieldname": "unBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "unTag", "fieldtype": "PropertyTypeTag_t"}, +{ "fieldname": "unRequiredBufferSize", "fieldtype": "uint32_t"}, +{ "fieldname": "eError", "fieldtype": "enum vr::ETrackedPropertyError"}, +{ "fieldname": "pszPath", "fieldtype": "const char *"}]} ], "methods":[{ "classname": "vr::IVRSystem", @@ -1205,8 +2382,7 @@ "params": [ { "paramname": "eEye" ,"paramtype": "vr::EVREye"}, { "paramname": "fNearZ" ,"paramtype": "float"}, -{ "paramname": "fFarZ" ,"paramtype": "float"}, -{ "paramname": "eProjType" ,"paramtype": "vr::EGraphicsAPIConvention"} +{ "paramname": "fFarZ" ,"paramtype": "float"} ] } ,{ @@ -1224,11 +2400,12 @@ ,{ "classname": "vr::IVRSystem", "methodname": "ComputeDistortion", - "returntype": "struct vr::DistortionCoordinates_t", + "returntype": "bool", "params": [ { "paramname": "eEye" ,"paramtype": "vr::EVREye"}, { "paramname": "fU" ,"paramtype": "float"}, -{ "paramname": "fV" ,"paramtype": "float"} +{ "paramname": "fV" ,"paramtype": "float"}, +{ "paramname": "pDistortionCoordinates" ,"paramtype": "struct vr::DistortionCoordinates_t *"} ] } ,{ @@ -1261,6 +2438,16 @@ { "paramname": "pnAdapterIndex" ,"paramtype": "int32_t *"} ] } +,{ + "classname": "vr::IVRSystem", + "methodname": "GetOutputDevice", + "returntype": "void", + "params": [ +{ "paramname": "pnDevice" ,"paramtype": "uint64_t *"}, +{ "paramname": "textureType" ,"paramtype": "vr::ETextureType"}, +{ "paramname": "pInstance" ,"paramtype": "struct VkInstance_T *"} + ] +} ,{ "classname": "vr::IVRSystem", "methodname": "IsDisplayOnDesktop", @@ -1411,6 +2598,19 @@ { "paramname": "pError" ,"paramtype": "vr::ETrackedPropertyError *"} ] } +,{ + "classname": "vr::IVRSystem", + "methodname": "GetArrayTrackedDeviceProperty", + "returntype": "uint32_t", + "params": [ +{ "paramname": "unDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "prop" ,"paramtype": "vr::ETrackedDeviceProperty"}, +{ "paramname": "propType" ,"paramtype": "vr::PropertyTypeTag_t"}, +{ "paramname": "pBuffer" ,"paramtype": "void *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"}, +{ "paramname": "pError" ,"paramtype": "vr::ETrackedPropertyError *"} + ] +} ,{ "classname": "vr::IVRSystem", "methodname": "GetStringTrackedDeviceProperty", @@ -1464,7 +2664,8 @@ "methodname": "GetHiddenAreaMesh", "returntype": "struct vr::HiddenAreaMesh_t", "params": [ -{ "paramname": "eEye" ,"paramtype": "vr::EVREye"} +{ "paramname": "eEye" ,"paramtype": "vr::EVREye"}, +{ "paramname": "type" ,"paramtype": "vr::EHiddenAreaMeshType"} ] } ,{ @@ -1473,7 +2674,8 @@ "returntype": "bool", "params": [ { "paramname": "unControllerDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, -{ "paramname": "pControllerState" ,"paramtype": "vr::VRControllerState_t *"} +{ "paramname": "pControllerState" ,"paramtype": "vr::VRControllerState_t *"}, +{ "paramname": "unControllerStateSize" ,"paramtype": "uint32_t"} ] } ,{ @@ -1484,6 +2686,7 @@ { "paramname": "eOrigin" ,"paramtype": "vr::ETrackingUniverseOrigin"}, { "paramname": "unControllerDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, { "paramname": "pControllerState" ,"paramtype": "vr::VRControllerState_t *"}, +{ "paramname": "unControllerStateSize" ,"paramtype": "uint32_t"}, { "paramname": "pTrackedDevicePose" ,"paramtype": "struct vr::TrackedDevicePose_t *"} ] } @@ -1515,29 +2718,23 @@ } ,{ "classname": "vr::IVRSystem", - "methodname": "CaptureInputFocus", + "methodname": "IsInputAvailable", "returntype": "bool" } ,{ "classname": "vr::IVRSystem", - "methodname": "ReleaseInputFocus", - "returntype": "void" + "methodname": "IsSteamVRDrawingControllers", + "returntype": "bool" } ,{ "classname": "vr::IVRSystem", - "methodname": "IsInputFocusCapturedByAnotherProcess", + "methodname": "ShouldApplicationPause", "returntype": "bool" } ,{ "classname": "vr::IVRSystem", - "methodname": "DriverDebugRequest", - "returntype": "uint32_t", - "params": [ -{ "paramname": "unDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, -{ "paramname": "pchRequest" ,"paramtype": "const char *"}, -{ "paramname": "pchResponseBuffer" ,"paramtype": "char *"}, -{ "paramname": "unResponseBufferSize" ,"paramtype": "uint32_t"} - ] + "methodname": "ShouldApplicationReduceRenderingWork", + "returntype": "bool" } ,{ "classname": "vr::IVRSystem", @@ -1554,8 +2751,17 @@ } ,{ "classname": "vr::IVRSystem", - "methodname": "AcknowledgeQuit_UserPrompt", - "returntype": "void" + "methodname": "GetAppContainerFilePaths", + "returntype": "uint32_t", + "params": [ +{ "paramname": "pchBuffer" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRSystem", + "methodname": "GetRuntimeVersion", + "returntype": "const char *" } ,{ "classname": "vr::IVRExtendedDisplay", @@ -1620,10 +2826,11 @@ } ,{ "classname": "vr::IVRTrackedCamera", - "methodname": "GetCameraIntrinisics", + "methodname": "GetCameraIntrinsics", "returntype": "vr::EVRTrackedCameraError", "params": [ { "paramname": "nDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "nCameraIndex" ,"paramtype": "uint32_t"}, { "paramname": "eFrameType" ,"paramtype": "vr::EVRTrackedCameraFrameType"}, { "paramname": "pFocalLength" ,"paramtype": "vr::HmdVector2_t *"}, { "paramname": "pCenter" ,"paramtype": "vr::HmdVector2_t *"} @@ -1635,6 +2842,7 @@ "returntype": "vr::EVRTrackedCameraError", "params": [ { "paramname": "nDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "nCameraIndex" ,"paramtype": "uint32_t"}, { "paramname": "eFrameType" ,"paramtype": "vr::EVRTrackedCameraFrameType"}, { "paramname": "flZNear" ,"paramtype": "float"}, { "paramname": "flZFar" ,"paramtype": "float"}, @@ -1717,6 +2925,19 @@ { "paramname": "glTextureId" ,"paramtype": "vr::glUInt_t"} ] } +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "SetCameraTrackingSpace", + "returntype": "void", + "params": [ +{ "paramname": "eUniverse" ,"paramtype": "vr::ETrackingUniverseOrigin"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "GetCameraTrackingSpace", + "returntype": "vr::ETrackingUniverseOrigin" +} ,{ "classname": "vr::IVRApplications", "methodname": "AddApplicationManifest", @@ -1753,7 +2974,7 @@ "returntype": "vr::EVRApplicationError", "params": [ { "paramname": "unApplicationIndex" ,"paramtype": "uint32_t"}, -{ "paramname": "pchAppKeyBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchAppKeyBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unAppKeyBufferLen" ,"paramtype": "uint32_t"} ] } @@ -1763,7 +2984,7 @@ "returntype": "vr::EVRApplicationError", "params": [ { "paramname": "unProcessId" ,"paramtype": "uint32_t"}, -{ "paramname": "pchAppKeyBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchAppKeyBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unAppKeyBufferLen" ,"paramtype": "uint32_t"} ] } @@ -1843,7 +3064,7 @@ "params": [ { "paramname": "pchAppKey" ,"paramtype": "const char *"}, { "paramname": "eProperty" ,"paramtype": "vr::EVRApplicationProperty"}, -{ "paramname": "pchPropertyValueBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchPropertyValueBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unPropertyValueBufferLen" ,"paramtype": "uint32_t"}, { "paramname": "peError" ,"paramtype": "vr::EVRApplicationError *"} ] @@ -1900,7 +3121,7 @@ "returntype": "bool", "params": [ { "paramname": "pchMimeType" ,"paramtype": "const char *"}, -{ "paramname": "pchAppKeyBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchAppKeyBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unAppKeyBufferLen" ,"paramtype": "uint32_t"} ] } @@ -1910,7 +3131,7 @@ "returntype": "bool", "params": [ { "paramname": "pchAppKey" ,"paramtype": "const char *"}, -{ "paramname": "pchMimeTypesBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchMimeTypesBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unMimeTypesBuffer" ,"paramtype": "uint32_t"} ] } @@ -1920,7 +3141,7 @@ "returntype": "uint32_t", "params": [ { "paramname": "pchMimeType" ,"paramtype": "const char *"}, -{ "paramname": "pchAppKeysThatSupportBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchAppKeysThatSupportBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unAppKeysThatSupportBuffer" ,"paramtype": "uint32_t"} ] } @@ -1930,7 +3151,7 @@ "returntype": "uint32_t", "params": [ { "paramname": "unHandle" ,"paramtype": "uint32_t"}, -{ "paramname": "pchArgs" ,"paramtype": "char *"}, +{ "paramname": "pchArgs" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unArgs" ,"paramtype": "uint32_t"} ] } @@ -1939,14 +3160,14 @@ "methodname": "GetStartingApplication", "returntype": "vr::EVRApplicationError", "params": [ -{ "paramname": "pchAppKeyBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchAppKeyBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unAppKeyBufferLen" ,"paramtype": "uint32_t"} ] } ,{ "classname": "vr::IVRApplications", - "methodname": "GetTransitionState", - "returntype": "vr::EVRApplicationTransitionState" + "methodname": "GetSceneApplicationState", + "returntype": "vr::EVRSceneApplicationState" } ,{ "classname": "vr::IVRApplications", @@ -1958,17 +3179,12 @@ } ,{ "classname": "vr::IVRApplications", - "methodname": "GetApplicationsTransitionStateNameFromEnum", + "methodname": "GetSceneApplicationStateNameFromEnum", "returntype": "const char *", "params": [ -{ "paramname": "state" ,"paramtype": "vr::EVRApplicationTransitionState"} +{ "paramname": "state" ,"paramtype": "vr::EVRSceneApplicationState"} ] } -,{ - "classname": "vr::IVRApplications", - "methodname": "IsQuitUserPromptRequested", - "returntype": "bool" -} ,{ "classname": "vr::IVRApplications", "methodname": "LaunchInternalProcess", @@ -1979,6 +3195,11 @@ { "paramname": "pchWorkingDirectory" ,"paramtype": "const char *"} ] } +,{ + "classname": "vr::IVRApplications", + "methodname": "GetCurrentSceneProcessId", + "returntype": "uint32_t" +} ,{ "classname": "vr::IVRChaperone", "methodname": "GetCalibrationState", @@ -2120,6 +3341,15 @@ { "paramname": "unQuadsCount" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVRChaperoneSetup", + "methodname": "SetWorkingPerimeter", + "returntype": "void", + "params": [ +{ "paramname": "pPointBuffer" ,"array_count": "unPointCount" ,"paramtype": "struct vr::HmdVector2_t *"}, +{ "paramname": "unPointCount" ,"paramtype": "uint32_t"} + ] +} ,{ "classname": "vr::IVRChaperoneSetup", "methodname": "SetWorkingSeatedZeroPoseToRawTrackingPose", @@ -2154,57 +3384,36 @@ } ,{ "classname": "vr::IVRChaperoneSetup", - "methodname": "SetWorkingCollisionBoundsTagsInfo", - "returntype": "void", - "params": [ -{ "paramname": "pTagsBuffer" ,"array_count": "unTagCount" ,"paramtype": "uint8_t *"}, -{ "paramname": "unTagCount" ,"paramtype": "uint32_t"} - ] -} -,{ - "classname": "vr::IVRChaperoneSetup", - "methodname": "GetLiveCollisionBoundsTagsInfo", + "methodname": "ExportLiveToBuffer", "returntype": "bool", "params": [ -{ "paramname": "pTagsBuffer" ,"out_array_count": "punTagCount" ,"paramtype": "uint8_t *"}, -{ "paramname": "punTagCount" ,"paramtype": "uint32_t *"} +{ "paramname": "pBuffer" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "pnBufferLength" ,"paramtype": "uint32_t *"} ] } ,{ "classname": "vr::IVRChaperoneSetup", - "methodname": "SetWorkingPhysicalBoundsInfo", + "methodname": "ImportFromBufferToWorking", "returntype": "bool", "params": [ -{ "paramname": "pQuadsBuffer" ,"array_count": "unQuadsCount" ,"paramtype": "struct vr::HmdQuad_t *"}, -{ "paramname": "unQuadsCount" ,"paramtype": "uint32_t"} +{ "paramname": "pBuffer" ,"paramtype": "const char *"}, +{ "paramname": "nImportFlags" ,"paramtype": "uint32_t"} ] } ,{ "classname": "vr::IVRChaperoneSetup", - "methodname": "GetLivePhysicalBoundsInfo", - "returntype": "bool", - "params": [ -{ "paramname": "pQuadsBuffer" ,"out_array_count": "punQuadsCount" ,"paramtype": "struct vr::HmdQuad_t *"}, -{ "paramname": "punQuadsCount" ,"paramtype": "uint32_t *"} - ] + "methodname": "ShowWorkingSetPreview", + "returntype": "void" } ,{ "classname": "vr::IVRChaperoneSetup", - "methodname": "ExportLiveToBuffer", - "returntype": "bool", - "params": [ -{ "paramname": "pBuffer" ,"out_string": " " ,"paramtype": "char *"}, -{ "paramname": "pnBufferLength" ,"paramtype": "uint32_t *"} - ] + "methodname": "HideWorkingSetPreview", + "returntype": "void" } ,{ "classname": "vr::IVRChaperoneSetup", - "methodname": "ImportFromBufferToWorking", - "returntype": "bool", - "params": [ -{ "paramname": "pBuffer" ,"paramtype": "const char *"}, -{ "paramname": "nImportFlags" ,"paramtype": "uint32_t"} - ] + "methodname": "RoomSetupStarting", + "returntype": "void" } ,{ "classname": "vr::IVRCompositor", @@ -2281,6 +3490,15 @@ { "paramname": "unFramesAgo" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetFrameTimings", + "returntype": "uint32_t", + "params": [ +{ "paramname": "pTiming" ,"array_count": "nFrames" ,"paramtype": "struct vr::Compositor_FrameTiming *"}, +{ "paramname": "nFrames" ,"paramtype": "uint32_t"} + ] +} ,{ "classname": "vr::IVRCompositor", "methodname": "GetFrameTimeRemaining", @@ -2308,6 +3526,14 @@ { "paramname": "bBackground" ,"paramtype": "bool"} ] } +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetCurrentFadeColor", + "returntype": "struct vr::HmdColor_t", + "params": [ +{ "paramname": "bBackground" ,"paramtype": "bool"} + ] +} ,{ "classname": "vr::IVRCompositor", "methodname": "FadeGrid", @@ -2317,6 +3543,11 @@ { "paramname": "bFadeIn" ,"paramtype": "bool"} ] } +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetCurrentGridAlpha", + "returntype": "float" +} ,{ "classname": "vr::IVRCompositor", "methodname": "SetSkyboxOverride", @@ -2422,6 +3653,14 @@ { "paramname": "ppD3D11ShaderResourceView" ,"paramtype": "void **"} ] } +,{ + "classname": "vr::IVRCompositor", + "methodname": "ReleaseMirrorTextureD3D11", + "returntype": "void", + "params": [ +{ "paramname": "pD3D11ShaderResourceView" ,"paramtype": "void *"} + ] +} ,{ "classname": "vr::IVRCompositor", "methodname": "GetMirrorTextureGL", @@ -2458,45 +3697,123 @@ ] } ,{ - "classname": "vr::IVROverlay", - "methodname": "FindOverlay", - "returntype": "vr::EVROverlayError", - "params": [ -{ "paramname": "pchOverlayKey" ,"paramtype": "const char *"}, -{ "paramname": "pOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t *"} + "classname": "vr::IVRCompositor", + "methodname": "GetVulkanInstanceExtensionsRequired", + "returntype": "uint32_t", + "params": [ +{ "paramname": "pchValue" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetVulkanDeviceExtensionsRequired", + "returntype": "uint32_t", + "params": [ +{ "paramname": "pPhysicalDevice" ,"paramtype": "struct VkPhysicalDevice_T *"}, +{ "paramname": "pchValue" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "SetExplicitTimingMode", + "returntype": "void", + "params": [ +{ "paramname": "eTimingMode" ,"paramtype": "vr::EVRCompositorTimingMode"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "SubmitExplicitTimingData", + "returntype": "vr::EVRCompositorError" +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "IsMotionSmoothingEnabled", + "returntype": "bool" +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "IsMotionSmoothingSupported", + "returntype": "bool" +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "IsCurrentSceneFocusAppLoading", + "returntype": "bool" +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "SetStageOverride_Async", + "returntype": "vr::EVRCompositorError", + "params": [ +{ "paramname": "pchRenderModelPath" ,"paramtype": "const char *"}, +{ "paramname": "pTransform" ,"paramtype": "const struct vr::HmdMatrix34_t *"}, +{ "paramname": "pRenderSettings" ,"paramtype": "const struct vr::Compositor_StageRenderSettings *"}, +{ "paramname": "nSizeOfRenderSettings" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "ClearStageOverride", + "returntype": "void" +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetCompositorBenchmarkResults", + "returntype": "bool", + "params": [ +{ "paramname": "pBenchmarkResults" ,"paramtype": "struct vr::Compositor_BenchmarkResults *"}, +{ "paramname": "nSizeOfBenchmarkResults" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetLastPosePredictionIDs", + "returntype": "vr::EVRCompositorError", + "params": [ +{ "paramname": "pRenderPosePredictionID" ,"paramtype": "uint32_t *"}, +{ "paramname": "pGamePosePredictionID" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetPosesForFrame", + "returntype": "vr::EVRCompositorError", + "params": [ +{ "paramname": "unPosePredictionID" ,"paramtype": "uint32_t"}, +{ "paramname": "pPoseArray" ,"array_count": "unPoseArrayCount" ,"paramtype": "struct vr::TrackedDevicePose_t *"}, +{ "paramname": "unPoseArrayCount" ,"paramtype": "uint32_t"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "CreateOverlay", + "methodname": "FindOverlay", "returntype": "vr::EVROverlayError", "params": [ { "paramname": "pchOverlayKey" ,"paramtype": "const char *"}, -{ "paramname": "pchOverlayFriendlyName" ,"paramtype": "const char *"}, { "paramname": "pOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t *"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "DestroyOverlay", + "methodname": "CreateOverlay", "returntype": "vr::EVROverlayError", "params": [ -{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} +{ "paramname": "pchOverlayKey" ,"paramtype": "const char *"}, +{ "paramname": "pchOverlayName" ,"paramtype": "const char *"}, +{ "paramname": "pOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t *"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "SetHighQualityOverlay", + "methodname": "DestroyOverlay", "returntype": "vr::EVROverlayError", "params": [ { "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} ] } -,{ - "classname": "vr::IVROverlay", - "methodname": "GetHighQualityOverlay", - "returntype": "vr::VROverlayHandle_t" -} ,{ "classname": "vr::IVROverlay", "methodname": "GetOverlayKey", @@ -2519,6 +3836,15 @@ { "paramname": "pError" ,"paramtype": "vr::EVROverlayError *"} ] } +,{ + "classname": "vr::IVROverlay", + "methodname": "SetOverlayName", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pchName" ,"paramtype": "const char *"} + ] +} ,{ "classname": "vr::IVROverlay", "methodname": "GetOverlayImageData", @@ -2576,6 +3902,15 @@ { "paramname": "pbEnabled" ,"paramtype": "bool *"} ] } +,{ + "classname": "vr::IVROverlay", + "methodname": "GetOverlayFlags", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pFlags" ,"paramtype": "uint32_t *"} + ] +} ,{ "classname": "vr::IVROverlay", "methodname": "SetOverlayColor", @@ -2672,22 +4007,20 @@ } ,{ "classname": "vr::IVROverlay", - "methodname": "SetOverlayAutoCurveDistanceRangeInMeters", + "methodname": "SetOverlayCurvature", "returntype": "vr::EVROverlayError", "params": [ { "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, -{ "paramname": "fMinDistanceInMeters" ,"paramtype": "float"}, -{ "paramname": "fMaxDistanceInMeters" ,"paramtype": "float"} +{ "paramname": "fCurvature" ,"paramtype": "float"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "GetOverlayAutoCurveDistanceRangeInMeters", + "methodname": "GetOverlayCurvature", "returntype": "vr::EVROverlayError", "params": [ { "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, -{ "paramname": "pfMinDistanceInMeters" ,"paramtype": "float *"}, -{ "paramname": "pfMaxDistanceInMeters" ,"paramtype": "float *"} +{ "paramname": "pfCurvature" ,"paramtype": "float *"} ] } ,{ @@ -2792,10 +4125,48 @@ "params": [ { "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, { "paramname": "punDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t *"}, -{ "paramname": "pchComponentName" ,"paramtype": "char *"}, +{ "paramname": "pchComponentName" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unComponentNameSize" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVROverlay", + "methodname": "GetOverlayTransformOverlayRelative", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "ulOverlayHandleParent" ,"paramtype": "vr::VROverlayHandle_t *"}, +{ "paramname": "pmatParentOverlayToOverlayTransform" ,"paramtype": "struct vr::HmdMatrix34_t *"} + ] +} +,{ + "classname": "vr::IVROverlay", + "methodname": "SetOverlayTransformOverlayRelative", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "ulOverlayHandleParent" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pmatParentOverlayToOverlayTransform" ,"paramtype": "const struct vr::HmdMatrix34_t *"} + ] +} +,{ + "classname": "vr::IVROverlay", + "methodname": "SetOverlayTransformCursor", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulCursorOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pvHotspot" ,"paramtype": "const struct vr::HmdVector2_t *"} + ] +} +,{ + "classname": "vr::IVROverlay", + "methodname": "GetOverlayTransformCursor", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pvHotspot" ,"paramtype": "struct vr::HmdVector2_t *"} + ] +} ,{ "classname": "vr::IVROverlay", "methodname": "ShowOverlay", @@ -2889,51 +4260,58 @@ } ,{ "classname": "vr::IVROverlay", - "methodname": "HandleControllerOverlayInteractionAsMouse", + "methodname": "IsHoverTargetOverlay", "returntype": "bool", "params": [ -{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, -{ "paramname": "unControllerDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"} +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "IsHoverTargetOverlay", - "returntype": "bool", + "methodname": "SetOverlayIntersectionMask", + "returntype": "vr::EVROverlayError", "params": [ -{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pMaskPrimitives" ,"paramtype": "struct vr::VROverlayIntersectionMaskPrimitive_t *"}, +{ "paramname": "unNumMaskPrimitives" ,"paramtype": "uint32_t"}, +{ "paramname": "unPrimitiveSize" ,"paramtype": "uint32_t"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "GetGamepadFocusOverlay", - "returntype": "vr::VROverlayHandle_t" + "methodname": "TriggerLaserMouseHapticVibration", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "fDurationSeconds" ,"paramtype": "float"}, +{ "paramname": "fFrequency" ,"paramtype": "float"}, +{ "paramname": "fAmplitude" ,"paramtype": "float"} + ] } ,{ "classname": "vr::IVROverlay", - "methodname": "SetGamepadFocusOverlay", + "methodname": "SetOverlayCursor", "returntype": "vr::EVROverlayError", "params": [ -{ "paramname": "ulNewFocusOverlay" ,"paramtype": "vr::VROverlayHandle_t"} +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "ulCursorHandle" ,"paramtype": "vr::VROverlayHandle_t"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "SetOverlayNeighbor", + "methodname": "SetOverlayCursorPositionOverride", "returntype": "vr::EVROverlayError", "params": [ -{ "paramname": "eDirection" ,"paramtype": "vr::EOverlayDirection"}, -{ "paramname": "ulFrom" ,"paramtype": "vr::VROverlayHandle_t"}, -{ "paramname": "ulTo" ,"paramtype": "vr::VROverlayHandle_t"} +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pvCursor" ,"paramtype": "const struct vr::HmdVector2_t *"} ] } ,{ "classname": "vr::IVROverlay", - "methodname": "MoveGamepadFocusToNeighbor", + "methodname": "ClearOverlayCursorPositionOverride", "returntype": "vr::EVROverlayError", "params": [ -{ "paramname": "eDirection" ,"paramtype": "vr::EOverlayDirection"}, -{ "paramname": "ulFrom" ,"paramtype": "vr::VROverlayHandle_t"} +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} ] } ,{ @@ -2962,7 +4340,7 @@ { "paramname": "pvBuffer" ,"paramtype": "void *"}, { "paramname": "unWidth" ,"paramtype": "uint32_t"}, { "paramname": "unHeight" ,"paramtype": "uint32_t"}, -{ "paramname": "unDepth" ,"paramtype": "uint32_t"} +{ "paramname": "unBytesPerPixel" ,"paramtype": "uint32_t"} ] } ,{ @@ -2985,8 +4363,9 @@ { "paramname": "pWidth" ,"paramtype": "uint32_t *"}, { "paramname": "pHeight" ,"paramtype": "uint32_t *"}, { "paramname": "pNativeFormat" ,"paramtype": "uint32_t *"}, -{ "paramname": "pAPI" ,"paramtype": "vr::EGraphicsAPIConvention *"}, -{ "paramname": "pColorSpace" ,"paramtype": "vr::EColorSpace *"} +{ "paramname": "pAPIType" ,"paramtype": "vr::ETextureType *"}, +{ "paramname": "pColorSpace" ,"paramtype": "vr::EColorSpace *"}, +{ "paramname": "pTextureBounds" ,"paramtype": "struct vr::VRTextureBounds_t *"} ] } ,{ @@ -3070,10 +4449,10 @@ "params": [ { "paramname": "eInputMode" ,"paramtype": "vr::EGamepadTextInputMode"}, { "paramname": "eLineInputMode" ,"paramtype": "vr::EGamepadTextInputLineMode"}, +{ "paramname": "unFlags" ,"paramtype": "uint32_t"}, { "paramname": "pchDescription" ,"paramtype": "const char *"}, { "paramname": "unCharMax" ,"paramtype": "uint32_t"}, { "paramname": "pchExistingText" ,"paramtype": "const char *"}, -{ "paramname": "bUseMinimalMode" ,"paramtype": "bool"}, { "paramname": "uUserValue" ,"paramtype": "uint64_t"} ] } @@ -3085,10 +4464,10 @@ { "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, { "paramname": "eInputMode" ,"paramtype": "vr::EGamepadTextInputMode"}, { "paramname": "eLineInputMode" ,"paramtype": "vr::EGamepadTextInputLineMode"}, +{ "paramname": "unFlags" ,"paramtype": "uint32_t"}, { "paramname": "pchDescription" ,"paramtype": "const char *"}, { "paramname": "unCharMax" ,"paramtype": "uint32_t"}, { "paramname": "pchExistingText" ,"paramtype": "const char *"}, -{ "paramname": "bUseMinimalMode" ,"paramtype": "bool"}, { "paramname": "uUserValue" ,"paramtype": "uint64_t"} ] } @@ -3124,6 +4503,127 @@ { "paramname": "avoidRect" ,"paramtype": "struct vr::HmdRect2_t"} ] } +,{ + "classname": "vr::IVROverlay", + "methodname": "ShowMessageOverlay", + "returntype": "vr::VRMessageOverlayResponse", + "params": [ +{ "paramname": "pchText" ,"paramtype": "const char *"}, +{ "paramname": "pchCaption" ,"paramtype": "const char *"}, +{ "paramname": "pchButton0Text" ,"paramtype": "const char *"}, +{ "paramname": "pchButton1Text" ,"paramtype": "const char *"}, +{ "paramname": "pchButton2Text" ,"paramtype": "const char *"}, +{ "paramname": "pchButton3Text" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVROverlay", + "methodname": "CloseMessageOverlay", + "returntype": "void" +} +,{ + "classname": "vr::IVROverlayView", + "methodname": "AcquireOverlayView", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pNativeDevice" ,"paramtype": "struct vr::VRNativeDevice_t *"}, +{ "paramname": "pOverlayView" ,"paramtype": "struct vr::VROverlayView_t *"}, +{ "paramname": "unOverlayViewSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVROverlayView", + "methodname": "ReleaseOverlayView", + "returntype": "vr::EVROverlayError", + "params": [ +{ "paramname": "pOverlayView" ,"paramtype": "struct vr::VROverlayView_t *"} + ] +} +,{ + "classname": "vr::IVROverlayView", + "methodname": "PostOverlayEvent", + "returntype": "void", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"}, +{ "paramname": "pvrEvent" ,"paramtype": "const struct vr::VREvent_t *"} + ] +} +,{ + "classname": "vr::IVROverlayView", + "methodname": "IsViewingPermitted", + "returntype": "bool", + "params": [ +{ "paramname": "ulOverlayHandle" ,"paramtype": "vr::VROverlayHandle_t"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "SetHeadsetViewSize", + "returntype": "void", + "params": [ +{ "paramname": "nWidth" ,"paramtype": "uint32_t"}, +{ "paramname": "nHeight" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "GetHeadsetViewSize", + "returntype": "void", + "params": [ +{ "paramname": "pnWidth" ,"paramtype": "uint32_t *"}, +{ "paramname": "pnHeight" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "SetHeadsetViewMode", + "returntype": "void", + "params": [ +{ "paramname": "eHeadsetViewMode" ,"paramtype": "vr::HeadsetViewMode_t"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "GetHeadsetViewMode", + "returntype": "vr::HeadsetViewMode_t" +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "SetHeadsetViewCropped", + "returntype": "void", + "params": [ +{ "paramname": "bCropped" ,"paramtype": "bool"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "GetHeadsetViewCropped", + "returntype": "bool" +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "GetHeadsetViewAspectRatio", + "returntype": "float" +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "SetHeadsetViewBlendRange", + "returntype": "void", + "params": [ +{ "paramname": "flStartPct" ,"paramtype": "float"}, +{ "paramname": "flEndPct" ,"paramtype": "float"} + ] +} +,{ + "classname": "vr::IVRHeadsetView", + "methodname": "GetHeadsetViewBlendRange", + "returntype": "void", + "params": [ +{ "paramname": "pStartPct" ,"paramtype": "float *"}, +{ "paramname": "pEndPct" ,"paramtype": "float *"} + ] +} ,{ "classname": "vr::IVRRenderModels", "methodname": "LoadRenderModel_Async", @@ -3239,6 +4739,18 @@ { "paramname": "unComponentRenderModelNameLen" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVRRenderModels", + "methodname": "GetComponentStateForDevicePath", + "returntype": "bool", + "params": [ +{ "paramname": "pchRenderModelName" ,"paramtype": "const char *"}, +{ "paramname": "pchComponentName" ,"paramtype": "const char *"}, +{ "paramname": "devicePath" ,"paramtype": "vr::VRInputValueHandle_t"}, +{ "paramname": "pState" ,"paramtype": "const vr::RenderModel_ControllerMode_State_t *"}, +{ "paramname": "pComponentState" ,"paramtype": "vr::RenderModel_ComponentState_t *"} + ] +} ,{ "classname": "vr::IVRRenderModels", "methodname": "GetComponentState", @@ -3322,76 +4834,75 @@ } ,{ "classname": "vr::IVRSettings", - "methodname": "Sync", - "returntype": "bool", + "methodname": "SetBool", + "returntype": "void", "params": [ -{ "paramname": "bForce" ,"paramtype": "bool"}, +{ "paramname": "pchSection" ,"paramtype": "const char *"}, +{ "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, +{ "paramname": "bValue" ,"paramtype": "bool"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "GetBool", - "returntype": "bool", + "methodname": "SetInt32", + "returntype": "void", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "bDefaultValue" ,"paramtype": "bool"}, +{ "paramname": "nValue" ,"paramtype": "int32_t"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "SetBool", + "methodname": "SetFloat", "returntype": "void", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "bValue" ,"paramtype": "bool"}, +{ "paramname": "flValue" ,"paramtype": "float"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "GetInt32", - "returntype": "int32_t", + "methodname": "SetString", + "returntype": "void", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "nDefaultValue" ,"paramtype": "int32_t"}, +{ "paramname": "pchValue" ,"paramtype": "const char *"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "SetInt32", - "returntype": "void", + "methodname": "GetBool", + "returntype": "bool", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "nValue" ,"paramtype": "int32_t"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "GetFloat", - "returntype": "float", + "methodname": "GetInt32", + "returntype": "int32_t", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "flDefaultValue" ,"paramtype": "float"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "SetFloat", - "returntype": "void", + "methodname": "GetFloat", + "returntype": "float", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "flValue" ,"paramtype": "float"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } @@ -3404,37 +4915,25 @@ { "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, { "paramname": "pchValue" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unValueLen" ,"paramtype": "uint32_t"}, -{ "paramname": "pchDefaultValue" ,"paramtype": "const char *"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "SetString", + "methodname": "RemoveSection", "returntype": "void", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, -{ "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, -{ "paramname": "pchValue" ,"paramtype": "const char *"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } ,{ "classname": "vr::IVRSettings", - "methodname": "RemoveSection", + "methodname": "RemoveKeyInSection", "returntype": "void", "params": [ { "paramname": "pchSection" ,"paramtype": "const char *"}, -{ "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} - ] -} -,{ - "classname": "vr::IVRSettings", - "methodname": "RemoveKeyInSection", - "returntype": "void", - "params": [ -{ "paramname": "pchSection" ,"paramtype": "const char *"}, -{ "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, +{ "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } @@ -3526,9 +5025,669 @@ "params": [ { "paramname": "pchResourceName" ,"paramtype": "const char *"}, { "paramname": "pchResourceTypeDirectory" ,"paramtype": "const char *"}, -{ "paramname": "pchPathBuffer" ,"paramtype": "char *"}, +{ "paramname": "pchPathBuffer" ,"out_string": " " ,"paramtype": "char *"}, { "paramname": "unBufferLen" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVRDriverManager", + "methodname": "GetDriverCount", + "returntype": "uint32_t" +} +,{ + "classname": "vr::IVRDriverManager", + "methodname": "GetDriverName", + "returntype": "uint32_t", + "params": [ +{ "paramname": "nDriver" ,"paramtype": "vr::DriverId_t"}, +{ "paramname": "pchValue" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRDriverManager", + "methodname": "GetDriverHandle", + "returntype": "DriverHandle_t", + "params": [ +{ "paramname": "pchDriverName" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRDriverManager", + "methodname": "IsEnabled", + "returntype": "bool", + "params": [ +{ "paramname": "nDriver" ,"paramtype": "vr::DriverId_t"} + ] +} +,{ + "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"}, +{ "paramname": "ulRestrictToDevice" ,"paramtype": "vr::VRInputValueHandle_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"}, +{ "paramname": "ulRestrictToDevice" ,"paramtype": "vr::VRInputValueHandle_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetPoseActionDataRelativeToNow", + "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"}, +{ "paramname": "ulRestrictToDevice" ,"paramtype": "vr::VRInputValueHandle_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetPoseActionDataForNextFrame", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eOrigin" ,"paramtype": "vr::ETrackingUniverseOrigin"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputPoseActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"}, +{ "paramname": "ulRestrictToDevice" ,"paramtype": "vr::VRInputValueHandle_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalActionData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pActionData" ,"paramtype": "struct vr::InputSkeletalActionData_t *"}, +{ "paramname": "unActionDataSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetDominantHand", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "peDominantHand" ,"paramtype": "vr::ETrackedControllerRole *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "SetDominantHand", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "eDominantHand" ,"paramtype": "vr::ETrackedControllerRole"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetBoneCount", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pBoneCount" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetBoneHierarchy", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pParentIndices" ,"array_count": "unIndexArayCount" ,"paramtype": "vr::BoneIndex_t *"}, +{ "paramname": "unIndexArayCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetBoneName", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "nBoneIndex" ,"paramtype": "vr::BoneIndex_t"}, +{ "paramname": "pchBoneName" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unNameBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalReferenceTransforms", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eTransformSpace" ,"paramtype": "vr::EVRSkeletalTransformSpace"}, +{ "paramname": "eReferencePose" ,"paramtype": "vr::EVRSkeletalReferencePose"}, +{ "paramname": "pTransformArray" ,"array_count": "unTransformArrayCount" ,"paramtype": "struct vr::VRBoneTransform_t *"}, +{ "paramname": "unTransformArrayCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalTrackingLevel", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pSkeletalTrackingLevel" ,"paramtype": "vr::EVRSkeletalTrackingLevel *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalBoneData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eTransformSpace" ,"paramtype": "vr::EVRSkeletalTransformSpace"}, +{ "paramname": "eMotionRange" ,"paramtype": "vr::EVRSkeletalMotionRange"}, +{ "paramname": "pTransformArray" ,"array_count": "unTransformArrayCount" ,"paramtype": "struct vr::VRBoneTransform_t *"}, +{ "paramname": "unTransformArrayCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalSummaryData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eSummaryType" ,"paramtype": "vr::EVRSummaryType"}, +{ "paramname": "pSkeletalSummaryData" ,"paramtype": "struct vr::VRSkeletalSummaryData_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetSkeletalBoneDataCompressed", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "eMotionRange" ,"paramtype": "vr::EVRSkeletalMotionRange"}, +{ "paramname": "pvCompressedData" ,"out_buffer_count": "unCompressedSize" ,"paramtype": "void *"}, +{ "paramname": "unCompressedSize" ,"paramtype": "uint32_t"}, +{ "paramname": "punRequiredCompressedSize" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "DecompressSkeletalBoneData", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pvCompressedBuffer" ,"paramtype": "const void *"}, +{ "paramname": "unCompressedBufferSize" ,"paramtype": "uint32_t"}, +{ "paramname": "eTransformSpace" ,"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"}, +{ "paramname": "ulRestrictToDevice" ,"paramtype": "vr::VRInputValueHandle_t"} + ] +} +,{ + "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"}, +{ "paramname": "unStringSectionsToInclude" ,"paramtype": "int32_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": "GetActionBindingInfo", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "action" ,"paramtype": "vr::VRActionHandle_t"}, +{ "paramname": "pOriginInfo" ,"paramtype": "struct vr::InputBindingInfo_t *"}, +{ "paramname": "unBindingInfoSize" ,"paramtype": "uint32_t"}, +{ "paramname": "unBindingInfoCount" ,"paramtype": "uint32_t"}, +{ "paramname": "punReturnedBindingInfoCount" ,"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::IVRInput", + "methodname": "GetComponentStateForBinding", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchRenderModelName" ,"paramtype": "const char *"}, +{ "paramname": "pchComponentName" ,"paramtype": "const char *"}, +{ "paramname": "pOriginInfo" ,"paramtype": "const struct vr::InputBindingInfo_t *"}, +{ "paramname": "unBindingInfoSize" ,"paramtype": "uint32_t"}, +{ "paramname": "unBindingInfoCount" ,"paramtype": "uint32_t"}, +{ "paramname": "pComponentState" ,"paramtype": "vr::RenderModel_ComponentState_t *"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "IsUsingLegacyInput", + "returntype": "bool" +} +,{ + "classname": "vr::IVRInput", + "methodname": "OpenBindingUI", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "pchAppKey" ,"paramtype": "const char *"}, +{ "paramname": "ulActionSetHandle" ,"paramtype": "vr::VRActionSetHandle_t"}, +{ "paramname": "ulDeviceHandle" ,"paramtype": "vr::VRInputValueHandle_t"}, +{ "paramname": "bShowOnDesktop" ,"paramtype": "bool"} + ] +} +,{ + "classname": "vr::IVRInput", + "methodname": "GetBindingVariant", + "returntype": "vr::EVRInputError", + "params": [ +{ "paramname": "ulDevicePath" ,"paramtype": "vr::VRInputValueHandle_t"}, +{ "paramname": "pchVariantArray" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unVariantArraySize" ,"paramtype": "uint32_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"} + ] +} +,{ + "classname": "vr::IVRIOBuffer", + "methodname": "HasReaders", + "returntype": "bool", + "params": [ +{ "paramname": "ulBuffer" ,"paramtype": "vr::IOBufferHandle_t"} + ] +} +,{ + "classname": "vr::IVRSpatialAnchors", + "methodname": "CreateSpatialAnchorFromDescriptor", + "returntype": "vr::EVRSpatialAnchorError", + "params": [ +{ "paramname": "pchDescriptor" ,"paramtype": "const char *"}, +{ "paramname": "pHandleOut" ,"paramtype": "vr::SpatialAnchorHandle_t *"} + ] +} +,{ + "classname": "vr::IVRSpatialAnchors", + "methodname": "CreateSpatialAnchorFromPose", + "returntype": "vr::EVRSpatialAnchorError", + "params": [ +{ "paramname": "unDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "eOrigin" ,"paramtype": "vr::ETrackingUniverseOrigin"}, +{ "paramname": "pPose" ,"paramtype": "struct vr::SpatialAnchorPose_t *"}, +{ "paramname": "pHandleOut" ,"paramtype": "vr::SpatialAnchorHandle_t *"} + ] +} +,{ + "classname": "vr::IVRSpatialAnchors", + "methodname": "GetSpatialAnchorPose", + "returntype": "vr::EVRSpatialAnchorError", + "params": [ +{ "paramname": "unHandle" ,"paramtype": "vr::SpatialAnchorHandle_t"}, +{ "paramname": "eOrigin" ,"paramtype": "vr::ETrackingUniverseOrigin"}, +{ "paramname": "pPoseOut" ,"paramtype": "struct vr::SpatialAnchorPose_t *"} + ] +} +,{ + "classname": "vr::IVRSpatialAnchors", + "methodname": "GetSpatialAnchorDescriptor", + "returntype": "vr::EVRSpatialAnchorError", + "params": [ +{ "paramname": "unHandle" ,"paramtype": "vr::SpatialAnchorHandle_t"}, +{ "paramname": "pchDescriptorOut" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "punDescriptorBufferLenInOut" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRDebug", + "methodname": "EmitVrProfilerEvent", + "returntype": "vr::EVRDebugError", + "params": [ +{ "paramname": "pchMessage" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRDebug", + "methodname": "BeginVrProfilerEvent", + "returntype": "vr::EVRDebugError", + "params": [ +{ "paramname": "pHandleOut" ,"paramtype": "vr::VrProfilerEventHandle_t *"} + ] +} +,{ + "classname": "vr::IVRDebug", + "methodname": "FinishVrProfilerEvent", + "returntype": "vr::EVRDebugError", + "params": [ +{ "paramname": "hHandle" ,"paramtype": "vr::VrProfilerEventHandle_t"}, +{ "paramname": "pchMessage" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRDebug", + "methodname": "DriverDebugRequest", + "returntype": "uint32_t", + "params": [ +{ "paramname": "unDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "pchRequest" ,"paramtype": "const char *"}, +{ "paramname": "pchResponseBuffer" ,"out_string": " " ,"paramtype": "char *"}, +{ "paramname": "unResponseBufferSize" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRProperties", + "methodname": "ReadPropertyBatch", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "ulContainerHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pBatch" ,"paramtype": "struct vr::PropertyRead_t *"}, +{ "paramname": "unBatchEntryCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRProperties", + "methodname": "WritePropertyBatch", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "ulContainerHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pBatch" ,"paramtype": "struct vr::PropertyWrite_t *"}, +{ "paramname": "unBatchEntryCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRProperties", + "methodname": "GetPropErrorNameFromEnum", + "returntype": "const char *", + "params": [ +{ "paramname": "error" ,"paramtype": "vr::ETrackedPropertyError"} + ] +} +,{ + "classname": "vr::IVRProperties", + "methodname": "TrackedDeviceToPropertyContainer", + "returntype": "PropertyContainerHandle_t", + "params": [ +{ "paramname": "nDevice" ,"paramtype": "vr::TrackedDeviceIndex_t"} + ] +} +,{ + "classname": "vr::IVRPaths", + "methodname": "ReadPathBatch", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "ulRootHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pBatch" ,"paramtype": "struct vr::PathRead_t *"}, +{ "paramname": "unBatchEntryCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRPaths", + "methodname": "WritePathBatch", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "ulRootHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pBatch" ,"paramtype": "struct vr::PathWrite_t *"}, +{ "paramname": "unBatchEntryCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRPaths", + "methodname": "StringToHandle", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "pHandle" ,"paramtype": "vr::PathHandle_t *"}, +{ "paramname": "pchPath" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRPaths", + "methodname": "HandleToString", + "returntype": "vr::ETrackedPropertyError", + "params": [ +{ "paramname": "pHandle" ,"paramtype": "vr::PathHandle_t"}, +{ "paramname": "pchBuffer" ,"paramtype": "char *"}, +{ "paramname": "unBufferSize" ,"paramtype": "uint32_t"}, +{ "paramname": "punBufferSizeUsed" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "Create", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "pulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t *"}, +{ "paramname": "pchPath" ,"paramtype": "const char *"}, +{ "paramname": "unBlockDataSize" ,"paramtype": "uint32_t"}, +{ "paramname": "unBlockHeaderSize" ,"paramtype": "uint32_t"}, +{ "paramname": "unBlockCount" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "Connect", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "pulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t *"}, +{ "paramname": "pchPath" ,"paramtype": "const char *"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "Destroy", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "AcquireWriteOnlyBlock", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pulBlockHandle" ,"paramtype": "vr::PropertyContainerHandle_t *"}, +{ "paramname": "ppvBuffer" ,"paramtype": "void **"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "ReleaseWriteOnlyBlock", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "ulBlockHandle" ,"paramtype": "vr::PropertyContainerHandle_t"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "WaitAndAcquireReadOnlyBlock", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pulBlockHandle" ,"paramtype": "vr::PropertyContainerHandle_t *"}, +{ "paramname": "ppvBuffer" ,"paramtype": "const void **"}, +{ "paramname": "eReadType" ,"paramtype": "vr::EBlockQueueReadType"}, +{ "paramname": "unTimeoutMs" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "AcquireReadOnlyBlock", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pulBlockHandle" ,"paramtype": "vr::PropertyContainerHandle_t *"}, +{ "paramname": "ppvBuffer" ,"paramtype": "const void **"}, +{ "paramname": "eReadType" ,"paramtype": "vr::EBlockQueueReadType"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "ReleaseReadOnlyBlock", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "ulBlockHandle" ,"paramtype": "vr::PropertyContainerHandle_t"} + ] +} +,{ + "classname": "vr::IVRBlockQueue", + "methodname": "QueueHasReader", + "returntype": "vr::EBlockQueueError", + "params": [ +{ "paramname": "ulQueueHandle" ,"paramtype": "vr::PropertyContainerHandle_t"}, +{ "paramname": "pbHasReaders" ,"paramtype": "bool *"} + ] +} ] } \ No newline at end of file diff --git a/ext/OpenVR/headers/openvr_capi.h b/ext/OpenVR/headers/openvr_capi.h index 030517e..050db74 100644 --- a/ext/OpenVR/headers/openvr_capi.h +++ b/ext/OpenVR/headers/openvr_capi.h @@ -17,7 +17,11 @@ #define EXTERN_C #endif +#if defined( _WIN32 ) #define OPENVR_FNTABLE_CALLTYPE __stdcall +#else +#define OPENVR_FNTABLE_CALLTYPE +#endif // OPENVR API export macro #if defined( _WIN32 ) && !defined( _X360 ) @@ -46,93 +50,181 @@ #if defined( __WIN32 ) typedef char bool; +#else +#include #endif +typedef uint64_t PropertyContainerHandle_t; +typedef uint32_t PropertyTypeTag_t; +typedef uint64_t VRActionHandle_t; +typedef uint64_t VRActionSetHandle_t; +typedef uint64_t VRInputValueHandle_t; +typedef uint64_t PathHandle_t; + // OpenVR Constants -static const unsigned int k_unTrackingStringSize = 32; -static const unsigned int k_unMaxDriverDebugResponseSize = 32768; -static const unsigned int k_unTrackedDeviceIndex_Hmd = 0; -static const unsigned int k_unMaxTrackedDeviceCount = 16; -static const unsigned int k_unTrackedDeviceIndexOther = 4294967294; -static const unsigned int k_unTrackedDeviceIndexInvalid = 4294967295; -static const unsigned int k_unMaxPropertyStringSize = 32768; -static const unsigned int k_unControllerStateAxisCount = 5; -static const unsigned long k_ulOverlayHandleInvalid = 0; -static const unsigned int k_unScreenshotHandleInvalid = 0; -static const char * IVRSystem_Version = "IVRSystem_012"; +static const unsigned long k_nDriverNone = 4294967295; +static const unsigned long k_unMaxDriverDebugResponseSize = 32768; +static const unsigned long k_unTrackedDeviceIndex_Hmd = 0; +static const unsigned long k_unMaxTrackedDeviceCount = 64; +static const unsigned long k_unTrackedDeviceIndexOther = 4294967294; +static const unsigned long k_unTrackedDeviceIndexInvalid = 4294967295; +static const unsigned long long k_ulInvalidPropertyContainer = 0; +static const unsigned long k_unInvalidPropertyTag = 0; +static const unsigned long long k_ulInvalidDriverHandle = 0; +static const unsigned long k_unFloatPropertyTag = 1; +static const unsigned long k_unInt32PropertyTag = 2; +static const unsigned long k_unUint64PropertyTag = 3; +static const unsigned long k_unBoolPropertyTag = 4; +static const unsigned long k_unStringPropertyTag = 5; +static const unsigned long k_unErrorPropertyTag = 6; +static const unsigned long k_unDoublePropertyTag = 7; +static const unsigned long k_unHmdMatrix34PropertyTag = 20; +static const unsigned long k_unHmdMatrix44PropertyTag = 21; +static const unsigned long k_unHmdVector3PropertyTag = 22; +static const unsigned long k_unHmdVector4PropertyTag = 23; +static const unsigned long k_unHmdVector2PropertyTag = 24; +static const unsigned long k_unHmdQuadPropertyTag = 25; +static const unsigned long k_unHiddenAreaPropertyTag = 30; +static const unsigned long k_unPathHandleInfoTag = 31; +static const unsigned long k_unActionPropertyTag = 32; +static const unsigned long k_unInputValuePropertyTag = 33; +static const unsigned long k_unWildcardPropertyTag = 34; +static const unsigned long k_unHapticVibrationPropertyTag = 35; +static const unsigned long k_unSkeletonPropertyTag = 36; +static const unsigned long k_unSpatialAnchorPosePropertyTag = 40; +static const unsigned long k_unJsonPropertyTag = 41; +static const unsigned long k_unActiveActionSetPropertyTag = 42; +static const unsigned long k_unOpenVRInternalReserved_Start = 1000; +static const unsigned long k_unOpenVRInternalReserved_End = 10000; +static const unsigned long k_unMaxPropertyStringSize = 32768; +static const unsigned long long k_ulInvalidActionHandle = 0; +static const unsigned long long k_ulInvalidActionSetHandle = 0; +static const unsigned long long k_ulInvalidInputValueHandle = 0; +static const unsigned long k_unControllerStateAxisCount = 5; +static const unsigned long long k_ulOverlayHandleInvalid = 0; +static const unsigned long k_unMaxDistortionFunctionParameters = 8; +static const unsigned long k_unScreenshotHandleInvalid = 0; +static const char * IVRSystem_Version = "IVRSystem_021"; static const char * IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; -static const char * IVRTrackedCamera_Version = "IVRTrackedCamera_003"; -static const unsigned int k_unMaxApplicationKeyLength = 128; -static const char * IVRApplications_Version = "IVRApplications_006"; +static const char * IVRTrackedCamera_Version = "IVRTrackedCamera_006"; +static const unsigned long k_unMaxApplicationKeyLength = 128; +static const char * k_pch_MimeType_HomeApp = "vr/home"; +static const char * k_pch_MimeType_GameTheater = "vr/game_theater"; +static const char * IVRApplications_Version = "IVRApplications_007"; static const char * IVRChaperone_Version = "IVRChaperone_003"; -static const char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; -static const char * IVRCompositor_Version = "IVRCompositor_016"; -static const unsigned int k_unVROverlayMaxKeyLength = 128; -static const unsigned int k_unVROverlayMaxNameLength = 128; -static const unsigned int k_unMaxOverlayCount = 64; -static const char * IVROverlay_Version = "IVROverlay_013"; +static const char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_006"; +static const char * IVRCompositor_Version = "IVRCompositor_026"; +static const unsigned long k_unVROverlayMaxKeyLength = 128; +static const unsigned long k_unVROverlayMaxNameLength = 128; +static const unsigned long k_unMaxOverlayCount = 128; +static const unsigned long k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; +static const char * IVROverlay_Version = "IVROverlay_024"; +static const char * IVROverlayView_Version = "IVROverlayView_003"; +static const unsigned long k_unHeadsetViewMaxWidth = 3840; +static const unsigned long k_unHeadsetViewMaxHeight = 2160; +static const char * k_pchHeadsetViewOverlayKey = "system.HeadsetView"; +static const char * IVRHeadsetView_Version = "IVRHeadsetView_001"; static const char * k_pch_Controller_Component_GDC2015 = "gdc2015"; static const char * k_pch_Controller_Component_Base = "base"; static const char * k_pch_Controller_Component_Tip = "tip"; static const char * k_pch_Controller_Component_HandGrip = "handgrip"; static const char * k_pch_Controller_Component_Status = "status"; -static const char * IVRRenderModels_Version = "IVRRenderModels_005"; -static const unsigned int k_unNotificationTextMaxSize = 256; +static const char * IVRRenderModels_Version = "IVRRenderModels_006"; +static const unsigned long k_unNotificationTextMaxSize = 256; static const char * IVRNotifications_Version = "IVRNotifications_002"; -static const unsigned int k_unMaxSettingsKeyLength = 128; -static const char * IVRSettings_Version = "IVRSettings_001"; +static const unsigned long k_unMaxSettingsKeyLength = 128; +static const char * IVRSettings_Version = "IVRSettings_003"; static const char * k_pch_SteamVR_Section = "steamvr"; static const char * k_pch_SteamVR_RequireHmd_String = "requireHmd"; static const char * k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; static const char * k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; static const char * k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; static const char * k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; -static const char * k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; static const char * k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; static const char * k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; static const char * k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; static const char * k_pch_SteamVR_LogLevel_Int32 = "loglevel"; static const char * k_pch_SteamVR_IPD_Float = "ipd"; static const char * k_pch_SteamVR_Background_String = "background"; +static const char * k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; static const char * k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; static const char * k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; -static const char * k_pch_SteamVR_Environment_String = "environment"; static const char * k_pch_SteamVR_GridColor_String = "gridColor"; static const char * k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; +static const char * k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor"; static const char * k_pch_SteamVR_ShowStage_Bool = "showStage"; static const char * k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; -static const char * k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit"; -static const char * k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout"; -static const char * k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout"; -static const char * k_pch_SteamVR_DirectMode_Bool = "directMode"; -static const char * k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; -static const char * k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; static const char * k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; static const char * k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; -static const char * k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; +static const char * k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement"; +static const char * k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip"; static const char * k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; -static const char * k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier"; -static const char * k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection"; -static const char * k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; +static const char * k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; +static const char * k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; +static const char * k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; +static const char * k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; +static const char * k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync"; static const char * k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; -static const char * k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; -static const char * k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; +static const char * k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; +static const char * k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView"; +static const char * k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView"; +static const char * k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode"; +static const char * k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye"; +static const char * k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; +static const char * k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; +static const char * k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph"; static const char * k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; -static const char * k_pch_SteamVR_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; -static const char * k_pch_SteamVR_UseGenericGraphcisDevice_Bool = "useGenericGraphicsDevice"; +static const char * k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; +static const char * k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; +static const char * k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; +static const char * k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; +static const char * k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; +static const char * k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; +static const char * k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; +static const char * k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; +static const char * k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; +static const char * k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; +static const char * k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; +static const char * k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; +static const char * k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; +static const char * k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; +static const char * k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid"; +static const char * k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; +static const char * k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; +static const char * k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; +static const char * k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; +static const char * k_pch_SteamVR_LastVersionNotice = "lastVersionNotice"; +static const char * k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate"; +static const char * k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR"; +static const char * k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG"; +static const char * k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB"; +static const char * k_pch_SteamVR_CustomIconStyle_String = "customIconStyle"; +static const char * k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle"; +static const char * k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate"; +static const char * k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority"; +static const char * k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2"; +static const char * k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption"; +static const char * k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches"; +static const char * k_pch_DirectMode_Section = "direct_mode"; +static const char * k_pch_DirectMode_Enable_Bool = "enable"; +static const char * k_pch_DirectMode_Count_Int32 = "count"; +static const char * k_pch_DirectMode_EdidVid_Int32 = "edidVid"; +static const char * k_pch_DirectMode_EdidPid_Int32 = "edidPid"; 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"; static const char * k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; static const char * k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; static const char * k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; -static const char * k_pch_Lighthouse_LighthouseName_String = "lighthousename"; -static const char * k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; -static const char * k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; static const char * k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; +static const char * k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; +static const char * k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; +static const char * k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; +static const char * k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations"; +static const char * k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; static const char * k_pch_Null_Section = "driver_null"; -static const char * k_pch_Null_EnableNullDriver_Bool = "enable"; static const char * k_pch_Null_SerialNumber_String = "serialNumber"; static const char * k_pch_Null_ModelNumber_String = "modelNumber"; static const char * k_pch_Null_WindowX_Int32 = "windowX"; @@ -143,8 +235,11 @@ static const char * k_pch_Null_RenderWidth_Int32 = "renderWidth"; static const char * k_pch_Null_RenderHeight_Int32 = "renderHeight"; static const char * k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; static const char * k_pch_Null_DisplayFrequency_Float = "displayFrequency"; +static const char * k_pch_WindowsMR_Section = "driver_holographic"; static const char * k_pch_UserInterface_Section = "userinterface"; static const char * k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; +static const char * k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; +static const char * k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; static const char * k_pch_UserInterface_Screenshots_Bool = "screenshots"; static const char * k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; static const char * k_pch_Notifications_Section = "notifications"; @@ -158,22 +253,23 @@ static const char * k_pch_Keyboard_OffsetRightX = "OffsetRightX"; static const char * k_pch_Keyboard_OffsetY = "OffsetY"; static const char * k_pch_Keyboard_Smoothing = "Smoothing"; static const char * k_pch_Perf_Section = "perfcheck"; -static const char * k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; -static const char * k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; -static const char * k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; +static const char * k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; static const char * k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; static const char * k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; static const char * k_pch_Perf_TestData_Float = "perfTestData"; +static const char * k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; static const char * k_pch_CollisionBounds_Section = "collisionBounds"; static const char * k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; static const char * k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; static const char * k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; static const char * k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; static const char * k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; +static const char * k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight"; static const char * k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; static const char * k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; static const char * k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; static const char * k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; +static const char * k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport"; static const char * k_pch_Camera_Section = "camera"; static const char * k_pch_Camera_EnableCamera_Bool = "enableCamera"; static const char * k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard"; @@ -183,16 +279,124 @@ static const char * k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGam static const char * k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; static const char * k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; static const char * k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; +static const char * k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; +static const char * k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; static const char * k_pch_audio_Section = "audio"; -static const char * k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; -static const char * k_pch_audio_OnRecordDevice_String = "onRecordDevice"; -static const char * k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; -static const char * k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; -static const char * k_pch_audio_OffRecordDevice_String = "offRecordDevice"; +static const char * k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice"; +static const char * k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride"; +static const char * k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride"; +static const char * k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName"; +static const char * k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice"; +static const char * k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride"; +static const char * k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride"; +static const char * k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName"; +static const char * k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror"; +static const char * k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice"; +static const char * k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName"; +static const char * k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; +static const char * k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice"; +static const char * k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume"; +static const char * k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; static const char * k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; +static const char * k_pch_Power_Section = "power"; +static const char * k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; +static const char * k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; +static const char * k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; +static const char * k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; +static const char * k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; +static const char * k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; +static const char * k_pch_Dashboard_Section = "dashboard"; +static const char * k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; +static const char * k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; +static const char * k_pch_Dashboard_Position = "position"; +static const char * k_pch_Dashboard_DesktopScale = "desktopScale"; +static const char * k_pch_Dashboard_DashboardScale = "dashboardScale"; static const char * k_pch_modelskin_Section = "modelskins"; +static const char * k_pch_Driver_Enable_Bool = "enable"; +static const char * k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode"; +static const char * k_pch_Driver_LoadPriority_Int32 = "loadPriority"; +static const char * k_pch_WebInterface_Section = "WebInterface"; +static const char * k_pch_VRWebHelper_Section = "VRWebHelper"; +static const char * k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; +static const char * k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; +static const char * k_pch_TrackingOverride_Section = "TrackingOverrides"; +static const char * k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; +static const char * k_pch_App_BindingLegacyAPISuffix_String = "_legacy"; +static const char * k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput"; +static const char * k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; +static const char * k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL"; +static const char * k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; +static const char * k_pch_App_DominantHand_Int32 = "DominantHand"; +static const char * k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK"; +static const char * k_pch_Trackers_Section = "trackers"; +static const char * k_pch_DesktopUI_Section = "DesktopUI"; +static const char * k_pch_LastKnown_Section = "LastKnown"; +static const char * k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; +static const char * k_pch_LastKnown_HMDModel_String = "HMDModel"; +static const char * k_pch_DismissedWarnings_Section = "DismissedWarnings"; +static const char * k_pch_Input_Section = "input"; +static const char * k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation"; +static const char * k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation"; +static const char * k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone"; +static const char * k_pch_GpuSpeed_Section = "GpuSpeed"; 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_unMaxActionNameLength = 64; +static const unsigned long k_unMaxActionSetNameLength = 64; +static const unsigned long k_unMaxActionOriginCount = 16; +static const unsigned long k_unMaxBoneNameLength = 32; +static const int k_nActionSetOverlayGlobalPriorityMin = 16777216; +static const int k_nActionSetOverlayGlobalPriorityMax = 33554431; +static const int k_nActionSetPriorityReservedMin = 33554432; +static const char * IVRInput_Version = "IVRInput_010"; +static const unsigned long long k_ulInvalidIOBufferHandle = 0; +static const char * IVRIOBuffer_Version = "IVRIOBuffer_002"; +static const unsigned long k_ulInvalidSpatialAnchorHandle = 0; +static const char * IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; +static const char * IVRDebug_Version = "IVRDebug_001"; +static const unsigned long long k_ulDisplayRedirectContainer = 25769803779; +static const char * IVRProperties_Version = "IVRProperties_001"; +static const char * k_pchPathUserHandRight = "/user/hand/right"; +static const char * k_pchPathUserHandLeft = "/user/hand/left"; +static const char * k_pchPathUserHandPrimary = "/user/hand/primary"; +static const char * k_pchPathUserHandSecondary = "/user/hand/secondary"; +static const char * k_pchPathUserHead = "/user/head"; +static const char * k_pchPathUserGamepad = "/user/gamepad"; +static const char * k_pchPathUserTreadmill = "/user/treadmill"; +static const char * k_pchPathUserStylus = "/user/stylus"; +static const char * k_pchPathDevices = "/devices"; +static const char * k_pchPathDevicePath = "/device_path"; +static const char * k_pchPathBestAliasPath = "/best_alias_path"; +static const char * k_pchPathBoundTrackerAliasPath = "/bound_tracker_path"; +static const char * k_pchPathBoundTrackerRole = "/bound_tracker_role"; +static const char * k_pchPathPoseRaw = "/pose/raw"; +static const char * k_pchPathPoseTip = "/pose/tip"; +static const char * k_pchPathSystemButtonClick = "/input/system/click"; +static const char * k_pchPathProximity = "/proximity"; +static const char * k_pchPathControllerTypePrefix = "/controller_type/"; +static const char * k_pchPathInputProfileSuffix = "/input_profile"; +static const char * k_pchPathBindingNameSuffix = "/binding_name"; +static const char * k_pchPathBindingUrlSuffix = "/binding_url"; +static const char * k_pchPathBindingErrorSuffix = "/binding_error"; +static const char * k_pchPathActiveActionSets = "/active_action_sets"; +static const char * k_pchPathComponentUpdates = "/total_component_updates"; +static const char * k_pchPathUserFootLeft = "/user/foot/left"; +static const char * k_pchPathUserFootRight = "/user/foot/right"; +static const char * k_pchPathUserShoulderLeft = "/user/shoulder/left"; +static const char * k_pchPathUserShoulderRight = "/user/shoulder/right"; +static const char * k_pchPathUserElbowLeft = "/user/elbow/left"; +static const char * k_pchPathUserElbowRight = "/user/elbow/right"; +static const char * k_pchPathUserKneeLeft = "/user/knee/left"; +static const char * k_pchPathUserKneeRight = "/user/knee/right"; +static const char * k_pchPathUserWaist = "/user/waist"; +static const char * k_pchPathUserChest = "/user/chest"; +static const char * k_pchPathUserCamera = "/user/camera"; +static const char * k_pchPathUserKeyboard = "/user/keyboard"; +static const char * k_pchPathClientAppKey = "/client_info/app_key"; +static const unsigned long long k_ulInvalidPathHandle = 0; +static const char * IVRPaths_Version = "IVRPaths_001"; +static const char * IVRBlockQueue_Version = "IVRBlockQueue_004"; // OpenVR Enums @@ -202,11 +406,17 @@ typedef enum EVREye EVREye_Eye_Right = 1, } EVREye; -typedef enum EGraphicsAPIConvention +typedef enum ETextureType { - EGraphicsAPIConvention_API_DirectX = 0, - EGraphicsAPIConvention_API_OpenGL = 1, -} EGraphicsAPIConvention; + ETextureType_TextureType_Invalid = -1, + ETextureType_TextureType_DirectX = 0, + ETextureType_TextureType_OpenGL = 1, + ETextureType_TextureType_Vulkan = 2, + ETextureType_TextureType_IOSurface = 3, + ETextureType_TextureType_DirectX12 = 4, + ETextureType_TextureType_DXGISharedHandle = 5, + ETextureType_TextureType_Metal = 6, +} ETextureType; typedef enum EColorSpace { @@ -222,6 +432,7 @@ typedef enum ETrackingResult ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101, ETrackingResult_TrackingResult_Running_OK = 200, ETrackingResult_TrackingResult_Running_OutOfRange = 201, + ETrackingResult_TrackingResult_Fallback_RotationOnly = 300, } ETrackingResult; typedef enum ETrackedDeviceClass @@ -229,8 +440,10 @@ typedef enum ETrackedDeviceClass ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0, ETrackedDeviceClass_TrackedDeviceClass_HMD = 1, ETrackedDeviceClass_TrackedDeviceClass_Controller = 2, + ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3, ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4, - ETrackedDeviceClass_TrackedDeviceClass_Other = 1000, + ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5, + ETrackedDeviceClass_TrackedDeviceClass_Max = 6, } ETrackedDeviceClass; typedef enum ETrackedControllerRole @@ -238,6 +451,10 @@ typedef enum ETrackedControllerRole ETrackedControllerRole_TrackedControllerRole_Invalid = 0, ETrackedControllerRole_TrackedControllerRole_LeftHand = 1, ETrackedControllerRole_TrackedControllerRole_RightHand = 2, + ETrackedControllerRole_TrackedControllerRole_OptOut = 3, + ETrackedControllerRole_TrackedControllerRole_Treadmill = 4, + ETrackedControllerRole_TrackedControllerRole_Stylus = 5, + ETrackedControllerRole_TrackedControllerRole_Max = 5, } ETrackedControllerRole; typedef enum ETrackingUniverseOrigin @@ -247,8 +464,17 @@ typedef enum ETrackingUniverseOrigin ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2, } ETrackingUniverseOrigin; +typedef enum EAdditionalRadioFeatures +{ + EAdditionalRadioFeatures_AdditionalRadioFeatures_None = 0, + EAdditionalRadioFeatures_AdditionalRadioFeatures_HTCLinkBox = 1, + EAdditionalRadioFeatures_AdditionalRadioFeatures_InternalDongle = 2, + EAdditionalRadioFeatures_AdditionalRadioFeatures_ExternalDongle = 4, +} EAdditionalRadioFeatures; + typedef enum ETrackedDeviceProperty { + ETrackedDeviceProperty_Prop_Invalid = 0, ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000, ETrackedDeviceProperty_Prop_ModelNumber_String = 1001, ETrackedDeviceProperty_Prop_SerialNumber_String = 1002, @@ -282,6 +508,25 @@ typedef enum ETrackedDeviceProperty ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030, ETrackedDeviceProperty_Prop_DriverVersion_String = 1031, ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032, + ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033, + ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034, + ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035, + ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036, + ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037, + ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038, + ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039, + ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040, + ETrackedDeviceProperty_Prop_CameraStreamFormat_Int32 = 1041, + ETrackedDeviceProperty_Prop_AdditionalDeviceSettingsPath_String = 1042, + ETrackedDeviceProperty_Prop_Identifiable_Bool = 1043, + ETrackedDeviceProperty_Prop_BootloaderVersion_Uint64 = 1044, + ETrackedDeviceProperty_Prop_AdditionalSystemReportData_String = 1045, + ETrackedDeviceProperty_Prop_CompositeFirmwareVersion_String = 1046, + ETrackedDeviceProperty_Prop_Firmware_RemindUpdate_Bool = 1047, + ETrackedDeviceProperty_Prop_PeripheralApplicationVersion_Uint64 = 1048, + ETrackedDeviceProperty_Prop_ManufacturerSerialNumber_String = 1049, + ETrackedDeviceProperty_Prop_ComputedSerialNumber_String = 1050, + ETrackedDeviceProperty_Prop_EstimatedDeviceFirstUseTime_Int32 = 1051, ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000, ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001, ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002, @@ -319,6 +564,68 @@ typedef enum ETrackedDeviceProperty ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036, + ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037, + ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038, + ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039, + ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040, + ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041, + ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042, + ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, + ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044, + ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045, + ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048, + ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049, + ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050, + ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, + ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052, + ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, + ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054, + ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056, + ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057, + ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058, + ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059, + 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_ConfigurationIncludesLighthouse20Features_Bool = 2069, + ETrackedDeviceProperty_Prop_AdditionalRadioFeatures_Uint64 = 2070, + ETrackedDeviceProperty_Prop_CameraWhiteBalance_Vector4_Array = 2071, + ETrackedDeviceProperty_Prop_CameraDistortionFunction_Int32_Array = 2072, + ETrackedDeviceProperty_Prop_CameraDistortionCoefficients_Float_Array = 2073, + ETrackedDeviceProperty_Prop_ExpectedControllerType_String = 2074, + ETrackedDeviceProperty_Prop_HmdTrackingStyle_Int32 = 2075, + ETrackedDeviceProperty_Prop_DriverProvidedChaperoneVisibility_Bool = 2076, + ETrackedDeviceProperty_Prop_HmdColumnCorrectionSettingPrefix_String = 2077, + ETrackedDeviceProperty_Prop_CameraSupportsCompatibilityModes_Bool = 2078, + ETrackedDeviceProperty_Prop_DisplayAvailableFrameRates_Float_Array = 2080, + ETrackedDeviceProperty_Prop_DisplaySupportsMultipleFramerates_Bool = 2081, + ETrackedDeviceProperty_Prop_DisplayColorMultLeft_Vector3 = 2082, + ETrackedDeviceProperty_Prop_DisplayColorMultRight_Vector3 = 2083, + ETrackedDeviceProperty_Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084, + ETrackedDeviceProperty_Prop_DisplaySupportsAnalogGain_Bool = 2085, + ETrackedDeviceProperty_Prop_DisplayMinAnalogGain_Float = 2086, + ETrackedDeviceProperty_Prop_DisplayMaxAnalogGain_Float = 2087, + ETrackedDeviceProperty_Prop_DashboardScale_Float = 2091, + ETrackedDeviceProperty_Prop_IpdUIRangeMinMeters_Float = 2100, + ETrackedDeviceProperty_Prop_IpdUIRangeMaxMeters_Float = 2101, + ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, + ETrackedDeviceProperty_Prop_Audio_DefaultPlaybackDeviceId_String = 2300, + ETrackedDeviceProperty_Prop_Audio_DefaultRecordingDeviceId_String = 2301, + ETrackedDeviceProperty_Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302, ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000, ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001, ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002, @@ -334,8 +641,35 @@ typedef enum ETrackedDeviceProperty ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004, ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005, ETrackedDeviceProperty_Prop_ModeLabel_String = 4006, + ETrackedDeviceProperty_Prop_CanWirelessIdentify_Bool = 4007, + ETrackedDeviceProperty_Prop_Nonce_Int32 = 4008, + ETrackedDeviceProperty_Prop_IconPathName_String = 5000, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandbyAlert_String = 5009, + ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100, + ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150, + ETrackedDeviceProperty_Prop_ParentContainer = 5151, + ETrackedDeviceProperty_Prop_OverrideContainer_Uint64 = 5152, + ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000, + ETrackedDeviceProperty_Prop_InstallPath_String = 6001, + ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002, + ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003, + ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004, + ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005, + ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006, + ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007, + ETrackedDeviceProperty_Prop_ControllerType_String = 7000, + ETrackedDeviceProperty_Prop_ControllerHandSelectionPriority_Int32 = 7002, ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000, ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999, + ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000, } ETrackedDeviceProperty; typedef enum ETrackedPropertyError @@ -350,13 +684,32 @@ typedef enum ETrackedPropertyError ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7, ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8, ETrackedPropertyError_TrackedProp_NotYetAvailable = 9, + ETrackedPropertyError_TrackedProp_PermissionDenied = 10, + ETrackedPropertyError_TrackedProp_InvalidOperation = 11, + ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12, + ETrackedPropertyError_TrackedProp_IPCReadFailure = 13, + ETrackedPropertyError_TrackedProp_OutOfMemory = 14, + ETrackedPropertyError_TrackedProp_InvalidContainer = 15, } ETrackedPropertyError; +typedef enum EHmdTrackingStyle +{ + EHmdTrackingStyle_HmdTrackingStyle_Unknown = 0, + EHmdTrackingStyle_HmdTrackingStyle_Lighthouse = 1, + EHmdTrackingStyle_HmdTrackingStyle_OutsideInCameras = 2, + EHmdTrackingStyle_HmdTrackingStyle_InsideOutCameras = 3, +} EHmdTrackingStyle; + typedef enum EVRSubmitFlags { EVRSubmitFlags_Submit_Default = 0, EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1, EVRSubmitFlags_Submit_GlRenderBuffer = 2, + EVRSubmitFlags_Submit_Reserved = 4, + EVRSubmitFlags_Submit_TextureWithPose = 8, + EVRSubmitFlags_Submit_TextureWithDepth = 16, + EVRSubmitFlags_Submit_FrameDiscontinuty = 32, + EVRSubmitFlags_Submit_VulkanTextureWithArrayData = 64, } EVRSubmitFlags; typedef enum EVRState @@ -385,94 +738,153 @@ typedef enum EVREventType EVREventType_VREvent_LeaveStandbyMode = 107, EVREventType_VREvent_TrackedDeviceRoleChanged = 108, EVREventType_VREvent_WatchdogWakeUpRequested = 109, + EVREventType_VREvent_LensDistortionChanged = 110, + EVREventType_VREvent_PropertyChanged = 111, + EVREventType_VREvent_WirelessDisconnect = 112, + EVREventType_VREvent_WirelessReconnect = 113, EVREventType_VREvent_ButtonPress = 200, EVREventType_VREvent_ButtonUnpress = 201, EVREventType_VREvent_ButtonTouch = 202, EVREventType_VREvent_ButtonUntouch = 203, + EVREventType_VREvent_Modal_Cancel = 257, EVREventType_VREvent_MouseMove = 300, EVREventType_VREvent_MouseButtonDown = 301, EVREventType_VREvent_MouseButtonUp = 302, EVREventType_VREvent_FocusEnter = 303, EVREventType_VREvent_FocusLeave = 304, - EVREventType_VREvent_Scroll = 305, + EVREventType_VREvent_ScrollDiscrete = 305, EVREventType_VREvent_TouchPadMove = 306, EVREventType_VREvent_OverlayFocusChanged = 307, + EVREventType_VREvent_ReloadOverlays = 308, + EVREventType_VREvent_ScrollSmooth = 309, + EVREventType_VREvent_LockMousePosition = 310, + EVREventType_VREvent_UnlockMousePosition = 311, EVREventType_VREvent_InputFocusCaptured = 400, EVREventType_VREvent_InputFocusReleased = 401, - EVREventType_VREvent_SceneFocusLost = 402, - EVREventType_VREvent_SceneFocusGained = 403, EVREventType_VREvent_SceneApplicationChanged = 404, EVREventType_VREvent_SceneFocusChanged = 405, EVREventType_VREvent_InputFocusChanged = 406, - EVREventType_VREvent_SceneApplicationSecondaryRenderingStarted = 407, + EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, + EVREventType_VREvent_ActionBindingReloaded = 409, EVREventType_VREvent_HideRenderModels = 410, EVREventType_VREvent_ShowRenderModels = 411, + EVREventType_VREvent_SceneApplicationStateChanged = 412, + EVREventType_VREvent_ConsoleOpened = 420, + EVREventType_VREvent_ConsoleClosed = 421, EVREventType_VREvent_OverlayShown = 500, EVREventType_VREvent_OverlayHidden = 501, EVREventType_VREvent_DashboardActivated = 502, EVREventType_VREvent_DashboardDeactivated = 503, - EVREventType_VREvent_DashboardThumbSelected = 504, EVREventType_VREvent_DashboardRequested = 505, EVREventType_VREvent_ResetDashboard = 506, - EVREventType_VREvent_RenderToast = 507, EVREventType_VREvent_ImageLoaded = 508, EVREventType_VREvent_ShowKeyboard = 509, EVREventType_VREvent_HideKeyboard = 510, EVREventType_VREvent_OverlayGamepadFocusGained = 511, EVREventType_VREvent_OverlayGamepadFocusLost = 512, EVREventType_VREvent_OverlaySharedTextureChanged = 513, - EVREventType_VREvent_DashboardGuideButtonDown = 514, - EVREventType_VREvent_DashboardGuideButtonUp = 515, EVREventType_VREvent_ScreenshotTriggered = 516, EVREventType_VREvent_ImageFailed = 517, + EVREventType_VREvent_DashboardOverlayCreated = 518, + EVREventType_VREvent_SwitchGamepadFocus = 519, EVREventType_VREvent_RequestScreenshot = 520, EVREventType_VREvent_ScreenshotTaken = 521, EVREventType_VREvent_ScreenshotFailed = 522, EVREventType_VREvent_SubmitScreenshotToDashboard = 523, EVREventType_VREvent_ScreenshotProgressToDashboard = 524, + EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525, + EVREventType_VREvent_RoomViewShown = 526, + EVREventType_VREvent_RoomViewHidden = 527, + EVREventType_VREvent_ShowUI = 528, + EVREventType_VREvent_ShowDevTools = 529, EVREventType_VREvent_Notification_Shown = 600, EVREventType_VREvent_Notification_Hidden = 601, EVREventType_VREvent_Notification_BeginInteraction = 602, EVREventType_VREvent_Notification_Destroyed = 603, EVREventType_VREvent_Quit = 700, EVREventType_VREvent_ProcessQuit = 701, - EVREventType_VREvent_QuitAborted_UserPrompt = 702, EVREventType_VREvent_QuitAcknowledged = 703, EVREventType_VREvent_DriverRequestedQuit = 704, + EVREventType_VREvent_RestartRequested = 705, EVREventType_VREvent_ChaperoneDataHasChanged = 800, EVREventType_VREvent_ChaperoneUniverseHasChanged = 801, EVREventType_VREvent_ChaperoneTempDataHasChanged = 802, EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803, EVREventType_VREvent_SeatedZeroPoseReset = 804, + EVREventType_VREvent_ChaperoneFlushCache = 805, + EVREventType_VREvent_ChaperoneRoomSetupStarting = 806, + EVREventType_VREvent_ChaperoneRoomSetupFinished = 807, EVREventType_VREvent_AudioSettingsHaveChanged = 820, EVREventType_VREvent_BackgroundSettingHasChanged = 850, EVREventType_VREvent_CameraSettingsHaveChanged = 851, EVREventType_VREvent_ReprojectionSettingHasChanged = 852, EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853, EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854, + EVREventType_VREvent_PowerSettingsHaveChanged = 855, + EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856, + EVREventType_VREvent_SteamVRSectionSettingChanged = 857, + EVREventType_VREvent_LighthouseSectionSettingChanged = 858, + EVREventType_VREvent_NullSectionSettingChanged = 859, + EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860, + EVREventType_VREvent_NotificationsSectionSettingChanged = 861, + EVREventType_VREvent_KeyboardSectionSettingChanged = 862, + EVREventType_VREvent_PerfSectionSettingChanged = 863, + EVREventType_VREvent_DashboardSectionSettingChanged = 864, + EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865, + EVREventType_VREvent_TrackersSectionSettingChanged = 866, + EVREventType_VREvent_LastKnownSectionSettingChanged = 867, + EVREventType_VREvent_DismissedWarningsSectionSettingChanged = 868, + EVREventType_VREvent_GpuSpeedSectionSettingChanged = 869, + EVREventType_VREvent_WindowsMRSectionSettingChanged = 870, + EVREventType_VREvent_OtherSectionSettingChanged = 871, EVREventType_VREvent_StatusUpdate = 900, + EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950, EVREventType_VREvent_MCImageUpdated = 1000, EVREventType_VREvent_FirmwareUpdateStarted = 1100, EVREventType_VREvent_FirmwareUpdateFinished = 1101, EVREventType_VREvent_KeyboardClosed = 1200, EVREventType_VREvent_KeyboardCharInput = 1201, EVREventType_VREvent_KeyboardDone = 1202, - EVREventType_VREvent_ApplicationTransitionStarted = 1300, - EVREventType_VREvent_ApplicationTransitionAborted = 1301, - EVREventType_VREvent_ApplicationTransitionNewAppStarted = 1302, EVREventType_VREvent_ApplicationListUpdated = 1303, EVREventType_VREvent_ApplicationMimeTypeLoad = 1304, - EVREventType_VREvent_Compositor_MirrorWindowShown = 1400, - EVREventType_VREvent_Compositor_MirrorWindowHidden = 1401, + EVREventType_VREvent_ProcessConnected = 1306, + EVREventType_VREvent_ProcessDisconnected = 1307, EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410, EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411, + EVREventType_VREvent_Compositor_DisplayDisconnected = 1412, + EVREventType_VREvent_Compositor_DisplayReconnected = 1413, + EVREventType_VREvent_Compositor_HDCPError = 1414, + EVREventType_VREvent_Compositor_ApplicationNotResponding = 1415, + EVREventType_VREvent_Compositor_ApplicationResumed = 1416, + EVREventType_VREvent_Compositor_OutOfVideoMemory = 1417, + EVREventType_VREvent_Compositor_DisplayModeNotSupported = 1418, + EVREventType_VREvent_Compositor_StageOverrideReady = 1419, EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500, EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501, EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502, EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503, + EVREventType_VREvent_TrackedCamera_EditingSurface = 1550, EVREventType_VREvent_PerformanceTest_EnableCapture = 1600, EVREventType_VREvent_PerformanceTest_DisableCapture = 1601, EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602, + 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_Input_ActionManifestReloaded = 1703, + EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704, + EVREventType_VREvent_Input_ProgressUpdate = 1705, + EVREventType_VREvent_Input_TrackerActivated = 1706, + EVREventType_VREvent_Input_BindingsUpdated = 1707, + EVREventType_VREvent_Input_BindingSubscriptionChanged = 1708, + EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800, + EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801, + EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802, + EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, + EVREventType_VREvent_SystemReport_Started = 1900, + EVREventType_VREvent_Monitor_ShowHeadsetView = 2000, + EVREventType_VREvent_Monitor_HideHeadsetView = 2001, EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000, EVREventType_VREvent_VendorSpecific_Reserved_End = 19999, } EVREventType; @@ -484,6 +896,7 @@ typedef enum EDeviceActivityLevel EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1, EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2, EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3, + EDeviceActivityLevel_k_EDeviceActivityLevel_Idle_Timeout = 4, } EDeviceActivityLevel; typedef enum EVRButtonId @@ -496,6 +909,7 @@ typedef enum EVRButtonId EVRButtonId_k_EButton_DPad_Right = 5, EVRButtonId_k_EButton_DPad_Down = 6, EVRButtonId_k_EButton_A = 7, + EVRButtonId_k_EButton_ProximitySensor = 31, EVRButtonId_k_EButton_Axis0 = 32, EVRButtonId_k_EButton_Axis1 = 33, EVRButtonId_k_EButton_Axis2 = 34, @@ -504,6 +918,9 @@ typedef enum EVRButtonId EVRButtonId_k_EButton_SteamVR_Touchpad = 32, EVRButtonId_k_EButton_SteamVR_Trigger = 33, EVRButtonId_k_EButton_Dashboard_Back = 2, + EVRButtonId_k_EButton_IndexController_A = 2, + EVRButtonId_k_EButton_IndexController_B = 1, + EVRButtonId_k_EButton_IndexController_JoyStick = 35, EVRButtonId_k_EButton_Max = 64, } EVRButtonId; @@ -514,6 +931,87 @@ typedef enum EVRMouseButton EVRMouseButton_VRMouseButton_Middle = 4, } EVRMouseButton; +typedef enum EShowUIType +{ + EShowUIType_ShowUI_ControllerBinding = 0, + EShowUIType_ShowUI_ManageTrackers = 1, + EShowUIType_ShowUI_Pairing = 3, + EShowUIType_ShowUI_Settings = 4, + EShowUIType_ShowUI_DebugCommands = 5, + EShowUIType_ShowUI_FullControllerBinding = 6, + EShowUIType_ShowUI_ManageDrivers = 7, +} EShowUIType; + +typedef enum EHDCPError +{ + EHDCPError_HDCPError_None = 0, + EHDCPError_HDCPError_LinkLost = 1, + EHDCPError_HDCPError_Tampered = 2, + EHDCPError_HDCPError_DeviceRevoked = 3, + EHDCPError_HDCPError_Unknown = 4, +} EHDCPError; + +typedef enum EVRComponentProperty +{ + EVRComponentProperty_VRComponentProperty_IsStatic = 1, + EVRComponentProperty_VRComponentProperty_IsVisible = 2, + EVRComponentProperty_VRComponentProperty_IsTouched = 4, + EVRComponentProperty_VRComponentProperty_IsPressed = 8, + EVRComponentProperty_VRComponentProperty_IsScrolled = 16, + EVRComponentProperty_VRComponentProperty_IsHighlighted = 32, +} EVRComponentProperty; + +typedef enum EVRInputError +{ + EVRInputError_VRInputError_None = 0, + EVRInputError_VRInputError_NameNotFound = 1, + EVRInputError_VRInputError_WrongType = 2, + EVRInputError_VRInputError_InvalidHandle = 3, + EVRInputError_VRInputError_InvalidParam = 4, + EVRInputError_VRInputError_NoSteam = 5, + EVRInputError_VRInputError_MaxCapacityReached = 6, + 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_VRInputError_MissingSkeletonData = 16, + EVRInputError_VRInputError_InvalidBoneIndex = 17, + EVRInputError_VRInputError_InvalidPriority = 18, + EVRInputError_VRInputError_PermissionDenied = 19, + EVRInputError_VRInputError_InvalidRenderModel = 20, +} EVRInputError; + +typedef enum EVRSpatialAnchorError +{ + EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0, + EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1, + EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2, + EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3, + EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4, + EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5, + EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6, + EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7, + EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8, + EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9, + EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10, + EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11, + EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12, + EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13, +} EVRSpatialAnchorError; + +typedef enum EHiddenAreaMeshType +{ + EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0, + EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1, + EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2, + EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3, +} EHiddenAreaMeshType; + typedef enum EVRControllerAxisType { EVRControllerAxisType_k_eControllerAxis_None = 0, @@ -557,8 +1055,13 @@ typedef enum EVROverlayError EVROverlayError_VROverlayError_RequestFailed = 23, EVROverlayError_VROverlayError_InvalidTexture = 24, EVROverlayError_VROverlayError_UnableToLoadFile = 25, - EVROverlayError_VROVerlayError_KeyboardAlreadyInUse = 26, + EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26, EVROverlayError_VROverlayError_NoNeighbor = 27, + EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29, + EVROverlayError_VROverlayError_BadMaskPrimitive = 30, + EVROverlayError_VROverlayError_TextureAlreadyLocked = 31, + EVROverlayError_VROverlayError_TextureLockCapacityReached = 32, + EVROverlayError_VROverlayError_TextureNotLocked = 33, } EVROverlayError; typedef enum EVRApplicationType @@ -570,7 +1073,9 @@ typedef enum EVRApplicationType EVRApplicationType_VRApplication_Utility = 4, EVRApplicationType_VRApplication_VRMonitor = 5, EVRApplicationType_VRApplication_SteamWatchdog = 6, - EVRApplicationType_VRApplication_Max = 7, + EVRApplicationType_VRApplication_Bootstrapper = 7, + EVRApplicationType_VRApplication_WebHelper = 8, + EVRApplicationType_VRApplication_Max = 9, } EVRApplicationType; typedef enum EVRFirmwareError @@ -589,6 +1094,21 @@ typedef enum EVRNotificationError EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103, } EVRNotificationError; +typedef enum EVRSkeletalMotionRange +{ + EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0, + EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1, +} EVRSkeletalMotionRange; + +typedef enum EVRSkeletalTrackingLevel +{ + EVRSkeletalTrackingLevel_VRSkeletalTracking_Estimated = 0, + EVRSkeletalTrackingLevel_VRSkeletalTracking_Partial = 1, + EVRSkeletalTrackingLevel_VRSkeletalTracking_Full = 2, + EVRSkeletalTrackingLevel_VRSkeletalTrackingLevel_Count = 3, + EVRSkeletalTrackingLevel_VRSkeletalTrackingLevel_Max = 2, +} EVRSkeletalTrackingLevel; + typedef enum EVRInitError { EVRInitError_VRInitError_None = 0, @@ -626,6 +1146,20 @@ typedef enum EVRInitError EVRInitError_VRInitError_Init_InvalidApplicationType = 130, EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131, EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132, + EVRInitError_VRInitError_Init_VRDashboardNotFound = 133, + EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134, + EVRInitError_VRInitError_Init_VRHomeNotFound = 135, + EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136, + EVRInitError_VRInitError_Init_RebootingBusy = 137, + EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138, + EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139, + EVRInitError_VRInitError_Init_USBServiceBusy = 140, + EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141, + EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142, + EVRInitError_VRInitError_Init_AlreadyRunning = 143, + EVRInitError_VRInitError_Init_FailedForVrMonitor = 144, + EVRInitError_VRInitError_Init_PropertyManagerInitFailed = 145, + EVRInitError_VRInitError_Init_WebServerFailed = 146, EVRInitError_VRInitError_Driver_Failed = 200, EVRInitError_VRInitError_Driver_Unknown = 201, EVRInitError_VRInitError_Driver_HmdUnknown = 202, @@ -638,6 +1172,7 @@ typedef enum EVRInitError EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211, EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212, + EVRInitError_VRInitError_Driver_HmdDisplayNotFoundLaptop = 213, EVRInitError_VRInitError_IPC_ServerInitFailed = 300, EVRInitError_VRInitError_IPC_ConnectFailed = 301, EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302, @@ -647,12 +1182,101 @@ typedef enum EVRInitError EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306, EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307, EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, + EVRInitError_VRInitError_IPC_ConnectFailedAfterTargetExited = 309, + EVRInitError_VRInitError_IPC_NamespaceUnavailable = 310, EVRInitError_VRInitError_Compositor_Failed = 400, EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401, EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402, EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403, EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404, + EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405, + EVRInitError_VRInitError_Compositor_SharedStateIsNull = 406, + EVRInitError_VRInitError_Compositor_NotificationManagerIsNull = 407, + EVRInitError_VRInitError_Compositor_ResourceManagerClientIsNull = 408, + EVRInitError_VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409, + EVRInitError_VRInitError_Compositor_PropertiesInterfaceIsNull = 410, + EVRInitError_VRInitError_Compositor_CreateFullscreenWindowFailed = 411, + EVRInitError_VRInitError_Compositor_SettingsInterfaceIsNull = 412, + EVRInitError_VRInitError_Compositor_FailedToShowWindow = 413, + EVRInitError_VRInitError_Compositor_DistortInterfaceIsNull = 414, + EVRInitError_VRInitError_Compositor_DisplayFrequencyFailure = 415, + EVRInitError_VRInitError_Compositor_RendererInitializationFailed = 416, + EVRInitError_VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417, + EVRInitError_VRInitError_Compositor_DXGIFactoryCreateFailed = 418, + EVRInitError_VRInitError_Compositor_DXGIFactoryQueryFailed = 419, + EVRInitError_VRInitError_Compositor_InvalidAdapterDesktop = 420, + EVRInitError_VRInitError_Compositor_InvalidHmdAttachment = 421, + EVRInitError_VRInitError_Compositor_InvalidOutputDesktop = 422, + EVRInitError_VRInitError_Compositor_InvalidDeviceProvided = 423, + EVRInitError_VRInitError_Compositor_D3D11RendererInitializationFailed = 424, + EVRInitError_VRInitError_Compositor_FailedToFindDisplayMode = 425, + EVRInitError_VRInitError_Compositor_FailedToCreateSwapChain = 426, + EVRInitError_VRInitError_Compositor_FailedToGetBackBuffer = 427, + EVRInitError_VRInitError_Compositor_FailedToCreateRenderTarget = 428, + EVRInitError_VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429, + EVRInitError_VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430, + EVRInitError_VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431, + EVRInitError_VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432, + EVRInitError_VRInitError_Compositor_SelectDisplayMode = 433, + EVRInitError_VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434, + EVRInitError_VRInitError_Compositor_NvAPISetDisplayMode = 435, + EVRInitError_VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436, + EVRInitError_VRInitError_Compositor_InvalidHmdPropertyContainer = 437, + EVRInitError_VRInitError_Compositor_UpdateDisplayFrequency = 438, + EVRInitError_VRInitError_Compositor_CreateRasterizerState = 439, + EVRInitError_VRInitError_Compositor_CreateWireframeRasterizerState = 440, + EVRInitError_VRInitError_Compositor_CreateSamplerState = 441, + EVRInitError_VRInitError_Compositor_CreateClampToBorderSamplerState = 442, + EVRInitError_VRInitError_Compositor_CreateAnisoSamplerState = 443, + EVRInitError_VRInitError_Compositor_CreateOverlaySamplerState = 444, + EVRInitError_VRInitError_Compositor_CreatePanoramaSamplerState = 445, + EVRInitError_VRInitError_Compositor_CreateFontSamplerState = 446, + EVRInitError_VRInitError_Compositor_CreateNoBlendState = 447, + EVRInitError_VRInitError_Compositor_CreateBlendState = 448, + EVRInitError_VRInitError_Compositor_CreateAlphaBlendState = 449, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskR = 450, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskG = 451, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskB = 452, + EVRInitError_VRInitError_Compositor_CreateDepthStencilState = 453, + EVRInitError_VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454, + EVRInitError_VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455, + EVRInitError_VRInitError_Compositor_CreateFlushTexture = 456, + EVRInitError_VRInitError_Compositor_CreateDistortionSurfaces = 457, + EVRInitError_VRInitError_Compositor_CreateConstantBuffer = 458, + EVRInitError_VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459, + EVRInitError_VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460, + EVRInitError_VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461, + EVRInitError_VRInitError_Compositor_CreateOverlayConstantBuffer = 462, + EVRInitError_VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463, + EVRInitError_VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464, + EVRInitError_VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465, + EVRInitError_VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466, + EVRInitError_VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467, + EVRInitError_VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468, + EVRInitError_VRInitError_Compositor_CreateGeomConstantBuffer = 469, + EVRInitError_VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470, + EVRInitError_VRInitError_Compositor_CreatePixelSimUBO = 471, + EVRInitError_VRInitError_Compositor_CreateMSAARenderTextures = 472, + EVRInitError_VRInitError_Compositor_CreateResolveRenderTextures = 473, + EVRInitError_VRInitError_Compositor_CreateComputeResolveRenderTextures = 474, + EVRInitError_VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475, + EVRInitError_VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476, + EVRInitError_VRInitError_Compositor_CreateFallbackSyncTexture = 477, + EVRInitError_VRInitError_Compositor_ShareFallbackSyncTexture = 478, + EVRInitError_VRInitError_Compositor_CreateOverlayIndexBuffer = 479, + EVRInitError_VRInitError_Compositor_CreateOverlayVertexBuffer = 480, + EVRInitError_VRInitError_Compositor_CreateTextVertexBuffer = 481, + EVRInitError_VRInitError_Compositor_CreateTextIndexBuffer = 482, + EVRInitError_VRInitError_Compositor_CreateMirrorTextures = 483, + EVRInitError_VRInitError_Compositor_CreateLastFrameRenderTexture = 484, + EVRInitError_VRInitError_Compositor_CreateMirrorOverlay = 485, + EVRInitError_VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486, + EVRInitError_VRInitError_Compositor_DisplayModeNotSupported = 487, + EVRInitError_VRInitError_Compositor_CreateOverlayInvalidCall = 488, + EVRInitError_VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489, + EVRInitError_VRInitError_Compositor_FailedToCreateMailbox = 490, EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001, EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103, @@ -666,7 +1290,9 @@ typedef enum EVRInitError EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111, EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112, EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, + EVRInitError_VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114, EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000, + EVRInitError_VRInitError_LastError = 2001, } EVRInitError; typedef enum EVRScreenshotType @@ -706,6 +1332,14 @@ typedef enum EVRTrackedCameraError EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115, } EVRTrackedCameraError; +typedef enum EVRTrackedCameraFrameLayout +{ + EVRTrackedCameraFrameLayout_Mono = 1, + EVRTrackedCameraFrameLayout_Stereo = 2, + EVRTrackedCameraFrameLayout_VerticalLayout = 16, + EVRTrackedCameraFrameLayout_HorizontalLayout = 32, +} EVRTrackedCameraFrameLayout; + typedef enum EVRTrackedCameraFrameType { EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0, @@ -714,6 +1348,37 @@ typedef enum EVRTrackedCameraFrameType EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3, } EVRTrackedCameraFrameType; +typedef enum EVRDistortionFunctionType +{ + EVRDistortionFunctionType_VRDistortionFunctionType_None = 0, + EVRDistortionFunctionType_VRDistortionFunctionType_FTheta = 1, + EVRDistortionFunctionType_VRDistortionFunctionType_Extended_FTheta = 2, + EVRDistortionFunctionType_MAX_DISTORTION_FUNCTION_TYPES = 3, +} EVRDistortionFunctionType; + +typedef enum EVSync +{ + EVSync_VSync_None = 0, + EVSync_VSync_WaitRender = 1, + EVSync_VSync_NoWaitRender = 2, +} EVSync; + +typedef enum EVRMuraCorrectionMode +{ + EVRMuraCorrectionMode_Default = 0, + EVRMuraCorrectionMode_NoCorrection = 1, +} EVRMuraCorrectionMode; + +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, @@ -732,6 +1397,7 @@ typedef enum EVRApplicationError EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112, EVRApplicationError_VRApplicationError_TransitionAborted = 113, EVRApplicationError_VRApplicationError_IsTemplate = 114, + EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115, EVRApplicationError_VRApplicationError_BufferTooSmall = 200, EVRApplicationError_VRApplicationError_PropertyNotSet = 201, EVRApplicationError_VRApplicationError_UnknownProperty = 202, @@ -750,19 +1416,24 @@ typedef enum EVRApplicationProperty EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51, EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52, EVRApplicationProperty_VRApplicationProperty_Source_String = 53, + EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54, EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60, EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61, EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62, + EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63, + EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64, + EVRApplicationProperty_VRApplicationProperty_IsHidden_Bool = 65, EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70, } EVRApplicationProperty; -typedef enum EVRApplicationTransitionState +typedef enum EVRSceneApplicationState { - EVRApplicationTransitionState_VRApplicationTransition_None = 0, - EVRApplicationTransitionState_VRApplicationTransition_OldAppQuitSent = 10, - EVRApplicationTransitionState_VRApplicationTransition_WaitingForExternalLaunch = 11, - EVRApplicationTransitionState_VRApplicationTransition_NewAppLaunched = 20, -} EVRApplicationTransitionState; + EVRSceneApplicationState_None = 0, + EVRSceneApplicationState_Starting = 1, + EVRSceneApplicationState_Quitting = 2, + EVRSceneApplicationState_Running = 3, + EVRSceneApplicationState_Waiting = 4, +} EVRSceneApplicationState; typedef enum ChaperoneCalibrationState { @@ -772,7 +1443,7 @@ typedef enum ChaperoneCalibrationState ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, ChaperoneCalibrationState_Error = 200, - ChaperoneCalibrationState_Error_BaseStationUninitalized = 201, + ChaperoneCalibrationState_Error_BaseStationUninitialized = 201, ChaperoneCalibrationState_Error_BaseStationConflict = 202, ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, @@ -801,8 +1472,18 @@ typedef enum EVRCompositorError EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105, EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106, EVRCompositorError_VRCompositorError_IndexOutOfRange = 107, + EVRCompositorError_VRCompositorError_AlreadySubmitted = 108, + EVRCompositorError_VRCompositorError_InvalidBounds = 109, + EVRCompositorError_VRCompositorError_AlreadySet = 110, } EVRCompositorError; +typedef enum EVRCompositorTimingMode +{ + EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0, + EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1, + EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2, +} EVRCompositorTimingMode; + typedef enum VROverlayInputMethod { VROverlayInputMethod_None = 0, @@ -811,31 +1492,49 @@ typedef enum VROverlayInputMethod typedef enum VROverlayTransformType { + VROverlayTransformType_VROverlayTransform_Invalid = -1, VROverlayTransformType_VROverlayTransform_Absolute = 0, VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1, VROverlayTransformType_VROverlayTransform_SystemOverlay = 2, VROverlayTransformType_VROverlayTransform_TrackedComponent = 3, + VROverlayTransformType_VROverlayTransform_Cursor = 4, + VROverlayTransformType_VROverlayTransform_DashboardTab = 5, + VROverlayTransformType_VROverlayTransform_DashboardThumb = 6, + VROverlayTransformType_VROverlayTransform_Mountable = 7, } VROverlayTransformType; typedef enum VROverlayFlags { - VROverlayFlags_None = 0, - VROverlayFlags_Curved = 1, - VROverlayFlags_RGSS4X = 2, - VROverlayFlags_NoDashboardTab = 3, - VROverlayFlags_AcceptsGamepadEvents = 4, - VROverlayFlags_ShowGamepadFocus = 5, - VROverlayFlags_SendVRScrollEvents = 6, - VROverlayFlags_SendVRTouchpadEvents = 7, - VROverlayFlags_ShowTouchPadScrollWheel = 8, - VROverlayFlags_TransferOwnershipToInternalProcess = 9, - VROverlayFlags_SideBySide_Parallel = 10, - VROverlayFlags_SideBySide_Crossed = 11, - VROverlayFlags_Panorama = 12, - VROverlayFlags_StereoPanorama = 13, - VROverlayFlags_SortWithNonSceneOverlays = 14, + VROverlayFlags_NoDashboardTab = 8, + VROverlayFlags_SendVRDiscreteScrollEvents = 64, + VROverlayFlags_SendVRTouchpadEvents = 128, + VROverlayFlags_ShowTouchPadScrollWheel = 256, + VROverlayFlags_TransferOwnershipToInternalProcess = 512, + VROverlayFlags_SideBySide_Parallel = 1024, + VROverlayFlags_SideBySide_Crossed = 2048, + VROverlayFlags_Panorama = 4096, + VROverlayFlags_StereoPanorama = 8192, + VROverlayFlags_SortWithNonSceneOverlays = 16384, + VROverlayFlags_VisibleInDashboard = 32768, + VROverlayFlags_MakeOverlaysInteractiveIfVisible = 65536, + VROverlayFlags_SendVRSmoothScrollEvents = 131072, + VROverlayFlags_ProtectedContent = 262144, + VROverlayFlags_HideLaserIntersection = 524288, + VROverlayFlags_WantsModalBehavior = 1048576, + VROverlayFlags_IsPremultiplied = 2097152, } VROverlayFlags; +typedef enum VRMessageOverlayResponse +{ + VRMessageOverlayResponse_ButtonPress_0 = 0, + VRMessageOverlayResponse_ButtonPress_1 = 1, + VRMessageOverlayResponse_ButtonPress_2 = 2, + VRMessageOverlayResponse_ButtonPress_3 = 3, + VRMessageOverlayResponse_CouldntFindSystemOverlay = 4, + VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5, + VRMessageOverlayResponse_ApplicationQuit = 6, +} VRMessageOverlayResponse; + typedef enum EGamepadTextInputMode { EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0, @@ -849,14 +1548,31 @@ typedef enum EGamepadTextInputLineMode EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1, } EGamepadTextInputLineMode; -typedef enum EOverlayDirection +typedef enum EVROverlayIntersectionMaskPrimitiveType { - EOverlayDirection_OverlayDirection_Up = 0, - EOverlayDirection_OverlayDirection_Down = 1, - EOverlayDirection_OverlayDirection_Left = 2, - EOverlayDirection_OverlayDirection_Right = 3, - EOverlayDirection_OverlayDirection_Count = 4, -} EOverlayDirection; + EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0, + EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1, +} EVROverlayIntersectionMaskPrimitiveType; + +typedef enum EKeyboardFlags +{ + EKeyboardFlags_KeyboardFlag_Minimal = 1, + EKeyboardFlags_KeyboardFlag_Modal = 2, +} EKeyboardFlags; + +typedef enum EDeviceType +{ + EDeviceType_DeviceType_Invalid = -1, + EDeviceType_DeviceType_DirectX11 = 0, + EDeviceType_DeviceType_Vulkan = 1, +} EDeviceType; + +typedef enum HeadsetViewMode_t +{ + HeadsetViewMode_t_HeadsetViewMode_Left = 0, + HeadsetViewMode_t_HeadsetViewMode_Right = 1, + HeadsetViewMode_t_HeadsetViewMode_Both = 2, +} HeadsetViewMode_t; typedef enum EVRRenderModelError { @@ -875,14 +1591,14 @@ typedef enum EVRRenderModelError EVRRenderModelError_VRRenderModelError_InvalidTexture = 400, } EVRRenderModelError; -typedef enum EVRComponentProperty +typedef enum EVRRenderModelTextureFormat { - EVRComponentProperty_VRComponentProperty_IsStatic = 1, - EVRComponentProperty_VRComponentProperty_IsVisible = 2, - EVRComponentProperty_VRComponentProperty_IsTouched = 4, - EVRComponentProperty_VRComponentProperty_IsPressed = 8, - EVRComponentProperty_VRComponentProperty_IsScrolled = 16, -} EVRComponentProperty; + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_RGBA8_SRGB = 0, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC2 = 1, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC4 = 2, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC7 = 3, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC7_SRGB = 4, +} EVRRenderModelTextureFormat; typedef enum EVRNotificationType { @@ -906,6 +1622,8 @@ typedef enum EVRSettingsError EVRSettingsError_VRSettingsError_IPCFailed = 1, EVRSettingsError_VRSettingsError_WriteFailed = 2, EVRSettingsError_VRSettingsError_ReadFailed = 3, + EVRSettingsError_VRSettingsError_JsonParseFailed = 4, + EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5, } EVRSettingsError; typedef enum EVRScreenshotError @@ -918,25 +1636,144 @@ typedef enum EVRScreenshotError EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108, } EVRScreenshotError; +typedef enum EVRSkeletalTransformSpace +{ + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0, + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1, +} EVRSkeletalTransformSpace; + +typedef enum EVRSkeletalReferencePose +{ + EVRSkeletalReferencePose_VRSkeletalReferencePose_BindPose = 0, + EVRSkeletalReferencePose_VRSkeletalReferencePose_OpenHand = 1, + EVRSkeletalReferencePose_VRSkeletalReferencePose_Fist = 2, + EVRSkeletalReferencePose_VRSkeletalReferencePose_GripLimit = 3, +} EVRSkeletalReferencePose; + +typedef enum EVRFinger +{ + EVRFinger_VRFinger_Thumb = 0, + EVRFinger_VRFinger_Index = 1, + EVRFinger_VRFinger_Middle = 2, + EVRFinger_VRFinger_Ring = 3, + EVRFinger_VRFinger_Pinky = 4, + EVRFinger_VRFinger_Count = 5, +} EVRFinger; + +typedef enum EVRFingerSplay +{ + EVRFingerSplay_VRFingerSplay_Thumb_Index = 0, + EVRFingerSplay_VRFingerSplay_Index_Middle = 1, + EVRFingerSplay_VRFingerSplay_Middle_Ring = 2, + EVRFingerSplay_VRFingerSplay_Ring_Pinky = 3, + EVRFingerSplay_VRFingerSplay_Count = 4, +} EVRFingerSplay; + +typedef enum EVRSummaryType +{ + EVRSummaryType_VRSummaryType_FromAnimation = 0, + EVRSummaryType_VRSummaryType_FromDevice = 1, +} EVRSummaryType; + +typedef enum EVRInputFilterCancelType +{ + EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0, + EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1, +} EVRInputFilterCancelType; + +typedef enum EVRInputStringBits +{ + EVRInputStringBits_VRInputString_Hand = 1, + EVRInputStringBits_VRInputString_ControllerType = 2, + EVRInputStringBits_VRInputString_InputSource = 4, + EVRInputStringBits_VRInputString_All = -1, +} EVRInputStringBits; + +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; + +typedef enum EVRDebugError +{ + EVRDebugError_VRDebugError_Success = 0, + EVRDebugError_VRDebugError_BadParameter = 1, +} EVRDebugError; + +typedef enum EPropertyWriteType +{ + EPropertyWriteType_PropertyWrite_Set = 0, + EPropertyWriteType_PropertyWrite_Erase = 1, + EPropertyWriteType_PropertyWrite_SetError = 2, +} EPropertyWriteType; + +typedef enum EBlockQueueError +{ + EBlockQueueError_BlockQueueError_None = 0, + EBlockQueueError_BlockQueueError_QueueAlreadyExists = 1, + EBlockQueueError_BlockQueueError_QueueNotFound = 2, + EBlockQueueError_BlockQueueError_BlockNotAvailable = 3, + EBlockQueueError_BlockQueueError_InvalidHandle = 4, + EBlockQueueError_BlockQueueError_InvalidParam = 5, + EBlockQueueError_BlockQueueError_ParamMismatch = 6, + EBlockQueueError_BlockQueueError_InternalError = 7, + EBlockQueueError_BlockQueueError_AlreadyInitialized = 8, + EBlockQueueError_BlockQueueError_OperationIsServerOnly = 9, + EBlockQueueError_BlockQueueError_TooManyConnections = 10, +} EBlockQueueError; + +typedef enum EBlockQueueReadType +{ + EBlockQueueReadType_BlockQueueRead_Latest = 0, + EBlockQueueReadType_BlockQueueRead_New = 1, + EBlockQueueReadType_BlockQueueRead_Next = 2, +} EBlockQueueReadType; + // OpenVR typedefs typedef uint32_t TrackedDeviceIndex_t; typedef uint32_t VRNotificationId; typedef uint64_t VROverlayHandle_t; + +typedef uint32_t SpatialAnchorHandle_t; typedef void * glSharedTextureHandle_t; typedef int32_t glInt_t; typedef uint32_t glUInt_t; +typedef uint64_t SharedTextureHandle_t; +typedef uint32_t DriverId_t; typedef uint32_t TrackedDeviceIndex_t; +typedef uint64_t WebConsoleHandle_t; +typedef uint64_t PropertyContainerHandle_t; +typedef uint32_t PropertyTypeTag_t; +typedef PropertyContainerHandle_t DriverHandle_t; +typedef uint64_t VRActionHandle_t; +typedef uint64_t VRActionSetHandle_t; +typedef uint64_t VRInputValueHandle_t; +typedef uint32_t VRComponentProperties; typedef uint64_t VROverlayHandle_t; +typedef int32_t BoneIndex_t; typedef uint64_t TrackedCameraHandle_t; typedef uint32_t ScreenshotHandle_t; -typedef uint32_t VRComponentProperties; typedef int32_t TextureID_t; typedef uint32_t VRNotificationId; +typedef uint64_t IOBufferHandle_t; +typedef uint64_t VrProfilerEventHandle_t; typedef EVRInitError HmdError; typedef EVREye Hmd_Eye; -typedef EGraphicsAPIConvention GraphicsAPIConvention; typedef EColorSpace ColorSpace; typedef ETrackingResult HmdTrackingResult; typedef ETrackedDeviceClass TrackedDeviceClass; @@ -950,6 +1787,7 @@ typedef EVROverlayError VROverlayError; typedef EVRFirmwareError VRFirmwareError; typedef EVRCompositorError VRCompositorError; typedef EVRScreenshotError VRScreenshotsError; +typedef uint64_t PathHandle_t; // OpenVR Structs @@ -958,6 +1796,11 @@ typedef struct HmdMatrix34_t float m[3][4]; //float[3][4] } HmdMatrix34_t; +typedef struct HmdMatrix33_t +{ + float m[3][3]; //float[3][3] +} HmdMatrix33_t; + typedef struct HmdMatrix44_t { float m[4][4]; //float[4][4] @@ -991,6 +1834,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; @@ -1020,7 +1871,7 @@ typedef struct DistortionCoordinates_t typedef struct Texture_t { void * handle; // void * - enum EGraphicsAPIConvention eType; + enum ETextureType eType; enum EColorSpace eColorSpace; } Texture_t; @@ -1042,6 +1893,55 @@ typedef struct VRTextureBounds_t float vMax; } VRTextureBounds_t; +typedef struct VRTextureWithPose_t +{ + struct HmdMatrix34_t mDeviceToAbsoluteTracking; +} VRTextureWithPose_t; + +typedef struct VRTextureDepthInfo_t +{ + void * handle; // void * + struct HmdMatrix44_t mProjection; + struct HmdVector2_t vRange; +} VRTextureDepthInfo_t; + +typedef struct VRTextureWithDepth_t +{ + struct VRTextureDepthInfo_t depth; +} VRTextureWithDepth_t; + +typedef struct VRTextureWithPoseAndDepth_t +{ + struct VRTextureDepthInfo_t depth; +} VRTextureWithPoseAndDepth_t; + +typedef struct VRVulkanTextureData_t +{ + uint64_t m_nImage; + struct VkDevice_T * m_pDevice; // struct VkDevice_T * + struct VkPhysicalDevice_T * m_pPhysicalDevice; // struct VkPhysicalDevice_T * + struct VkInstance_T * m_pInstance; // struct VkInstance_T * + struct VkQueue_T * m_pQueue; // struct VkQueue_T * + uint32_t m_nQueueFamilyIndex; + uint32_t m_nWidth; + uint32_t m_nHeight; + uint32_t m_nFormat; + uint32_t m_nSampleCount; +} VRVulkanTextureData_t; + +typedef struct VRVulkanTextureArrayData_t +{ + uint32_t m_unArrayIndex; + uint32_t m_unArraySize; +} VRVulkanTextureArrayData_t; + +typedef struct D3D12TextureData_t +{ + struct ID3D12Resource * m_pResource; // struct ID3D12Resource * + struct ID3D12CommandQueue * m_pCommandQueue; // struct ID3D12CommandQueue * + uint32_t m_nNodeMask; +} D3D12TextureData_t; + typedef struct VREvent_Controller_t { uint32_t button; @@ -1058,7 +1958,8 @@ typedef struct VREvent_Scroll_t { float xdelta; float ydelta; - uint32_t repeatCount; + uint32_t unused; + float viewportscale; } VREvent_Scroll_t; typedef struct VREvent_TouchPadMove_t @@ -1082,11 +1983,13 @@ typedef struct VREvent_Process_t uint32_t pid; uint32_t oldPid; bool bForced; + bool bConnectionLost; } VREvent_Process_t; typedef struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; } VREvent_Overlay_t; typedef struct VREvent_Status_t @@ -1096,7 +1999,7 @@ typedef struct VREvent_Status_t typedef struct VREvent_Keyboard_t { - char * cNewInput[8]; //char[8] + char cNewInput[8]; //char[8] uint64_t uUserValue; } VREvent_Keyboard_t; @@ -1115,6 +2018,10 @@ typedef struct VREvent_Reserved_t { uint64_t reserved0; uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; } VREvent_Reserved_t; typedef struct VREvent_PerformanceTest_t @@ -1144,6 +2051,90 @@ typedef struct VREvent_ApplicationLaunch_t uint32_t unArgsHandle; } VREvent_ApplicationLaunch_t; +typedef struct VREvent_EditingCameraSurface_t +{ + uint64_t overlayHandle; + uint32_t nVisualMode; +} VREvent_EditingCameraSurface_t; + +typedef struct VREvent_MessageOverlay_t +{ + uint32_t unVRMessageOverlayResponse; +} VREvent_MessageOverlay_t; + +typedef struct VREvent_Property_t +{ + PropertyContainerHandle_t container; + enum ETrackedDeviceProperty prop; +} VREvent_Property_t; + +typedef struct VREvent_HapticVibration_t +{ + uint64_t containerHandle; + uint64_t componentHandle; + float fDurationSeconds; + float fFrequency; + float fAmplitude; +} VREvent_HapticVibration_t; + +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; + uint64_t pathControllerType; +} VREvent_InputBindingLoad_t; + +typedef struct VREvent_InputActionManifestLoad_t +{ + uint64_t pathAppKey; + uint64_t pathMessage; + uint64_t pathMessageParam; + uint64_t pathManifestPath; +} VREvent_InputActionManifestLoad_t; + +typedef struct VREvent_SpatialAnchor_t +{ + SpatialAnchorHandle_t unHandle; +} VREvent_SpatialAnchor_t; + +typedef struct VREvent_ProgressUpdate_t +{ + uint64_t ulApplicationPropertyContainer; + uint64_t pathDevice; + uint64_t pathInputSource; + uint64_t pathProgressAction; + uint64_t pathIcon; + float fProgress; +} VREvent_ProgressUpdate_t; + +typedef struct VREvent_ShowUI_t +{ + enum EShowUIType eType; +} VREvent_ShowUI_t; + +typedef struct VREvent_ShowDevTools_t +{ + int32_t nBrowserIdentifier; +} VREvent_ShowDevTools_t; + +typedef struct VREvent_HDCPError_t +{ + enum EHDCPError eCode; +} VREvent_HDCPError_t; + +typedef struct RenderModel_ComponentState_t +{ + struct HmdMatrix34_t mTrackingToComponentRenderModel; + struct HmdMatrix34_t mTrackingToComponentLocal; + VRComponentProperties uProperties; +} RenderModel_ComponentState_t; + typedef struct HiddenAreaMesh_t { struct HmdVector2_t * pVertexData; // const struct vr::HmdVector2_t * @@ -1164,23 +2155,11 @@ typedef struct VRControllerState_t struct VRControllerAxis_t rAxis[5]; //struct vr::VRControllerAxis_t[5] } VRControllerState_t; -typedef struct Compositor_OverlaySettings -{ - uint32_t size; - bool curved; - bool antialias; - float scale; - float distance; - float alpha; - float uOffset; - float vOffset; - float uScale; - float vScale; - float gridDivs; - float gridWidth; - float gridScale; - struct HmdMatrix44_t transform; -} Compositor_OverlaySettings; +typedef struct VRBoneTransform_t +{ + struct HmdVector4_t position; + struct HmdQuaternionf_t orientation; +} VRBoneTransform_t; typedef struct CameraVideoStreamFrameHeader_t { @@ -1189,20 +2168,16 @@ typedef struct CameraVideoStreamFrameHeader_t uint32_t nHeight; uint32_t nBytesPerPixel; uint32_t nFrameSequence; - struct TrackedDevicePose_t standingTrackedDevicePose; + struct TrackedDevicePose_t trackedDevicePose; + uint64_t ulFrameExposureTime; } CameraVideoStreamFrameHeader_t; -typedef struct AppOverrideKeys_t -{ - char * pchKey; // const char * - char * pchValue; // const char * -} AppOverrideKeys_t; - typedef struct Compositor_FrameTiming { uint32_t m_nSize; uint32_t m_nFrameIndex; uint32_t m_nNumFramePresents; + uint32_t m_nNumMisPresented; uint32_t m_nNumDroppedFrames; uint32_t m_nReprojectionFlags; double m_flSystemTimeInSeconds; @@ -1223,8 +2198,39 @@ typedef struct Compositor_FrameTiming float m_flCompositorUpdateEndMs; float m_flCompositorRenderStartMs; TrackedDevicePose_t m_HmdPose; + uint32_t m_nNumVSyncsReadyForUse; + uint32_t m_nNumVSyncsToFirstView; } Compositor_FrameTiming; +typedef struct Compositor_BenchmarkResults +{ + float m_flMegaPixelsPerSecond; + float m_flHmdRecommendedMegaPixelsPerSecond; +} Compositor_BenchmarkResults; + +typedef struct DriverDirectMode_FrameTiming +{ + uint32_t m_nSize; + uint32_t m_nNumFramePresents; + uint32_t m_nNumMisPresented; + uint32_t m_nNumDroppedFrames; + 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 * + char * pchValue; // const char * +} AppOverrideKeys_t; + typedef struct Compositor_CumulativeStats { uint32_t m_nPid; @@ -1244,6 +2250,18 @@ typedef struct Compositor_CumulativeStats uint32_t m_nNumReprojectedFramesTimedOut; } Compositor_CumulativeStats; +typedef struct Compositor_StageRenderSettings +{ + struct HmdColor_t m_PrimaryColor; + struct HmdColor_t m_SecondaryColor; + float m_flVignetteInnerRadius; + float m_flVignetteOuterRadius; + float m_flFresnelStrength; + bool m_bBackfaceCulling; + bool m_bGreyscale; + bool m_bWireframe; +} Compositor_StageRenderSettings; + typedef struct VROverlayIntersectionParams_t { struct HmdVector3_t vSource; @@ -1259,12 +2277,42 @@ typedef struct VROverlayIntersectionResults_t float fDistance; } VROverlayIntersectionResults_t; -typedef struct RenderModel_ComponentState_t +typedef struct IntersectionMaskRectangle_t { - struct HmdMatrix34_t mTrackingToComponentRenderModel; - struct HmdMatrix34_t mTrackingToComponentLocal; - VRComponentProperties uProperties; -} RenderModel_ComponentState_t; + float m_flTopLeftX; + float m_flTopLeftY; + float m_flWidth; + float m_flHeight; +} IntersectionMaskRectangle_t; + +typedef struct IntersectionMaskCircle_t +{ + float m_flCenterX; + float m_flCenterY; + float m_flRadius; +} IntersectionMaskCircle_t; + +typedef struct VROverlayView_t +{ + VROverlayHandle_t overlayHandle; + struct Texture_t texture; + struct VRTextureBounds_t textureBounds; +} VROverlayView_t; + +typedef struct VRVulkanDevice_t +{ + struct VkInstance_T * m_pInstance; // struct VkInstance_T * + struct VkDevice_T * m_pDevice; // struct VkDevice_T * + struct VkPhysicalDevice_T * m_pPhysicalDevice; // struct VkPhysicalDevice_T * + struct VkQueue_T * m_pQueue; // struct VkQueue_T * + uint32_t m_uQueueFamilyIndex; +} VRVulkanDevice_t; + +typedef struct VRNativeDevice_t +{ + void * handle; // void * + enum EDeviceType eType; +} VRNativeDevice_t; typedef struct RenderModel_Vertex_t { @@ -1273,13 +2321,23 @@ typedef struct RenderModel_Vertex_t float rfTextureCoord[2]; //float[2] } RenderModel_Vertex_t; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( push, 4 ) +#endif typedef struct RenderModel_TextureMap_t { uint16_t unWidth; uint16_t unHeight; uint8_t * rubTextureMapData; // const uint8_t * + enum EVRRenderModelTextureFormat format; } RenderModel_TextureMap_t; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( push, 4 ) +#endif typedef struct RenderModel_t { struct RenderModel_Vertex_t * rVertexData; // const struct vr::RenderModel_Vertex_t * @@ -1289,6 +2347,9 @@ typedef struct RenderModel_t TextureID_t diffuseTextureId; } RenderModel_t; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif typedef struct RenderModel_ControllerMode_State_t { bool bScrollWheelVisible; @@ -1302,13 +2363,91 @@ typedef struct NotificationBitmap_t int32_t m_nBytesPerPixel; } NotificationBitmap_t; +typedef struct CVRSettingHelper +{ + intptr_t m_pSettings; // class vr::IVRSettings * +} CVRSettingHelper; + +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 InputSkeletalActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; +} InputSkeletalActionData_t; + +typedef struct InputOriginInfo_t +{ + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char rchRenderModelComponentName[128]; //char[128] +} InputOriginInfo_t; + +typedef struct InputBindingInfo_t +{ + char rchDevicePathName[128]; //char[128] + char rchInputPathName[128]; //char[128] + char rchModeName[128]; //char[128] + char rchSlotName[128]; //char[128] + char rchInputSourceType[32]; //char[32] +} InputBindingInfo_t; + +typedef struct VRActiveActionSet_t +{ + VRActionSetHandle_t ulActionSet; + VRInputValueHandle_t ulRestrictedToDevice; + VRActionSetHandle_t ulSecondaryActionSet; + uint32_t unPadding; + int32_t nPriority; +} VRActiveActionSet_t; + +typedef struct VRSkeletalSummaryData_t +{ + float flFingerCurl[5]; //float[5] + float flFingerSplay[4]; //float[4] +} VRSkeletalSummaryData_t; + +typedef struct SpatialAnchorPose_t +{ + struct HmdMatrix34_t mAnchorToAbsoluteTracking; +} SpatialAnchorPose_t; + typedef struct COpenVRContext { intptr_t m_pVRSystem; // class vr::IVRSystem * intptr_t m_pVRChaperone; // class vr::IVRChaperone * intptr_t m_pVRChaperoneSetup; // class vr::IVRChaperoneSetup * intptr_t m_pVRCompositor; // class vr::IVRCompositor * + intptr_t m_pVRHeadsetView; // class vr::IVRHeadsetView * intptr_t m_pVROverlay; // class vr::IVROverlay * + intptr_t m_pVROverlayView; // class vr::IVROverlayView * intptr_t m_pVRResources; // class vr::IVRResources * intptr_t m_pVRRenderModels; // class vr::IVRRenderModels * intptr_t m_pVRExtendedDisplay; // class vr::IVRExtendedDisplay * @@ -1316,8 +2455,63 @@ typedef struct COpenVRContext intptr_t m_pVRApplications; // class vr::IVRApplications * 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 * + intptr_t m_pVRSpatialAnchors; // class vr::IVRSpatialAnchors * + intptr_t m_pVRDebug; // class vr::IVRDebug * + intptr_t m_pVRNotifications; // class vr::IVRNotifications * } COpenVRContext; +typedef struct PropertyWrite_t +{ + enum ETrackedDeviceProperty prop; + enum EPropertyWriteType writeType; + enum ETrackedPropertyError eSetError; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + enum ETrackedPropertyError eError; +} PropertyWrite_t; + +typedef struct PropertyRead_t +{ + enum ETrackedDeviceProperty prop; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + uint32_t unRequiredBufferSize; + enum ETrackedPropertyError eError; +} PropertyRead_t; + +typedef struct CVRPropertyHelpers +{ + intptr_t m_pProperties; // class vr::IVRProperties * +} CVRPropertyHelpers; + +typedef struct PathWrite_t +{ + PathHandle_t ulPath; + enum EPropertyWriteType writeType; + enum ETrackedPropertyError eSetError; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + enum ETrackedPropertyError eError; + char * pszPath; // const char * +} PathWrite_t; + +typedef struct PathRead_t +{ + PathHandle_t ulPath; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + uint32_t unRequiredBufferSize; + enum ETrackedPropertyError eError; + char * pszPath; // const char * +} PathRead_t; + typedef union { @@ -1335,8 +2529,25 @@ typedef union VREvent_PerformanceTest_t performanceTest; VREvent_TouchPadMove_t touchPadMove; VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; + VREvent_Screenshot_t screenshot; + VREvent_ScreenshotProgress_t screenshotProgress; + VREvent_ApplicationLaunch_t applicationLaunch; + VREvent_EditingCameraSurface_t cameraSurface; + VREvent_MessageOverlay_t messageOverlay; + VREvent_Property_t property; + VREvent_HapticVibration_t hapticVibration; + VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; + VREvent_InputActionManifestLoad_t actionManifest; + VREvent_SpatialAnchor_t spatialAnchor; } VREvent_Data_t; +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + /** An event posted by the server to all running applications */ struct VREvent_t { @@ -1347,19 +2558,37 @@ struct VREvent_t VREvent_Data_t data; }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif + + +typedef union +{ + IntersectionMaskRectangle_t m_Rectangle; + IntersectionMaskCircle_t m_Circle; +} VROverlayIntersectionMaskPrimitive_Data_t; + +struct VROverlayIntersectionMaskPrimitive_t +{ + EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType; + VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; +}; + // OpenVR Function Pointer Tables struct VR_IVRSystem_FnTable { void (OPENVR_FNTABLE_CALLTYPE *GetRecommendedRenderTargetSize)(uint32_t * pnWidth, uint32_t * pnHeight); - struct HmdMatrix44_t (OPENVR_FNTABLE_CALLTYPE *GetProjectionMatrix)(EVREye eEye, float fNearZ, float fFarZ, EGraphicsAPIConvention eProjType); + struct HmdMatrix44_t (OPENVR_FNTABLE_CALLTYPE *GetProjectionMatrix)(EVREye eEye, float fNearZ, float fFarZ); void (OPENVR_FNTABLE_CALLTYPE *GetProjectionRaw)(EVREye eEye, float * pfLeft, float * pfRight, float * pfTop, float * pfBottom); - struct DistortionCoordinates_t (OPENVR_FNTABLE_CALLTYPE *ComputeDistortion)(EVREye eEye, float fU, float fV); + bool (OPENVR_FNTABLE_CALLTYPE *ComputeDistortion)(EVREye eEye, float fU, float fV, struct DistortionCoordinates_t * pDistortionCoordinates); struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetEyeToHeadTransform)(EVREye eEye); bool (OPENVR_FNTABLE_CALLTYPE *GetTimeSinceLastVsync)(float * pfSecondsSinceLastVsync, uint64_t * pulFrameCounter); int32_t (OPENVR_FNTABLE_CALLTYPE *GetD3D9AdapterIndex)(); void (OPENVR_FNTABLE_CALLTYPE *GetDXGIOutputInfo)(int32_t * pnAdapterIndex); + void (OPENVR_FNTABLE_CALLTYPE *GetOutputDevice)(uint64_t * pnDevice, ETextureType textureType, struct VkInstance_T * pInstance); bool (OPENVR_FNTABLE_CALLTYPE *IsDisplayOnDesktop)(); bool (OPENVR_FNTABLE_CALLTYPE *SetDisplayVisibility)(bool bIsVisibleOnDesktop); void (OPENVR_FNTABLE_CALLTYPE *GetDeviceToAbsoluteTrackingPose)(ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, struct TrackedDevicePose_t * pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount); @@ -1378,24 +2607,26 @@ struct VR_IVRSystem_FnTable int32_t (OPENVR_FNTABLE_CALLTYPE *GetInt32TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); uint64_t (OPENVR_FNTABLE_CALLTYPE *GetUint64TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetMatrix34TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetArrayTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, PropertyTypeTag_t propType, void * pBuffer, uint32_t unBufferSize, ETrackedPropertyError * pError); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetStringTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, char * pchValue, uint32_t unBufferSize, ETrackedPropertyError * pError); char * (OPENVR_FNTABLE_CALLTYPE *GetPropErrorNameFromEnum)(ETrackedPropertyError error); bool (OPENVR_FNTABLE_CALLTYPE *PollNextEvent)(struct VREvent_t * pEvent, uint32_t uncbVREvent); bool (OPENVR_FNTABLE_CALLTYPE *PollNextEventWithPose)(ETrackingUniverseOrigin eOrigin, struct VREvent_t * pEvent, uint32_t uncbVREvent, TrackedDevicePose_t * pTrackedDevicePose); char * (OPENVR_FNTABLE_CALLTYPE *GetEventTypeNameFromEnum)(EVREventType eType); - struct HiddenAreaMesh_t (OPENVR_FNTABLE_CALLTYPE *GetHiddenAreaMesh)(EVREye eEye); - bool (OPENVR_FNTABLE_CALLTYPE *GetControllerState)(TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState); - bool (OPENVR_FNTABLE_CALLTYPE *GetControllerStateWithPose)(ETrackingUniverseOrigin eOrigin, TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState, struct TrackedDevicePose_t * pTrackedDevicePose); + struct HiddenAreaMesh_t (OPENVR_FNTABLE_CALLTYPE *GetHiddenAreaMesh)(EVREye eEye, EHiddenAreaMeshType type); + bool (OPENVR_FNTABLE_CALLTYPE *GetControllerState)(TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState, uint32_t unControllerStateSize); + bool (OPENVR_FNTABLE_CALLTYPE *GetControllerStateWithPose)(ETrackingUniverseOrigin eOrigin, TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState, uint32_t unControllerStateSize, struct TrackedDevicePose_t * pTrackedDevicePose); void (OPENVR_FNTABLE_CALLTYPE *TriggerHapticPulse)(TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec); char * (OPENVR_FNTABLE_CALLTYPE *GetButtonIdNameFromEnum)(EVRButtonId eButtonId); char * (OPENVR_FNTABLE_CALLTYPE *GetControllerAxisTypeNameFromEnum)(EVRControllerAxisType eAxisType); - bool (OPENVR_FNTABLE_CALLTYPE *CaptureInputFocus)(); - void (OPENVR_FNTABLE_CALLTYPE *ReleaseInputFocus)(); - bool (OPENVR_FNTABLE_CALLTYPE *IsInputFocusCapturedByAnotherProcess)(); - uint32_t (OPENVR_FNTABLE_CALLTYPE *DriverDebugRequest)(TrackedDeviceIndex_t unDeviceIndex, char * pchRequest, char * pchResponseBuffer, uint32_t unResponseBufferSize); + bool (OPENVR_FNTABLE_CALLTYPE *IsInputAvailable)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsSteamVRDrawingControllers)(); + bool (OPENVR_FNTABLE_CALLTYPE *ShouldApplicationPause)(); + bool (OPENVR_FNTABLE_CALLTYPE *ShouldApplicationReduceRenderingWork)(); EVRFirmwareError (OPENVR_FNTABLE_CALLTYPE *PerformFirmwareUpdate)(TrackedDeviceIndex_t unDeviceIndex); void (OPENVR_FNTABLE_CALLTYPE *AcknowledgeQuit_Exiting)(); - void (OPENVR_FNTABLE_CALLTYPE *AcknowledgeQuit_UserPrompt)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetAppContainerFilePaths)(char * pchBuffer, uint32_t unBufferSize); + char * (OPENVR_FNTABLE_CALLTYPE *GetRuntimeVersion)(); }; struct VR_IVRExtendedDisplay_FnTable @@ -1410,8 +2641,8 @@ struct VR_IVRTrackedCamera_FnTable char * (OPENVR_FNTABLE_CALLTYPE *GetCameraErrorNameFromEnum)(EVRTrackedCameraError eCameraError); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *HasCamera)(TrackedDeviceIndex_t nDeviceIndex, bool * pHasCamera); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraFrameSize)(TrackedDeviceIndex_t nDeviceIndex, EVRTrackedCameraFrameType eFrameType, uint32_t * pnWidth, uint32_t * pnHeight, uint32_t * pnFrameBufferSize); - EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraIntrinisics)(TrackedDeviceIndex_t nDeviceIndex, EVRTrackedCameraFrameType eFrameType, HmdVector2_t * pFocalLength, HmdVector2_t * pCenter); - EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraProjection)(TrackedDeviceIndex_t nDeviceIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, HmdMatrix44_t * pProjection); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraIntrinsics)(TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, EVRTrackedCameraFrameType eFrameType, HmdVector2_t * pFocalLength, HmdVector2_t * pCenter); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraProjection)(TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, HmdMatrix44_t * pProjection); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *AcquireVideoStreamingService)(TrackedDeviceIndex_t nDeviceIndex, TrackedCameraHandle_t * pHandle); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *ReleaseVideoStreamingService)(TrackedCameraHandle_t hTrackedCamera); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamFrameBuffer)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, void * pFrameBuffer, uint32_t nFrameBufferSize, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); @@ -1419,6 +2650,8 @@ struct VR_IVRTrackedCamera_FnTable EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamTextureD3D11)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, void * pD3D11DeviceOrResource, void ** ppD3D11ShaderResourceView, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamTextureGL)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, glUInt_t * pglTextureId, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *ReleaseVideoStreamTextureGL)(TrackedCameraHandle_t hTrackedCamera, glUInt_t glTextureId); + void (OPENVR_FNTABLE_CALLTYPE *SetCameraTrackingSpace)(ETrackingUniverseOrigin eUniverse); + ETrackingUniverseOrigin (OPENVR_FNTABLE_CALLTYPE *GetCameraTrackingSpace)(); }; struct VR_IVRApplications_FnTable @@ -1448,11 +2681,11 @@ struct VR_IVRApplications_FnTable uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationsThatSupportMimeType)(char * pchMimeType, char * pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationLaunchArguments)(uint32_t unHandle, char * pchArgs, uint32_t unArgs); EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *GetStartingApplication)(char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); - EVRApplicationTransitionState (OPENVR_FNTABLE_CALLTYPE *GetTransitionState)(); + EVRSceneApplicationState (OPENVR_FNTABLE_CALLTYPE *GetSceneApplicationState)(); EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *PerformApplicationPrelaunchCheck)(char * pchAppKey); - char * (OPENVR_FNTABLE_CALLTYPE *GetApplicationsTransitionStateNameFromEnum)(EVRApplicationTransitionState state); - bool (OPENVR_FNTABLE_CALLTYPE *IsQuitUserPromptRequested)(); + char * (OPENVR_FNTABLE_CALLTYPE *GetSceneApplicationStateNameFromEnum)(EVRSceneApplicationState state); EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchInternalProcess)(char * pchBinaryPath, char * pchArguments, char * pchWorkingDirectory); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetCurrentSceneProcessId)(); }; struct VR_IVRChaperone_FnTable @@ -1479,16 +2712,16 @@ struct VR_IVRChaperoneSetup_FnTable bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingStandingZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pmatStandingZeroPoseToRawTrackingPose); void (OPENVR_FNTABLE_CALLTYPE *SetWorkingPlayAreaSize)(float sizeX, float sizeZ); void (OPENVR_FNTABLE_CALLTYPE *SetWorkingCollisionBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t unQuadsCount); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingPerimeter)(struct HmdVector2_t * pPointBuffer, uint32_t unPointCount); void (OPENVR_FNTABLE_CALLTYPE *SetWorkingSeatedZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pMatSeatedZeroPoseToRawTrackingPose); void (OPENVR_FNTABLE_CALLTYPE *SetWorkingStandingZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pMatStandingZeroPoseToRawTrackingPose); void (OPENVR_FNTABLE_CALLTYPE *ReloadFromDisk)(EChaperoneConfigFile configFile); bool (OPENVR_FNTABLE_CALLTYPE *GetLiveSeatedZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose); - void (OPENVR_FNTABLE_CALLTYPE *SetWorkingCollisionBoundsTagsInfo)(uint8_t * pTagsBuffer, uint32_t unTagCount); - bool (OPENVR_FNTABLE_CALLTYPE *GetLiveCollisionBoundsTagsInfo)(uint8_t * pTagsBuffer, uint32_t * punTagCount); - bool (OPENVR_FNTABLE_CALLTYPE *SetWorkingPhysicalBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t unQuadsCount); - bool (OPENVR_FNTABLE_CALLTYPE *GetLivePhysicalBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t * punQuadsCount); bool (OPENVR_FNTABLE_CALLTYPE *ExportLiveToBuffer)(char * pBuffer, uint32_t * pnBufferLength); bool (OPENVR_FNTABLE_CALLTYPE *ImportFromBufferToWorking)(char * pBuffer, uint32_t nImportFlags); + void (OPENVR_FNTABLE_CALLTYPE *ShowWorkingSetPreview)(); + void (OPENVR_FNTABLE_CALLTYPE *HideWorkingSetPreview)(); + void (OPENVR_FNTABLE_CALLTYPE *RoomSetupStarting)(); }; struct VR_IVRCompositor_FnTable @@ -1502,10 +2735,13 @@ struct VR_IVRCompositor_FnTable void (OPENVR_FNTABLE_CALLTYPE *ClearLastSubmittedFrame)(); void (OPENVR_FNTABLE_CALLTYPE *PostPresentHandoff)(); bool (OPENVR_FNTABLE_CALLTYPE *GetFrameTiming)(struct Compositor_FrameTiming * pTiming, uint32_t unFramesAgo); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetFrameTimings)(struct Compositor_FrameTiming * pTiming, uint32_t nFrames); float (OPENVR_FNTABLE_CALLTYPE *GetFrameTimeRemaining)(); void (OPENVR_FNTABLE_CALLTYPE *GetCumulativeStats)(struct Compositor_CumulativeStats * pStats, uint32_t nStatsSizeInBytes); void (OPENVR_FNTABLE_CALLTYPE *FadeToColor)(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground); + struct HmdColor_t (OPENVR_FNTABLE_CALLTYPE *GetCurrentFadeColor)(bool bBackground); void (OPENVR_FNTABLE_CALLTYPE *FadeGrid)(float fSeconds, bool bFadeIn); + float (OPENVR_FNTABLE_CALLTYPE *GetCurrentGridAlpha)(); EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SetSkyboxOverride)(struct Texture_t * pTextures, uint32_t unTextureCount); void (OPENVR_FNTABLE_CALLTYPE *ClearSkyboxOverride)(); void (OPENVR_FNTABLE_CALLTYPE *CompositorBringToFront)(); @@ -1524,27 +2760,40 @@ struct VR_IVRCompositor_FnTable void (OPENVR_FNTABLE_CALLTYPE *ForceReconnectProcess)(); void (OPENVR_FNTABLE_CALLTYPE *SuspendRendering)(bool bSuspend); EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetMirrorTextureD3D11)(EVREye eEye, void * pD3D11DeviceOrResource, void ** ppD3D11ShaderResourceView); + void (OPENVR_FNTABLE_CALLTYPE *ReleaseMirrorTextureD3D11)(void * pD3D11ShaderResourceView); EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetMirrorTextureGL)(EVREye eEye, glUInt_t * pglTextureId, glSharedTextureHandle_t * pglSharedTextureHandle); bool (OPENVR_FNTABLE_CALLTYPE *ReleaseSharedGLTexture)(glUInt_t glTextureId, glSharedTextureHandle_t glSharedTextureHandle); void (OPENVR_FNTABLE_CALLTYPE *LockGLSharedTextureForAccess)(glSharedTextureHandle_t glSharedTextureHandle); void (OPENVR_FNTABLE_CALLTYPE *UnlockGLSharedTextureForAccess)(glSharedTextureHandle_t glSharedTextureHandle); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetVulkanInstanceExtensionsRequired)(char * pchValue, uint32_t unBufferSize); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetVulkanDeviceExtensionsRequired)(struct VkPhysicalDevice_T * pPhysicalDevice, char * pchValue, uint32_t unBufferSize); + void (OPENVR_FNTABLE_CALLTYPE *SetExplicitTimingMode)(EVRCompositorTimingMode eTimingMode); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SubmitExplicitTimingData)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsMotionSmoothingEnabled)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsMotionSmoothingSupported)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsCurrentSceneFocusAppLoading)(); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SetStageOverride_Async)(char * pchRenderModelPath, struct HmdMatrix34_t * pTransform, struct Compositor_StageRenderSettings * pRenderSettings, uint32_t nSizeOfRenderSettings); + void (OPENVR_FNTABLE_CALLTYPE *ClearStageOverride)(); + bool (OPENVR_FNTABLE_CALLTYPE *GetCompositorBenchmarkResults)(struct Compositor_BenchmarkResults * pBenchmarkResults, uint32_t nSizeOfBenchmarkResults); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetLastPosePredictionIDs)(uint32_t * pRenderPosePredictionID, uint32_t * pGamePosePredictionID); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetPosesForFrame)(uint32_t unPosePredictionID, struct TrackedDevicePose_t * pPoseArray, uint32_t unPoseArrayCount); }; struct VR_IVROverlay_FnTable { EVROverlayError (OPENVR_FNTABLE_CALLTYPE *FindOverlay)(char * pchOverlayKey, VROverlayHandle_t * pOverlayHandle); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *CreateOverlay)(char * pchOverlayKey, char * pchOverlayFriendlyName, VROverlayHandle_t * pOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *CreateOverlay)(char * pchOverlayKey, char * pchOverlayName, VROverlayHandle_t * pOverlayHandle); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *DestroyOverlay)(VROverlayHandle_t ulOverlayHandle); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetHighQualityOverlay)(VROverlayHandle_t ulOverlayHandle); - VROverlayHandle_t (OPENVR_FNTABLE_CALLTYPE *GetHighQualityOverlay)(); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayKey)(VROverlayHandle_t ulOverlayHandle, char * pchValue, uint32_t unBufferSize, EVROverlayError * pError); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayName)(VROverlayHandle_t ulOverlayHandle, char * pchValue, uint32_t unBufferSize, EVROverlayError * pError); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayName)(VROverlayHandle_t ulOverlayHandle, char * pchName); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayImageData)(VROverlayHandle_t ulOverlayHandle, void * pvBuffer, uint32_t unBufferSize, uint32_t * punWidth, uint32_t * punHeight); char * (OPENVR_FNTABLE_CALLTYPE *GetOverlayErrorNameFromEnum)(EVROverlayError error); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayRenderingPid)(VROverlayHandle_t ulOverlayHandle, uint32_t unPID); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayRenderingPid)(VROverlayHandle_t ulOverlayHandle); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayFlag)(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayFlag)(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool * pbEnabled); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayFlags)(VROverlayHandle_t ulOverlayHandle, uint32_t * pFlags); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayColor)(VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayColor)(VROverlayHandle_t ulOverlayHandle, float * pfRed, float * pfGreen, float * pfBlue); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayAlpha)(VROverlayHandle_t ulOverlayHandle, float fAlpha); @@ -1555,8 +2804,8 @@ struct VR_IVROverlay_FnTable EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlaySortOrder)(VROverlayHandle_t ulOverlayHandle, uint32_t * punSortOrder); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayWidthInMeters)(VROverlayHandle_t ulOverlayHandle, float fWidthInMeters); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayWidthInMeters)(VROverlayHandle_t ulOverlayHandle, float * pfWidthInMeters); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayAutoCurveDistanceRangeInMeters)(VROverlayHandle_t ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayAutoCurveDistanceRangeInMeters)(VROverlayHandle_t ulOverlayHandle, float * pfMinDistanceInMeters, float * pfMaxDistanceInMeters); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCurvature)(VROverlayHandle_t ulOverlayHandle, float fCurvature); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayCurvature)(VROverlayHandle_t ulOverlayHandle, float * pfCurvature); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTextureColorSpace)(VROverlayHandle_t ulOverlayHandle, EColorSpace eTextureColorSpace); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTextureColorSpace)(VROverlayHandle_t ulOverlayHandle, EColorSpace * peTextureColorSpace); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTextureBounds)(VROverlayHandle_t ulOverlayHandle, struct VRTextureBounds_t * pOverlayTextureBounds); @@ -1568,6 +2817,10 @@ struct VR_IVROverlay_FnTable EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformTrackedDeviceRelative)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t * punTrackedDevice, struct HmdMatrix34_t * pmatTrackedDeviceToOverlayTransform); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformTrackedDeviceComponent)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, char * pchComponentName); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformTrackedDeviceComponent)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t * punDeviceIndex, char * pchComponentName, uint32_t unComponentNameSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformOverlayRelative)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t * ulOverlayHandleParent, struct HmdMatrix34_t * pmatParentOverlayToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformOverlayRelative)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulOverlayHandleParent, struct HmdMatrix34_t * pmatParentOverlayToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformCursor)(VROverlayHandle_t ulCursorOverlayHandle, struct HmdVector2_t * pvHotspot); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformCursor)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvHotspot); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowOverlay)(VROverlayHandle_t ulOverlayHandle); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *HideOverlay)(VROverlayHandle_t ulOverlayHandle); bool (OPENVR_FNTABLE_CALLTYPE *IsOverlayVisible)(VROverlayHandle_t ulOverlayHandle); @@ -1578,17 +2831,17 @@ struct VR_IVROverlay_FnTable EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayMouseScale)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvecMouseScale); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayMouseScale)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvecMouseScale); bool (OPENVR_FNTABLE_CALLTYPE *ComputeOverlayIntersection)(VROverlayHandle_t ulOverlayHandle, struct VROverlayIntersectionParams_t * pParams, struct VROverlayIntersectionResults_t * pResults); - bool (OPENVR_FNTABLE_CALLTYPE *HandleControllerOverlayInteractionAsMouse)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unControllerDeviceIndex); bool (OPENVR_FNTABLE_CALLTYPE *IsHoverTargetOverlay)(VROverlayHandle_t ulOverlayHandle); - VROverlayHandle_t (OPENVR_FNTABLE_CALLTYPE *GetGamepadFocusOverlay)(); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetGamepadFocusOverlay)(VROverlayHandle_t ulNewFocusOverlay); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayNeighbor)(EOverlayDirection eDirection, VROverlayHandle_t ulFrom, VROverlayHandle_t ulTo); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *MoveGamepadFocusToNeighbor)(EOverlayDirection eDirection, VROverlayHandle_t ulFrom); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayIntersectionMask)(VROverlayHandle_t ulOverlayHandle, struct VROverlayIntersectionMaskPrimitive_t * pMaskPrimitives, uint32_t unNumMaskPrimitives, uint32_t unPrimitiveSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *TriggerLaserMouseHapticVibration)(VROverlayHandle_t ulOverlayHandle, float fDurationSeconds, float fFrequency, float fAmplitude); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCursor)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulCursorHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCursorPositionOverride)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvCursor); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ClearOverlayCursorPositionOverride)(VROverlayHandle_t ulOverlayHandle); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTexture)(VROverlayHandle_t ulOverlayHandle, struct Texture_t * pTexture); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ClearOverlayTexture)(VROverlayHandle_t ulOverlayHandle); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayRaw)(VROverlayHandle_t ulOverlayHandle, void * pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unDepth); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayRaw)(VROverlayHandle_t ulOverlayHandle, void * pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unBytesPerPixel); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayFromFile)(VROverlayHandle_t ulOverlayHandle, char * pchFilePath); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTexture)(VROverlayHandle_t ulOverlayHandle, void ** pNativeTextureHandle, void * pNativeTextureRef, uint32_t * pWidth, uint32_t * pHeight, uint32_t * pNativeFormat, EGraphicsAPIConvention * pAPI, EColorSpace * pColorSpace); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTexture)(VROverlayHandle_t ulOverlayHandle, void ** pNativeTextureHandle, void * pNativeTextureRef, uint32_t * pWidth, uint32_t * pHeight, uint32_t * pNativeFormat, ETextureType * pAPIType, EColorSpace * pColorSpace, struct VRTextureBounds_t * pTextureBounds); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ReleaseNativeOverlayHandle)(VROverlayHandle_t ulOverlayHandle, void * pNativeTextureHandle); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTextureSize)(VROverlayHandle_t ulOverlayHandle, uint32_t * pWidth, uint32_t * pHeight); EVROverlayError (OPENVR_FNTABLE_CALLTYPE *CreateDashboardOverlay)(char * pchOverlayKey, char * pchOverlayFriendlyName, VROverlayHandle_t * pMainHandle, VROverlayHandle_t * pThumbnailHandle); @@ -1598,12 +2851,35 @@ struct VR_IVROverlay_FnTable EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetDashboardOverlaySceneProcess)(VROverlayHandle_t ulOverlayHandle, uint32_t * punProcessId); void (OPENVR_FNTABLE_CALLTYPE *ShowDashboard)(char * pchOverlayToShow); TrackedDeviceIndex_t (OPENVR_FNTABLE_CALLTYPE *GetPrimaryDashboardDevice)(); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboard)(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, char * pchDescription, uint32_t unCharMax, char * pchExistingText, bool bUseMinimalMode, uint64_t uUserValue); - EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboardForOverlay)(VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, char * pchDescription, uint32_t unCharMax, char * pchExistingText, bool bUseMinimalMode, uint64_t uUserValue); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboard)(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, char * pchDescription, uint32_t unCharMax, char * pchExistingText, uint64_t uUserValue); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboardForOverlay)(VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, char * pchDescription, uint32_t unCharMax, char * pchExistingText, uint64_t uUserValue); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetKeyboardText)(char * pchText, uint32_t cchText); void (OPENVR_FNTABLE_CALLTYPE *HideKeyboard)(); void (OPENVR_FNTABLE_CALLTYPE *SetKeyboardTransformAbsolute)(ETrackingUniverseOrigin eTrackingOrigin, struct HmdMatrix34_t * pmatTrackingOriginToKeyboardTransform); void (OPENVR_FNTABLE_CALLTYPE *SetKeyboardPositionForOverlay)(VROverlayHandle_t ulOverlayHandle, struct HmdRect2_t avoidRect); + VRMessageOverlayResponse (OPENVR_FNTABLE_CALLTYPE *ShowMessageOverlay)(char * pchText, char * pchCaption, char * pchButton0Text, char * pchButton1Text, char * pchButton2Text, char * pchButton3Text); + void (OPENVR_FNTABLE_CALLTYPE *CloseMessageOverlay)(); +}; + +struct VR_IVROverlayView_FnTable +{ + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *AcquireOverlayView)(VROverlayHandle_t ulOverlayHandle, struct VRNativeDevice_t * pNativeDevice, struct VROverlayView_t * pOverlayView, uint32_t unOverlayViewSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ReleaseOverlayView)(struct VROverlayView_t * pOverlayView); + void (OPENVR_FNTABLE_CALLTYPE *PostOverlayEvent)(VROverlayHandle_t ulOverlayHandle, struct VREvent_t * pvrEvent); + bool (OPENVR_FNTABLE_CALLTYPE *IsViewingPermitted)(VROverlayHandle_t ulOverlayHandle); +}; + +struct VR_IVRHeadsetView_FnTable +{ + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewSize)(uint32_t nWidth, uint32_t nHeight); + void (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewSize)(uint32_t * pnWidth, uint32_t * pnHeight); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewMode)(HeadsetViewMode_t eHeadsetViewMode); + HeadsetViewMode_t (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewMode)(); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewCropped)(bool bCropped); + bool (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewCropped)(); + float (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewAspectRatio)(); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewBlendRange)(float flStartPct, float flEndPct); + void (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewBlendRange)(float * pStartPct, float * pEndPct); }; struct VR_IVRRenderModels_FnTable @@ -1621,6 +2897,7 @@ struct VR_IVRRenderModels_FnTable uint32_t (OPENVR_FNTABLE_CALLTYPE *GetComponentName)(char * pchRenderModelName, uint32_t unComponentIndex, char * pchComponentName, uint32_t unComponentNameLen); uint64_t (OPENVR_FNTABLE_CALLTYPE *GetComponentButtonMask)(char * pchRenderModelName, char * pchComponentName); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetComponentRenderModelName)(char * pchRenderModelName, char * pchComponentName, char * pchComponentRenderModelName, uint32_t unComponentRenderModelNameLen); + bool (OPENVR_FNTABLE_CALLTYPE *GetComponentStateForDevicePath)(char * pchRenderModelName, char * pchComponentName, VRInputValueHandle_t devicePath, RenderModel_ControllerMode_State_t * pState, RenderModel_ComponentState_t * pComponentState); bool (OPENVR_FNTABLE_CALLTYPE *GetComponentState)(char * pchRenderModelName, char * pchComponentName, VRControllerState_t * pControllerState, struct RenderModel_ControllerMode_State_t * pState, struct RenderModel_ComponentState_t * pComponentState); bool (OPENVR_FNTABLE_CALLTYPE *RenderModelHasComponent)(char * pchRenderModelName, char * pchComponentName); uint32_t (OPENVR_FNTABLE_CALLTYPE *GetRenderModelThumbnailURL)(char * pchRenderModelName, char * pchThumbnailURL, uint32_t unThumbnailURLLen, EVRRenderModelError * peError); @@ -1637,15 +2914,14 @@ struct VR_IVRNotifications_FnTable struct VR_IVRSettings_FnTable { char * (OPENVR_FNTABLE_CALLTYPE *GetSettingsErrorNameFromEnum)(EVRSettingsError eError); - bool (OPENVR_FNTABLE_CALLTYPE *Sync)(bool bForce, EVRSettingsError * peError); - bool (OPENVR_FNTABLE_CALLTYPE *GetBool)(char * pchSection, char * pchSettingsKey, bool bDefaultValue, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *SetBool)(char * pchSection, char * pchSettingsKey, bool bValue, EVRSettingsError * peError); - int32_t (OPENVR_FNTABLE_CALLTYPE *GetInt32)(char * pchSection, char * pchSettingsKey, int32_t nDefaultValue, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *SetInt32)(char * pchSection, char * pchSettingsKey, int32_t nValue, EVRSettingsError * peError); - float (OPENVR_FNTABLE_CALLTYPE *GetFloat)(char * pchSection, char * pchSettingsKey, float flDefaultValue, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *SetFloat)(char * pchSection, char * pchSettingsKey, float flValue, EVRSettingsError * peError); - void (OPENVR_FNTABLE_CALLTYPE *GetString)(char * pchSection, char * pchSettingsKey, char * pchValue, uint32_t unValueLen, char * pchDefaultValue, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *SetString)(char * pchSection, char * pchSettingsKey, char * pchValue, EVRSettingsError * peError); + bool (OPENVR_FNTABLE_CALLTYPE *GetBool)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + int32_t (OPENVR_FNTABLE_CALLTYPE *GetInt32)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + float (OPENVR_FNTABLE_CALLTYPE *GetFloat)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *GetString)(char * pchSection, char * pchSettingsKey, char * pchValue, uint32_t unValueLen, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *RemoveSection)(char * pchSection, EVRSettingsError * peError); void (OPENVR_FNTABLE_CALLTYPE *RemoveKeyInSection)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); }; @@ -1667,6 +2943,105 @@ struct VR_IVRResources_FnTable uint32_t (OPENVR_FNTABLE_CALLTYPE *GetResourceFullPath)(char * pchResourceName, char * pchResourceTypeDirectory, char * pchPathBuffer, uint32_t unBufferLen); }; +struct VR_IVRDriverManager_FnTable +{ + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetDriverCount)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetDriverName)(DriverId_t nDriver, char * pchValue, uint32_t unBufferSize); + DriverHandle_t (OPENVR_FNTABLE_CALLTYPE *GetDriverHandle)(char * pchDriverName); + bool (OPENVR_FNTABLE_CALLTYPE *IsEnabled)(DriverId_t nDriver); +}; + +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, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetAnalogActionData)(VRActionHandle_t action, struct InputAnalogActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetPoseActionDataRelativeToNow)(VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, struct InputPoseActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetPoseActionDataForNextFrame)(VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, struct InputPoseActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalActionData)(VRActionHandle_t action, struct InputSkeletalActionData_t * pActionData, uint32_t unActionDataSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetDominantHand)(ETrackedControllerRole * peDominantHand); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *SetDominantHand)(ETrackedControllerRole eDominantHand); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneCount)(VRActionHandle_t action, uint32_t * pBoneCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneHierarchy)(VRActionHandle_t action, BoneIndex_t * pParentIndices, uint32_t unIndexArayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneName)(VRActionHandle_t action, BoneIndex_t nBoneIndex, char * pchBoneName, uint32_t unNameBufferSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalReferenceTransforms)(VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalTrackingLevel)(VRActionHandle_t action, EVRSkeletalTrackingLevel * pSkeletalTrackingLevel); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalBoneData)(VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalSummaryData)(VRActionHandle_t action, EVRSummaryType eSummaryType, struct VRSkeletalSummaryData_t * pSkeletalSummaryData); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalBoneDataCompressed)(VRActionHandle_t action, EVRSkeletalMotionRange eMotionRange, void * pvCompressedData, uint32_t unCompressedSize, uint32_t * punRequiredCompressedSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *DecompressSkeletalBoneData)(void * pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *TriggerHapticVibrationAction)(VRActionHandle_t action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, VRInputValueHandle_t ulRestrictToDevice); + 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, int32_t unStringSectionsToInclude); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetOriginTrackedDeviceInfo)(VRInputValueHandle_t origin, struct InputOriginInfo_t * pOriginInfo, uint32_t unOriginInfoSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionBindingInfo)(VRActionHandle_t action, struct InputBindingInfo_t * pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, uint32_t * punReturnedBindingInfoCount); + 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); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetComponentStateForBinding)(char * pchRenderModelName, char * pchComponentName, struct InputBindingInfo_t * pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, RenderModel_ComponentState_t * pComponentState); + bool (OPENVR_FNTABLE_CALLTYPE *IsUsingLegacyInput)(); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *OpenBindingUI)(char * pchAppKey, VRActionSetHandle_t ulActionSetHandle, VRInputValueHandle_t ulDeviceHandle, bool bShowOnDesktop); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBindingVariant)(VRInputValueHandle_t ulDevicePath, char * pchVariantArray, uint32_t unVariantArraySize); +}; + +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); + bool (OPENVR_FNTABLE_CALLTYPE *HasReaders)(IOBufferHandle_t ulBuffer); +}; + +struct VR_IVRSpatialAnchors_FnTable +{ + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *CreateSpatialAnchorFromDescriptor)(char * pchDescriptor, SpatialAnchorHandle_t * pHandleOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *CreateSpatialAnchorFromPose)(TrackedDeviceIndex_t unDeviceIndex, ETrackingUniverseOrigin eOrigin, struct SpatialAnchorPose_t * pPose, SpatialAnchorHandle_t * pHandleOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *GetSpatialAnchorPose)(SpatialAnchorHandle_t unHandle, ETrackingUniverseOrigin eOrigin, struct SpatialAnchorPose_t * pPoseOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *GetSpatialAnchorDescriptor)(SpatialAnchorHandle_t unHandle, char * pchDescriptorOut, uint32_t * punDescriptorBufferLenInOut); +}; + +struct VR_IVRDebug_FnTable +{ + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *EmitVrProfilerEvent)(char * pchMessage); + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *BeginVrProfilerEvent)(VrProfilerEventHandle_t * pHandleOut); + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *FinishVrProfilerEvent)(VrProfilerEventHandle_t hHandle, char * pchMessage); + uint32_t (OPENVR_FNTABLE_CALLTYPE *DriverDebugRequest)(TrackedDeviceIndex_t unDeviceIndex, char * pchRequest, char * pchResponseBuffer, uint32_t unResponseBufferSize); +}; + +struct VR_IVRProperties_FnTable +{ + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *ReadPropertyBatch)(PropertyContainerHandle_t ulContainerHandle, struct PropertyRead_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *WritePropertyBatch)(PropertyContainerHandle_t ulContainerHandle, struct PropertyWrite_t * pBatch, uint32_t unBatchEntryCount); + char * (OPENVR_FNTABLE_CALLTYPE *GetPropErrorNameFromEnum)(ETrackedPropertyError error); + PropertyContainerHandle_t (OPENVR_FNTABLE_CALLTYPE *TrackedDeviceToPropertyContainer)(TrackedDeviceIndex_t nDevice); +}; + +struct VR_IVRPaths_FnTable +{ + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *ReadPathBatch)(PropertyContainerHandle_t ulRootHandle, struct PathRead_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *WritePathBatch)(PropertyContainerHandle_t ulRootHandle, struct PathWrite_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *StringToHandle)(PathHandle_t * pHandle, char * pchPath); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *HandleToString)(PathHandle_t pHandle, char * pchBuffer, uint32_t unBufferSize, uint32_t * punBufferSizeUsed); +}; + +struct VR_IVRBlockQueue_FnTable +{ + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Create)(PropertyContainerHandle_t * pulQueueHandle, char * pchPath, uint32_t unBlockDataSize, uint32_t unBlockHeaderSize, uint32_t unBlockCount); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Connect)(PropertyContainerHandle_t * pulQueueHandle, char * pchPath); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Destroy)(PropertyContainerHandle_t ulQueueHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *AcquireWriteOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *ReleaseWriteOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t ulBlockHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *WaitAndAcquireReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer, EBlockQueueReadType eReadType, uint32_t unTimeoutMs); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *AcquireReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer, EBlockQueueReadType eReadType); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *ReleaseReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t ulBlockHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *QueueHasReader)(PropertyContainerHandle_t ulQueueHandle, bool * pbHasReaders); +}; + #if 0 // Global entry points diff --git a/ext/OpenVR/headers/openvr_driver.h b/ext/OpenVR/headers/openvr_driver.h index c5e37e8..00d1346 100644 --- a/ext/OpenVR/headers/openvr_driver.h +++ b/ext/OpenVR/headers/openvr_driver.h @@ -11,23 +11,35 @@ +// version.h +namespace vr +{ + static const uint32_t k_nSteamVRVersionMajor = 1; + static const uint32_t k_nSteamVRVersionMinor = 12; + static const uint32_t k_nSteamVRVersionBuild = 5; +} // namespace vr + // vrtypes.h #ifndef _INCLUDE_VRTYPES_H -#define _INCLUDE_VRTYPES_H +#define _INCLUDE_VRTYPES_H + +// Forward declarations to avoid requiring vulkan.h +struct VkDevice_T; +struct VkPhysicalDevice_T; +struct VkInstance_T; +struct VkQueue_T; + +// Forward declarations to avoid requiring d3d12.h +struct ID3D12Resource; +struct ID3D12CommandQueue; namespace vr { +#pragma pack( push, 8 ) -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +/** A handle for a spatial anchor. This handle is only valid during the session it was created in. +* Anchors that live beyond one session should be saved by their string descriptors. */ +typedef uint32_t SpatialAnchorHandle_t; typedef void* glSharedTextureHandle_t; typedef int32_t glInt_t; @@ -36,13 +48,18 @@ typedef uint32_t glUInt_t; // right-handed system // +y is up // +x is to the right -// -z is going away from you +// -z is forward // Distance unit is meters struct HmdMatrix34_t { float m[3][4]; }; +struct HmdMatrix33_t +{ + float m[3][3]; +}; + struct HmdMatrix44_t { float m[4][4]; @@ -73,6 +90,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; @@ -105,10 +127,19 @@ enum EVREye Eye_Right = 1 }; -enum EGraphicsAPIConvention +enum ETextureType { - API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane - API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane + TextureType_Invalid = -1, // Handle has been invalidated + TextureType_DirectX = 0, // Handle is an ID3D11Texture + TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags + TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure + TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef, deprecated in favor of TextureType_Metal on supported platforms + TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure + TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets. + // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it + TextureType_Metal = 6, // Handle is a MTLTexture conforming to the MTLSharedTexture protocol. Textures submitted to IVRCompositor::Submit which + // are of type MTLTextureType2DArray assume layer 0 is the left eye texture (vr::EVREye::Eye_left), layer 1 is the right + // eye texture (vr::EVREye::Eye_Right) }; enum EColorSpace @@ -120,11 +151,15 @@ enum EColorSpace struct Texture_t { - void* handle; // Native d3d texture pointer or GL texture id. - EGraphicsAPIConvention eType; + void* handle; // See ETextureType definition above + ETextureType eType; EColorSpace eColorSpace; }; +// Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource). +typedef uint64_t SharedTextureHandle_t; +#define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0) + enum ETrackingResult { TrackingResult_Uninitialized = 1, @@ -134,15 +169,19 @@ enum ETrackingResult TrackingResult_Running_OK = 200, TrackingResult_Running_OutOfRange = 201, + + TrackingResult_Fallback_RotationOnly = 300, }; -static const uint32_t k_unTrackingStringSize = 32; +typedef uint32_t DriverId_t; +static const uint32_t k_nDriverNone = 0xFFFFFFFF; + static const uint32_t k_unMaxDriverDebugResponseSize = 32768; /** Used to pass device IDs to API calls */ typedef uint32_t TrackedDeviceIndex_t; static const uint32_t k_unTrackedDeviceIndex_Hmd = 0; -static const uint32_t k_unMaxTrackedDeviceCount = 16; +static const uint32_t k_unMaxTrackedDeviceCount = 64; static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE; static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF; @@ -152,9 +191,11 @@ enum ETrackedDeviceClass TrackedDeviceClass_Invalid = 0, // the ID was not valid. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays TrackedDeviceClass_Controller = 2, // Tracked controllers + TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points + TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices - TrackedDeviceClass_Other = 1000, + TrackedDeviceClass_Max }; @@ -164,9 +205,28 @@ enum ETrackedControllerRole TrackedControllerRole_Invalid = 0, // Invalid value for controller type TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand + TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection + TrackedControllerRole_Treadmill = 4, // Tracked device is a treadmill or other locomotion device + TrackedControllerRole_Stylus = 5, // Tracked device is a stylus + TrackedControllerRole_Max = 5 }; +/** Returns true if the tracked controller role is allowed to be a hand */ +inline bool IsRoleAllowedAsHand( ETrackedControllerRole eRole ) +{ + switch ( eRole ) + { + case TrackedControllerRole_Invalid: + case TrackedControllerRole_LeftHand: + case TrackedControllerRole_RightHand: + return true; + default: + return false; + } +} + + /** describes a single pose for a tracked object */ struct TrackedDevicePose_t { @@ -187,14 +247,68 @@ enum ETrackingUniverseOrigin { TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user - TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. You probably don't want this one. + TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one. +}; + +enum EAdditionalRadioFeatures +{ + AdditionalRadioFeatures_None = 0x00000000, + AdditionalRadioFeatures_HTCLinkBox = 0x00000001, + AdditionalRadioFeatures_InternalDongle = 0x00000002, + AdditionalRadioFeatures_ExternalDongle = 0x00000004, }; +typedef uint64_t WebConsoleHandle_t; +#define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0) + +// Refers to a single container of properties +typedef uint64_t PropertyContainerHandle_t; +typedef uint32_t PropertyTypeTag_t; + +static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0; +static const PropertyTypeTag_t k_unInvalidPropertyTag = 0; + +typedef PropertyContainerHandle_t DriverHandle_t; +static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0; + +// Use these tags to set/get common types as struct properties +static const PropertyTypeTag_t k_unFloatPropertyTag = 1; +static const PropertyTypeTag_t k_unInt32PropertyTag = 2; +static const PropertyTypeTag_t k_unUint64PropertyTag = 3; +static const PropertyTypeTag_t k_unBoolPropertyTag = 4; +static const PropertyTypeTag_t k_unStringPropertyTag = 5; +static const PropertyTypeTag_t k_unErrorPropertyTag = 6; +static const PropertyTypeTag_t k_unDoublePropertyTag = 7; + +static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20; +static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21; +static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22; +static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23; +static const PropertyTypeTag_t k_unHmdVector2PropertyTag = 24; +static const PropertyTypeTag_t k_unHmdQuadPropertyTag = 25; + +static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30; +static const PropertyTypeTag_t k_unPathHandleInfoTag = 31; +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_unSpatialAnchorPosePropertyTag = 40; +static const PropertyTypeTag_t k_unJsonPropertyTag = 41; +static const PropertyTypeTag_t k_unActiveActionSetPropertyTag = 42; + +static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; +static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; + /** Each entry in this enum represents a property that can be retrieved about a * tracked device. Many fields are only valid for one ETrackedDeviceClass. */ enum ETrackedDeviceProperty { + Prop_Invalid = 0, + // general properties that apply to all device classes Prop_TrackingSystemName_String = 1000, Prop_ModelNumber_String = 1001, @@ -229,6 +343,25 @@ enum ETrackedDeviceProperty Prop_HasCamera_Bool = 1030, Prop_DriverVersion_String = 1031, Prop_Firmware_ForceUpdateRequired_Bool = 1032, + Prop_ViveSystemButtonFixRequired_Bool = 1033, + Prop_ParentDriver_Uint64 = 1034, + Prop_ResourceRoot_String = 1035, + Prop_RegisteredDeviceType_String = 1036, + Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided + Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design + Prop_NumCameras_Int32 = 1039, + Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value + Prop_CameraStreamFormat_Int32 = 1041, // ECameraVideoStreamFormat value + Prop_AdditionalDeviceSettingsPath_String = 1042, // driver-relative path to additional device and global configuration settings + Prop_Identifiable_Bool = 1043, // Whether device supports being identified from vrmonitor (e.g. blink LED, vibrate haptics, etc) + Prop_BootloaderVersion_Uint64 = 1044, + Prop_AdditionalSystemReportData_String = 1045, // additional string to include in system reports about a tracked device + Prop_CompositeFirmwareVersion_String = 1046, // additional FW components from a device that gets propagated into reports + Prop_Firmware_RemindUpdate_Bool = 1047, + Prop_PeripheralApplicationVersion_Uint64 = 1048, + Prop_ManufacturerSerialNumber_String = 1049, + Prop_ComputedSerialNumber_String = 1050, + Prop_EstimatedDeviceFirstUseTime_Int32 = 1051, // Properties that are unique to TrackedDeviceClass_HMD Prop_ReportsTimeSinceVSync_Bool = 2000, @@ -268,6 +401,75 @@ enum ETrackedDeviceProperty Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, Prop_DisplaySuppressed_Bool = 2036, + Prop_DisplayAllowNightMode_Bool = 2037, + Prop_DisplayMCImageWidth_Int32 = 2038, + Prop_DisplayMCImageHeight_Int32 = 2039, + Prop_DisplayMCImageNumChannels_Int32 = 2040, + Prop_DisplayMCImageData_Binary = 2041, + Prop_SecondsFromPhotonsToVblank_Float = 2042, + Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, + Prop_DisplayDebugMode_Bool = 2044, + Prop_GraphicsAdapterLuid_Uint64 = 2045, + Prop_DriverProvidedChaperonePath_String = 2048, + Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for + Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for + Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded + Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded + Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded + Prop_DoNotApplyPrediction_Bool = 2054, // currently no effect. was used to disable HMD pose prediction on MR, which is now done by MR driver setting velocity=0 + Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion + Prop_DriverIsDrawingControllers_Bool = 2057, + Prop_DriverRequestsApplicationPause_Bool = 2058, + Prop_DriverRequestsReducedRendering_Bool = 2059, + 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, + // reserved 2068 + Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069, + Prop_AdditionalRadioFeatures_Uint64 = 2070, + Prop_CameraWhiteBalance_Vector4_Array = 2071, // Prop_NumCameras_Int32-sized array of float[4] RGBG white balance calibration data (max size is vr::k_unMaxCameras) + Prop_CameraDistortionFunction_Int32_Array = 2072, // Prop_NumCameras_Int32-sized array of vr::EVRDistortionFunctionType values (max size is vr::k_unMaxCameras) + Prop_CameraDistortionCoefficients_Float_Array = 2073, // Prop_NumCameras_Int32-sized array of double[vr::k_unMaxDistortionFunctionParameters] (max size is vr::k_unMaxCameras) + Prop_ExpectedControllerType_String = 2074, + Prop_HmdTrackingStyle_Int32 = 2075, // one of EHmdTrackingStyle + Prop_DriverProvidedChaperoneVisibility_Bool = 2076, + Prop_HmdColumnCorrectionSettingPrefix_String = 2077, + Prop_CameraSupportsCompatibilityModes_Bool = 2078, + + Prop_DisplayAvailableFrameRates_Float_Array = 2080, // populated by compositor from actual EDID list when available from GPU driver + Prop_DisplaySupportsMultipleFramerates_Bool = 2081, // if this is true but Prop_DisplayAvailableFrameRates_Float_Array is empty, explain to user + Prop_DisplayColorMultLeft_Vector3 = 2082, + Prop_DisplayColorMultRight_Vector3 = 2083, + Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084, + Prop_DisplaySupportsAnalogGain_Bool = 2085, + Prop_DisplayMinAnalogGain_Float = 2086, + Prop_DisplayMaxAnalogGain_Float = 2087, + + // Prop_DashboardLayoutPathName_String = 2090, // DELETED + Prop_DashboardScale_Float = 2091, + Prop_IpdUIRangeMinMeters_Float = 2100, + Prop_IpdUIRangeMaxMeters_Float = 2101, + + // Driver requested mura correction properties + Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, + + Prop_Audio_DefaultPlaybackDeviceId_String = 2300, + Prop_Audio_DefaultRecordingDeviceId_String = 2301, + Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302, // Properties that are unique to TrackedDeviceClass_Controller Prop_AttachedDeviceId_String = 3000, @@ -287,10 +489,47 @@ enum ETrackedDeviceProperty Prop_TrackingRangeMinimumMeters_Float = 4004, Prop_TrackingRangeMaximumMeters_Float = 4005, Prop_ModeLabel_String = 4006, + Prop_CanWirelessIdentify_Bool = 4007, // volatile, based on radio presence and fw discovery + Prop_Nonce_Int32 = 4008, + + // Properties that are used for user interface like icons names + Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties. + Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + Prop_NamedIconPathDeviceStandbyAlert_String = 5009, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others + + // Properties that are used by helpers, but are opaque to applications + Prop_DisplayHiddenArea_Binary_Start = 5100, + Prop_DisplayHiddenArea_Binary_End = 5150, + Prop_ParentContainer = 5151, + Prop_OverrideContainer_Uint64 = 5152, + + // Properties that are unique to drivers + Prop_UserConfigPath_String = 6000, + Prop_InstallPath_String = 6001, + Prop_HasDisplayComponent_Bool = 6002, + Prop_HasControllerComponent_Bool = 6003, + Prop_HasCameraComponent_Bool = 6004, + Prop_HasDriverDirectModeComponent_Bool = 6005, + Prop_HasVirtualDisplayComponent_Bool = 6006, + Prop_HasSpatialAnchorsSupport_Bool = 6007, + + // Properties that are set internally based on other information provided by drivers + Prop_ControllerType_String = 7000, + //Prop_LegacyInputProfile_String = 7001, // This is no longer used. See "legacy_binding" in the input profile instead. + Prop_ControllerHandSelectionPriority_Int32 = 7002, // Allows hand assignments to prefer some controllers over others. High numbers are selected over low numbers // Vendors are free to expose private debug data in this reserved region Prop_VendorSpecific_Reserved_Start = 10000, Prop_VendorSpecific_Reserved_End = 10999, + + Prop_TrackedDeviceProperty_Max = 1000000, }; /** No string property will ever be longer than this length */ @@ -303,14 +542,39 @@ enum ETrackedPropertyError TrackedProp_WrongDataType = 1, TrackedProp_WrongDeviceClass = 2, TrackedProp_BufferTooSmall = 3, - TrackedProp_UnknownProperty = 4, + TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever). TrackedProp_InvalidDevice = 5, TrackedProp_CouldNotContactServer = 6, TrackedProp_ValueNotProvidedByDevice = 7, TrackedProp_StringExceedsMaximumLength = 8, TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later. + TrackedProp_PermissionDenied = 10, + TrackedProp_InvalidOperation = 11, + TrackedProp_CannotWriteToWildcards = 12, + TrackedProp_IPCReadFailure = 13, + TrackedProp_OutOfMemory = 14, + TrackedProp_InvalidContainer = 15, +}; + +/** Used to drive certain text in the UI when talking about the tracking system for the HMD */ +enum EHmdTrackingStyle +{ + HmdTrackingStyle_Unknown = 0, + + HmdTrackingStyle_Lighthouse = 1, // base stations and lasers + HmdTrackingStyle_OutsideInCameras = 2, // Cameras and LED, Rift 1 style + HmdTrackingStyle_InsideOutCameras = 3, // Cameras on HMD looking at the world }; +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; + + /** Allows the application to control what part of the provided texture will be used in the * frame buffer. */ struct VRTextureBounds_t @@ -319,6 +583,28 @@ struct VRTextureBounds_t float uMax, vMax; }; +/** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */ +struct VRTextureWithPose_t : public Texture_t +{ + HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures. +}; + +struct VRTextureDepthInfo_t +{ + void* handle; // See ETextureType definition above + HmdMatrix44_t mProjection; + HmdVector2_t vRange; // 0..1 +}; + +struct VRTextureWithDepth_t : public Texture_t +{ + VRTextureDepthInfo_t depth; +}; + +struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t +{ + VRTextureDepthInfo_t depth; +}; /** Allows the application to control how scene textures are used by the compositor when calling Submit. */ enum EVRSubmitFlags @@ -333,8 +619,57 @@ enum EVRSubmitFlags // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag. Submit_GlRenderBuffer = 0x02, + + // Do not use + Submit_Reserved = 0x04, + + // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t. + // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t. + Submit_TextureWithPose = 0x08, + + // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t. + // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t. + Submit_TextureWithDepth = 0x10, + + // Set to indicate a discontinuity between this and the last frame. + // This will prevent motion smoothing from attempting to extrapolate using the pair. + Submit_FrameDiscontinuty = 0x20, + + // Set to indicate that pTexture->handle is a contains VRVulkanTextureArrayData_t + Submit_VulkanTextureWithArrayData = 0x40, +}; + +/** Data required for passing Vulkan textures to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. +* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */ +struct VRVulkanTextureData_t +{ + uint64_t m_nImage; // VkImage + VkDevice_T *m_pDevice; + VkPhysicalDevice_T *m_pPhysicalDevice; + VkInstance_T *m_pInstance; + VkQueue_T *m_pQueue; + uint32_t m_nQueueFamilyIndex; + uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount; +}; + +/** Data required for passing Vulkan texture arrays to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. +* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */ +struct VRVulkanTextureArrayData_t : public VRVulkanTextureData_t +{ + uint32_t m_unArrayIndex; + uint32_t m_unArraySize; }; +/** Data required for passing D3D12 textures to IVRCompositor::Submit. +* Be sure to call OpenVR_Shutdown before destroying these resources. */ +struct D3D12TextureData_t +{ + ID3D12Resource *m_pResource; + ID3D12CommandQueue *m_pCommandQueue; + uint32_t m_nNodeMask; +}; /** Status of the overall system or tracked objects */ enum EVRState @@ -358,136 +693,231 @@ enum EVREventType VREvent_TrackedDeviceActivated = 100, VREvent_TrackedDeviceDeactivated = 101, VREvent_TrackedDeviceUpdated = 102, - VREvent_TrackedDeviceUserInteractionStarted = 103, + VREvent_TrackedDeviceUserInteractionStarted = 103, VREvent_TrackedDeviceUserInteractionEnded = 104, VREvent_IpdChanged = 105, VREvent_EnterStandbyMode = 106, VREvent_LeaveStandbyMode = 107, VREvent_TrackedDeviceRoleChanged = 108, VREvent_WatchdogWakeUpRequested = 109, + VREvent_LensDistortionChanged = 110, + VREvent_PropertyChanged = 111, + VREvent_WirelessDisconnect = 112, + VREvent_WirelessReconnect = 113, VREvent_ButtonPress = 200, // data is controller VREvent_ButtonUnpress = 201, // data is controller VREvent_ButtonTouch = 202, // data is controller VREvent_ButtonUntouch = 203, // data is controller + // VREvent_DualAnalog_Press = 250, // No longer sent + // VREvent_DualAnalog_Unpress = 251, // No longer sent + // VREvent_DualAnalog_Touch = 252, // No longer sent + // VREvent_DualAnalog_Untouch = 253, // No longer sent + // VREvent_DualAnalog_Move = 254, // No longer sent + // VREvent_DualAnalog_ModeSwitch1 = 255, // No longer sent + // VREvent_DualAnalog_ModeSwitch2 = 256, // No longer sent + VREvent_Modal_Cancel = 257, // Sent to overlays with the + VREvent_MouseMove = 300, // data is mouse VREvent_MouseButtonDown = 301, // data is mouse VREvent_MouseButtonUp = 302, // data is mouse VREvent_FocusEnter = 303, // data is overlay VREvent_FocusLeave = 304, // data is overlay - VREvent_Scroll = 305, // data is mouse + VREvent_ScrollDiscrete = 305, // data is scroll VREvent_TouchPadMove = 306, // data is mouse VREvent_OverlayFocusChanged = 307, // data is overlay, global event + VREvent_ReloadOverlays = 308, + VREvent_ScrollSmooth = 309, // data is scroll + VREvent_LockMousePosition = 310, + VREvent_UnlockMousePosition = 311, VREvent_InputFocusCaptured = 400, // data is process DEPRECATED VREvent_InputFocusReleased = 401, // data is process DEPRECATED - VREvent_SceneFocusLost = 402, // data is process - VREvent_SceneFocusGained = 403, // data is process + // VREvent_SceneFocusLost = 402, // data is process + // VREvent_SceneFocusGained = 403, // data is process VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor) VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene VREvent_InputFocusChanged = 406, // data is process - VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process + // VREvent_SceneApplicationSecondaryRenderingStarted = 407, + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process + VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility + VREvent_SceneApplicationStateChanged = 412, // No data; but query VRApplications()->GetSceneApplicationState(); + + VREvent_ConsoleOpened = 420, + VREvent_ConsoleClosed = 421, + VREvent_OverlayShown = 500, VREvent_OverlayHidden = 501, - VREvent_DashboardActivated = 502, - VREvent_DashboardDeactivated = 503, - VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay - VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay - VREvent_ResetDashboard = 506, // Send to the overlay manager - VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID - VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading - VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it - VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it - VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it - VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else + VREvent_DashboardActivated = 502, + VREvent_DashboardDeactivated = 503, + //VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay - No longer sent + VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay + VREvent_ResetDashboard = 506, // Send to the overlay manager + //VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID -- no longer sent + VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading + VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it + VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it + VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it + VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else VREvent_OverlaySharedTextureChanged = 513, - VREvent_DashboardGuideButtonDown = 514, - VREvent_DashboardGuideButtonUp = 515, - VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot - VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load + //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent + //VREvent_DashboardGuideButtonUp = 515, + VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot + VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load + VREvent_DashboardOverlayCreated = 518, + VREvent_SwitchGamepadFocus = 519, // Screenshot API - VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot - VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken - VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken - VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted - VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted + VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot + VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken + VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken + VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted + VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted + + VREvent_PrimaryDashboardDeviceChanged = 525, + VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled + VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled + VREvent_ShowUI = 528, // data is showUi + VREvent_ShowDevTools = 529, // data is showDevTools VREvent_Notification_Shown = 600, VREvent_Notification_Hidden = 601, VREvent_Notification_BeginInteraction = 602, VREvent_Notification_Destroyed = 603, - VREvent_Quit = 700, // data is process - VREvent_ProcessQuit = 701, // data is process - VREvent_QuitAborted_UserPrompt = 702, // data is process - VREvent_QuitAcknowledged = 703, // data is process - VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down - - VREvent_ChaperoneDataHasChanged = 800, - VREvent_ChaperoneUniverseHasChanged = 801, - VREvent_ChaperoneTempDataHasChanged = 802, - VREvent_ChaperoneSettingsHaveChanged = 803, - VREvent_SeatedZeroPoseReset = 804, - - VREvent_AudioSettingsHaveChanged = 820, - - VREvent_BackgroundSettingHasChanged = 850, - VREvent_CameraSettingsHaveChanged = 851, - VREvent_ReprojectionSettingHasChanged = 852, - VREvent_ModelSkinSettingsHaveChanged = 853, - VREvent_EnvironmentSettingsHaveChanged = 854, - - VREvent_StatusUpdate = 900, - - VREvent_MCImageUpdated = 1000, - - VREvent_FirmwareUpdateStarted = 1100, - VREvent_FirmwareUpdateFinished = 1101, - - VREvent_KeyboardClosed = 1200, - VREvent_KeyboardCharInput = 1201, - VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard - - VREvent_ApplicationTransitionStarted = 1300, - VREvent_ApplicationTransitionAborted = 1301, - VREvent_ApplicationTransitionNewAppStarted = 1302, - VREvent_ApplicationListUpdated = 1303, - VREvent_ApplicationMimeTypeLoad = 1304, - - VREvent_Compositor_MirrorWindowShown = 1400, - VREvent_Compositor_MirrorWindowHidden = 1401, - VREvent_Compositor_ChaperoneBoundsShown = 1410, - VREvent_Compositor_ChaperoneBoundsHidden = 1411, + VREvent_Quit = 700, // data is process + VREvent_ProcessQuit = 701, // data is process + //VREvent_QuitAborted_UserPrompt = 702, // data is process + VREvent_QuitAcknowledged = 703, // data is process + VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down + VREvent_RestartRequested = 705, // A driver or other component wants the user to restart SteamVR + + VREvent_ChaperoneDataHasChanged = 800, // this will never happen with the new chaperone system + VREvent_ChaperoneUniverseHasChanged = 801, + VREvent_ChaperoneTempDataHasChanged = 802, // this will never happen with the new chaperone system + VREvent_ChaperoneSettingsHaveChanged = 803, + VREvent_SeatedZeroPoseReset = 804, + VREvent_ChaperoneFlushCache = 805, // Sent when the process needs to reload any cached data it retrieved from VRChaperone() + VREvent_ChaperoneRoomSetupStarting = 806, // Triggered by CVRChaperoneClient::RoomSetupStarting + VREvent_ChaperoneRoomSetupFinished = 807, // Triggered by CVRChaperoneClient::CommitWorkingCopy + + VREvent_AudioSettingsHaveChanged = 820, + + VREvent_BackgroundSettingHasChanged = 850, + VREvent_CameraSettingsHaveChanged = 851, + VREvent_ReprojectionSettingHasChanged = 852, + VREvent_ModelSkinSettingsHaveChanged = 853, + VREvent_EnvironmentSettingsHaveChanged = 854, + VREvent_PowerSettingsHaveChanged = 855, + VREvent_EnableHomeAppSettingsHaveChanged = 856, + VREvent_SteamVRSectionSettingChanged = 857, + VREvent_LighthouseSectionSettingChanged = 858, + VREvent_NullSectionSettingChanged = 859, + VREvent_UserInterfaceSectionSettingChanged = 860, + VREvent_NotificationsSectionSettingChanged = 861, + VREvent_KeyboardSectionSettingChanged = 862, + VREvent_PerfSectionSettingChanged = 863, + VREvent_DashboardSectionSettingChanged = 864, + VREvent_WebInterfaceSectionSettingChanged = 865, + VREvent_TrackersSectionSettingChanged = 866, + VREvent_LastKnownSectionSettingChanged = 867, + VREvent_DismissedWarningsSectionSettingChanged = 868, + VREvent_GpuSpeedSectionSettingChanged = 869, + VREvent_WindowsMRSectionSettingChanged = 870, + VREvent_OtherSectionSettingChanged = 871, + + VREvent_StatusUpdate = 900, + + VREvent_WebInterface_InstallDriverCompleted = 950, + + VREvent_MCImageUpdated = 1000, + + VREvent_FirmwareUpdateStarted = 1100, + VREvent_FirmwareUpdateFinished = 1101, + + VREvent_KeyboardClosed = 1200, + VREvent_KeyboardCharInput = 1201, + VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard + + //VREvent_ApplicationTransitionStarted = 1300, + //VREvent_ApplicationTransitionAborted = 1301, + //VREvent_ApplicationTransitionNewAppStarted = 1302, + VREvent_ApplicationListUpdated = 1303, + VREvent_ApplicationMimeTypeLoad = 1304, + // VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, + VREvent_ProcessConnected = 1306, + VREvent_ProcessDisconnected = 1307, + + //VREvent_Compositor_MirrorWindowShown = 1400, // DEPRECATED + //VREvent_Compositor_MirrorWindowHidden = 1401, // DEPRECATED + VREvent_Compositor_ChaperoneBoundsShown = 1410, + VREvent_Compositor_ChaperoneBoundsHidden = 1411, + VREvent_Compositor_DisplayDisconnected = 1412, + VREvent_Compositor_DisplayReconnected = 1413, + VREvent_Compositor_HDCPError = 1414, // data is hdcpError + VREvent_Compositor_ApplicationNotResponding = 1415, + VREvent_Compositor_ApplicationResumed = 1416, + VREvent_Compositor_OutOfVideoMemory = 1417, + VREvent_Compositor_DisplayModeNotSupported = 1418, // k_pch_SteamVR_PreferredRefreshRate + VREvent_Compositor_StageOverrideReady = 1419, VREvent_TrackedCamera_StartVideoStream = 1500, VREvent_TrackedCamera_StopVideoStream = 1501, VREvent_TrackedCamera_PauseVideoStream = 1502, VREvent_TrackedCamera_ResumeVideoStream = 1503, + VREvent_TrackedCamera_EditingSurface = 1550, - VREvent_PerformanceTest_EnableCapture = 1600, - VREvent_PerformanceTest_DisableCapture = 1601, - VREvent_PerformanceTest_FidelityLevel = 1602, + VREvent_PerformanceTest_EnableCapture = 1600, + VREvent_PerformanceTest_DisableCapture = 1601, + VREvent_PerformanceTest_FidelityLevel = 1602, + + VREvent_MessageOverlay_Closed = 1650, + VREvent_MessageOverlayCloseRequested = 1651, + VREvent_Input_HapticVibration = 1700, // data is hapticVibration + VREvent_Input_BindingLoadFailed = 1701, // data is inputBinding + VREvent_Input_BindingLoadSuccessful = 1702, // data is inputBinding + VREvent_Input_ActionManifestReloaded = 1703, // no data + VREvent_Input_ActionManifestLoadFailed = 1704, // data is actionManifest + VREvent_Input_ProgressUpdate = 1705, // data is progressUpdate + VREvent_Input_TrackerActivated = 1706, + VREvent_Input_BindingsUpdated = 1707, + VREvent_Input_BindingSubscriptionChanged = 1708, + + VREvent_SpatialAnchors_PoseUpdated = 1800, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_DescriptorUpdated = 1801, // data is spatialAnchor. broadcast + VREvent_SpatialAnchors_RequestPoseUpdate = 1802, // data is spatialAnchor. sent to specific driver + VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, // data is spatialAnchor. sent to specific driver + + VREvent_SystemReport_Started = 1900, // user or system initiated generation of a system report. broadcast + + VREvent_Monitor_ShowHeadsetView = 2000, // data is process + VREvent_Monitor_HideHeadsetView = 2001, // data is process + // Vendors are free to expose private events in this reserved region - VREvent_VendorSpecific_Reserved_Start = 10000, - VREvent_VendorSpecific_Reserved_End = 19999, + VREvent_VendorSpecific_Reserved_Start = 10000, + VREvent_VendorSpecific_Reserved_End = 19999, }; /** Level of Hmd activity */ +// UserInteraction_Timeout means the device is in the process of timing out. +// InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout ) +// VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction. +// VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle enum EDeviceActivityLevel -{ - k_EDeviceActivityLevel_Unknown = -1, - k_EDeviceActivityLevel_Idle = 0, - k_EDeviceActivityLevel_UserInteraction = 1, - k_EDeviceActivityLevel_UserInteraction_Timeout = 2, - k_EDeviceActivityLevel_Standby = 3, +{ + k_EDeviceActivityLevel_Unknown = -1, + k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds + k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now + k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds + k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management) + k_EDeviceActivityLevel_Idle_Timeout = 4, }; @@ -502,6 +932,8 @@ enum EVRButtonId k_EButton_DPad_Right = 5, k_EButton_DPad_Down = 6, k_EButton_A = 7, + + k_EButton_ProximitySensor = 31, k_EButton_Axis0 = 32, k_EButton_Axis1 = 33, @@ -515,6 +947,10 @@ enum EVRButtonId k_EButton_Dashboard_Back = k_EButton_Grip, + k_EButton_IndexController_A = k_EButton_Grip, + k_EButton_IndexController_B = k_EButton_ApplicationMenu, + k_EButton_IndexController_JoyStick = k_EButton_Axis3, + k_EButton_Max = 64 }; @@ -543,15 +979,17 @@ struct VREvent_Mouse_t uint32_t button; // EVRMouseButton enum }; -/** used for simulated mouse wheel scroll in overlay space */ +/** used for simulated mouse wheel scroll */ struct VREvent_Scroll_t { - float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe - uint32_t repeatCount; + float xdelta, ydelta; + uint32_t unused; + float viewportscale; // For scrolling on an overlay with laser mouse, this is the overlay's vertical size relative to the overlay height. Range: [0,1] }; /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger - is on the touchpad (or just released from it) + is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents + flag set. **/ struct VREvent_TouchPadMove_t { @@ -583,6 +1021,8 @@ struct VREvent_Process_t uint32_t pid; uint32_t oldPid; bool bForced; + // If the associated event was triggered by a connection loss + bool bConnectionLost; }; @@ -590,6 +1030,7 @@ struct VREvent_Process_t struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; }; @@ -622,6 +1063,10 @@ struct VREvent_Reserved_t { uint64_t reserved0; uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; }; struct VREvent_PerformanceTest_t @@ -651,7 +1096,104 @@ struct VREvent_ApplicationLaunch_t uint32_t unArgsHandle; }; -/** If you change this you must manually update openvr_interop.cs.py */ +struct VREvent_EditingCameraSurface_t +{ + uint64_t overlayHandle; + uint32_t nVisualMode; +}; + +struct VREvent_MessageOverlay_t +{ + uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum +}; + +struct VREvent_Property_t +{ + PropertyContainerHandle_t container; + ETrackedDeviceProperty prop; +}; + +struct VREvent_HapticVibration_t +{ + uint64_t containerHandle; // property container handle of the device with the haptic component + uint64_t componentHandle; // Which haptic component needs to vibrate + float fDurationSeconds; + float fFrequency; + float fAmplitude; +}; + +struct VREvent_WebConsole_t +{ + WebConsoleHandle_t webConsoleHandle; +}; + +struct VREvent_InputBindingLoad_t +{ + vr::PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; + uint64_t pathControllerType; +}; + +struct VREvent_InputActionManifestLoad_t +{ + uint64_t pathAppKey; + uint64_t pathMessage; + uint64_t pathMessageParam; + uint64_t pathManifestPath; +}; + +struct VREvent_SpatialAnchor_t +{ + SpatialAnchorHandle_t unHandle; +}; + +struct VREvent_ProgressUpdate_t +{ + uint64_t ulApplicationPropertyContainer; + uint64_t pathDevice; + uint64_t pathInputSource; + uint64_t pathProgressAction; + uint64_t pathIcon; + float fProgress; +}; + +enum EShowUIType +{ + ShowUI_ControllerBinding = 0, + ShowUI_ManageTrackers = 1, + // ShowUI_QuickStart = 2, // Deprecated + ShowUI_Pairing = 3, + ShowUI_Settings = 4, + ShowUI_DebugCommands = 5, + ShowUI_FullControllerBinding = 6, + ShowUI_ManageDrivers = 7, +}; + +struct VREvent_ShowUI_t +{ + EShowUIType eType; +}; + +struct VREvent_ShowDevTools_t +{ + int32_t nBrowserIdentifier; +}; + +enum EHDCPError +{ + HDCPError_None = 0, + HDCPError_LinkLost = 1, + HDCPError_Tampered = 2, + HDCPError_DeviceRevoked = 3, + HDCPError_Unknown = 4 +}; + +struct VREvent_HDCPError_t +{ + EHDCPError eCode; +}; + typedef union { VREvent_Reserved_t reserved; @@ -671,8 +1213,28 @@ typedef union VREvent_Screenshot_t screenshot; VREvent_ScreenshotProgress_t screenshotProgress; VREvent_ApplicationLaunch_t applicationLaunch; + VREvent_EditingCameraSurface_t cameraSurface; + VREvent_MessageOverlay_t messageOverlay; + VREvent_Property_t property; + VREvent_HapticVibration_t hapticVibration; + VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; + VREvent_InputActionManifestLoad_t actionManifest; + VREvent_SpatialAnchor_t spatialAnchor; + VREvent_ProgressUpdate_t progressUpdate; + VREvent_ShowUI_t showUi; + VREvent_ShowDevTools_t showDevTools; + VREvent_HDCPError_t hdcpError; + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ } VREvent_Data_t; + +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + /** An event posted by the server to all running applications */ struct VREvent_t { @@ -683,6 +1245,74 @@ struct VREvent_t VREvent_Data_t data; }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif + +typedef uint32_t VRComponentProperties; + +enum EVRComponentProperty +{ + VRComponentProperty_IsStatic = (1 << 0), + VRComponentProperty_IsVisible = (1 << 1), + VRComponentProperty_IsTouched = (1 << 2), + VRComponentProperty_IsPressed = (1 << 3), + VRComponentProperty_IsScrolled = (1 << 4), + VRComponentProperty_IsHighlighted = (1 << 5), +}; + + +/** Describes state information about a render-model component, including transforms and other dynamic properties */ +struct RenderModel_ComponentState_t +{ + HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model + HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface ) + VRComponentProperties uProperties; +}; + + +enum EVRInputError +{ + VRInputError_None = 0, + VRInputError_NameNotFound = 1, + VRInputError_WrongType = 2, + VRInputError_InvalidHandle = 3, + VRInputError_InvalidParam = 4, + VRInputError_NoSteam = 5, + VRInputError_MaxCapacityReached = 6, + 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, + VRInputError_MissingSkeletonData = 16, + VRInputError_InvalidBoneIndex = 17, + VRInputError_InvalidPriority = 18, + VRInputError_PermissionDenied = 19, + VRInputError_InvalidRenderModel = 20, +}; + +enum EVRSpatialAnchorError +{ + VRSpatialAnchorError_Success = 0, + VRSpatialAnchorError_Internal = 1, + VRSpatialAnchorError_UnknownHandle = 2, + VRSpatialAnchorError_ArrayTooSmall = 3, + VRSpatialAnchorError_InvalidDescriptorChar = 4, + VRSpatialAnchorError_NotYetAvailable = 5, + VRSpatialAnchorError_NotAvailableInThisUniverse = 6, + VRSpatialAnchorError_PermanentlyUnavailable = 7, + VRSpatialAnchorError_WrongDriver = 8, + VRSpatialAnchorError_DescriptorTooLong = 9, + VRSpatialAnchorError_Unknown = 10, + VRSpatialAnchorError_NoRoomCalibration = 11, + VRSpatialAnchorError_InvalidArgument = 12, + VRSpatialAnchorError_UnknownDriver = 13, +}; /** The mesh to draw into the stencil (or depth) buffer to perform * early stencil (or depth) kills of pixels that will never appear on the HMD. @@ -697,6 +1327,16 @@ struct HiddenAreaMesh_t }; +enum EHiddenAreaMeshType +{ + k_eHiddenAreaMesh_Standard = 0, + k_eHiddenAreaMesh_Inverse = 1, + k_eHiddenAreaMesh_LineLoop = 2, + + k_eHiddenAreaMesh_Max = 3, +}; + + /** Identifies what kind of axis is on the controller at index n. Read this type * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n ); */ @@ -721,6 +1361,12 @@ struct VRControllerAxis_t static const uint32_t k_unControllerStateAxisCount = 5; +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + /** Holds all the state of a controller at one moment in time. */ struct VRControllerState001_t { @@ -735,6 +1381,9 @@ struct VRControllerState001_t // Axis data for the controller's analog inputs VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ]; }; +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif typedef VRControllerState001_t VRControllerState_t; @@ -761,17 +1410,6 @@ enum ECollisionBoundsStyle COLLISION_BOUNDS_STYLE_COUNT }; -/** Allows the application to customize how the overlay appears in the compositor */ -struct Compositor_OverlaySettings -{ - uint32_t size; // sizeof(Compositor_OverlaySettings) - bool curved, antialias; - float scale, distance, alpha; - float uOffset, vOffset, uScale, vScale; - float gridDivs, gridWidth, gridScale; - HmdMatrix44_t transform; -}; - /** used to refer to a single VR overlay */ typedef uint64_t VROverlayHandle_t; @@ -780,26 +1418,31 @@ static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0; /** Errors that can occur around VR overlays */ enum EVROverlayError { - VROverlayError_None = 0, - - VROverlayError_UnknownOverlay = 10, - VROverlayError_InvalidHandle = 11, - VROverlayError_PermissionDenied = 12, - VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist - VROverlayError_WrongVisibilityType = 14, - VROverlayError_KeyTooLong = 15, - VROverlayError_NameTooLong = 16, - VROverlayError_KeyInUse = 17, - VROverlayError_WrongTransformType = 18, - VROverlayError_InvalidTrackedDevice = 19, - VROverlayError_InvalidParameter = 20, - VROverlayError_ThumbnailCantBeDestroyed = 21, - VROverlayError_ArrayTooSmall = 22, - VROverlayError_RequestFailed = 23, - VROverlayError_InvalidTexture = 24, - VROverlayError_UnableToLoadFile = 25, - VROVerlayError_KeyboardAlreadyInUse = 26, - VROverlayError_NoNeighbor = 27, + VROverlayError_None = 0, + + VROverlayError_UnknownOverlay = 10, + VROverlayError_InvalidHandle = 11, + VROverlayError_PermissionDenied = 12, + VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist + VROverlayError_WrongVisibilityType = 14, + VROverlayError_KeyTooLong = 15, + VROverlayError_NameTooLong = 16, + VROverlayError_KeyInUse = 17, + VROverlayError_WrongTransformType = 18, + VROverlayError_InvalidTrackedDevice = 19, + VROverlayError_InvalidParameter = 20, + VROverlayError_ThumbnailCantBeDestroyed = 21, + VROverlayError_ArrayTooSmall = 22, + VROverlayError_RequestFailed = 23, + VROverlayError_InvalidTexture = 24, + VROverlayError_UnableToLoadFile = 25, + VROverlayError_KeyboardAlreadyInUse = 26, + VROverlayError_NoNeighbor = 27, + VROverlayError_TooManyMaskPrimitives = 29, + VROverlayError_BadMaskPrimitive = 30, + VROverlayError_TextureAlreadyLocked = 31, + VROverlayError_TextureLockCapacityReached = 32, + VROverlayError_TextureNotLocked = 33, }; /** enum values to pass in to VR_Init to identify whether the application will @@ -815,6 +1458,8 @@ enum EVRApplicationType // interfaces (like IVRSettings and IVRApplications) but not hardware. VRApplication_VRMonitor = 5, // Reserved for vrmonitor VRApplication_SteamWatchdog = 6,// Reserved for Steam + VRApplication_Bootstrapper = 7, // reserved for vrstartup + VRApplication_WebHelper = 8, // reserved for vrwebhelper VRApplication_Max }; @@ -840,6 +1485,53 @@ enum EVRNotificationError }; +enum EVRSkeletalMotionRange +{ + // The range of motion of the skeleton takes into account any physical limits imposed by + // the controller itself. This will tend to be the most accurate pose compared to the user's + // actual hand pose, but might not allow a closed fist for example + VRSkeletalMotionRange_WithController = 0, + + // Retarget the range of motion provided by the input device to make the hand appear to move + // as if it was not holding a controller. eg: map "hand grasping controller" to "closed fist" + VRSkeletalMotionRange_WithoutController = 1, +}; + +enum EVRSkeletalTrackingLevel +{ + // body part location can't be directly determined by the device. Any skeletal pose provided by + // the device is estimated by assuming the position required to active buttons, triggers, joysticks, + // or other input sensors. + // E.g. Vive Controller, Gamepad + VRSkeletalTracking_Estimated = 0, + + // body part location can be measured directly but with fewer degrees of freedom than the actual body + // part. Certain body part positions may be unmeasured by the device and estimated from other input data. + // E.g. Index Controllers, gloves that only measure finger curl + VRSkeletalTracking_Partial = 1, + + // Body part location can be measured directly throughout the entire range of motion of the body part. + // E.g. Mocap suit for the full body, gloves that measure rotation of each finger segment + VRSkeletalTracking_Full = 2, + + VRSkeletalTrackingLevel_Count, + VRSkeletalTrackingLevel_Max = VRSkeletalTrackingLevel_Count - 1 +}; + + + +/** Holds the transform for a single bone */ +struct VRBoneTransform_t +{ + HmdVector4_t position; + HmdQuaternionf_t orientation; +}; + +/** Type used for referring to bones by their index */ +typedef int32_t BoneIndex_t; +const BoneIndex_t k_unInvalidBoneIndex = -1; + + /** error codes returned by Vr_Init */ // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp @@ -848,71 +1540,176 @@ enum EVRInitError VRInitError_None = 0, VRInitError_Unknown = 1, - VRInitError_Init_InstallationNotFound = 100, - VRInitError_Init_InstallationCorrupt = 101, - VRInitError_Init_VRClientDLLNotFound = 102, - VRInitError_Init_FileNotFound = 103, - VRInitError_Init_FactoryNotFound = 104, - VRInitError_Init_InterfaceNotFound = 105, - VRInitError_Init_InvalidInterface = 106, - VRInitError_Init_UserConfigDirectoryInvalid = 107, - VRInitError_Init_HmdNotFound = 108, - VRInitError_Init_NotInitialized = 109, - VRInitError_Init_PathRegistryNotFound = 110, - VRInitError_Init_NoConfigPath = 111, - VRInitError_Init_NoLogPath = 112, - VRInitError_Init_PathRegistryNotWritable = 113, - VRInitError_Init_AppInfoInitFailed = 114, - VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver - VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup - VRInitError_Init_AnotherAppLaunching = 117, - VRInitError_Init_SettingsInitFailed = 118, - VRInitError_Init_ShuttingDown = 119, - VRInitError_Init_TooManyObjects = 120, - VRInitError_Init_NoServerForBackgroundApp = 121, - VRInitError_Init_NotSupportedWithCompositor = 122, - VRInitError_Init_NotAvailableToUtilityApps = 123, - VRInitError_Init_Internal = 124, - VRInitError_Init_HmdDriverIdIsNone = 125, - VRInitError_Init_HmdNotFoundPresenceFailed = 126, - VRInitError_Init_VRMonitorNotFound = 127, - VRInitError_Init_VRMonitorStartupFailed = 128, - VRInitError_Init_LowPowerWatchdogNotSupported = 129, - VRInitError_Init_InvalidApplicationType = 130, - VRInitError_Init_NotAvailableToWatchdogApps = 131, - VRInitError_Init_WatchdogDisabledInSettings = 132, - - VRInitError_Driver_Failed = 200, - VRInitError_Driver_Unknown = 201, - VRInitError_Driver_HmdUnknown = 202, - VRInitError_Driver_NotLoaded = 203, - VRInitError_Driver_RuntimeOutOfDate = 204, - VRInitError_Driver_HmdInUse = 205, - VRInitError_Driver_NotCalibrated = 206, - VRInitError_Driver_CalibrationInvalid = 207, - VRInitError_Driver_HmdDisplayNotFound = 208, + VRInitError_Init_InstallationNotFound = 100, + VRInitError_Init_InstallationCorrupt = 101, + VRInitError_Init_VRClientDLLNotFound = 102, + VRInitError_Init_FileNotFound = 103, + VRInitError_Init_FactoryNotFound = 104, + VRInitError_Init_InterfaceNotFound = 105, + VRInitError_Init_InvalidInterface = 106, + VRInitError_Init_UserConfigDirectoryInvalid = 107, + VRInitError_Init_HmdNotFound = 108, + VRInitError_Init_NotInitialized = 109, + VRInitError_Init_PathRegistryNotFound = 110, + VRInitError_Init_NoConfigPath = 111, + VRInitError_Init_NoLogPath = 112, + VRInitError_Init_PathRegistryNotWritable = 113, + VRInitError_Init_AppInfoInitFailed = 114, + VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver + VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup + VRInitError_Init_AnotherAppLaunching = 117, + VRInitError_Init_SettingsInitFailed = 118, + VRInitError_Init_ShuttingDown = 119, + VRInitError_Init_TooManyObjects = 120, + VRInitError_Init_NoServerForBackgroundApp = 121, + VRInitError_Init_NotSupportedWithCompositor = 122, + VRInitError_Init_NotAvailableToUtilityApps = 123, + VRInitError_Init_Internal = 124, + VRInitError_Init_HmdDriverIdIsNone = 125, + VRInitError_Init_HmdNotFoundPresenceFailed = 126, + VRInitError_Init_VRMonitorNotFound = 127, + VRInitError_Init_VRMonitorStartupFailed = 128, + VRInitError_Init_LowPowerWatchdogNotSupported = 129, + VRInitError_Init_InvalidApplicationType = 130, + VRInitError_Init_NotAvailableToWatchdogApps = 131, + VRInitError_Init_WatchdogDisabledInSettings = 132, + VRInitError_Init_VRDashboardNotFound = 133, + VRInitError_Init_VRDashboardStartupFailed = 134, + VRInitError_Init_VRHomeNotFound = 135, + VRInitError_Init_VRHomeStartupFailed = 136, + VRInitError_Init_RebootingBusy = 137, + VRInitError_Init_FirmwareUpdateBusy = 138, + VRInitError_Init_FirmwareRecoveryBusy = 139, + VRInitError_Init_USBServiceBusy = 140, + VRInitError_Init_VRWebHelperStartupFailed = 141, + VRInitError_Init_TrackerManagerInitFailed = 142, + VRInitError_Init_AlreadyRunning = 143, + VRInitError_Init_FailedForVrMonitor = 144, + VRInitError_Init_PropertyManagerInitFailed = 145, + VRInitError_Init_WebServerFailed = 146, + + VRInitError_Driver_Failed = 200, + VRInitError_Driver_Unknown = 201, + VRInitError_Driver_HmdUnknown = 202, + VRInitError_Driver_NotLoaded = 203, + VRInitError_Driver_RuntimeOutOfDate = 204, + VRInitError_Driver_HmdInUse = 205, + VRInitError_Driver_NotCalibrated = 206, + VRInitError_Driver_CalibrationInvalid = 207, + VRInitError_Driver_HmdDisplayNotFound = 208, VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, - // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons - VRInitError_Driver_HmdDriverIdOutOfBounds = 211, - VRInitError_Driver_HmdDisplayMirrored = 212, - - VRInitError_IPC_ServerInitFailed = 300, - VRInitError_IPC_ConnectFailed = 301, - VRInitError_IPC_SharedStateInitFailed = 302, - VRInitError_IPC_CompositorInitFailed = 303, - VRInitError_IPC_MutexInitFailed = 304, - VRInitError_IPC_Failed = 305, - VRInitError_IPC_CompositorConnectFailed = 306, + // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons + VRInitError_Driver_HmdDriverIdOutOfBounds = 211, + VRInitError_Driver_HmdDisplayMirrored = 212, + VRInitError_Driver_HmdDisplayNotFoundLaptop = 213, + // Never make error 259 because we return it from main and it would conflict with STILL_ACTIVE + + VRInitError_IPC_ServerInitFailed = 300, + VRInitError_IPC_ConnectFailed = 301, + VRInitError_IPC_SharedStateInitFailed = 302, + VRInitError_IPC_CompositorInitFailed = 303, + VRInitError_IPC_MutexInitFailed = 304, + VRInitError_IPC_Failed = 305, + VRInitError_IPC_CompositorConnectFailed = 306, VRInitError_IPC_CompositorInvalidConnectResponse = 307, VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, - - VRInitError_Compositor_Failed = 400, - VRInitError_Compositor_D3D11HardwareRequired = 401, - VRInitError_Compositor_FirmwareRequiresUpdate = 402, - VRInitError_Compositor_OverlayInitFailed = 403, - VRInitError_Compositor_ScreenshotsInitFailed = 404, - - VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + VRInitError_IPC_ConnectFailedAfterTargetExited = 309, + VRInitError_IPC_NamespaceUnavailable = 310, + + VRInitError_Compositor_Failed = 400, + VRInitError_Compositor_D3D11HardwareRequired = 401, + VRInitError_Compositor_FirmwareRequiresUpdate = 402, + VRInitError_Compositor_OverlayInitFailed = 403, + VRInitError_Compositor_ScreenshotsInitFailed = 404, + VRInitError_Compositor_UnableToCreateDevice = 405, + VRInitError_Compositor_SharedStateIsNull = 406, + VRInitError_Compositor_NotificationManagerIsNull = 407, + VRInitError_Compositor_ResourceManagerClientIsNull = 408, + VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409, + VRInitError_Compositor_PropertiesInterfaceIsNull = 410, + VRInitError_Compositor_CreateFullscreenWindowFailed = 411, + VRInitError_Compositor_SettingsInterfaceIsNull = 412, + VRInitError_Compositor_FailedToShowWindow = 413, + VRInitError_Compositor_DistortInterfaceIsNull = 414, + VRInitError_Compositor_DisplayFrequencyFailure = 415, + VRInitError_Compositor_RendererInitializationFailed = 416, + VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417, + VRInitError_Compositor_DXGIFactoryCreateFailed = 418, + VRInitError_Compositor_DXGIFactoryQueryFailed = 419, + VRInitError_Compositor_InvalidAdapterDesktop = 420, + VRInitError_Compositor_InvalidHmdAttachment = 421, + VRInitError_Compositor_InvalidOutputDesktop = 422, + VRInitError_Compositor_InvalidDeviceProvided = 423, + VRInitError_Compositor_D3D11RendererInitializationFailed = 424, + VRInitError_Compositor_FailedToFindDisplayMode = 425, + VRInitError_Compositor_FailedToCreateSwapChain = 426, + VRInitError_Compositor_FailedToGetBackBuffer = 427, + VRInitError_Compositor_FailedToCreateRenderTarget = 428, + VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429, + VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430, + VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431, + VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432, + VRInitError_Compositor_SelectDisplayMode = 433, + VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434, + VRInitError_Compositor_NvAPISetDisplayMode = 435, + VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436, + VRInitError_Compositor_InvalidHmdPropertyContainer = 437, + VRInitError_Compositor_UpdateDisplayFrequency = 438, + VRInitError_Compositor_CreateRasterizerState = 439, + VRInitError_Compositor_CreateWireframeRasterizerState = 440, + VRInitError_Compositor_CreateSamplerState = 441, + VRInitError_Compositor_CreateClampToBorderSamplerState = 442, + VRInitError_Compositor_CreateAnisoSamplerState = 443, + VRInitError_Compositor_CreateOverlaySamplerState = 444, + VRInitError_Compositor_CreatePanoramaSamplerState = 445, + VRInitError_Compositor_CreateFontSamplerState = 446, + VRInitError_Compositor_CreateNoBlendState = 447, + VRInitError_Compositor_CreateBlendState = 448, + VRInitError_Compositor_CreateAlphaBlendState = 449, + VRInitError_Compositor_CreateBlendStateMaskR = 450, + VRInitError_Compositor_CreateBlendStateMaskG = 451, + VRInitError_Compositor_CreateBlendStateMaskB = 452, + VRInitError_Compositor_CreateDepthStencilState = 453, + VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454, + VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455, + VRInitError_Compositor_CreateFlushTexture = 456, + VRInitError_Compositor_CreateDistortionSurfaces = 457, + VRInitError_Compositor_CreateConstantBuffer = 458, + VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459, + VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460, + VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461, + VRInitError_Compositor_CreateOverlayConstantBuffer = 462, + VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463, + VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464, + VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465, + VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466, + VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467, + VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468, + VRInitError_Compositor_CreateGeomConstantBuffer = 469, + VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470, + VRInitError_Compositor_CreatePixelSimUBO = 471, + VRInitError_Compositor_CreateMSAARenderTextures = 472, + VRInitError_Compositor_CreateResolveRenderTextures = 473, + VRInitError_Compositor_CreateComputeResolveRenderTextures = 474, + VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475, + VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476, + VRInitError_Compositor_CreateFallbackSyncTexture = 477, + VRInitError_Compositor_ShareFallbackSyncTexture = 478, + VRInitError_Compositor_CreateOverlayIndexBuffer = 479, + VRInitError_Compositor_CreateOverlayVertexBuffer = 480, + VRInitError_Compositor_CreateTextVertexBuffer = 481, + VRInitError_Compositor_CreateTextIndexBuffer = 482, + VRInitError_Compositor_CreateMirrorTextures = 483, + VRInitError_Compositor_CreateLastFrameRenderTexture = 484, + VRInitError_Compositor_CreateMirrorOverlay = 485, + VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486, + VRInitError_Compositor_DisplayModeNotSupported = 487, + VRInitError_Compositor_CreateOverlayInvalidCall = 488, + VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489, + VRInitError_Compositor_FailedToCreateMailbox = 490, + + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + VRInitError_VendorSpecific_WindowsNotInDevMode = 1001, VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, @@ -927,8 +1724,12 @@ enum EVRInitError VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111, VRInitError_VendorSpecific_HmdFound_UserDataError = 1112, VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, + VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114, VRInitError_Steam_SteamInstallationNotFound = 2000, + + // Strictly a placeholder + VRInitError_LastError }; enum EVRScreenshotType @@ -968,6 +1769,14 @@ enum EVRTrackedCameraError VRTrackedCameraError_InvalidFrameBufferSize = 115, }; +enum EVRTrackedCameraFrameLayout +{ + EVRTrackedCameraFrameLayout_Mono = 0x0001, + EVRTrackedCameraFrameLayout_Stereo = 0x0002, + EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right) + EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right +}; + enum EVRTrackedCameraFrameType { VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted. @@ -976,6 +1785,16 @@ enum EVRTrackedCameraFrameType MAX_CAMERA_FRAME_TYPES }; +enum EVRDistortionFunctionType +{ + VRDistortionFunctionType_None, + VRDistortionFunctionType_FTheta, + VRDistortionFunctionType_Extended_FTheta, + MAX_DISTORTION_FUNCTION_TYPES, +}; + +static const uint32_t k_unMaxDistortionFunctionParameters = 8; + typedef uint64_t TrackedCameraHandle_t; #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0) @@ -989,7 +1808,9 @@ struct CameraVideoStreamFrameHeader_t uint32_t nFrameSequence; - TrackedDevicePose_t standingTrackedDevicePose; + TrackedDevicePose_t trackedDevicePose; + + uint64_t ulFrameExposureTime; // mid-point of the exposure of the image in host system ticks }; // Screenshot types @@ -997,34 +1818,162 @@ typedef uint32_t ScreenshotHandle_t; static const uint32_t k_unScreenshotHandleInvalid = 0; +/** Compositor frame timing reprojection flags. */ +const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01; +const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02; +const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicates the async reprojection mode is active, + // but does not indicate if reprojection actually happened or not. + // Use the ReprojectionReason flags above to check if reprojection + // was actually applied (i.e. scene texture was reused). + // NumFramePresents > 1 also indicates the scene texture was reused, + // and also the number of times that it was presented in total. + +const uint32_t VRCompositor_ReprojectionMotion = 0x08; // This flag indicates whether or not motion smoothing was triggered for this frame + +const uint32_t VRCompositor_PredictionMask = 0x30; // The runtime may predict more than one frame (up to four) ahead if + // it detects the application is taking too long to render. These two + // bits will contain the count of additional frames (normally zero). + // Use the VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES macro to read from + // the latest frame timing entry. + +const uint32_t VRCompositor_ThrottleMask = 0xC0; // Number of frames the compositor is throttling the application. + // Use the VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES macro to read from + // the latest frame timing entry. + +#define VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_PredictionMask ) >> 4 ) +#define VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_ThrottleMask ) >> 6 ) + +/** Provides a single frame's timing information to the app */ +struct Compositor_FrameTiming +{ + uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming ) + uint32_t m_nFrameIndex; + uint32_t m_nNumFramePresents; // number of times this frame was presented + uint32_t m_nNumMisPresented; // number of times this frame was presented on a vsync other than it was originally predicted to + uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out + uint32_t m_nReprojectionFlags; + + /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */ + double m_flSystemTimeInSeconds; + + /** These times may include work from other processes due to OS scheduling. + * The fewer packets of work these are broken up into, the less likely this will happen. + * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started + * processing that work earlier in the frame. */ + float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit) + float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window) + float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work + float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc. + float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame + float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time) + + /** Miscellaneous measured intervals. */ + float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses + float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long) + float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure) + float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue) + + /** The following are all relative to this frame's SystemTimeInSeconds */ + float m_flWaitGetPosesCalledMs; + float m_flNewPosesReadyMs; + float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit + float m_flCompositorUpdateStartMs; + float m_flCompositorUpdateEndMs; + float m_flCompositorRenderStartMs; + + vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame + + uint32_t m_nNumVSyncsReadyForUse; + uint32_t m_nNumVSyncsToFirstView; +}; + +/** Provides compositor benchmark results to the app */ +struct Compositor_BenchmarkResults +{ + float m_flMegaPixelsPerSecond; // Measurement of GPU MP/s performed by compositor benchmark + float m_flHmdRecommendedMegaPixelsPerSecond; // Recommended default MP/s given the HMD resolution, refresh, and panel mask. +}; + +/** Frame timing data provided by direct mode drivers. */ +struct DriverDirectMode_FrameTiming +{ + uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming ) + uint32_t m_nNumFramePresents; // number of times frame was presented + uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to + uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync) + uint32_t m_nReprojectionFlags; +}; + +/** These flags will be set on DriverDirectMode_FrameTiming::m_nReprojectionFlags when IVRDriverDirectModeComponent::GetFrameTiming is called for drivers to optionally respond to. */ +const uint32_t VRCompositor_ReprojectionMotion_Enabled = 0x100; // Motion Smoothing is enabled in the UI for the currently running application +const uint32_t VRCompositor_ReprojectionMotion_ForcedOn = 0x200; // Motion Smoothing is forced on in the UI for the currently running application +const uint32_t VRCompositor_ReprojectionMotion_AppThrottled = 0x400; // Application is requesting throttling via ForceInterleavedReprojectionOn + + +enum EVSync +{ + VSync_None, + VSync_WaitRender, // block following render work until vsync + VSync_NoWaitRender, // do not block following render work (allow to get started early) +}; + +enum EVRMuraCorrectionMode +{ + EVRMuraCorrectionMode_Default = 0, + EVRMuraCorrectionMode_NoCorrection +}; + +/** 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 #if defined(_WIN32) -#ifdef VR_API_EXPORT -#define VR_INTERFACE extern "C" __declspec( dllexport ) -#else -#define VR_INTERFACE extern "C" __declspec( dllimport ) -#endif + #if !defined(OPENVR_BUILD_STATIC) + #ifdef VR_API_EXPORT + #define VR_INTERFACE extern "C" __declspec( dllexport ) + #else + #define VR_INTERFACE extern "C" __declspec( dllimport ) + #endif + #else + #define VR_INTERFACE extern "C" + #endif #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__) #ifdef VR_API_EXPORT -#define VR_INTERFACE extern "C" __attribute__((visibility("default"))) + #define VR_INTERFACE extern "C" __attribute__((visibility("default"))) #else -#define VR_INTERFACE extern "C" + #define VR_INTERFACE extern "C" #endif #else -#error "Unsupported Platform." + #error "Unsupported Platform." #endif #if defined( _WIN32 ) -#define VR_CALLTYPE __cdecl + #define VR_CALLTYPE __cdecl #else -#define VR_CALLTYPE + #define VR_CALLTYPE #endif } // namespace vr @@ -1058,16 +2007,7 @@ static const uint32_t k_unScreenshotHandleInvalid = 0; namespace vr { -#if defined(__linux__) || defined(__APPLE__) - // The 32-bit version of gcc has the alignment requirement for uint64 and double set to - // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned. - // The 64-bit version of gcc has the alignment requirement for these types set to - // 8 meaning that unless we use #pragma pack(4) our structures will get bigger. - // The 64-bit structure packing has to match the 32-bit structure packing for each platform. - #pragma pack( push, 4 ) -#else - #pragma pack( push, 8 ) -#endif +#pragma pack( push, 8 ) enum ECameraVideoStreamFormat { @@ -1075,34 +2015,50 @@ enum ECameraVideoStreamFormat CVS_FORMAT_RAW10 = 1, // 10 bits per pixel CVS_FORMAT_NV12 = 2, // 12 bits per pixel CVS_FORMAT_RGB24 = 3, // 24 bits per pixel + CVS_FORMAT_NV12_2 = 4, // 12 bits per pixel, 2x height + CVS_FORMAT_YUYV16 = 5, // 16 bits per pixel + CVS_FORMAT_BAYER16BG = 6, // 16 bits per pixel, 10-bit BG-format Bayer, see https://docs.opencv.org/3.1.0/de/d25/imgproc_color_conversions.html + CVS_FORMAT_MJPEG = 7, // variable-sized MJPEG Open DML format, see https://www.loc.gov/preservation/digital/formats/fdd/fdd000063.shtml CVS_MAX_FORMATS }; enum ECameraCompatibilityMode { CAMERA_COMPAT_MODE_BULK_DEFAULT = 0, - CAMERA_COMPAT_MODE_BULK_64K_DMA, - CAMERA_COMPAT_MODE_BULK_16K_DMA, - CAMERA_COMPAT_MODE_BULK_8K_DMA, - CAMERA_COMPAT_MODE_ISO_52FPS, - CAMERA_COMPAT_MODE_ISO_50FPS, - CAMERA_COMPAT_MODE_ISO_48FPS, - CAMERA_COMPAT_MODE_ISO_46FPS, - CAMERA_COMPAT_MODE_ISO_44FPS, - CAMERA_COMPAT_MODE_ISO_42FPS, - CAMERA_COMPAT_MODE_ISO_40FPS, - CAMERA_COMPAT_MODE_ISO_35FPS, - CAMERA_COMPAT_MODE_ISO_30FPS, + CAMERA_COMPAT_MODE_BULK_64K_DMA = 1, + CAMERA_COMPAT_MODE_BULK_16K_DMA = 2, + CAMERA_COMPAT_MODE_BULK_8K_DMA = 3, + CAMERA_COMPAT_MODE_ISO_52FPS = 4, + CAMERA_COMPAT_MODE_ISO_50FPS = 5, + CAMERA_COMPAT_MODE_ISO_48FPS = 6, + CAMERA_COMPAT_MODE_ISO_46FPS = 7, + CAMERA_COMPAT_MODE_ISO_44FPS = 8, + CAMERA_COMPAT_MODE_ISO_42FPS = 9, + CAMERA_COMPAT_MODE_ISO_40FPS = 10, + CAMERA_COMPAT_MODE_ISO_35FPS = 11, + CAMERA_COMPAT_MODE_ISO_30FPS = 12, + CAMERA_COMPAT_MODE_ISO_15FPS = 13, MAX_CAMERA_COMPAT_MODES }; +enum ETrackedCameraRoomViewMode +{ + TRACKED_CAMERA_ROOMVIEW_MODE_DEFAULT = 0, + TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_A = 1, + TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_B = 2, + TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_TRANSLUSCENT = 3, + TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_OPAQUE = 4, + TRACKED_CAMERA_ROOMVIEW_MODE_COUNT = 5, +}; + #ifdef _MSC_VER #define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) ) #else #define VR_CAMERA_DECL_ALIGN( x ) // #endif -#define MAX_CAMERA_FRAME_SHARED_HANDLES 4 +static const uint32_t k_unMaxCameras = 4; +static const uint32_t k_unMaxCameraFrameSharedHandles = 4; VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t { @@ -1139,7 +2095,7 @@ VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t double m_flSyncMarkerError; - TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by HMD layer when used as a tracked camera + TrackedDevicePose_t m_RawTrackedDevicePose; // Raw-and-uncalibrated pose, supplied by HMD layer when used as a tracked camera uint64_t m_pImageData; }; @@ -1150,6 +2106,8 @@ VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t #endif // _VRTRACKEDCAMERATYPES_H // ivrsettings.h +#include + namespace vr { enum EVRSettingsError @@ -1158,6 +2116,8 @@ namespace vr VRSettingsError_IPCFailed = 1, VRSettingsError_WriteFailed = 2, VRSettingsError_ReadFailed = 3, + VRSettingsError_JsonParseFailed = 4, + VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set }; // The maximum length of a settings key @@ -1168,88 +2128,201 @@ namespace vr public: virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0; - // Returns true if file sync occurred (force or settings dirty) - virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0; - - virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, bool bDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; - virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; - virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, float flDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; - virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, const char *pchDefaultValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0; - + + // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory + // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or "" + virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; + virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0; + virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0; virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; }; //----------------------------------------------------------------------------- - static const char * const IVRSettings_Version = "IVRSettings_001"; + static const char * const IVRSettings_Version = "IVRSettings_003"; + + class CVRSettingHelper + { + IVRSettings *m_pSettings; + public: + CVRSettingHelper( IVRSettings *pSettings ) + { + m_pSettings = pSettings; + } + + const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) + { + return m_pSettings->GetSettingsErrorNameFromEnum( eError ); + } + + void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetBool( pchSection, pchSettingsKey, bValue, peError ); + } + + void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetInt32( pchSection, pchSettingsKey, nValue, peError ); + } + void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetFloat( pchSection, pchSettingsKey, flValue, peError ); + } + void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( pchSection, pchSettingsKey, pchValue, peError ); + } + void SetString( const std::string & sSection, const std::string & sSettingsKey, const std::string & sValue, EVRSettingsError *peError = nullptr ) + { + m_pSettings->SetString( sSection.c_str(), sSettingsKey.c_str(), sValue.c_str(), peError ); + } + + bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetBool( pchSection, pchSettingsKey, peError ); + } + int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetInt32( pchSection, pchSettingsKey, peError ); + } + float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + return m_pSettings->GetFloat( pchSection, pchSettingsKey, peError ); + } + void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) + { + m_pSettings->GetString( pchSection, pchSettingsKey, pchValue, unValueLen, peError ); + } + std::string GetString( const std::string & sSection, const std::string & sSettingsKey, EVRSettingsError *peError = nullptr ) + { + char buf[4096]; + vr::EVRSettingsError eError; + m_pSettings->GetString( sSection.c_str(), sSettingsKey.c_str(), buf, sizeof( buf ), &eError ); + if ( peError ) + *peError = eError; + if ( eError == vr::VRSettingsError_None ) + return buf; + else + return ""; + } + + void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveSection( pchSection, peError ); + } + void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) + { + m_pSettings->RemoveKeyInSection( pchSection, pchSettingsKey, peError ); + } + }; + //----------------------------------------------------------------------------- // steamvr keys - static const char * const k_pch_SteamVR_Section = "steamvr"; static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd"; static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; - static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion"; static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps"; static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel"; static const char * const k_pch_SteamVR_IPD_Float = "ipd"; static const char * const k_pch_SteamVR_Background_String = "background"; + static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; - static const char * const k_pch_SteamVR_Environment_String = "environment"; static const char * const k_pch_SteamVR_GridColor_String = "gridColor"; static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; + static const char * const k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor"; static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage"; static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; - static const char * const k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit"; - static const char * const k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout"; - static const char * const k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout"; - static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode"; - static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; - static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; - static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; + static const char * const k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement"; + static const char * const k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip"; static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; - static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier"; - static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection"; - static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; + static const char * const k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; + static const char * const k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; + static const char * const k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; + static const char * const k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync"; static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; - static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; - static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; + static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; + static const char * const k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView"; + static const char * const k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView"; + static const char * const k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode"; + static const char * const k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye"; + static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; + static const char * const k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; + static const char * const k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph"; static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; - static const char * const k_pch_SteamVR_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; - static const char * const k_pch_SteamVR_UseGenericGraphcisDevice_Bool = "useGenericGraphicsDevice"; + static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; + static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; + static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; + static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; + static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; + static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; + static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; + static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; + static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; + static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; + static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; + static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; + static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; + static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; + static const char * const k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid"; + static const char * const k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; + static const char * const k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; + static const char * const k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; + static const char * const k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; + static const char * const k_pch_SteamVR_LastVersionNotice = "lastVersionNotice"; + static const char * const k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG"; + static const char * const k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB"; + static const char * const k_pch_SteamVR_CustomIconStyle_String = "customIconStyle"; + static const char * const k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle"; + static const char * const k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate"; + static const char * const k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority"; + static const char * const k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2"; + static const char * const k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption"; + static const char * const k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches"; + //----------------------------------------------------------------------------- + // direct mode keys + static const char * const k_pch_DirectMode_Section = "direct_mode"; + static const char * const k_pch_DirectMode_Enable_Bool = "enable"; + static const char * const k_pch_DirectMode_Count_Int32 = "count"; + static const char * const k_pch_DirectMode_EdidVid_Int32 = "edidVid"; + static const char * const k_pch_DirectMode_EdidPid_Int32 = "edidPid"; //----------------------------------------------------------------------------- // lighthouse keys - static const char * const k_pch_Lighthouse_Section = "driver_lighthouse"; static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; + static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; - static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; - static const char * const k_pch_Lighthouse_LighthouseName_String = "lighthousename"; - static const char * const k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees"; - static const char * const k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect"; static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; + static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; + static const char * const k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; + static const char * const k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations"; + static const char * const k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; //----------------------------------------------------------------------------- // null keys - static const char * const k_pch_Null_Section = "driver_null"; - static const char * const k_pch_Null_EnableNullDriver_Bool = "enable"; static const char * const k_pch_Null_SerialNumber_String = "serialNumber"; static const char * const k_pch_Null_ModelNumber_String = "modelNumber"; static const char * const k_pch_Null_WindowX_Int32 = "windowX"; @@ -1261,10 +2334,16 @@ namespace vr static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency"; + //----------------------------------------------------------------------------- + // Windows MR keys + static const char * const k_pch_WindowsMR_Section = "driver_holographic"; + //----------------------------------------------------------------------------- // user interface keys static const char * const k_pch_UserInterface_Section = "userinterface"; static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; + static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; + static const char * const k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots"; static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; @@ -1287,12 +2366,11 @@ namespace vr //----------------------------------------------------------------------------- // perf keys static const char * const k_pch_Perf_Section = "perfcheck"; - static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; - static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; - static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; + static const char * const k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; static const char * const k_pch_Perf_TestData_Float = "perfTestData"; + static const char * const k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; //----------------------------------------------------------------------------- // collision bounds keys @@ -1302,10 +2380,12 @@ namespace vr static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; + static const char * const k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight"; static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; + static const char * const k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport"; //----------------------------------------------------------------------------- // camera keys @@ -1318,35 +2398,127 @@ namespace vr static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; + static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; + static const char * const k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; //----------------------------------------------------------------------------- // audio keys static const char * const k_pch_audio_Section = "audio"; - static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; - static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice"; - static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; - static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; - static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice"; + static const char * const k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice"; + static const char * const k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride"; + static const char * const k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride"; + static const char * const k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName"; + static const char * const k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice"; + static const char * const k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride"; + static const char * const k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride"; + static const char * const k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName"; + static const char * const k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror"; + static const char * const k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice"; + static const char * const k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName"; + static const char * const k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; + static const char * const k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice"; + static const char * const k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume"; + static const char * const k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; + //----------------------------------------------------------------------------- + // power management keys + static const char * const k_pch_Power_Section = "power"; + static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; + static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; + static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; + static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; + static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; + static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; + + //----------------------------------------------------------------------------- + // dashboard keys + static const char * const k_pch_Dashboard_Section = "dashboard"; + static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; + static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; + static const char * const k_pch_Dashboard_Position = "position"; + static const char * const k_pch_Dashboard_DesktopScale = "desktopScale"; + static const char * const k_pch_Dashboard_DashboardScale = "dashboardScale"; + //----------------------------------------------------------------------------- // model skin keys static const char * const k_pch_modelskin_Section = "modelskins"; -} // namespace vr + //----------------------------------------------------------------------------- + // driver keys - These could be checked in any driver_ section + static const char * const k_pch_Driver_Enable_Bool = "enable"; + static const char * const k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode"; + static const char * const k_pch_Driver_LoadPriority_Int32 = "loadPriority"; -// iservertrackeddevicedriver.h -namespace vr -{ + //----------------------------------------------------------------------------- + // web interface keys + static const char* const k_pch_WebInterface_Section = "WebInterface"; + //----------------------------------------------------------------------------- + // vrwebhelper keys + static const char* const k_pch_VRWebHelper_Section = "VRWebHelper"; + static const char* const k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; + static const char* const k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; -struct DriverPoseQuaternion_t -{ - double w, x, y, z; -}; + //----------------------------------------------------------------------------- + // 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"; -struct DriverPose_t -{ + //----------------------------------------------------------------------------- + // 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_BindingLegacyAPISuffix_String = "_legacy"; + static const char* const k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput"; + static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; + static const char* const k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL"; + static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; + static const char* const k_pch_App_DominantHand_Int32 = "DominantHand"; + static const char* const k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK"; + + //----------------------------------------------------------------------------- + // configuration for trackers + static const char * const k_pch_Trackers_Section = "trackers"; + + //----------------------------------------------------------------------------- + // configuration for desktop UI windows + static const char * const k_pch_DesktopUI_Section = "DesktopUI"; + + //----------------------------------------------------------------------------- + // Last known keys for righting recovery + static const char * const k_pch_LastKnown_Section = "LastKnown"; + static const char* const k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; + static const char* const k_pch_LastKnown_HMDModel_String = "HMDModel"; + + //----------------------------------------------------------------------------- + // Dismissed warnings + static const char * const k_pch_DismissedWarnings_Section = "DismissedWarnings"; + + //----------------------------------------------------------------------------- + // Input Settings + static const char * const k_pch_Input_Section = "input"; + static const char* const k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation"; + static const char* const k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation"; + static const char* const k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone"; + + //----------------------------------------------------------------------------- + // Log of GPU performance + static const char * const k_pch_GpuSpeed_Section = "GpuSpeed"; + +} // namespace vr + +// iservertrackeddevicedriver.h +namespace vr +{ + + +struct DriverPoseQuaternion_t +{ + double w, x, y, z; +}; + +struct DriverPose_t +{ /* Time offset of this pose, in seconds from the actual time of the pose, * relative to the time of the PoseUpdated() call made by the driver. */ @@ -1434,8 +2606,8 @@ class ITrackedDeviceServerDriver * and thread use it can when it is deactivated */ virtual void Deactivate() = 0; - /** Handles a request from the system to power off this device */ - virtual void PowerOff() = 0; + /** Handles a request from the system to put this device into standby mode. What that means is defined per-device. */ + virtual void EnterStandby() = 0; /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL * if the requested interface or version is not supported. */ @@ -1450,38 +2622,11 @@ class ITrackedDeviceServerDriver // Tracking Methods // ------------------------------------ virtual DriverPose_t GetPose() = 0; - - // ------------------------------------ - // Property Methods - // ------------------------------------ - - /** Returns a bool property. If the property is not available this function will return false. */ - virtual bool GetBoolTrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0; - - /** Returns a float property. If the property is not available this function will return 0. */ - virtual float GetFloatTrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0; - - /** Returns an int property. If the property is not available this function will return 0. */ - virtual int32_t GetInt32TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0; - - /** Returns a uint64 property. If the property is not available this function will return 0. */ - virtual uint64_t GetUint64TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0; - - /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */ - virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0; - - /** Returns a string property. If the property is not available this function will return 0 and pError will be - * set to an error. Otherwise it returns the length of the number of bytes necessary to hold this string including - * the trailing null. If the buffer is too small the error will be TrackedProp_BufferTooSmall. Strings will - * generally fit in buffers of k_unTrackingStringSize characters. Drivers may not return strings longer than - * k_unMaxPropertyStringSize. */ - virtual uint32_t GetStringTrackedDeviceProperty( ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError ) = 0; - }; -static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_004"; +static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_005"; } // ivrdisplaycomponent.h @@ -1548,59 +2693,56 @@ namespace vr // ----------------------------------- /** Specific to Oculus compositor support, textures supplied must be created using this method. */ - virtual void CreateSwapTextureSet( uint32_t unPid, uint32_t unFormat, uint32_t unWidth, uint32_t unHeight, void *(*pSharedTextureHandles)[3] ) {} + struct SwapTextureSetDesc_t + { + uint32_t nWidth; + uint32_t nHeight; + uint32_t nFormat; + uint32_t nSampleCount; + }; + virtual void CreateSwapTextureSet( uint32_t unPid, const SwapTextureSetDesc_t *pSwapTextureSetDesc, vr::SharedTextureHandle_t( *pSharedTextureHandles )[ 3 ] ) {} /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */ - virtual void DestroySwapTextureSet( void *pSharedTextureHandle ) {} + virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sharedTextureHandle ) {} /** Used to purge all texture sets for a given process. */ virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {} /** After Present returns, calls this to get the next index to use for rendering. */ - virtual void GetNextSwapTextureSetIndex( void *pSharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {} + virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {} /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */ - virtual void SubmitLayer( void *pSharedTextureHandles[ 2 ], const vr::VRTextureBounds_t( &bounds )[ 2 ], const vr::HmdMatrix34_t *pPose ) {} - - /** Submits queued layers for display. */ - virtual void Present( void *hSyncTexture ) {} - - }; - - static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_001"; - -} - -// ivrcontrollercomponent.h -namespace vr -{ + struct SubmitLayerPerEye_t + { + // Shared texture handles (depth not always provided). + vr::SharedTextureHandle_t hTexture, hDepthTexture; + // Valid region of provided texture (and depth). + vr::VRTextureBounds_t bounds; - // ---------------------------------------------------------------------------------------------- - // Purpose: Controller access on a single tracked device. - // ---------------------------------------------------------------------------------------------- - class IVRControllerComponent - { - public: + // Projection matrix used to render the depth buffer. + vr::HmdMatrix44_t mProjection; - // ------------------------------------ - // Controller Methods - // ------------------------------------ + // Hmd pose used to render this layer. + vr::HmdMatrix34_t mHmdPose; + }; + virtual void SubmitLayer( const SubmitLayerPerEye_t( &perEye )[ 2 ] ) {} - /** Gets the current state of a controller. */ - virtual VRControllerState_t GetControllerState( ) = 0; + /** Submits queued layers for display. */ + virtual void Present( vr::SharedTextureHandle_t syncTexture ) {} - /** Returns a uint64 property. If the property is not available this function will return 0. */ - virtual bool TriggerHapticPulse( uint32_t unAxisId, uint16_t usPulseDurationMicroseconds ) = 0; + /** Called after Present to allow driver to take more time until vsync after they've successfully acquired the sync texture in Present.*/ + virtual void PostPresent() {} + /** Called to get additional frame timing stats from driver. Check m_nSize for versioning (new members will be added to end only). */ + virtual void GetFrameTiming( DriverDirectMode_FrameTiming *pFrameTiming ) {} }; - - - static const char *IVRControllerComponent_Version = "IVRControllerComponent_001"; + static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_006"; } + // ivrcameracomponent.h namespace vr { @@ -1634,17 +2776,17 @@ namespace vr virtual bool SetAutoExposure( bool bEnable ) = 0; virtual bool PauseVideoStream() = 0; virtual bool ResumeVideoStream() = 0; - virtual bool GetCameraDistortion( float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0; - virtual bool GetCameraProjection( vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; + virtual bool GetCameraDistortion( uint32_t nCameraIndex, float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0; + virtual bool GetCameraProjection( uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0; virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0; virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0; virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0; virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0; - virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0; + virtual bool GetCameraIntrinsics( uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter, vr::EVRDistortionFunctionType *peDistortionType, double rCoefficients[ k_unMaxDistortionFunctionParameters ] ) = 0; }; - static const char *IVRCameraComponent_Version = "IVRCameraComponent_002"; + static const char *IVRCameraComponent_Version = "IVRCameraComponent_003"; } // itrackeddevicedriverprovider.h namespace vr @@ -1654,68 +2796,19 @@ class ITrackedDeviceServerDriver; struct TrackedDeviceDriverInfo_t; struct DriverPose_t; -class IDriverLog -{ -public: - /** Writes a log message to the log file prefixed with the driver name */ - virtual void Log( const char *pchLogMessage ) = 0; -}; - /** This interface is provided by vrserver to allow the driver to notify * the system when something changes about a device. These changes must * not change the serial number or class of the device because those values * are permanently associated with the device's index. */ -class IServerDriverHost +class IVRDriverContext { public: - /** Notifies the server that a tracked device has been added. If this function returns true - * the server will call Activate on the device. If it returns false some kind of error - * has occurred and the device will not be activated. */ - virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber ) = 0; - - /** Notifies the server that a tracked device's pose has been updated */ - virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose ) = 0; - - /** Notifies the server that the property cache for the specified device should be invalidated */ - virtual void TrackedDevicePropertiesChanged( uint32_t unWhichDevice ) = 0; - - /** Notifies the server that vsync has occurred on the the display attached to the device. This is - * only permitted on devices of the HMD class. */ - virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0; - - /** notifies the server that the button was pressed */ - virtual void TrackedDeviceButtonPressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0; - - /** notifies the server that the button was unpressed */ - virtual void TrackedDeviceButtonUnpressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0; - - /** notifies the server that the button was pressed */ - virtual void TrackedDeviceButtonTouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0; - - /** notifies the server that the button was unpressed */ - virtual void TrackedDeviceButtonUntouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0; - - /** notifies the server than a controller axis changed */ - virtual void TrackedDeviceAxisUpdated( uint32_t unWhichDevice, uint32_t unWhichAxis, const VRControllerAxis_t & axisState ) = 0; + /** Returns the requested interface. If the interface was not available it will return NULL and fill + * out the error. */ + virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError = nullptr ) = 0; - /** Notifies the server that the MC image has been updated for the display attached to the device. This is - * only permitted on devices of the HMD class. */ - virtual void MCImageUpdated() = 0; - - /** always returns a pointer to a valid interface pointer of IVRSettings */ - virtual IVRSettings *GetSettings( const char *pchInterfaceVersion ) = 0; - - /** Notifies the server that the physical IPD adjustment has been moved on the HMD */ - virtual void PhysicalIpdSet( uint32_t unWhichDevice, float fPhysicalIpdMeters ) = 0; - - /** Notifies the server that the proximity sensor on the specified device */ - virtual void ProximitySensorState( uint32_t unWhichDevice, bool bProximitySensorTriggered ) = 0; - - /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */ - virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0; - - /** Returns true if SteamVR is exiting */ - virtual bool IsExiting() = 0; + /** Returns the property container handle for this driver */ + virtual DriverHandle_t GetDriverHandle() = 0; }; @@ -1732,7 +2825,7 @@ class IServerTrackedDeviceProvider * config files. * pchDriverInstallDir - The absolute path of the root directory for the driver. */ - virtual EVRInitError Init( IDriverLog *pDriverLog, vr::IServerDriverHost *pDriverHost, const char *pchUserDriverConfigDir, const char *pchDriverInstallDir ) = 0; + virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; /** cleans up the driver right before it is unloaded */ virtual void Cleanup() = 0; @@ -1740,15 +2833,6 @@ class IServerTrackedDeviceProvider /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */ virtual const char * const *GetInterfaceVersions() = 0; - /** returns the number of HMDs that this driver manages that are physically connected. */ - virtual uint32_t GetTrackedDeviceCount() = 0; - - /** returns a single HMD */ - virtual ITrackedDeviceServerDriver *GetTrackedDeviceDriver( uint32_t unWhich ) = 0; - - /** returns a single HMD by ID */ - virtual ITrackedDeviceServerDriver* FindTrackedDeviceDriver( const char *pchId ) = 0; - /** Allows the driver do to some work in the main loop of the server. */ virtual void RunFrame() = 0; @@ -1769,122 +2853,1246 @@ class IServerTrackedDeviceProvider }; -static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_003"; +static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_004"; + -/** This interface is provided by vrclient to allow the driver call back and query various information */ -class IClientDriverHost + +/** This interface must be implemented in each driver. It will be loaded in vrclient.dll */ +class IVRWatchdogProvider { public: - /** Returns the device class of a tracked device. If there has not been a device connected in this slot - * since the application started this function will return TrackedDevice_Invalid. For previous detected - * devices the function will return the previously observed device class. - * - * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check - * the device class. Every device with something other than TrackedDevice_Invalid is associated with an - * actual tracked device. */ - virtual ETrackedDeviceClass GetTrackedDeviceClass( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0; + /** initializes the driver in watchdog mode. */ + virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; + + /** cleans up the driver right before it is unloaded */ + virtual void Cleanup() = 0; +}; - /** Returns true if there is a device connected in this slot. */ - virtual bool IsTrackedDeviceConnected( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0; +static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001"; - /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */ - virtual bool GetBoolTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; - /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */ - virtual float GetFloatTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; - /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */ - virtual int32_t GetInt32TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; - /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */ - virtual uint64_t GetUint64TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0; +/** This is an optional interface drivers may implement. It will be loaded in vrcompositor.exe */ +class IVRCompositorPluginProvider +{ +public: + /** initializes the driver when used to load compositor plugins */ + virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; - /** Returns a string property. If the device index is not valid or the property is not a float type this function will - * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing - * null. Strings will generally fit in buffers of k_unTrackingStringSize characters. */ - virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0; + /** cleans up the driver right before it is unloaded */ + virtual void Cleanup() = 0; - /** always returns a pointer to a valid interface pointer of IVRSettings */ - virtual IVRSettings *GetSettings( const char *pchInterfaceVersion ) = 0; + /** Returns the versions of interfaces used by this driver */ + virtual const char * const *GetInterfaceVersions() = 0; - /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should - * cause SteamVR to start */ - virtual void WatchdogWakeUp() = 0; + /** Requests a component interface of the driver for specific functionality. The driver should return NULL + * if the requested interface or version is not supported. */ + virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0; }; +static const char *IVRCompositorPluginProvider_Version = "IVRCompositorPluginProvider_001"; + +} +// ivrproperties.h +#include +#include + +namespace vr +{ + + /** This container is automatically created before a display redirect device is activated. + * Any properties in this container will be returned when that property is read from the HMD's + * property container. */ + static const PropertyContainerHandle_t k_ulDisplayRedirectContainer = 0x600000003; + + enum EPropertyWriteType + { + PropertyWrite_Set = 0, + PropertyWrite_Erase = 1, + PropertyWrite_SetError = 2 + }; -/** Defines the mode that the client driver should start in. */ -enum EClientDriverMode + struct PropertyWrite_t + { + ETrackedDeviceProperty prop; + EPropertyWriteType writeType; + ETrackedPropertyError eSetError; + void *pvBuffer; + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + ETrackedPropertyError eError; + }; + + struct PropertyRead_t + { + ETrackedDeviceProperty prop; + void *pvBuffer; + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + uint32_t unRequiredBufferSize; + ETrackedPropertyError eError; + }; + + +class IVRProperties { - ClientDriverMode_Normal = 0, - ClientDriverMode_Watchdog = 1, // client should return VRInitError_Init_LowPowerWatchdogNotSupported if it can't support this mode +public: + + /** Reads a set of properties atomically. See the PropertyReadBatch_t struct for more information. */ + virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0; + + /** Writes a set of properties atomically. See the PropertyWriteBatch_t struct for more information. */ + virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0; + + /** returns a string that corresponds with the specified property error. The string will be the name + * of the error enum value for all valid error codes */ + virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0; + + /** Returns a container handle given a tracked device index */ + virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) = 0; }; +static const char * const IVRProperties_Version = "IVRProperties_001"; -/** This interface must be implemented in each driver. It will be loaded in vrclient.dll */ -class IClientTrackedDeviceProvider +class CVRPropertyHelpers { public: - /** initializes the driver. This will be called before any other methods are called, - * except BIsHmdPresent(). BIsHmdPresent is called outside of the Init/Cleanup pair. - * If Init returns anything other than VRInitError_None the driver DLL will be unloaded. - * - * pDriverHost will never be NULL, and will always be a pointer to a IClientDriverHost interface - * - * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user - * config files. - * pchDriverInstallDir - The absolute path of the root directory for the driver. - */ - virtual EVRInitError Init( EClientDriverMode eDriverMode, IDriverLog *pDriverLog, vr::IClientDriverHost *pDriverHost, const char *pchUserDriverConfigDir, const char *pchDriverInstallDir ) = 0; + CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProperties ) {} + + /** Returns a scaler property. If the device index is not valid or the property value type does not match, + * this function will return false. */ + bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + HmdVector2_t GetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + HmdVector3_t GetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + HmdVector4_t GetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + double GetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); + + /** Returns a single typed property. If the device index is not valid or the property is not a string type this function will + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ + uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L ); - /** cleans up the driver right before it is unloaded */ - virtual void Cleanup() = 0; - /** Called when the client needs to inform an application if an HMD is attached that uses - * this driver. This method should be as lightweight as possible and should have no side effects - * such as hooking process functions or leaving resources loaded. Init will not be called before - * this method and Cleanup will not be called after it. - */ - virtual bool BIsHmdPresent( const char *pchUserConfigDir ) = 0; + /** Returns a string property. If the device index is not valid or the property is not a string type this function will + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ + uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ); - /** called when the client inits an HMD to let the client driver know which one is in use */ - virtual EVRInitError SetDisplayId( const char *pchDisplayId ) = 0; + /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will + * return an empty string. */ + std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr ); - /** Returns the stencil mesh information for the current HMD. If this HMD does not have a stencil mesh the vertex data and count will be - * NULL and 0 respectively. This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering - * each eye's view. The pixels covered by this mesh will never be seen by the user after the lens distortion is applied and based on visibility to the panels. - * This will improve perf by letting the GPU early-reject pixels the user will never see before running the pixel shader. - * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye. - */ - virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye ) = 0; + /** Reads a std::vector of data from a property. */ + template< typename T> + ETrackedPropertyError GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector *pvecResults ); - /** Get the MC image for the current HMD. - * Returns the size in bytes of the buffer required to hold the specified resource. */ - virtual uint32_t GetMCImage( uint32_t *pImgWidth, uint32_t *pImgHeight, uint32_t *pChannels, void *pDataBuffer, uint32_t unBufferLen ) = 0; + /** Sets a scaler property. The new value will be returned on any subsequent call to get this property in any process. */ + ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue ); + ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue ); + ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ); + ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue ); + ETrackedPropertyError SetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector2_t & vNewValue ); + ETrackedPropertyError SetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector3_t & vNewValue ); + ETrackedPropertyError SetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector4_t & vNewValue ); + ETrackedPropertyError SetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, double vNewValue ); + + /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */ + ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue ); + + /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */ + ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag ); + + /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */ + ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError ); + + /** Clears any value or error set for the property. */ + ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop ); + + /* Turns a device index into a property container handle. */ + PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDevice ); } + + /** Sets a std::vector of typed data to a property. */ + template< typename T> + ETrackedPropertyError SetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector *vecProperties ); + + /** Returns true if the specified property is set on the specified container */ + bool IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError = nullptr ); +private: + template + T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag ); + + IVRProperties *m_pProperties; }; -static const char *IClientTrackedDeviceProvider_Version = "IClientTrackedDeviceProvider_004"; +inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError ) +{ + PropertyRead_t batch; + batch.prop = prop; + batch.pvBuffer = pvBuffer; + batch.unBufferSize = unBufferSize; + + m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 ); + + if ( pError ) + { + *pError = batch.eError; + } + + if ( punTag ) + { + *punTag = batch.unTag; + } + + return batch.unRequiredBufferSize; } +/** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */ +inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag ) +{ + PropertyWrite_t batch; + batch.writeType = PropertyWrite_Set; + batch.prop = prop; + batch.pvBuffer = pvNewValue; + batch.unBufferSize = unNewValueSize; + batch.unTag = unTag; + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); -namespace vr + return batch.eError; +} + + +/** Returns a string property. If the device index is not valid or the property is not a string type this function will +* return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing +* null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ +inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError ) { - static const char * const k_InterfaceVersions[] = + PropertyTypeTag_t unTag; + ETrackedPropertyError error; + uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue, unBufferSize, &unTag, &error ); + if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success ) { - IVRSettings_Version, - ITrackedDeviceServerDriver_Version, - IVRDisplayComponent_Version, - IVRDriverDirectModeComponent_Version, - IVRControllerComponent_Version, - IVRCameraComponent_Version, - IServerTrackedDeviceProvider_Version, - IClientTrackedDeviceProvider_Version, - nullptr + error = TrackedProp_WrongDataType; + } + + if ( pError ) + { + *pError = error; + } + + if ( error != TrackedProp_Success ) + { + if ( pchValue && unBufferSize ) + { + *pchValue = '\0'; + } + } + + return unRequiredSize; +} + + +/** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will +* return an empty string. */ +inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError ) +{ + char buf[1024]; + vr::ETrackedPropertyError err; + uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf, sizeof(buf), &err ); + + std::string sResult; + + if ( err == TrackedProp_Success ) + { + sResult = buf; + } + else if ( err == TrackedProp_BufferTooSmall ) + { + char *pchBuffer = new char[unRequiredBufferLen]; + unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchBuffer, unRequiredBufferLen, &err ); + sResult = pchBuffer; + delete[] pchBuffer; + } + + if ( peError ) + { + *peError = err; + } + + return sResult; +} + + +/** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */ +inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue ) +{ + if ( !pchNewValue ) + return TrackedProp_InvalidOperation; + + // this is strlen without the dependency on string.h + const char *pchCurr = pchNewValue; + while ( *pchCurr ) + { + pchCurr++; + } + + return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint32_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag ); +} + + +template +inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag ) +{ + T bValue; + ETrackedPropertyError eError; + PropertyTypeTag_t unReadTag; + GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unReadTag, &eError ); + if ( unReadTag != unTypeTag && eError == TrackedProp_Success ) + { + eError = TrackedProp_WrongDataType; }; + + if ( pError ) + *pError = eError; + if ( eError != TrackedProp_Success ) + { + return bDefault; + } + else + { + return bValue; + } +} + + +inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + return GetPropertyHelper( ulContainerHandle, prop, pError, false, k_unBoolPropertyTag ); +} + +inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + return GetPropertyHelper( ulContainerHandle, prop, pError, 0.f, k_unFloatPropertyTag ); +} + +inline double CVRPropertyHelpers::GetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + return GetPropertyHelper( ulContainerHandle, prop, pError, 0., k_unDoublePropertyTag ); +} + +inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + return GetPropertyHelper( ulContainerHandle, prop, pError, 0, k_unInt32PropertyTag ); +} + +inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + return GetPropertyHelper( ulContainerHandle, prop, pError, 0, k_unUint64PropertyTag ); +} + +inline HmdVector2_t CVRPropertyHelpers::GetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + HmdVector2_t defaultval = { 0 }; + return GetPropertyHelper( ulContainerHandle, prop, pError, defaultval, k_unHmdVector2PropertyTag ); +} + +inline HmdVector3_t CVRPropertyHelpers::GetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + HmdVector3_t defaultval = { 0 }; + return GetPropertyHelper( ulContainerHandle, prop, pError, defaultval, k_unHmdVector3PropertyTag ); +} + +inline HmdVector4_t CVRPropertyHelpers::GetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) +{ + HmdVector4_t defaultval = { 0 }; + return GetPropertyHelper( ulContainerHandle, prop, pError, defaultval, k_unHmdVector4PropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue ) +{ + return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewValue ), k_unBoolPropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue ) +{ + return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unFloatPropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, double fNewValue ) +{ + return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unDoublePropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ) +{ + return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewValue ), k_unInt32PropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue ) +{ + return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewValue ), k_unUint64PropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector2_t & vNewValue ) +{ + return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector2_t ), k_unHmdVector2PropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector3_t & vNewValue ) +{ + return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector3_t ), k_unHmdVector3PropertyTag ); +} + +inline ETrackedPropertyError CVRPropertyHelpers::SetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector4_t & vNewValue ) +{ + return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector4_t ), k_unHmdVector4PropertyTag ); +} + +/** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */ +inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError ) +{ + PropertyWrite_t batch; + batch.writeType = PropertyWrite_SetError; + batch.prop = prop; + batch.eSetError = eError; + + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); + + return batch.eError; +} + +/** Clears any value or error set for the property. */ +inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop ) +{ + PropertyWrite_t batch; + batch.writeType = PropertyWrite_Erase; + batch.prop = prop; + + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); + + return batch.eError; + +} + +template< typename T > +ETrackedPropertyError CVRPropertyHelpers::SetPropertyVector(PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, PropertyTypeTag_t unTag, std::vector *pvecProperties) +{ + return SetProperty( ulContainer, prop, &(*pvecProperties)[0], (uint32_t)(pvecProperties->size() * sizeof( T )), unTag ); +} + +template< typename T > +ETrackedPropertyError CVRPropertyHelpers::GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector *pvecResults ) +{ + ETrackedPropertyError err; + PropertyTypeTag_t unTag; + uint32_t unNeeded; + if ( pvecResults->empty() ) + unNeeded = GetProperty( ulContainer, prop, nullptr, 0, &unTag, &err ); + else + unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err ); + uint32_t unFound = unNeeded / sizeof( T ); + if ( err == TrackedProp_Success ) + { + if ( unTag != unExpectedTag && unFound > 0 ) + { + return TrackedProp_WrongDataType; + } + + pvecResults->resize( unFound ); + return TrackedProp_Success; + } + else if ( err == TrackedProp_BufferTooSmall ) + { + pvecResults->resize( unFound ); + unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err ); + unFound = unNeeded / sizeof( T ); + + if ( err == TrackedProp_Success ) + { + if ( unTag != unExpectedTag ) + { + return TrackedProp_WrongDataType; + } + + pvecResults->resize( unFound ); + return TrackedProp_Success; + } + } + return err; +} + +inline bool CVRPropertyHelpers::IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError ) +{ + ETrackedPropertyError error; + GetProperty( ulContainer, prop, nullptr, 0, nullptr, &error ); + if ( peError ) + *peError = error; + return error == TrackedProp_Success || error == TrackedProp_BufferTooSmall; +} + +} + + + +// ivrdriverinput.h +namespace vr +{ + + typedef uint64_t VRInputComponentHandle_t; + static const VRInputComponentHandle_t k_ulInvalidInputComponentHandle = 0; + + enum EVRScalarType + { + VRScalarType_Absolute = 0, + VRScalarType_Relative = 1, + }; + + + enum EVRScalarUnits + { + VRScalarUnits_NormalizedOneSided = 0, // Value ranges from 0 to 1 + VRScalarUnits_NormalizedTwoSided = 1, // Value ranges from -1 to 1 + }; + + class IVRDriverInput + { + public: + + /** Creates a boolean input component for the device */ + virtual EVRInputError CreateBooleanComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0; + + /** Updates a boolean component */ + virtual EVRInputError UpdateBooleanComponent( VRInputComponentHandle_t ulComponent, bool bNewValue, double fTimeOffset ) = 0; + + /** Creates a scalar input component for the device */ + virtual EVRInputError CreateScalarComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle, EVRScalarType eType, EVRScalarUnits eUnits ) = 0; + + /** Updates a boolean component */ + virtual EVRInputError UpdateScalarComponent( VRInputComponentHandle_t ulComponent, float fNewValue, double fTimeOffset ) = 0; + + /** 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, EVRSkeletalTrackingLevel eSkeletalTrackingLevel, const VRBoneTransform_t *pGripLimitTransforms, uint32_t unGripLimitTransformCount, VRInputComponentHandle_t *pHandle ) = 0; + + /** Updates a skeleton component. */ + virtual EVRInputError UpdateSkeletonComponent( VRInputComponentHandle_t ulComponent, EVRSkeletalMotionRange eMotionRange, const VRBoneTransform_t *pTransforms, uint32_t unTransformCount ) = 0; + + }; + + static const char * const IVRDriverInput_Version = "IVRDriverInput_003"; + +} // namespace vr + +// ivrdriverlog.h +namespace vr +{ + +class IVRDriverLog +{ +public: + /** Writes a log message to the log file prefixed with the driver name */ + virtual void Log( const char *pchLogMessage ) = 0; +}; + + +static const char *IVRDriverLog_Version = "IVRDriverLog_001"; + +} +// ivrserverdriverhost.h +namespace vr +{ + +class ITrackedDeviceServerDriver; +struct TrackedDeviceDriverInfo_t; +struct DriverPose_t; + +/** This interface is provided by vrserver to allow the driver to notify +* the system when something changes about a device. These changes must +* not change the serial number or class of the device because those values +* are permanently associated with the device's index. */ +class IVRServerDriverHost +{ +public: + /** Notifies the server that a tracked device has been added. If this function returns true + * the server will call Activate on the device. If it returns false some kind of error + * has occurred and the device will not be activated. */ + virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETrackedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0; + + /** Notifies the server that a tracked device's pose has been updated */ + virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose, uint32_t unPoseStructSize ) = 0; + + /** Notifies the server that vsync has occurred on the the display attached to the device. This is + * only permitted on devices of the HMD class. */ + virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0; + + /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */ + virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0; + + /** Returns true if SteamVR is exiting */ + virtual bool IsExiting() = 0; + + /** Returns true and fills the event with the next event on the queue if there is one. If there are no events + * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */ + virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0; + + /** Provides access to device poses for drivers. Poses are in their "raw" tracking space which is uniquely + * defined by each driver providing poses for its devices. It is up to clients of this function to correlate + * poses across different drivers. Poses are indexed by their device id, and their associated driver and + * other properties can be looked up via IVRProperties. */ + virtual void GetRawTrackedDevicePoses( float fPredictedSecondsFromNow, TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0; + + /** Notifies the server that a tracked device's display component transforms have been updated. */ + virtual void TrackedDeviceDisplayTransformUpdated( uint32_t unWhichDevice, HmdMatrix34_t eyeToHeadLeft, HmdMatrix34_t eyeToHeadRight ) = 0; + + /** Requests that SteamVR be restarted. The provided reason will be displayed to the user and should be in the current locale. */ + virtual void RequestRestart( const char *pchLocalizedReason, const char *pchExecutableToStart, const char *pchArguments, const char *pchWorkingDirectory ) = 0; + + /** Interface for copying a range of timing data. Frames are returned in ascending order (oldest to newest) with the last being the most recent frame. + * Only the first entry's m_nSize needs to be set, as the rest will be inferred from that. Returns total number of entries filled out. */ + virtual uint32_t GetFrameTimings( Compositor_FrameTiming *pTiming, uint32_t nFrames ) = 0; +}; + +static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_005"; + +} + +// ivrcompositordriverhost.h +namespace vr +{ + +class IVRCompositorDriverHost +{ +public: + /** Returns true and fills the event with the next event on the queue if there is one. If there are no events + * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */ + virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0; +}; + +static const char *IVRCompositorDriverHost_Version = "IVRCompositorDriverHost_001"; + +} + +// ivrhiddenarea.h +namespace vr +{ + +class CVRHiddenAreaHelpers +{ +public: + CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pProperties ) {} + + /** Stores a hidden area mesh in a property */ + ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount ); + + /** retrieves a hidden area mesh from a property. Returns the vert count read out of the property. */ + uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError ); + +private: + ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType type ) + { + return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_Start + ((int)type * 2) + (int)eEye); + } + + IVRProperties *m_pProperties; +}; + + +inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount ) +{ + ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); + CVRPropertyHelpers propHelpers( m_pProperties ); + return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVertCount, k_unHiddenAreaPropertyTag ); +} + + +inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError ) +{ + ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); + CVRPropertyHelpers propHelpers( m_pProperties ); + ETrackedPropertyError propError; + PropertyTypeTag_t unTag; + uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t )*unVertCount, &unTag, &propError ); + if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaPropertyTag ) + { + propError = TrackedProp_WrongDataType; + unBytesNeeded = 0; + } + + if ( peError ) + { + *peError = propError; + } + + return unBytesNeeded / sizeof( HmdVector2_t ); +} + +} +// ivrwatchdoghost.h +namespace vr +{ + +/** This interface is provided by vrclient to allow the driver to make everything wake up */ +class IVRWatchdogHost +{ +public: + /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should + * cause SteamVR to start */ + virtual void WatchdogWakeUp( vr::ETrackedDeviceClass eDeviceClass ) = 0; +}; + +static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_002"; + +}; + + + +// ivrvirtualdisplay.h +namespace vr +{ + struct PresentInfo_t + { + SharedTextureHandle_t backbufferTextureHandle; + EVSync vsync; + uint64_t nFrameId; + double flVSyncTimeInSeconds; + }; + + // ---------------------------------------------------------------------------------------------- + // Purpose: This component is used for drivers that implement a virtual display (e.g. wireless). + // ---------------------------------------------------------------------------------------------- + class IVRVirtualDisplay + { + public: + + /** Submits final backbuffer for display. */ + virtual void Present( const PresentInfo_t *pPresentInfo, uint32_t unPresentInfoSize ) = 0; + + /** Block until the last presented buffer start scanning out. */ + virtual void WaitForPresent() = 0; + + /** Provides timing data for synchronizing with display. */ + virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0; + }; + + static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_002"; +} + + +// ivrresources.h +namespace vr +{ + +class IVRResources +{ +public: + + // ------------------------------------ + // Shared Resource Methods + // ------------------------------------ + + /** Loads the specified resource into the provided buffer if large enough. + * Returns the size in bytes of the buffer required to hold the specified resource. */ + virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0; + + /** Provides the full path to the specified resource. Resource names can include named directories for + * drivers and other things, and this resolves all of those and returns the actual physical path. + * pchResourceTypeDirectory is the subdirectory of resources to look in. */ + virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0; +}; + +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; + + /** inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes. */ + virtual bool HasReaders( vr::IOBufferHandle_t ulBuffer ) = 0; + }; + + static const char *IVRIOBuffer_Version = "IVRIOBuffer_002"; +} + +// ivrdrivermanager.h +namespace vr +{ + +class IVRDriverManager +{ +public: + virtual uint32_t GetDriverCount() const = 0; + + /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */ + virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; + + virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0; + + virtual bool IsEnabled( vr::DriverId_t nDriver ) const = 0; +}; + +static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; + +} // namespace vr + + + +// ivrdriverspatialanchors.h +namespace vr +{ + struct SpatialAnchorDriverPose_t + { + /** This position is in the same "world" space (+Y up) as provided by DriverPose_t. */ + vr::HmdQuaternion_t qWorldRotation; + vr::HmdVector3d_t vWorldTranslation; + + /** The pose will automatically start returning VRSpatialAnchorError_NotAvailableInThisUniverse + * if this is nonzero and does not match the current universe ID. */ + uint64_t ulRequiredUniverseId; + + /** When this time expires, SteamVR will start generating + * VREvent_SpatialAnchors_RequestPoseUpdate when the pose is read by an application + * to let the driver know it is still worth updating. + * You can use this facility in several ways: + * 1. Set to -1 to never receive an update request for this pose. The driver + * may still update poses at any time. + * 2. Set to 0 to always receive an update request *after* each time the pose + * is read. The rate of requests could be very high if the application gets + * the pose at framerate. + * 3. If the driver knows there is no reason to update the pose for some amount of + * time, it can set that time here and receive the update request reminder later. + * 4. If the driver plans to automatically update this pose for some amount of time + * (as it gets better information about the virtual location of this anchor) it can + * set that duration here to indicate that no "update requested" reminders are needed. + * When that automatic update period expires, any future interest in the pose will + * be indicated by a pose update request. + * The driver may always update the pose, including during the valid duration. */ + double fValidDuration; // seconds + }; + + class IVRDriverSpatialAnchors + { + public: + + /* NOTE: You must declare support for spatial anchors in your driver manifest. Add + * "spatialAnchorsSupport": true to your manifest. Without that setting, SteamVR + * will short-circuit anchor requests from applications and provide a generic descriptor + * that does not have any of the advantages of true spatial anchors. */ + + /* The driver should monitor for events VREvent_SpatialAnchors_RequestPoseUpdate (for new + * descriptors from applications that need UpdateSpatialAnchorPose()) and for + * VREvent_SpatialAnchors_RequestDescriptorUpdate (for new poses that need UpdateSpatialAnchorDescriptor()). + * For automatic pose updates over time, the driver should keep track of the handles it + * has seen and provide updates when conditions change. If the driver uses fValidDuration, + * it may wait for VREvent_SpatialAnchors_RequestPoseUpdate instead of keeping track itself. */ + + /** Update a pose for a spatial anchor. Should be called when an event notifies the driver that a + * new descriptor has been registered by an application. May be called for any anchor whenever the + * driver has better information about the best virtual coordinate to represent the anchor. Should + * be called on all active handles whenever driver state changes in a way that changes how physical + * world locations map to virtual coordinates (e.g. anything that would cause a universe ID change). + * This fires an event when it is called for the first time (to alert whoever submitted the descriptor). */ + virtual EVRSpatialAnchorError UpdateSpatialAnchorPose( SpatialAnchorHandle_t unHandle, const SpatialAnchorDriverPose_t *pPose ) = 0; + + /** Invalidate any pose associated with the handle and cause future calls to GetSpatialAnchorPose (on + * both the client and driver side) to return the specified error. eError must be one of + * VRSpatialAnchorError_NotYetAvailable, VRSpatialAnchorError_NotAvailableInThisUniverse, or + * VRSpatialAnchorError_PermanentlyUnavailable */ + virtual EVRSpatialAnchorError SetSpatialAnchorPoseError( SpatialAnchorHandle_t unHandle, EVRSpatialAnchorError eError, double fValidDuration ) = 0; + + /** Update the descriptor for a spatial anchor. Should be called when an event notifies the driver + * that a new pose has been registered by an application. May be called for any anchor whenever the + * driver has better or additional information it wants to include in the anchor descriptor. Note, + * however, that the application may never fetch the updated anchor descriptor and may request the + * original descriptor in a future session having ignored the update. + * The supplied descriptor should be only the driver's opaque internal data, not the decorated form that + * is used by clients (wrapped by runtime metadata). The descriptor must not contain non-ASCII characters or + * the two special characters ~ or " + * This fires an event every time it is called. */ + virtual EVRSpatialAnchorError UpdateSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, const char *pchDescriptor ) = 0; + + /** Get the pose for a given handle. */ + virtual EVRSpatialAnchorError GetSpatialAnchorPose( SpatialAnchorHandle_t unHandle, SpatialAnchorDriverPose_t *pDriverPoseOut ) = 0; + + /** Get the descriptor for a given handle. This will be VRSpatialAnchorError_NotYetAvailable for handles + * where the driver has not yet built a descriptor. It will be the application-supplied descriptor for previously + * saved anchors that the application is requesting poses for. If the driver has called UpdateSpatialAnchorDescriptor() + * already in this session, it will be the descriptor provided by the driver. + * If bDecorated, returns the descriptor wrapped with runtime metadata suitable for a client to save. Else returns only + * the driver's opaque internal data. + */ + virtual EVRSpatialAnchorError GetSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, VR_OUT_STRING() char *pchDescriptorOut, uint32_t *punDescriptorBufferLenInOut, bool bDecorated ) = 0; + + }; + + static const char * const IVRDriverSpatialAnchors_Version = "IVRDriverSpatialAnchors_001"; + +} // namespace vr + + + +namespace vr +{ +#if !defined( OPENVR_INTERFACE_INTERNAL ) + static const char * const k_InterfaceVersions[] = + { + IVRSettings_Version, + ITrackedDeviceServerDriver_Version, + IVRDisplayComponent_Version, + IVRDriverDirectModeComponent_Version, + IVRCameraComponent_Version, + IServerTrackedDeviceProvider_Version, + IVRWatchdogProvider_Version, + IVRVirtualDisplay_Version, + IVRDriverManager_Version, + IVRResources_Version, + IVRCompositorPluginProvider_Version, + nullptr + }; + + inline IVRDriverContext *&VRDriverContext() + { + static IVRDriverContext *pHost; + return pHost; + } + + class COpenVRDriverContext + { + public: + COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAreaHelpers(nullptr) { Clear(); } + void Clear(); + + EVRInitError InitServer(); + EVRInitError InitWatchdog(); + EVRInitError InitCompositor(); + + IVRSettings *VRSettings() + { + if ( m_pVRSettings == nullptr ) + { + EVRInitError eError; + m_pVRSettings = (IVRSettings *)VRDriverContext()->GetGenericInterface( IVRSettings_Version, &eError ); + } + return m_pVRSettings; + } + + IVRProperties *VRPropertiesRaw() + { + if ( m_pVRProperties == nullptr ) + { + EVRInitError eError; + m_pVRProperties = (IVRProperties *)VRDriverContext()->GetGenericInterface( IVRProperties_Version, &eError ); + m_propertyHelpers = CVRPropertyHelpers( m_pVRProperties ); + m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pVRProperties ); + } + return m_pVRProperties; + } + + CVRPropertyHelpers *VRProperties() + { + VRPropertiesRaw(); + return &m_propertyHelpers; + } + + CVRHiddenAreaHelpers *VRHiddenArea() + { + VRPropertiesRaw(); + return &m_hiddenAreaHelpers; + } + + IVRServerDriverHost *VRServerDriverHost() + { + if ( m_pVRServerDriverHost == nullptr ) + { + EVRInitError eError; + m_pVRServerDriverHost = (IVRServerDriverHost *)VRDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError ); + } + return m_pVRServerDriverHost; + } + + IVRWatchdogHost *VRWatchdogHost() + { + if ( m_pVRWatchdogHost == nullptr ) + { + EVRInitError eError; + m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverContext()->GetGenericInterface( IVRWatchdogHost_Version, &eError ); + } + return m_pVRWatchdogHost; + } + + IVRCompositorDriverHost *VRCompositorDriverHost() + { + if ( m_pVRCompositorDriverHost == nullptr ) + { + EVRInitError eError; + m_pVRCompositorDriverHost = ( IVRCompositorDriverHost * )VRDriverContext()->GetGenericInterface( IVRCompositorDriverHost_Version, &eError ); + } + return m_pVRCompositorDriverHost; + } + + IVRDriverLog *VRDriverLog() + { + if ( m_pVRDriverLog == nullptr ) + { + EVRInitError eError; + m_pVRDriverLog = (IVRDriverLog *)VRDriverContext()->GetGenericInterface( IVRDriverLog_Version, &eError ); + } + return m_pVRDriverLog; + } + + DriverHandle_t VR_CALLTYPE VRDriverHandle() + { + return VRDriverContext()->GetDriverHandle(); + } + + IVRDriverManager *VRDriverManager() + { + if ( !m_pVRDriverManager ) + { + EVRInitError eError; + m_pVRDriverManager = (IVRDriverManager *)VRDriverContext()->GetGenericInterface( IVRDriverManager_Version, &eError ); + } + return m_pVRDriverManager; + } + + IVRResources *VRResources() + { + if ( !m_pVRResources ) + { + EVRInitError eError; + m_pVRResources = (IVRResources *)VRDriverContext()->GetGenericInterface( IVRResources_Version, &eError ); + } + return m_pVRResources; + } + + IVRDriverInput *VRDriverInput() + { + if ( !m_pVRDriverInput ) + { + EVRInitError eError; + m_pVRDriverInput = (IVRDriverInput *)VRDriverContext()->GetGenericInterface( IVRDriverInput_Version, &eError ); + } + return m_pVRDriverInput; + } + + IVRIOBuffer *VRIOBuffer() + { + if ( !m_pVRIOBuffer ) + { + EVRInitError eError; + m_pVRIOBuffer = (IVRIOBuffer *)VRDriverContext()->GetGenericInterface( IVRIOBuffer_Version, &eError ); + } + return m_pVRIOBuffer; + } + + IVRDriverSpatialAnchors *VRDriverSpatialAnchors() + { + if ( !m_pVRDriverSpatialAnchors ) + { + EVRInitError eError; + m_pVRDriverSpatialAnchors = (IVRDriverSpatialAnchors *)VRDriverContext()->GetGenericInterface( IVRDriverSpatialAnchors_Version, &eError ); + } + return m_pVRDriverSpatialAnchors; + } + + private: + CVRPropertyHelpers m_propertyHelpers; + CVRHiddenAreaHelpers m_hiddenAreaHelpers; + + IVRSettings *m_pVRSettings; + IVRProperties *m_pVRProperties; + IVRServerDriverHost *m_pVRServerDriverHost; + IVRWatchdogHost *m_pVRWatchdogHost; + IVRCompositorDriverHost *m_pVRCompositorDriverHost; + IVRDriverLog *m_pVRDriverLog; + IVRDriverManager *m_pVRDriverManager; + IVRResources *m_pVRResources; + IVRDriverInput *m_pVRDriverInput; + IVRIOBuffer *m_pVRIOBuffer; + IVRDriverSpatialAnchors *m_pVRDriverSpatialAnchors; + }; + + inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext() + { + static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void * )]; + return *(COpenVRDriverContext *)ctx; // bypass zero-init constructor + } + + inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleServerDriverContext().VRSettings(); } + inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInternal_ModuleServerDriverContext().VRPropertiesRaw(); } + inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInternal_ModuleServerDriverContext().VRProperties(); } + inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRInternal_ModuleServerDriverContext().VRHiddenArea(); } + inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_ModuleServerDriverContext().VRDriverLog(); } + inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRServerDriverHost(); } + inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInternal_ModuleServerDriverContext().VRWatchdogHost(); } + inline IVRCompositorDriverHost *VR_CALLTYPE VRCompositorDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRCompositorDriverHost(); } + inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRInternal_ModuleServerDriverContext().VRDriverHandle(); } + 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 IVRDriverSpatialAnchors *VR_CALLTYPE VRDriverSpatialAnchors() { return OpenVRInternal_ModuleServerDriverContext().VRDriverSpatialAnchors(); } + + inline void COpenVRDriverContext::Clear() + { + m_pVRSettings = nullptr; + m_pVRProperties = nullptr; + m_pVRServerDriverHost = nullptr; + m_pVRWatchdogHost = nullptr; + m_pVRCompositorDriverHost = nullptr; + m_pVRDriverLog = nullptr; + m_pVRDriverManager = nullptr; + m_pVRResources = nullptr; + m_pVRDriverInput = nullptr; + m_pVRIOBuffer = nullptr; + m_pVRDriverSpatialAnchors = nullptr; + } + + inline EVRInitError COpenVRDriverContext::InitServer() + { + Clear(); + if ( !VRServerDriverHost() + || !VRSettings() + || !VRProperties() + || !VRDriverLog() + || !VRDriverManager() + || !VRResources() ) + return VRInitError_Init_InterfaceNotFound; + return VRInitError_None; + } + + inline EVRInitError COpenVRDriverContext::InitWatchdog() + { + Clear(); + if ( !VRWatchdogHost() + || !VRSettings() + || !VRDriverLog() ) + return VRInitError_Init_InterfaceNotFound; + return VRInitError_None; + } + + inline EVRInitError COpenVRDriverContext::InitCompositor() + { + Clear(); + if ( !VRCompositorDriverHost() + || !VRSettings() + || !VRProperties() + || !VRDriverLog() + || !VRDriverManager() + || !VRResources() ) + return VRInitError_Init_InterfaceNotFound; + return VRInitError_None; + } + + inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext ) + { + VRDriverContext() = pContext; + return OpenVRInternal_ModuleServerDriverContext().InitServer(); + } + + inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContext ) + { + VRDriverContext() = pContext; + return OpenVRInternal_ModuleServerDriverContext().InitWatchdog(); + } + + inline EVRInitError InitCompositorDriverContext( IVRDriverContext *pContext ) + { + VRDriverContext() = pContext; + return OpenVRInternal_ModuleServerDriverContext().InitCompositor(); + } + + inline void CleanupDriverContext() + { + VRDriverContext() = nullptr; + OpenVRInternal_ModuleServerDriverContext().Clear(); + } + + #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \ + { \ + vr::EVRInitError eError = vr::InitServerDriverContext( pContext ); \ + if( eError != vr::VRInitError_None ) \ + return eError; \ + } + + #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \ + vr::CleanupDriverContext(); + + #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \ + { \ + vr::EVRInitError eError = vr::InitWatchdogDriverContext( pContext ); \ + if( eError != vr::VRInitError_None ) \ + return eError; \ + } + + #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \ + vr::CleanupDriverContext(); + +#define VR_INIT_COMPOSITOR_DRIVER_CONTEXT( pContext ) \ + { \ + vr::EVRInitError eError = vr::InitCompositorDriverContext( pContext ); \ + if( eError != vr::VRInitError_None ) \ + return eError; \ + } + +#define VR_CLEANUP_COMPOSITOR_DRIVER_CONTEXT() \ + vr::CleanupDriverContext(); + + +#endif // OPENVR_INTERFACE_INTERNAL + } // End diff --git a/ext/OpenVR/lib/msw/x64/openvr_api.lib b/ext/OpenVR/lib/msw/x64/openvr_api.lib index abb60cf..3b95d6b 100644 Binary files a/ext/OpenVR/lib/msw/x64/openvr_api.lib and b/ext/OpenVR/lib/msw/x64/openvr_api.lib differ diff --git a/ext/OpenVR/lib/msw/x86/openvr_api.lib b/ext/OpenVR/lib/msw/x86/openvr_api.lib index dd0ad21..b61a5a0 100644 Binary files a/ext/OpenVR/lib/msw/x86/openvr_api.lib and b/ext/OpenVR/lib/msw/x86/openvr_api.lib differ diff --git a/include/cinder/vr/Hmd.h b/include/cinder/vr/Hmd.h index 11ae95e..7e0b5ee 100644 --- a/include/cinder/vr/Hmd.h +++ b/include/cinder/vr/Hmd.h @@ -98,6 +98,7 @@ class Hmd { const ci::vr::CameraEye& getEyeCamera( ci::vr::Eye eye ) const; ci::mat4 getEyeViewMatrix( ci::vr::Eye eye ) const; + ci::mat4 getEyePoseMatrix( ci::vr::Eye eye ) const; ci::mat4 getEyeProjectionMatrix( ci::vr::Eye eye ) const; ci::mat4 getEyeViewProjectionMatrix( ci::vr::Eye eye ) const; virtual ci::Area getEyeViewport( ci::vr::Eye eye ) const = 0; @@ -153,6 +154,7 @@ class Hmd { std::vector mEyes; ci::vr::CameraEye mEyeCamera[ci::vr::EYE_COUNT]; ci::vr::CameraEye mHmdCamera; + ci::mat4 mEyePoseMatrix[ci::vr::EYE_COUNT]; ci::mat4 mDeviceToTrackingMatrix; ci::mat4 mTrackingToDeviceMatrix; diff --git a/include/cinder/vr/SessionOptions.h b/include/cinder/vr/SessionOptions.h index af5c52c..e548082 100644 --- a/include/cinder/vr/SessionOptions.h +++ b/include/cinder/vr/SessionOptions.h @@ -38,9 +38,12 @@ #pragma once +#include "cinder/vr/Controller.h" #include "cinder/vr/Platform.h" +#include "cinder/Surface.h" #include +#include namespace cinder { namespace vr { @@ -92,7 +95,9 @@ class SessionOptions { SessionOptions& setControllerConnected( std::function value ) { mControllerConnected = value; return *this; } std::function getControllerDisconnected() const { return mControllerDisconnected; } SessionOptions& setControllerDisconnected( std::function value ) { mControllerDisconnected = value; return *this; } - + + const ci::Surface8uRef getHandIcon( ci::vr::Controller::Type type ) const; + SessionOptions& setHandIcon( ci::vr::Controller::Type type, const ci::Surface8uRef& surf ); private: bool mVerticalSync = false; float mFrameRate = 90.0f; @@ -101,6 +106,8 @@ class SessionOptions { ci::vr::OriginMode mOriginMode = ci::vr::ORIGIN_MODE_HMD_ORIENTED; ci::vec3 mOriginOffset = ci::vec3( 0, 0, -1 ); + std::map mHandIcons; + uint32_t mSampleCount = 1; uint32_t mMipLevels = 1; diff --git a/include/cinder/vr/oculus/Hmd.h b/include/cinder/vr/oculus/Hmd.h index 37b1534..ac6c1c2 100644 --- a/include/cinder/vr/oculus/Hmd.h +++ b/include/cinder/vr/oculus/Hmd.h @@ -136,7 +136,7 @@ class Hmd : public vr::Hmd { ::ovrEyeRenderDesc mEyeRenderDesc[ovrEye_Count]; ::ovrPosef mEyeRenderPose[ovrEye_Count]; - ::ovrVector3f mEyeViewOffset[ovrEye_Count]; + ::ovrPosef mEyeViewPose[ovrEye_Count]; ::ovrLayerEyeFov mBaseLayer; ::ovrTextureSwapChain mTextureSwapChain = nullptr; diff --git a/include/cinder/vr/openvr/Hmd.h b/include/cinder/vr/openvr/Hmd.h index 4d5f914..8358768 100644 --- a/include/cinder/vr/openvr/Hmd.h +++ b/include/cinder/vr/openvr/Hmd.h @@ -121,7 +121,6 @@ class Hmd : public vr::Hmd { float mFarClip = 100.0f; ci::mat4 mEyeProjectionMatrix[ci::vr::EYE_COUNT]; - ci::mat4 mEyePoseMatrix[ci::vr::EYE_COUNT]; ci::gl::FboRef mRenderTargetLeft; ci::gl::FboRef mRenderTargetRight; diff --git a/samples/Basic/vc2013/Basic.sln b/samples/Basic/vc2015/Basic.sln similarity index 100% rename from samples/Basic/vc2013/Basic.sln rename to samples/Basic/vc2015/Basic.sln diff --git a/samples/Basic/vc2013/Basic.vcxproj b/samples/Basic/vc2015/Basic.vcxproj similarity index 89% rename from samples/Basic/vc2013/Basic.vcxproj rename to samples/Basic/vc2015/Basic.vcxproj index 1c5f38b..9b70e06 100644 --- a/samples/Basic/vc2013/Basic.vcxproj +++ b/samples/Basic/vc2015/Basic.vcxproj @@ -22,32 +22,33 @@ {09C0F333-A09A-4FFA-81AA-17FBA0649C19} Basic Win32Proj + 10.0.16299.0 Application false - v120 + v140 Unicode true Application false - v120 + v140 Unicode true Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode @@ -93,8 +94,8 @@ "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -123,8 +124,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -154,8 +155,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -187,8 +188,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows diff --git a/samples/Basic/vc2013/Basic.vcxproj.filters b/samples/Basic/vc2015/Basic.vcxproj.filters similarity index 100% rename from samples/Basic/vc2013/Basic.vcxproj.filters rename to samples/Basic/vc2015/Basic.vcxproj.filters diff --git a/samples/Basic/vc2013/Resources.rc b/samples/Basic/vc2015/Resources.rc similarity index 100% rename from samples/Basic/vc2013/Resources.rc rename to samples/Basic/vc2015/Resources.rc diff --git a/samples/ControllerBasic/vc2013/ControllerBasic.sln b/samples/ControllerBasic/vc2015/ControllerBasic.sln similarity index 100% rename from samples/ControllerBasic/vc2013/ControllerBasic.sln rename to samples/ControllerBasic/vc2015/ControllerBasic.sln diff --git a/samples/ControllerBasic/vc2013/ControllerBasic.vcxproj b/samples/ControllerBasic/vc2015/ControllerBasic.vcxproj similarity index 89% rename from samples/ControllerBasic/vc2013/ControllerBasic.vcxproj rename to samples/ControllerBasic/vc2015/ControllerBasic.vcxproj index 876b486..5f6e513 100644 --- a/samples/ControllerBasic/vc2013/ControllerBasic.vcxproj +++ b/samples/ControllerBasic/vc2015/ControllerBasic.vcxproj @@ -22,32 +22,33 @@ {09C0F333-A09A-4FFA-81AA-17FBA0649C19} Basic Win32Proj + 10.0.16299.0 Application false - v120 + v140 Unicode true Application false - v120 + v140 Unicode true Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode @@ -93,8 +94,8 @@ "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -123,8 +124,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -153,8 +154,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -186,8 +187,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows diff --git a/samples/ControllerBasic/vc2013/ControllerBasic.vcxproj.filters b/samples/ControllerBasic/vc2015/ControllerBasic.vcxproj.filters similarity index 100% rename from samples/ControllerBasic/vc2013/ControllerBasic.vcxproj.filters rename to samples/ControllerBasic/vc2015/ControllerBasic.vcxproj.filters diff --git a/samples/ControllerBasic/vc2013/Resources.rc b/samples/ControllerBasic/vc2015/Resources.rc similarity index 100% rename from samples/ControllerBasic/vc2013/Resources.rc rename to samples/ControllerBasic/vc2015/Resources.rc diff --git a/samples/ControllerIntermediate/vc2013/ControllerIntermediate.sln b/samples/ControllerIntermediate/vc2015/ControllerIntermediate.sln similarity index 100% rename from samples/ControllerIntermediate/vc2013/ControllerIntermediate.sln rename to samples/ControllerIntermediate/vc2015/ControllerIntermediate.sln diff --git a/samples/ControllerIntermediate/vc2013/ControllerIntermediate.vcxproj b/samples/ControllerIntermediate/vc2015/ControllerIntermediate.vcxproj similarity index 89% rename from samples/ControllerIntermediate/vc2013/ControllerIntermediate.vcxproj rename to samples/ControllerIntermediate/vc2015/ControllerIntermediate.vcxproj index 94617ed..dcab5b1 100644 --- a/samples/ControllerIntermediate/vc2013/ControllerIntermediate.vcxproj +++ b/samples/ControllerIntermediate/vc2015/ControllerIntermediate.vcxproj @@ -22,32 +22,33 @@ {09C0F333-A09A-4FFA-81AA-17FBA0649C19} Basic Win32Proj + 10.0.16299.0 Application false - v120 + v140 Unicode true Application false - v120 + v140 Unicode true Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode @@ -93,8 +94,8 @@ "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -123,8 +124,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -153,8 +154,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -186,8 +187,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows diff --git a/samples/ControllerIntermediate/vc2013/ControllerIntermediate.vcxproj.filters b/samples/ControllerIntermediate/vc2015/ControllerIntermediate.vcxproj.filters similarity index 100% rename from samples/ControllerIntermediate/vc2013/ControllerIntermediate.vcxproj.filters rename to samples/ControllerIntermediate/vc2015/ControllerIntermediate.vcxproj.filters diff --git a/samples/ControllerIntermediate/vc2013/Resources.rc b/samples/ControllerIntermediate/vc2015/Resources.rc similarity index 100% rename from samples/ControllerIntermediate/vc2013/Resources.rc rename to samples/ControllerIntermediate/vc2015/Resources.rc diff --git a/samples/CoordSysBasic/vc2013/CoordSysBasic.sln b/samples/CoordSysBasic/vc2015/CoordSysBasic.sln similarity index 100% rename from samples/CoordSysBasic/vc2013/CoordSysBasic.sln rename to samples/CoordSysBasic/vc2015/CoordSysBasic.sln diff --git a/samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj b/samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj similarity index 89% rename from samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj rename to samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj index 0e411ea..e5db59b 100644 --- a/samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj +++ b/samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj @@ -22,32 +22,33 @@ {09C0F333-A09A-4FFA-81AA-17FBA0649C19} Basic Win32Proj + 10.0.16299.0 Application false - v120 + v140 Unicode true Application false - v120 + v140 Unicode true Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode @@ -93,8 +94,8 @@ "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -123,8 +124,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -153,8 +154,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -186,8 +187,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -207,7 +208,6 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb - diff --git a/samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj.filters b/samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj.filters similarity index 97% rename from samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj.filters rename to samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj.filters index 9c299a8..058f2ad 100644 --- a/samples/CoordSysBasic/vc2013/CoordSysBasic.vcxproj.filters +++ b/samples/CoordSysBasic/vc2015/CoordSysBasic.vcxproj.filters @@ -18,9 +18,6 @@ Header Files - - Source Files - @@ -32,4 +29,9 @@ Resource Files + + + Source Files + + \ No newline at end of file diff --git a/samples/CoordSysBasic/vc2013/Resources.rc b/samples/CoordSysBasic/vc2015/Resources.rc similarity index 100% rename from samples/CoordSysBasic/vc2013/Resources.rc rename to samples/CoordSysBasic/vc2015/Resources.rc diff --git a/samples/TeleportBasic/src/TeleportBasicApp.cpp b/samples/TeleportBasic/src/TeleportBasicApp.cpp index cce28d4..8fc5725 100644 --- a/samples/TeleportBasic/src/TeleportBasicApp.cpp +++ b/samples/TeleportBasic/src/TeleportBasicApp.cpp @@ -493,7 +493,7 @@ void TeleportBasicApp::draw() void prepareSettings( App::Settings *settings ) { - settings->setTitle( "Cinder VR ControllerIntermediate" ); + settings->setTitle( "Cinder VR TeleportBasic" ); settings->setWindowSize( 1920/2, 1080/2 ); } diff --git a/samples/TeleportBasic/vc2013/Resources.rc b/samples/TeleportBasic/vc2015/Resources.rc similarity index 100% rename from samples/TeleportBasic/vc2013/Resources.rc rename to samples/TeleportBasic/vc2015/Resources.rc diff --git a/samples/TeleportBasic/vc2013/TeleportBasic.sln b/samples/TeleportBasic/vc2015/TeleportBasic.sln similarity index 100% rename from samples/TeleportBasic/vc2013/TeleportBasic.sln rename to samples/TeleportBasic/vc2015/TeleportBasic.sln diff --git a/samples/TeleportBasic/vc2013/TeleportBasic.vcxproj b/samples/TeleportBasic/vc2015/TeleportBasic.vcxproj similarity index 89% rename from samples/TeleportBasic/vc2013/TeleportBasic.vcxproj rename to samples/TeleportBasic/vc2015/TeleportBasic.vcxproj index bad6924..b77b29d 100644 --- a/samples/TeleportBasic/vc2013/TeleportBasic.vcxproj +++ b/samples/TeleportBasic/vc2015/TeleportBasic.vcxproj @@ -22,32 +22,33 @@ {09C0F333-A09A-4FFA-81AA-17FBA0649C19} Basic Win32Proj + 10.0.16299.0 Application false - v120 + v140 Unicode true Application false - v120 + v140 Unicode true Application true - v120 + v140 Unicode Application true - v120 + v140 Unicode @@ -93,8 +94,8 @@ "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -123,8 +124,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset)_d.lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) true Windows false @@ -153,8 +154,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -186,8 +187,8 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb "..\..\..\..\..\include";..\include - cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) - ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\Windows\$(Platform)\Release\VS2013;..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) + cinder.lib;OpenGL32.lib;..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\cinder-vr-$(PlatformToolset).lib;%(AdditionalDependencies) + ..\..\..\..\..\lib\msw\$(PlatformTarget);..\..\..\..\..\lib\msw\$(PlatformTarget)\$(Configuration)\$(PlatformToolset);..\..\..\ext\LibOVR\Lib\msw\$(PlatformTarget)\$(PlatformToolset);..\..\..\ext\OpenVR\lib\msw\$(PlatformTarget) false true Windows @@ -205,10 +206,10 @@ copy $(ProjectDir)\..\..\..\ext\OpenVR\bin\msw\$(PlatformTarget)\openvr_api.pdb - + - + diff --git a/samples/TeleportBasic/vc2013/TeleportBasic.vcxproj.filters b/samples/TeleportBasic/vc2015/TeleportBasic.vcxproj.filters similarity index 100% rename from samples/TeleportBasic/vc2013/TeleportBasic.vcxproj.filters rename to samples/TeleportBasic/vc2015/TeleportBasic.vcxproj.filters diff --git a/src/cinder/vr/Context.cpp b/src/cinder/vr/Context.cpp index 88d9ef9..4b53a39 100644 --- a/src/cinder/vr/Context.cpp +++ b/src/cinder/vr/Context.cpp @@ -52,9 +52,19 @@ namespace cinder { namespace vr { Context::Context( const ci::vr::SessionOptions& sessionOptions, ci::vr::DeviceManager* deviceManager ) : mSessionOptions( sessionOptions ), mDeviceManager( deviceManager ) { - mControllerIconTextures[ci::vr::Controller::TYPE_LEFT] = ci::gl::Texture2d::create( getHandIcon( ci::vr::Controller::TYPE_LEFT ) ); - mControllerIconTextures[ci::vr::Controller::TYPE_RIGHT] = ci::gl::Texture2d::create( getHandIcon( ci::vr::Controller::TYPE_RIGHT ) ); - + if (mSessionOptions.getHandIcon(ci::vr::Controller::TYPE_LEFT) != nullptr) { + mControllerIconTextures[ci::vr::Controller::TYPE_LEFT] = ci::gl::Texture2d::create(*mSessionOptions.getHandIcon(ci::vr::Controller::TYPE_LEFT)); + } + else { + mControllerIconTextures[ci::vr::Controller::TYPE_LEFT] = ci::gl::Texture2d::create(getHandIcon(ci::vr::Controller::TYPE_LEFT)); + } + if (mSessionOptions.getHandIcon(ci::vr::Controller::TYPE_RIGHT) != nullptr) { + mControllerIconTextures[ci::vr::Controller::TYPE_RIGHT] = ci::gl::Texture2d::create(*mSessionOptions.getHandIcon(ci::vr::Controller::TYPE_RIGHT)); + } + else { + mControllerIconTextures[ci::vr::Controller::TYPE_RIGHT] = ci::gl::Texture2d::create(getHandIcon(ci::vr::Controller::TYPE_RIGHT)); + } + if( mSessionOptions.getControllerConnected() ) { mSignalControllerConnected.connect( mSessionOptions.getControllerConnected() ); } diff --git a/src/cinder/vr/Hmd.cpp b/src/cinder/vr/Hmd.cpp index 507813c..a67ad2e 100644 --- a/src/cinder/vr/Hmd.cpp +++ b/src/cinder/vr/Hmd.cpp @@ -103,6 +103,11 @@ ci::mat4 Hmd::getEyeViewMatrix( ci::vr::Eye eye ) const return result; } +ci::mat4 Hmd::getEyePoseMatrix(ci::vr::Eye eye) const +{ + return mEyePoseMatrix[ eye ]; +} + ci::mat4 Hmd::getEyeProjectionMatrix( ci::vr::Eye eye ) const { const ci::vr::CameraEye& cam = mEyeCamera[eye]; diff --git a/src/cinder/vr/SessionOptions.cpp b/src/cinder/vr/SessionOptions.cpp index 531a586..e208178 100644 --- a/src/cinder/vr/SessionOptions.cpp +++ b/src/cinder/vr/SessionOptions.cpp @@ -40,6 +40,18 @@ namespace cinder { namespace vr { - + const Surface8uRef SessionOptions::getHandIcon( Controller::Type type ) const + { + if ( mHandIcons.find( type ) != mHandIcons.end() ) { + return mHandIcons.at( type ); + } + return nullptr; + } + + SessionOptions& SessionOptions::setHandIcon( Controller::Type type, const Surface8uRef& surf ) + { + mHandIcons[ type ] = surf; + return *this; + } }} // namespace cinder::vr \ No newline at end of file diff --git a/src/cinder/vr/oculus/Hmd.cpp b/src/cinder/vr/oculus/Hmd.cpp index e84a4e3..8b6e2b3 100644 --- a/src/cinder/vr/oculus/Hmd.cpp +++ b/src/cinder/vr/oculus/Hmd.cpp @@ -225,13 +225,13 @@ void Hmd::onClipValueChange( float nearClip, float farClip ) void Hmd::onMonoscopicChange() { if( isMonoscopic() ) { - auto centerEyeOffset = 0.5f * ( fromOvr( mEyeRenderDesc[0].HmdToEyeOffset ) + fromOvr( mEyeRenderDesc[1].HmdToEyeOffset ) ); - mEyeViewOffset[0] = toOvr( centerEyeOffset ); - mEyeViewOffset[1] = toOvr( centerEyeOffset ); + auto centerEyeOffset = 0.5f * ( fromOvr( mEyeRenderDesc[0].HmdToEyePose.Position ) + fromOvr( mEyeRenderDesc[1].HmdToEyePose.Position ) ); + mEyeViewPose[0].Position = toOvr( centerEyeOffset ); + mEyeViewPose[1].Position = toOvr( centerEyeOffset ); } else { - mEyeViewOffset[0] = mEyeRenderDesc[0].HmdToEyeOffset; - mEyeViewOffset[1] = mEyeRenderDesc[1].HmdToEyeOffset; + mEyeViewPose[0].Position = mEyeRenderDesc[0].HmdToEyePose.Position; + mEyeViewPose[1].Position = mEyeRenderDesc[1].HmdToEyePose.Position; } } @@ -275,7 +275,7 @@ void Hmd::bind() // Calculate input ray calculateInputRay(); - ::ovr_GetEyePoses( mSession, mFrameIndex, ovrTrue, mEyeViewOffset, mEyeRenderPose, &mSensorSampleTime ); + ::ovr_GetEyePoses( mSession, mFrameIndex, ovrTrue, mEyeViewPose, mEyeRenderPose, &mSensorSampleTime ); const ::ovrEyeType kEyes[2] = { ::ovrEye_Left, ::ovrEye_Right }; for( auto eye : kEyes ) { // View matrix @@ -333,7 +333,7 @@ void Hmd::submitFrame() mBaseLayer.SensorSampleTime = mSensorSampleTime; for( auto eye : getEyes() ) { auto area = getEyeViewport( eye ); - viewScaleDesc.HmdToEyeOffset[eye] = mEyeViewOffset[eye]; + viewScaleDesc.HmdToEyePose[eye] = mEyeViewPose[eye]; mBaseLayer.Fov[eye] = mEyeRenderDesc[eye].Fov; mBaseLayer.RenderPose[eye] = mEyeRenderPose[eye]; mBaseLayer.Viewport[eye] = { { area.x1, area.y1 }, { area.getWidth(), area.getHeight() } }; diff --git a/src/cinder/vr/openvr/Context.cpp b/src/cinder/vr/openvr/Context.cpp index b458aaa..0fc3985 100644 --- a/src/cinder/vr/openvr/Context.cpp +++ b/src/cinder/vr/openvr/Context.cpp @@ -296,7 +296,7 @@ void Context::processTrackedDeviceEvents( const ::vr::VREvent_t &event ) if( ci::vr::Controller::TYPE_UNKNOWN != ctrlType ) { ::vr::VRControllerState_t state = {}; - if( mVrSystem->GetControllerState( deviceIndex, &state ) && mViveControllers[ctrlType]->isEventsEnabled() ) { + if( mVrSystem->GetControllerState( deviceIndex, &state, sizeof( state ) ) ) { mViveControllers[ctrlType]->processControllerState( state ); } } diff --git a/src/cinder/vr/openvr/Controller.cpp b/src/cinder/vr/openvr/Controller.cpp index 4572ecb..dd2c5a4 100644 --- a/src/cinder/vr/openvr/Controller.cpp +++ b/src/cinder/vr/openvr/Controller.cpp @@ -247,14 +247,10 @@ void Controller::processAxes( const ::vr::VRControllerState_t& state ) const uint64_t buttonMasdk = ::vr::ButtonMaskFromId( ::vr::k_EButton_SteamVR_Touchpad ); const bool isTouched = ( buttonMasdk == ( state.ulButtonTouched & buttonMasdk ) ); ci::vec2 value = ci::vec2( 0.0f ); - if( isTouched ) { - value.x = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].x; - value.y = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].y; - } - if( isTouched != mTrackPadTouched ) { - mTrackPadTouched = isTouched; - setAxisValue( mAxes[0].get(), value ); - } + value.x = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].x; + value.y = state.rAxis[ci::vr::openvr::Controller::AXIS_INDEX_TOUCHPAD].y; + mTrackPadTouched = isTouched; + setAxisValue( mAxes[0].get(), value ); } void Controller::processControllerPose( const ci::mat4& inverseLookMatrix, const ci::mat4& inverseOriginMatrix, const ci::mat4& deviceToTrackingMatrix, const ci::mat4& trackingToDeviceMatrix ) diff --git a/src/cinder/vr/openvr/Hmd.cpp b/src/cinder/vr/openvr/Hmd.cpp index 32b6bc1..b42cf8b 100644 --- a/src/cinder/vr/openvr/Hmd.cpp +++ b/src/cinder/vr/openvr/Hmd.cpp @@ -291,14 +291,15 @@ void Hmd::setupDistortion() for( int x = 0; x < lensGridSegmentCountH; ++x ) { float u = x * w; float v = 1.0f - ( y * h ); - ::vr::DistortionCoordinates_t dc = mVrSystem->ComputeDistortion( ::vr::Eye_Left, u, v ); - - VertexDesc vert = VertexDesc(); - vert.position = ci::vec2( xOffset + u, -1.0f + ( 2.0f * y * h ) ); - vert.texCoordRed = ci::vec2( dc.rfRed[0], 1.0f - dc.rfRed[1] ); - vert.texCoordGreen = ci::vec2( dc.rfGreen[0], 1.0f - dc.rfGreen[1] ); - vert.texCoordBlue = ci::vec2( dc.rfBlue[0], 1.0f - dc.rfBlue[1] ); - vertexData.push_back( vert ); + ::vr::DistortionCoordinates_t dc; + if( mVrSystem->ComputeDistortion( ::vr::Eye_Left, u, v, &dc ) ) { + VertexDesc vert = VertexDesc(); + vert.position = ci::vec2( xOffset + u, -1.0f + ( 2.0f * y * h ) ); + vert.texCoordRed = ci::vec2( dc.rfRed[0], 1.0f - dc.rfRed[1] ); + vert.texCoordGreen = ci::vec2( dc.rfGreen[0], 1.0f - dc.rfGreen[1] ); + vert.texCoordBlue = ci::vec2( dc.rfBlue[0], 1.0f - dc.rfBlue[1] ); + vertexData.push_back( vert ); + } } } @@ -308,14 +309,15 @@ void Hmd::setupDistortion() for( int x = 0; x < lensGridSegmentCountH; ++x ) { float u = x * w; float v = 1 - ( y * h ); - ::vr::DistortionCoordinates_t dc = mVrSystem->ComputeDistortion( ::vr::Eye_Right, u, v ); - - VertexDesc vert = VertexDesc(); - vert.position = ci::vec2( xOffset + u, -1.0f + ( 2.0f * y * h ) ); - vert.texCoordRed = ci::vec2( dc.rfRed[0], 1.0f - dc.rfRed[1] ); - vert.texCoordGreen = ci::vec2( dc.rfGreen[0], 1.0f - dc.rfGreen[1] ); - vert.texCoordBlue = ci::vec2( dc.rfBlue[0], 1.0f - dc.rfBlue[1] ); - vertexData.push_back( vert ); + ::vr::DistortionCoordinates_t dc; + if ( mVrSystem->ComputeDistortion( ::vr::Eye_Right, u, v, &dc ) ) { + VertexDesc vert = VertexDesc(); + vert.position = ci::vec2( xOffset + u, -1.0f + ( 2.0f * y * h ) ); + vert.texCoordRed = ci::vec2( dc.rfRed[0], 1.0f - dc.rfRed[1] ); + vert.texCoordGreen = ci::vec2( dc.rfGreen[0], 1.0f - dc.rfGreen[1] ); + vert.texCoordBlue = ci::vec2( dc.rfBlue[0], 1.0f - dc.rfBlue[1] ); + vertexData.push_back( vert ); + } } } @@ -436,7 +438,7 @@ void Hmd::updatePoseData() void Hmd::updateControllerGeometry() { - if( mVrSystem->IsInputFocusCapturedByAnotherProcess() ) { + if( !mVrSystem->IsInputAvailable() ) { return; } @@ -555,14 +557,14 @@ void Hmd::submitFrame() // Left eye { GLuint resolvedTexId = mRenderTargetLeft->getColorTexture()->getId(); - ::vr::Texture_t eyeTex = { reinterpret_cast( resolvedTexId ), ::vr::API_OpenGL, ::vr::ColorSpace_Gamma }; + ::vr::Texture_t eyeTex = { reinterpret_cast( resolvedTexId ), ::vr::TextureType_OpenGL, ::vr::ColorSpace_Gamma }; ::vr::VRCompositor()->Submit( ::vr::Eye_Left, &eyeTex ); } // Right eye { GLuint resolvedTexId = mRenderTargetRight->getColorTexture()->getId(); - ::vr::Texture_t eyeTex = { reinterpret_cast( resolvedTexId ), ::vr::API_OpenGL, ::vr::ColorSpace_Gamma }; + ::vr::Texture_t eyeTex = { reinterpret_cast( resolvedTexId ), ::vr::TextureType_OpenGL, ::vr::ColorSpace_Gamma }; ::vr::VRCompositor()->Submit( ::vr::Eye_Right, &eyeTex ); } @@ -793,7 +795,7 @@ void Hmd::drawMirroredImpl( const ci::Rectf& r ) void Hmd::drawControllers( ci::vr::Eye eye ) { - if( mVrSystem->IsInputFocusCapturedByAnotherProcess() ) { + if( !mVrSystem->IsInputAvailable() ) { return; } @@ -845,10 +847,12 @@ void Hmd::drawControllers( ci::vr::Eye eye ) ci::gl::rotate( 0.11f, 1.0f, 0.0f, 0.0f ); ci::gl::scale( ci::vec3( 0.01f ) ); const auto& tex = mContext->getControllerIconTexture( ctrlType ); - tex->bind( 0 ); - mControllerIconBatch[ctrlType]->getGlslProg()->uniform( "uTex0", 0 ); - mControllerIconBatch[ctrlType]->draw(); - tex->unbind( 0 ); + if (tex != nullptr) { + tex->bind( 0 ); + mControllerIconBatch[ctrlType]->getGlslProg()->uniform( "uTex0", 0 ); + mControllerIconBatch[ctrlType]->draw(); + tex->unbind( 0 ); + } } } } diff --git a/src/cinder/vr/openvr/OpenVr.cpp b/src/cinder/vr/openvr/OpenVr.cpp index eb1f265..b72fccd 100644 --- a/src/cinder/vr/openvr/OpenVr.cpp +++ b/src/cinder/vr/openvr/OpenVr.cpp @@ -125,7 +125,7 @@ std::string getTrackedDeviceString( ::vr::IVRSystem* vrSystem, ::vr::TrackedDevi ci::mat4 getHmdEyeProjectionMatrix( ::vr::IVRSystem* vrSystem, ::vr::Hmd_Eye eye, float nearClip, float farClip ) { - ::vr::HmdMatrix44_t mat = vrSystem->GetProjectionMatrix( eye, nearClip, farClip, ::vr::API_OpenGL ); + ::vr::HmdMatrix44_t mat = vrSystem->GetProjectionMatrix( eye, nearClip, farClip ); return ci::vr::openvr::fromOpenVr( mat ); } diff --git a/vc2013/Cinder-VR.sln b/vc2015/Cinder-VR.sln similarity index 100% rename from vc2013/Cinder-VR.sln rename to vc2015/Cinder-VR.sln diff --git a/vc2013/Cinder-VR.vcxproj b/vc2015/Cinder-VR.vcxproj similarity index 94% rename from vc2013/Cinder-VR.vcxproj rename to vc2015/Cinder-VR.vcxproj index dc3492d..01797d3 100644 --- a/vc2013/Cinder-VR.vcxproj +++ b/vc2015/Cinder-VR.vcxproj @@ -64,31 +64,32 @@ {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE} Win32Proj CinderVR + 10.0.16299.0 StaticLibrary true - v120 + v140 Unicode StaticLibrary true - v120 + v140 Unicode StaticLibrary false - v120 + v140 true Unicode StaticLibrary false - v120 + v140 true Unicode @@ -109,19 +110,19 @@ - ..\lib\msw\$(PlatformTarget)\ - cinder-vr-$(PlatformToolset)_d + ..\lib\msw\$(PlatformTarget)\$(Configuration)\ + cinder-vr-$(PlatformToolset) - cinder-vr-$(PlatformToolset)_d - ..\lib\msw\$(PlatformTarget)\ + cinder-vr-$(PlatformToolset) + ..\lib\msw\$(PlatformTarget)\$(Configuration)\ - ..\lib\msw\$(PlatformTarget)\ + ..\lib\msw\$(PlatformTarget)\$(Configuration)\ cinder-vr-$(PlatformToolset) - ..\lib\msw\$(PlatformTarget)\ + ..\lib\msw\$(PlatformTarget)\$(Configuration)\ cinder-vr-$(PlatformToolset) diff --git a/vc2013/Cinder-VR.vcxproj.filters b/vc2015/Cinder-VR.vcxproj.filters similarity index 100% rename from vc2013/Cinder-VR.vcxproj.filters rename to vc2015/Cinder-VR.vcxproj.filters diff --git a/vc2017/Cinder-VR.sln b/vc2017/Cinder-VR.sln new file mode 100644 index 0000000..d3a936f --- /dev/null +++ b/vc2017/Cinder-VR.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cinder-VR", "Cinder-VR.vcxproj", "{D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Debug|Win32.ActiveCfg = Debug|Win32 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Debug|Win32.Build.0 = Debug|Win32 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Debug|x64.ActiveCfg = Debug|x64 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Debug|x64.Build.0 = Debug|x64 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Release|Win32.ActiveCfg = Release|Win32 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Release|Win32.Build.0 = Release|Win32 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Release|x64.ActiveCfg = Release|x64 + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vc2017/Cinder-VR.vcxproj b/vc2017/Cinder-VR.vcxproj new file mode 100644 index 0000000..5fac370 --- /dev/null +++ b/vc2017/Cinder-VR.vcxproj @@ -0,0 +1,209 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {D650630A-84D1-4DC1-80E3-F8B1D0EE34DE} + Win32Proj + CinderVR + 10.0.18362.0 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + ..\lib\msw\$(PlatformTarget)\$(Configuration) + cinder-vr-$(PlatformToolset) + + + cinder-vr-$(PlatformToolset) + ..\lib\msw\$(PlatformTarget)\$(Configuration) + + + ..\lib\msw\$(PlatformTarget)\$(Configuration) + cinder-vr-$(PlatformToolset) + + + ..\lib\msw\$(PlatformTarget)\$(Configuration) + cinder-vr-$(PlatformToolset) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\include;..\..\..\include;..\ext\LibOVR\Include;..\ext\OpenVR\headers;%(AdditionalIncludeDirectories) + $(IntDir)\$(PlatformTarget)\%(RelativeDir)\ + MultiThreadedDebug + + + Windows + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + ..\include;..\..\..\include;..\ext\LibOVR\Include;..\ext\OpenVR\headers;%(AdditionalIncludeDirectories) + $(IntDir)\$(PlatformTarget)\%(RelativeDir)\ + MultiThreadedDebug + + + Windows + true + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\include;..\..\..\include;..\ext\LibOVR\Include;..\ext\OpenVR\headers;%(AdditionalIncludeDirectories) + $(IntDir)\$(PlatformTarget)\%(RelativeDir)\ + MultiThreaded + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + ..\include;..\..\..\include;..\ext\LibOVR\Include;..\ext\OpenVR\headers;%(AdditionalIncludeDirectories) + $(IntDir)\$(PlatformTarget)\%(RelativeDir)\ + MultiThreaded + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/vc2017/Cinder-VR.vcxproj.filters b/vc2017/Cinder-VR.vcxproj.filters new file mode 100644 index 0000000..78a002e --- /dev/null +++ b/vc2017/Cinder-VR.vcxproj.filters @@ -0,0 +1,159 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {9cd05c4b-9361-4ca6-954a-3698a4552932} + + + {9087b1e2-c388-42b2-8067-841deaa6be6c} + + + {dc8bbd1c-becf-46fb-b453-56f2d637b5f3} + + + {8a978d55-c8c5-47fa-a292-2fd3fcf099c0} + + + {5416bdb4-8193-4589-a8d2-742ab9d934f4} + + + {8219568f-ba64-4c56-a5a4-18cb966e0f51} + + + {59e3cb88-0476-4c14-990b-c7d01539b6ff} + + + {6dbc9c31-5e6f-464f-8414-bd542ff2cb1a} + + + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr + + + Header Files\cinder\vr\openvr + + + Header Files\cinder\vr\openvr + + + Header Files\cinder\vr\openvr + + + Header Files\cinder\vr\openvr + + + Header Files\cinder\vr\oculus + + + Header Files\cinder\vr\oculus + + + Header Files\cinder\vr\oculus + + + Header Files\cinder\vr\oculus + + + Header Files\cinder\vr\openvr + + + Header Files\cinder\vr\oculus + + + Header Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr + + + Source Files\cinder\vr\openvr + + + Source Files\cinder\vr\openvr + + + Source Files\cinder\vr\openvr + + + Source Files\cinder\vr\openvr + + + Source Files\cinder\vr\oculus + + + Source Files\cinder\vr\oculus + + + Source Files\cinder\vr\oculus + + + Source Files\cinder\vr\oculus + + + Source Files\cinder\vr\openvr + + + Source Files\cinder\vr\oculus + + + Source Files\cinder\vr + + + \ No newline at end of file