diff --git a/bin/linux64/libopenvr_api.so b/bin/linux64/libopenvr_api.so index 62c24e44..89dc2458 100755 Binary files a/bin/linux64/libopenvr_api.so and b/bin/linux64/libopenvr_api.so differ diff --git a/bin/linux64/libopenvr_api.so.dbg b/bin/linux64/libopenvr_api.so.dbg index 19ecf398..258014be 100755 Binary files a/bin/linux64/libopenvr_api.so.dbg and b/bin/linux64/libopenvr_api.so.dbg differ diff --git a/bin/osx32/libopenvr_api.dylib b/bin/osx32/libopenvr_api.dylib index ddccc13c..5138526a 100755 Binary files a/bin/osx32/libopenvr_api.dylib and b/bin/osx32/libopenvr_api.dylib differ diff --git a/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib b/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib index 8858ec35..0b41064a 100644 Binary files a/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib and b/bin/osx32/libopenvr_api.dylib.dSYM/Contents/Resources/DWARF/libopenvr_api.dylib differ diff --git a/bin/win32/openvr_api.dll b/bin/win32/openvr_api.dll index 25bdf6dc..8494ad36 100644 Binary files a/bin/win32/openvr_api.dll and b/bin/win32/openvr_api.dll differ diff --git a/bin/win32/openvr_api.pdb b/bin/win32/openvr_api.pdb index 2cc49fb6..f0cf4cd5 100644 Binary files a/bin/win32/openvr_api.pdb and b/bin/win32/openvr_api.pdb differ diff --git a/bin/win64/openvr_api.dll b/bin/win64/openvr_api.dll index ee01bf53..2df9f2e4 100644 Binary files a/bin/win64/openvr_api.dll and b/bin/win64/openvr_api.dll differ diff --git a/bin/win64/openvr_api.pdb b/bin/win64/openvr_api.pdb index f277c53e..4bbd8d36 100644 Binary files a/bin/win64/openvr_api.pdb and b/bin/win64/openvr_api.pdb differ diff --git a/headers/openvr.h b/headers/openvr.h index 9439eb1d..4ea5d84f 100644 --- a/headers/openvr.h +++ b/headers/openvr.h @@ -375,6 +375,9 @@ enum EVREventType 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_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_OverlayShown = 500, VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, @@ -416,6 +419,7 @@ enum EVREventType VREvent_KeyboardClosed = 1200, VREvent_KeyboardCharInput = 1201, + VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard VREvent_ApplicationTransitionStarted = 1300, VREvent_ApplicationTransitionAborted = 1301, @@ -818,6 +822,9 @@ enum EVRInitError VRInitError_IPC_MutexInitFailed = 304, VRInitError_IPC_Failed = 305, + VRInitError_Compositor_Failed = 400, + VRInitError_Compositor_D3D11HardwareRequired = 401, + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, @@ -1277,6 +1284,9 @@ namespace vr * dashboard overlay applications. */ virtual EVRApplicationError LaunchDashboardOverlay( const char *pchAppKey ) = 0; + /** Cancel a pending launch for an application */ + virtual bool CancelApplicationLaunch( const char *pchAppKey ) = 0; + /** Identifies a running application. OpenVR can't always tell which process started in response * to a URL. This function allows a URL handler (or the process itself) to identify the app key * for the now running application. Passing a process ID of 0 identifies the calling process. @@ -1330,13 +1340,9 @@ namespace vr /** Returns true if the outgoing scene app has requested a save prompt before exiting */ virtual bool IsQuitUserPromptRequested() = 0; - }; - static const char * const IVRApplications_Version = "IVRApplications_003"; - - /** Returns the current IVRApplications pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRApplications *VR_CALLTYPE VRApplications(); + static const char * const IVRApplications_Version = "IVRApplications_004"; } // namespace vr @@ -1370,7 +1376,9 @@ namespace vr virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; virtual void GetString( const char *pchSection, const char *pchSettingsKey, 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; + virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0; + virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; }; //----------------------------------------------------------------------------- @@ -1397,6 +1405,10 @@ namespace vr static const char * const k_pch_SteamVR_AutomaticDirectModeEnabled_Bool = "automaticDirectModeEnabled"; static const char * const k_pch_SteamVR_RequestDirectModeEnabled_Bool = "requestDirectModeEnabled"; static const char * const k_pch_SteamVR_RequestDirectModeDisabled_Bool = "requestDirectModeDisabled"; + static const char * const k_pch_SteamVR_RequestDirectModeEdidVid_Int32 = "requestDirectModeEdidVid"; + static const char * const k_pch_SteamVR_RequestDirectModeEdidPid_Int32 = "requestDirectModeEdidPid"; + static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; + static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; //----------------------------------------------------------------------------- // lighthouse keys @@ -1455,6 +1467,7 @@ namespace vr static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; 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"; //----------------------------------------------------------------------------- // camera keys @@ -1464,9 +1477,6 @@ namespace vr static const char * const IVRSettings_Version = "IVRSettings_001"; - /** Returns the current IVRSettings pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRSettings *VR_CALLTYPE VRSettings(); - } // namespace vr // ivrchaperone.h @@ -1657,6 +1667,7 @@ enum EVRCompositorError VRCompositorError_TextureIsOnWrongDevice = 104, VRCompositorError_TextureUsesUnsupportedFormat = 105, VRCompositorError_SharedTexturesNotSupported = 106, + VRCompositorError_IndexOutOfRange = 107, }; @@ -1721,6 +1732,11 @@ class IVRCompositor virtual EVRCompositorError GetLastPoses( VR_ARRAY_COUNT( unRenderPoseArrayCount ) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount, VR_ARRAY_COUNT( unGamePoseArrayCount ) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0; + /** Interface for accessing last set of poses returned by WaitGetPoses one at a time. + * Returns VRCompositorError_IndexOutOfRange if unDeviceIndex not less than k_unMaxTrackedDeviceCount otherwise VRCompositorError_None. + * It is okay to pass NULL for either pose if you only want one of the values. */ + virtual EVRCompositorError GetLastPoseForTrackedDeviceIndex( TrackedDeviceIndex_t unDeviceIndex, TrackedDevicePose_t *pOutputPose, TrackedDevicePose_t *pOutputGamePose ) = 0; + /** Updated scene texture to display. If pBounds is NULL the entire texture will be used. If called from an OpenGL app, consider adding a glFlush after * Submitting both frames to signal the driver to start processing, otherwise it may wait until the command buffer fills up, causing the app to miss frames. * @@ -1799,9 +1815,12 @@ class IVRCompositor /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */ virtual void CompositorDumpImages() = 0; + + /** Let an app know it should be rendering with low resources */ + virtual bool ShouldAppRenderWithLowResources() = 0; }; -static const char * const IVRCompositor_Version = "IVRCompositor_011"; +static const char * const IVRCompositor_Version = "IVRCompositor_012"; } // namespace vr @@ -2450,19 +2469,18 @@ namespace vr namespace vr { - - /** Finds the active installation of the VR API and initializes it. The provided path must be absolute + /** 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 + * 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. */ - VR_INTERFACE vr::IVRSystem *VR_CALLTYPE VR_Init( vr::EVRInitError *peError, vr::EVRApplicationType eApplicationType = vr::VRApplication_Scene ); + inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType ); - /** unloads vrclient.dll. Any interface pointers from the interface are + /** unloads vrclient.dll. Any interface pointers from the interface are * invalid after this point */ - VR_INTERFACE void VR_CALLTYPE VR_Shutdown(); + inline void VR_Shutdown(); /** Returns true if there is an HMD attached. This check is as lightweight as possible and * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants @@ -2473,40 +2491,27 @@ namespace vr /** Returns true if the OpenVR runtime is installed. */ VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled(); + /** Returns where the OpenVR runtime is installed. */ + VR_INTERFACE const char *VR_CALLTYPE VR_RuntimePath(); + /** 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( vr::EVRInitError error ); + 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( vr::EVRInitError error ); + VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription( EVRInitError error ); /** Returns the interface of the specified version. This method must be called after VR_Init. The * pointer returned is valid until VR_Shutdown is called. */ - VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface( const char *pchInterfaceVersion, vr::EVRInitError *peError ); - - /** Returns the current IVRSystem pointer or NULL if VR_Init has not been called successfully */ - VR_INTERFACE vr::IVRSystem *VR_CALLTYPE VRSystem(); - - /** Returns the current IVRChaperone pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRChaperone *VR_CALLTYPE VRChaperone(); - - /** Returns the current IVRChaperoneSetup pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRChaperoneSetup *VR_CALLTYPE VRChaperoneSetup(); - - /** Returns the current IVRCompositor pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRCompositor *VR_CALLTYPE VRCompositor(); + VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError ); - /** Returns the current IVROverlay pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVROverlay *VR_CALLTYPE VROverlay(); - - /** Returns the current IVRRenderModels pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRRenderModels *VR_CALLTYPE VRRenderModels(); + /** Returns whether the interface of the specified version exists. + */ + VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid( const char *pchInterfaceVersion ); - /** Returns the current IVRExtendedDisplay pointer or NULL the interface could not be found. - * This function will also return NULL if the VR Compositor is running as the extended display - * interface is incompatible with the compositor. */ - VR_INTERFACE vr::IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay(); + /** Returns a token that represents whether the VR interface handles need to be reloaded */ + VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken(); // These typedefs allow old enum names from SDK 0.9.11 to be used in applications. // They will go away in the future. @@ -2525,4 +2530,202 @@ namespace vr typedef EVROverlayError VROverlayError; typedef EVRFirmwareError VRFirmwareError; typedef EVRCompositorError VRCompositorError; + + inline uint32_t &VRToken() + { + static uint32_t token; + return token; + } + + class COpenVRContext + { + public: + COpenVRContext() { Clear(); } + void Clear(); + + inline void CheckClear() + { + if ( VRToken() != VR_GetInitToken() ) + { + Clear(); + VRToken() = VR_GetInitToken(); + } + } + + IVRSystem *VRSystem() + { + CheckClear(); + if ( m_pVRSystem == nullptr ) + { + EVRInitError eError; + m_pVRSystem = ( IVRSystem * )VR_GetGenericInterface( IVRSystem_Version, &eError ); + } + return m_pVRSystem; + } + IVRChaperone *VRChaperone() + { + CheckClear(); + if ( m_pVRChaperone == nullptr ) + { + EVRInitError eError; + m_pVRChaperone = ( IVRChaperone * )VR_GetGenericInterface( IVRChaperone_Version, &eError ); + } + return m_pVRChaperone; + } + + IVRChaperoneSetup *VRChaperoneSetup() + { + CheckClear(); + if ( m_pVRChaperoneSetup == nullptr ) + { + EVRInitError eError; + m_pVRChaperoneSetup = ( IVRChaperoneSetup * )VR_GetGenericInterface( IVRChaperoneSetup_Version, &eError ); + } + return m_pVRChaperoneSetup; + } + + IVRCompositor *VRCompositor() + { + CheckClear(); + if ( m_pVRCompositor == nullptr ) + { + EVRInitError eError; + m_pVRCompositor = ( IVRCompositor * )VR_GetGenericInterface( IVRCompositor_Version, &eError ); + } + return m_pVRCompositor; + } + + IVROverlay *VROverlay() + { + CheckClear(); + if ( m_pVROverlay == nullptr ) + { + EVRInitError eError; + m_pVROverlay = ( IVROverlay * )VR_GetGenericInterface( IVROverlay_Version, &eError ); + } + return m_pVROverlay; + } + + IVRRenderModels *VRRenderModels() + { + CheckClear(); + if ( m_pVRRenderModels == nullptr ) + { + EVRInitError eError; + m_pVRRenderModels = ( IVRRenderModels * )VR_GetGenericInterface( IVRRenderModels_Version, &eError ); + } + return m_pVRRenderModels; + } + + IVRExtendedDisplay *VRExtendedDisplay() + { + CheckClear(); + if ( m_pVRExtendedDisplay == nullptr ) + { + EVRInitError eError; + m_pVRExtendedDisplay = ( IVRExtendedDisplay * )VR_GetGenericInterface( IVRExtendedDisplay_Version, &eError ); + } + return m_pVRExtendedDisplay; + } + + IVRSettings *VRSettings() + { + CheckClear(); + if ( m_pVRSettings == nullptr ) + { + EVRInitError eError; + m_pVRSettings = ( IVRSettings * )VR_GetGenericInterface( IVRSettings_Version, &eError ); + } + return m_pVRSettings; + } + + IVRApplications *VRApplications() + { + CheckClear(); + if ( m_pVRApplications == nullptr ) + { + EVRInitError eError; + m_pVRApplications = ( IVRApplications * )VR_GetGenericInterface( IVRApplications_Version, &eError ); + } + return m_pVRApplications; + } + + private: + IVRSystem *m_pVRSystem; + IVRChaperone *m_pVRChaperone; + IVRChaperoneSetup *m_pVRChaperoneSetup; + IVRCompositor *m_pVRCompositor; + IVROverlay *m_pVROverlay; + IVRRenderModels *m_pVRRenderModels; + IVRExtendedDisplay *m_pVRExtendedDisplay; + IVRSettings *m_pVRSettings; + IVRApplications *m_pVRApplications; + }; + + inline COpenVRContext &OpenVRInternal_ModuleContext() + { + static void *ctx[ sizeof( COpenVRContext ) / sizeof( void * ) ]; + return *( COpenVRContext * )ctx; // bypass zero-init constructor + } + + inline IVRSystem *VR_CALLTYPE VRSystem() { return OpenVRInternal_ModuleContext().VRSystem(); } + inline IVRChaperone *VR_CALLTYPE VRChaperone() { return OpenVRInternal_ModuleContext().VRChaperone(); } + 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 IVRRenderModels *VR_CALLTYPE VRRenderModels() { return OpenVRInternal_ModuleContext().VRRenderModels(); } + inline IVRApplications *VR_CALLTYPE VRApplications() { return OpenVRInternal_ModuleContext().VRApplications(); } + inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleContext().VRSettings(); } + inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); } + + inline void COpenVRContext::Clear() + { + m_pVRSystem = nullptr; + m_pVRChaperone = nullptr; + m_pVRChaperoneSetup = nullptr; + m_pVRCompositor = nullptr; + m_pVROverlay = nullptr; + m_pVRRenderModels = nullptr; + m_pVRExtendedDisplay = nullptr; + m_pVRSettings = nullptr; + m_pVRApplications = nullptr; + } + + VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal( EVRInitError *peError, EVRApplicationType eApplicationType ); + 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 ) + { + IVRSystem *pVRSystem = nullptr; + + EVRInitError eError; + VRToken() = VR_InitInternal( &eError, eApplicationType ); + COpenVRContext &ctx = OpenVRInternal_ModuleContext(); + ctx.Clear(); + + if ( eError == VRInitError_None ) + { + if ( VR_IsInterfaceVersionValid( IVRSystem_Version ) ) + { + pVRSystem = VRSystem(); + } + else + { + VR_ShutdownInternal(); + eError = VRInitError_Init_InterfaceNotFound; + } + } + + if ( peError ) + *peError = eError; + return pVRSystem; + } + + /** unloads vrclient.dll. Any interface pointers from the interface are + * invalid after this point */ + inline void VR_Shutdown() + { + VR_ShutdownInternal(); + } } diff --git a/headers/openvr_api.cs b/headers/openvr_api.cs index c58e8263..447e697c 100644 --- a/headers/openvr_api.cs +++ b/headers/openvr_api.cs @@ -131,6 +131,8 @@ class VRNativeEntrypoints internal static extern EVRApplicationError VR_IVRApplications_LaunchApplication(IntPtr instancePtr, string pchAppKey); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRApplications_LaunchDashboardOverlay")] internal static extern EVRApplicationError VR_IVRApplications_LaunchDashboardOverlay(IntPtr instancePtr, string pchAppKey); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRApplications_CancelApplicationLaunch")] + internal static extern bool VR_IVRApplications_CancelApplicationLaunch(IntPtr instancePtr, string pchAppKey); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRApplications_IdentifyApplication")] internal static extern EVRApplicationError VR_IVRApplications_IdentifyApplication(IntPtr instancePtr, uint unProcessId, string pchAppKey); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRApplications_GetApplicationProcessId")] @@ -217,6 +219,8 @@ class VRNativeEntrypoints internal static extern EVRCompositorError VR_IVRCompositor_WaitGetPoses(IntPtr instancePtr, [In, Out] TrackedDevicePose_t[] pRenderPoseArray, uint unRenderPoseArrayCount, [In, Out] TrackedDevicePose_t[] pGamePoseArray, uint unGamePoseArrayCount); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_GetLastPoses")] internal static extern EVRCompositorError VR_IVRCompositor_GetLastPoses(IntPtr instancePtr, [In, Out] TrackedDevicePose_t[] pRenderPoseArray, uint unRenderPoseArrayCount, [In, Out] TrackedDevicePose_t[] pGamePoseArray, uint unGamePoseArrayCount); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_GetLastPoseForTrackedDeviceIndex")] + internal static extern EVRCompositorError VR_IVRCompositor_GetLastPoseForTrackedDeviceIndex(IntPtr instancePtr, uint unDeviceIndex, ref TrackedDevicePose_t pOutputPose, ref TrackedDevicePose_t pOutputGamePose); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_Submit")] internal static extern EVRCompositorError VR_IVRCompositor_Submit(IntPtr instancePtr, EVREye eEye, ref Texture_t pTexture, ref VRTextureBounds_t pBounds, EVRSubmitFlags nSubmitFlags); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_ClearLastSubmittedFrame")] @@ -257,6 +261,8 @@ class VRNativeEntrypoints internal static extern bool VR_IVRCompositor_IsMirrorWindowVisible(IntPtr instancePtr); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_CompositorDumpImages")] internal static extern void VR_IVRCompositor_CompositorDumpImages(IntPtr instancePtr); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRCompositor_ShouldAppRenderWithLowResources")] + internal static extern bool VR_IVRCompositor_ShouldAppRenderWithLowResources(IntPtr instancePtr); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVROverlay_FindOverlay")] internal static extern EVROverlayError VR_IVROverlay_FindOverlay(IntPtr instancePtr, string pchOverlayKey, ref ulong pOverlayHandle); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVROverlay_CreateOverlay")] @@ -437,6 +443,8 @@ class VRNativeEntrypoints internal static extern void VR_IVRSettings_SetString(IntPtr instancePtr, string pchSection, string pchSettingsKey, string pchValue, ref EVRSettingsError peError); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRSettings_RemoveSection")] internal static extern void VR_IVRSettings_RemoveSection(IntPtr instancePtr, string pchSection, ref EVRSettingsError peError); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRSettings_RemoveKeyInSection")] + internal static extern void VR_IVRSettings_RemoveKeyInSection(IntPtr instancePtr, string pchSection, string pchSettingsKey, ref EVRSettingsError peError); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_HasCamera")] internal static extern bool VR_IVRTrackedCamera_HasCamera(IntPtr instancePtr, uint nDeviceIndex); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_GetCameraFirmwareDescription")] @@ -469,6 +477,22 @@ class VRNativeEntrypoints internal static extern bool VR_IVRTrackedCamera_GetCameraDistortion(IntPtr instancePtr, uint nDeviceIndex, float flInputU, float flInputV, ref float pflOutputU, ref float pflOutputV); [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_GetCameraProjection")] internal static extern bool VR_IVRTrackedCamera_GetCameraProjection(IntPtr instancePtr, uint nDeviceIndex, float flWidthPixels, float flHeightPixels, float flZNear, float flZFar, ref HmdMatrix44_t pProjection); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_GetRecommendedCameraUndistortion")] + internal static extern bool VR_IVRTrackedCamera_GetRecommendedCameraUndistortion(IntPtr instancePtr, uint nDeviceIndex, ref uint pUndistortionWidthPixels, ref uint pUndistortionHeightPixels); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_SetCameraUndistortion")] + internal static extern bool VR_IVRTrackedCamera_SetCameraUndistortion(IntPtr instancePtr, uint nDeviceIndex, uint nUndistortionWidthPixels, uint nUndistortionHeightPixels); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_RequestVideoServicesForTool")] + internal static extern void VR_IVRTrackedCamera_RequestVideoServicesForTool(IntPtr instancePtr); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_ReleaseVideoServicesForTool")] + internal static extern void VR_IVRTrackedCamera_ReleaseVideoServicesForTool(IntPtr instancePtr); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_GetVideoStreamFrameSharedTextureGL")] + internal static extern bool VR_IVRTrackedCamera_GetVideoStreamFrameSharedTextureGL(IntPtr instancePtr, bool bUndistorted, ref uint pglTextureId, IntPtr pglSharedTextureHandle); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_ReleaseVideoStreamFrameSharedTextureGL")] + internal static extern bool VR_IVRTrackedCamera_ReleaseVideoStreamFrameSharedTextureGL(IntPtr instancePtr, uint glTextureId, IntPtr glSharedTextureHandle); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_LockSharedTextureGL")] + internal static extern void VR_IVRTrackedCamera_LockSharedTextureGL(IntPtr instancePtr, IntPtr glSharedTextureHandle, ref CameraVideoStreamFrame_t pFrameImage); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IVRTrackedCamera_UnlockSharedTextureGL")] + internal static extern void VR_IVRTrackedCamera_UnlockSharedTextureGL(IntPtr instancePtr, IntPtr glSharedTextureHandle); } @@ -549,6 +573,7 @@ public abstract class IVRApplications public abstract EVRApplicationError GetApplicationKeyByProcessId(uint unProcessId,string pchAppKeyBuffer,uint unAppKeyBufferLen); public abstract EVRApplicationError LaunchApplication(string pchAppKey); public abstract EVRApplicationError LaunchDashboardOverlay(string pchAppKey); + public abstract bool CancelApplicationLaunch(string pchAppKey); public abstract EVRApplicationError IdentifyApplication(uint unProcessId,string pchAppKey); public abstract uint GetApplicationProcessId(string pchAppKey); public abstract string GetApplicationsErrorNameFromEnum(EVRApplicationError error); @@ -610,6 +635,7 @@ public abstract class IVRCompositor public abstract ETrackingUniverseOrigin GetTrackingSpace(); public abstract EVRCompositorError WaitGetPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray); public abstract EVRCompositorError GetLastPoses(TrackedDevicePose_t [] pRenderPoseArray,TrackedDevicePose_t [] pGamePoseArray); + public abstract EVRCompositorError GetLastPoseForTrackedDeviceIndex(uint unDeviceIndex,ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pOutputGamePose); public abstract EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags); public abstract void ClearLastSubmittedFrame(); public abstract void PostPresentHandoff(); @@ -630,6 +656,7 @@ public abstract class IVRCompositor public abstract void HideMirrorWindow(); public abstract bool IsMirrorWindowVisible(); public abstract void CompositorDumpImages(); + public abstract bool ShouldAppRenderWithLowResources(); } @@ -744,6 +771,7 @@ public abstract class IVRSettings public abstract void GetString(string pchSection,string pchSettingsKey,string pchValue,uint unValueLen,string pchDefaultValue,ref EVRSettingsError peError); public abstract void SetString(string pchSection,string pchSettingsKey,string pchValue,ref EVRSettingsError peError); public abstract void RemoveSection(string pchSection,ref EVRSettingsError peError); + public abstract void RemoveKeyInSection(string pchSection,string pchSettingsKey,ref EVRSettingsError peError); } @@ -766,6 +794,14 @@ public abstract class IVRTrackedCamera public abstract bool ResumeVideoStream(uint nDeviceIndex); public abstract bool GetCameraDistortion(uint nDeviceIndex,float flInputU,float flInputV,ref float pflOutputU,ref float pflOutputV); public abstract bool GetCameraProjection(uint nDeviceIndex,float flWidthPixels,float flHeightPixels,float flZNear,float flZFar,ref HmdMatrix44_t pProjection); + public abstract bool GetRecommendedCameraUndistortion(uint nDeviceIndex,ref uint pUndistortionWidthPixels,ref uint pUndistortionHeightPixels); + public abstract bool SetCameraUndistortion(uint nDeviceIndex,uint nUndistortionWidthPixels,uint nUndistortionHeightPixels); + public abstract void RequestVideoServicesForTool(); + public abstract void ReleaseVideoServicesForTool(); + public abstract bool GetVideoStreamFrameSharedTextureGL(bool bUndistorted,ref uint pglTextureId,IntPtr pglSharedTextureHandle); + public abstract bool ReleaseVideoStreamFrameSharedTextureGL(uint glTextureId,IntPtr glSharedTextureHandle); + public abstract void LockSharedTextureGL(IntPtr glSharedTextureHandle,ref CameraVideoStreamFrame_t pFrameImage); + public abstract void UnlockSharedTextureGL(IntPtr glSharedTextureHandle); } @@ -1172,6 +1208,12 @@ public override EVRApplicationError LaunchDashboardOverlay(string pchAppKey) EVRApplicationError result = VRNativeEntrypoints.VR_IVRApplications_LaunchDashboardOverlay(m_pVRApplications,pchAppKey); return result; } + public override bool CancelApplicationLaunch(string pchAppKey) + { + CheckIfUsable(); + bool result = VRNativeEntrypoints.VR_IVRApplications_CancelApplicationLaunch(m_pVRApplications,pchAppKey); + return result; + } public override EVRApplicationError IdentifyApplication(uint unProcessId,string pchAppKey) { CheckIfUsable(); @@ -1494,6 +1536,12 @@ public override EVRCompositorError GetLastPoses(TrackedDevicePose_t [] pRenderPo EVRCompositorError result = VRNativeEntrypoints.VR_IVRCompositor_GetLastPoses(m_pVRCompositor,pRenderPoseArray,(uint) pRenderPoseArray.Length,pGamePoseArray,(uint) pGamePoseArray.Length); return result; } + public override EVRCompositorError GetLastPoseForTrackedDeviceIndex(uint unDeviceIndex,ref TrackedDevicePose_t pOutputPose,ref TrackedDevicePose_t pOutputGamePose) + { + CheckIfUsable(); + EVRCompositorError result = VRNativeEntrypoints.VR_IVRCompositor_GetLastPoseForTrackedDeviceIndex(m_pVRCompositor,unDeviceIndex,ref pOutputPose,ref pOutputGamePose); + return result; + } public override EVRCompositorError Submit(EVREye eEye,ref Texture_t pTexture,ref VRTextureBounds_t pBounds,EVRSubmitFlags nSubmitFlags) { CheckIfUsable(); @@ -1603,6 +1651,12 @@ public override void CompositorDumpImages() CheckIfUsable(); VRNativeEntrypoints.VR_IVRCompositor_CompositorDumpImages(m_pVRCompositor); } + public override bool ShouldAppRenderWithLowResources() + { + CheckIfUsable(); + bool result = VRNativeEntrypoints.VR_IVRCompositor_ShouldAppRenderWithLowResources(m_pVRCompositor); + return result; + } } @@ -2228,6 +2282,11 @@ public override void RemoveSection(string pchSection,ref EVRSettingsError peErro CheckIfUsable(); VRNativeEntrypoints.VR_IVRSettings_RemoveSection(m_pVRSettings,pchSection,ref peError); } + public override void RemoveKeyInSection(string pchSection,string pchSettingsKey,ref EVRSettingsError peError) + { + CheckIfUsable(); + VRNativeEntrypoints.VR_IVRSettings_RemoveKeyInSection(m_pVRSettings,pchSection,pchSettingsKey,ref peError); + } } @@ -2350,23 +2409,74 @@ public override bool GetCameraProjection(uint nDeviceIndex,float flWidthPixels,f bool result = VRNativeEntrypoints.VR_IVRTrackedCamera_GetCameraProjection(m_pVRTrackedCamera,nDeviceIndex,flWidthPixels,flHeightPixels,flZNear,flZFar,ref pProjection); return result; } + public override bool GetRecommendedCameraUndistortion(uint nDeviceIndex,ref uint pUndistortionWidthPixels,ref uint pUndistortionHeightPixels) + { + CheckIfUsable(); + pUndistortionWidthPixels = 0; + pUndistortionHeightPixels = 0; + bool result = VRNativeEntrypoints.VR_IVRTrackedCamera_GetRecommendedCameraUndistortion(m_pVRTrackedCamera,nDeviceIndex,ref pUndistortionWidthPixels,ref pUndistortionHeightPixels); + return result; + } + public override bool SetCameraUndistortion(uint nDeviceIndex,uint nUndistortionWidthPixels,uint nUndistortionHeightPixels) + { + CheckIfUsable(); + bool result = VRNativeEntrypoints.VR_IVRTrackedCamera_SetCameraUndistortion(m_pVRTrackedCamera,nDeviceIndex,nUndistortionWidthPixels,nUndistortionHeightPixels); + return result; + } + public override void RequestVideoServicesForTool() + { + CheckIfUsable(); + VRNativeEntrypoints.VR_IVRTrackedCamera_RequestVideoServicesForTool(m_pVRTrackedCamera); + } + public override void ReleaseVideoServicesForTool() + { + CheckIfUsable(); + VRNativeEntrypoints.VR_IVRTrackedCamera_ReleaseVideoServicesForTool(m_pVRTrackedCamera); + } + public override bool GetVideoStreamFrameSharedTextureGL(bool bUndistorted,ref uint pglTextureId,IntPtr pglSharedTextureHandle) + { + CheckIfUsable(); + pglTextureId = 0; + bool result = VRNativeEntrypoints.VR_IVRTrackedCamera_GetVideoStreamFrameSharedTextureGL(m_pVRTrackedCamera,bUndistorted,ref pglTextureId,pglSharedTextureHandle); + return result; + } + public override bool ReleaseVideoStreamFrameSharedTextureGL(uint glTextureId,IntPtr glSharedTextureHandle) + { + CheckIfUsable(); + bool result = VRNativeEntrypoints.VR_IVRTrackedCamera_ReleaseVideoStreamFrameSharedTextureGL(m_pVRTrackedCamera,glTextureId,glSharedTextureHandle); + return result; + } + public override void LockSharedTextureGL(IntPtr glSharedTextureHandle,ref CameraVideoStreamFrame_t pFrameImage) + { + CheckIfUsable(); + VRNativeEntrypoints.VR_IVRTrackedCamera_LockSharedTextureGL(m_pVRTrackedCamera,glSharedTextureHandle,ref pFrameImage); + } + public override void UnlockSharedTextureGL(IntPtr glSharedTextureHandle) + { + CheckIfUsable(); + VRNativeEntrypoints.VR_IVRTrackedCamera_UnlockSharedTextureGL(m_pVRTrackedCamera,glSharedTextureHandle); + } } public class OpenVRInterop { - [DllImportAttribute("openvr_api", EntryPoint = "VR_Init")] - internal static extern IntPtr Init(ref EVRInitError peError, EVRApplicationType eApplicationType); - [DllImportAttribute("openvr_api", EntryPoint = "VR_Shutdown")] - internal static extern void Shutdown(); - [DllImportAttribute("openvr_api", EntryPoint = "VR_GetGenericInterface")] - internal static extern IntPtr GetGenericInterface([In, MarshalAs(UnmanagedType.LPStr)] string pchInterfaceVersion, ref EVRInitError peError); + [DllImportAttribute("openvr_api", EntryPoint = "VR_InitInternal")] + internal static extern uint InitInternal(ref EVRInitError peError, EVRApplicationType eApplicationType); + [DllImportAttribute("openvr_api", EntryPoint = "VR_ShutdownInternal")] + internal static extern void ShutdownInternal(); [DllImportAttribute("openvr_api", EntryPoint = "VR_IsHmdPresent")] internal static extern bool IsHmdPresent(); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IsRuntimeInstalled")] + internal static extern bool IsRuntimeInstalled(); [DllImportAttribute("openvr_api", EntryPoint = "VR_GetStringForHmdError")] internal static extern IntPtr GetStringForHmdError(EVRInitError error); - [DllImportAttribute("openvr_api", EntryPoint = "VR_IsRuntimeInstalled")] - internal static extern bool VR_IsRuntimeInstalled(); + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetGenericInterface")] + internal static extern IntPtr GetGenericInterface([In, MarshalAs(UnmanagedType.LPStr)] string pchInterfaceVersion, ref EVRInitError peError); + [DllImportAttribute("openvr_api", EntryPoint = "VR_IsInterfaceVersionValid")] + internal static extern bool IsInterfaceVersionValid([In, MarshalAs(UnmanagedType.LPStr)] string pchInterfaceVersion); + [DllImportAttribute("openvr_api", EntryPoint = "VR_GetInitToken")] + internal static extern uint GetInitToken(); } @@ -2555,6 +2665,8 @@ public enum EVREventType VREvent_SceneFocusGained = 403, VREvent_SceneApplicationChanged = 404, VREvent_SceneFocusChanged = 405, + VREvent_HideRenderModels = 410, + VREvent_ShowRenderModels = 411, VREvent_OverlayShown = 500, VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, @@ -2588,6 +2700,7 @@ public enum EVREventType VREvent_FirmwareUpdateFinished = 1101, VREvent_KeyboardClosed = 1200, VREvent_KeyboardCharInput = 1201, + VREvent_KeyboardDone = 1202, VREvent_ApplicationTransitionStarted = 1300, VREvent_ApplicationTransitionAborted = 1301, VREvent_ApplicationTransitionNewAppStarted = 1302, @@ -2744,6 +2857,8 @@ public enum EVRInitError IPC_CompositorInitFailed = 303, IPC_MutexInitFailed = 304, IPC_Failed = 305, + Compositor_Failed = 400, + Compositor_D3D11HardwareRequired = 401, VendorSpecific_UnableToConnectToOculusRuntime = 1000, VendorSpecific_HmdFound_CantOpenDevice = 1101, VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, @@ -2831,6 +2946,7 @@ public enum EVRCompositorError TextureIsOnWrongDevice = 104, TextureUsesUnsupportedFormat = 105, SharedTexturesNotSupported = 106, + IndexOutOfRange = 107, } public enum VROverlayInputMethod { @@ -2934,7 +3050,12 @@ public enum ECameraVideoStreamFormat [FieldOffset(0)] public VREvent_Notification_t notification; [FieldOffset(0)] public VREvent_Overlay_t overlay; [FieldOffset(0)] public VREvent_Status_t status; - [FieldOffset(0)] public VREvent_Keyboard_t keyboard; + [FieldOffset(0)] public VREvent_Ipd_t ipd; + [FieldOffset(0)] public VREvent_Chaperone_t chaperone; + [FieldOffset(0)] public VREvent_PerformanceTest_t performanceTest; + [FieldOffset(0)] public VREvent_TouchPadMove_t touchPadMove; + [FieldOffset(0)] public VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; + [FieldOffset(0)] public VREvent_Keyboard_t keyboard; // This has to be at the end due to a mono bug } [StructLayout(LayoutKind.Sequential)] public struct HmdMatrix34_t @@ -3238,22 +3359,30 @@ public enum ECameraVideoStreamFormat public float[] m_Pad; //float[4] public IntPtr m_pImageData; // void * } +[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_pVROverlay; // class vr::IVROverlay * + public IntPtr m_pVRRenderModels; // class vr::IVRRenderModels * + public IntPtr m_pVRExtendedDisplay; // class vr::IVRExtendedDisplay * + public IntPtr m_pVRSettings; // class vr::IVRSettings * + public IntPtr m_pVRApplications; // class vr::IVRApplications * +} public class OpenVR { - public static IntPtr Init(ref EVRInitError peError, EVRApplicationType eApplicationType = EVRApplicationType.VRApplication_Scene) - { - return OpenVRInterop.Init(ref peError, eApplicationType); - } - public static void Shutdown() + public static uint InitInternal(ref EVRInitError peError, EVRApplicationType eApplicationType) { - OpenVRInterop.Shutdown(); + return OpenVRInterop.InitInternal(ref peError, eApplicationType); } - public static IntPtr GetGenericInterface(string pchInterfaceVersion, ref EVRInitError peError) + public static void ShutdownInternal() { - return OpenVRInterop.GetGenericInterface(pchInterfaceVersion, ref peError); + OpenVRInterop.ShutdownInternal(); } public static bool IsHmdPresent() @@ -3261,11 +3390,31 @@ public static bool IsHmdPresent() return OpenVRInterop.IsHmdPresent(); } + public static bool IsRuntimeInstalled() + { + return OpenVRInterop.IsRuntimeInstalled(); + } + public static string GetStringForHmdError(EVRInitError error) { return Marshal.PtrToStringAnsi(OpenVRInterop.GetStringForHmdError(error)); } + public static IntPtr GetGenericInterface(string pchInterfaceVersion, ref EVRInitError peError) + { + return OpenVRInterop.GetGenericInterface(pchInterfaceVersion, ref peError); + } + + public static bool IsInterfaceVersionValid(string pchInterfaceVersion) + { + return OpenVRInterop.IsInterfaceVersionValid(pchInterfaceVersion); + } + + public static uint GetInitToken() + { + return OpenVRInterop.GetInitToken(); + } + public const uint k_unTrackingStringSize = 32; public const uint k_unMaxDriverDebugResponseSize = 32768; public const uint k_unTrackedDeviceIndex_Hmd = 0; @@ -3277,10 +3426,10 @@ public static string GetStringForHmdError(EVRInitError error) public const string IVRSystem_Version = "IVRSystem_011"; public const string IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; public const uint k_unMaxApplicationKeyLength = 128; - public const string IVRApplications_Version = "IVRApplications_003"; + public const string IVRApplications_Version = "IVRApplications_004"; public const string IVRChaperone_Version = "IVRChaperone_003"; public const string IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; - public const string IVRCompositor_Version = "IVRCompositor_011"; + public const string IVRCompositor_Version = "IVRCompositor_012"; public const uint k_unVROverlayMaxKeyLength = 128; public const uint k_unVROverlayMaxNameLength = 128; public const uint k_unMaxOverlayCount = 32; @@ -3315,6 +3464,10 @@ public static string GetStringForHmdError(EVRInitError error) public const string k_pch_SteamVR_AutomaticDirectModeEnabled_Bool = "automaticDirectModeEnabled"; public const string k_pch_SteamVR_RequestDirectModeEnabled_Bool = "requestDirectModeEnabled"; public const string k_pch_SteamVR_RequestDirectModeDisabled_Bool = "requestDirectModeDisabled"; + public const string k_pch_SteamVR_RequestDirectModeEdidVid_Int32 = "requestDirectModeEdidVid"; + public const string k_pch_SteamVR_RequestDirectModeEdidPid_Int32 = "requestDirectModeEdidPid"; + public const string k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; + public const string k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; public const string k_pch_Lighthouse_Section = "driver_lighthouse"; public const string k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; public const string k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; @@ -3352,34 +3505,218 @@ public static string GetStringForHmdError(EVRInitError error) public const string k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; 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_Camera_Section = "camera"; public const string IVRSettings_Version = "IVRSettings_001"; public const string IVRTrackedCamera_Version = "IVRTrackedCamera_001"; -} + static uint VRToken { get; set; } + class COpenVRContext + { + public COpenVRContext() { Clear(); } -public class Unity -{ - public const int k_nRenderEventID_WaitGetPoses = 201510020; - public const int k_nRenderEventID_SubmitL = 201510021; - public const int k_nRenderEventID_SubmitR = 201510022; - public const int k_nRenderEventID_Flush = 201510023; - public const int k_nRenderEventID_PostPresentHandoff = 201510024; + public void Clear() + { + m_pVRSystem = null; + m_pVRChaperone = null; + m_pVRChaperoneSetup = null; + m_pVRCompositor = null; + m_pVROverlay = null; + m_pVRRenderModels = null; + m_pVRExtendedDisplay = null; + m_pVRSettings = null; + m_pVRApplications = null; + } + + void CheckClear() + { + if (VRToken != GetInitToken()) + { + Clear(); + VRToken = GetInitToken(); + } + } + + public CVRSystem VRSystem() + { + CheckClear(); + if (m_pVRSystem == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRSystem_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRSystem = new CVRSystem(pInterface); + } + return m_pVRSystem; + } + + public CVRChaperone VRChaperone() + { + CheckClear(); + if (m_pVRChaperone == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRChaperone_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRChaperone = new CVRChaperone(pInterface); + } + return m_pVRChaperone; + } + + public CVRChaperoneSetup VRChaperoneSetup() + { + CheckClear(); + if (m_pVRChaperoneSetup == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRChaperoneSetup_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRChaperoneSetup = new CVRChaperoneSetup(pInterface); + } + return m_pVRChaperoneSetup; + } + + public CVRCompositor VRCompositor() + { + CheckClear(); + if (m_pVRCompositor == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRCompositor_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRCompositor = new CVRCompositor(pInterface); + } + return m_pVRCompositor; + } - [DllImport("openvr_api", EntryPoint="UnityHooks_GetRenderEventFunc")] - public static extern IntPtr GetRenderEventFunc(); + public CVROverlay VROverlay() + { + CheckClear(); + if (m_pVROverlay == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVROverlay_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVROverlay = new CVROverlay(pInterface); + } + return m_pVROverlay; + } + + public CVRRenderModels VRRenderModels() + { + CheckClear(); + if (m_pVRRenderModels == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRRenderModels_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRRenderModels = new CVRRenderModels(pInterface); + } + return m_pVRRenderModels; + } + + public CVRExtendedDisplay VRExtendedDisplay() + { + CheckClear(); + if (m_pVRExtendedDisplay == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRExtendedDisplay_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRExtendedDisplay = new CVRExtendedDisplay(pInterface); + } + return m_pVRExtendedDisplay; + } + + public CVRSettings VRSettings() + { + CheckClear(); + if (m_pVRSettings == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRSettings_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRSettings = new CVRSettings(pInterface); + } + return m_pVRSettings; + } + + public CVRApplications VRApplications() + { + CheckClear(); + if (m_pVRApplications == null) + { + var eError = EVRInitError.None; + var pInterface = GetGenericInterface(IVRApplications_Version, ref eError); + if (pInterface != IntPtr.Zero && eError == EVRInitError.None) + m_pVRApplications = new CVRApplications(pInterface); + } + return m_pVRApplications; + } + + private CVRSystem m_pVRSystem; + private CVRChaperone m_pVRChaperone; + private CVRChaperoneSetup m_pVRChaperoneSetup; + private CVRCompositor m_pVRCompositor; + private CVROverlay m_pVROverlay; + private CVRRenderModels m_pVRRenderModels; + private CVRExtendedDisplay m_pVRExtendedDisplay; + private CVRSettings m_pVRSettings; + private CVRApplications m_pVRApplications; + }; + + private static COpenVRContext _OpenVRInternal_ModuleContext = null; + static COpenVRContext OpenVRInternal_ModuleContext + { + get + { + if (_OpenVRInternal_ModuleContext == null) + _OpenVRInternal_ModuleContext = new COpenVRContext(); + return _OpenVRInternal_ModuleContext; + } + } + + public static CVRSystem System { get { return OpenVRInternal_ModuleContext.VRSystem(); } } + 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 CVROverlay Overlay { get { return OpenVRInternal_ModuleContext.VROverlay(); } } + public static CVRRenderModels RenderModels { get { return OpenVRInternal_ModuleContext.VRRenderModels(); } } + public static CVRApplications Applications { get { return OpenVRInternal_ModuleContext.VRApplications(); } } + public static CVRSettings Settings { get { return OpenVRInternal_ModuleContext.VRSettings(); } } + public static CVRExtendedDisplay ExtendedDisplay { get { return OpenVRInternal_ModuleContext.VRExtendedDisplay(); } } - [DllImport("openvr_api", EntryPoint="UnityHooks_SetSubmitParams")] - public static extern void SetSubmitParams(VRTextureBounds_t boundsL, VRTextureBounds_t boundsR, EVRSubmitFlags nSubmitFlags); + /** Finds the active installation of vrclient.dll and initializes it */ + public static CVRSystem Init(ref EVRInitError peError, EVRApplicationType eApplicationType = EVRApplicationType.VRApplication_Scene) + { + VRToken = InitInternal(ref peError, eApplicationType); + OpenVRInternal_ModuleContext.Clear(); + + if (peError != EVRInitError.None) + return null; - [DllImport("openvr_api", EntryPoint="UnityHooks_SetColorSpace")] - public static extern void SetColorSpace(EColorSpace eColorSpace); + bool bInterfaceValid = IsInterfaceVersionValid(IVRSystem_Version); + if (!bInterfaceValid) + { + ShutdownInternal(); + peError = EVRInitError.Init_InterfaceNotFound; + return null; + } + + return OpenVR.System; + } + + /** unloads vrclient.dll. Any interface pointers from the interface are + * invalid after this point */ + public static void Shutdown() + { + ShutdownInternal(); + } - [DllImport("openvr_api", EntryPoint="UnityHooks_EventWriteString")] - public static extern void EventWriteString([In, MarshalAs(UnmanagedType.LPWStr)] string sEvent); } + } diff --git a/headers/openvr_api.json b/headers/openvr_api.json index 0c8c77c8..7a5b5c59 100644 --- a/headers/openvr_api.json +++ b/headers/openvr_api.json @@ -198,6 +198,8 @@ ,{"name": "VREvent_SceneFocusGained","value": "403"} ,{"name": "VREvent_SceneApplicationChanged","value": "404"} ,{"name": "VREvent_SceneFocusChanged","value": "405"} + ,{"name": "VREvent_HideRenderModels","value": "410"} + ,{"name": "VREvent_ShowRenderModels","value": "411"} ,{"name": "VREvent_OverlayShown","value": "500"} ,{"name": "VREvent_OverlayHidden","value": "501"} ,{"name": "VREvent_DashboardActivated","value": "502"} @@ -231,6 +233,7 @@ ,{"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"} @@ -376,6 +379,8 @@ ,{"name": "VRInitError_IPC_CompositorInitFailed","value": "303"} ,{"name": "VRInitError_IPC_MutexInitFailed","value": "304"} ,{"name": "VRInitError_IPC_Failed","value": "305"} + ,{"name": "VRInitError_Compositor_Failed","value": "400"} + ,{"name": "VRInitError_Compositor_D3D11HardwareRequired","value": "401"} ,{"name": "VRInitError_VendorSpecific_UnableToConnectToOculusRuntime","value": "1000"} ,{"name": "VRInitError_VendorSpecific_HmdFound_CantOpenDevice","value": "1101"} ,{"name": "VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart","value": "1102"} @@ -457,6 +462,7 @@ ,{"name": "VRCompositorError_TextureIsOnWrongDevice","value": "104"} ,{"name": "VRCompositorError_TextureUsesUnsupportedFormat","value": "105"} ,{"name": "VRCompositorError_SharedTexturesNotSupported","value": "106"} + ,{"name": "VRCompositorError_IndexOutOfRange","value": "107"} ]} , {"enumname": "vr::VROverlayInputMethod","values": [ {"name": "VROverlayInputMethod_None","value": "0"} @@ -561,13 +567,13 @@ ,{ "constname": "k_unMaxApplicationKeyLength","consttype": "const uint32_t", "constval": "128"} ,{ - "constname": "IVRApplications_Version","consttype": "const char *const", "constval": "IVRApplications_003"} + "constname": "IVRApplications_Version","consttype": "const char *const", "constval": "IVRApplications_004"} ,{ "constname": "IVRChaperone_Version","consttype": "const char *const", "constval": "IVRChaperone_003"} ,{ "constname": "IVRChaperoneSetup_Version","consttype": "const char *const", "constval": "IVRChaperoneSetup_005"} ,{ - "constname": "IVRCompositor_Version","consttype": "const char *const", "constval": "IVRCompositor_011"} + "constname": "IVRCompositor_Version","consttype": "const char *const", "constval": "IVRCompositor_012"} ,{ "constname": "k_unVROverlayMaxKeyLength","consttype": "const uint32_t", "constval": "128"} ,{ @@ -636,6 +642,14 @@ "constname": "k_pch_SteamVR_RequestDirectModeEnabled_Bool","consttype": "const char *const", "constval": "requestDirectModeEnabled"} ,{ "constname": "k_pch_SteamVR_RequestDirectModeDisabled_Bool","consttype": "const char *const", "constval": "requestDirectModeDisabled"} +,{ + "constname": "k_pch_SteamVR_RequestDirectModeEdidVid_Int32","consttype": "const char *const", "constval": "requestDirectModeEdidVid"} +,{ + "constname": "k_pch_SteamVR_RequestDirectModeEdidPid_Int32","consttype": "const char *const", "constval": "requestDirectModeEdidPid"} +,{ + "constname": "k_pch_SteamVR_UsingSpeakers_Bool","consttype": "const char *const", "constval": "usingSpeakers"} +,{ + "constname": "k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float","consttype": "const char *const", "constval": "speakersForwardYawOffsetDegrees"} ,{ "constname": "k_pch_Lighthouse_Section","consttype": "const char *const", "constval": "driver_lighthouse"} ,{ @@ -710,6 +724,8 @@ "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_Camera_Section","consttype": "const char *const", "constval": "camera"} ,{ @@ -926,6 +942,16 @@ { "fieldname": "m_matDeviceToAbsoluteTracking", "fieldtype": "vr::HmdMatrix34_t"}, { "fieldname": "m_Pad", "fieldtype": "float [4]"}, { "fieldname": "m_pImageData", "fieldtype": "void *"}]} +,{"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_pVROverlay", "fieldtype": "class vr::IVROverlay *"}, +{ "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 *"}]} ], "methods":[{ "classname": "vr::IVRSystem", @@ -1409,6 +1435,14 @@ { "paramname": "pchAppKey" ,"paramtype": "const char *"} ] } +,{ + "classname": "vr::IVRApplications", + "methodname": "CancelApplicationLaunch", + "returntype": "bool", + "params": [ +{ "paramname": "pchAppKey" ,"paramtype": "const char *"} + ] +} ,{ "classname": "vr::IVRApplications", "methodname": "IdentifyApplication", @@ -1762,6 +1796,16 @@ { "paramname": "unGamePoseArrayCount" ,"paramtype": "uint32_t"} ] } +,{ + "classname": "vr::IVRCompositor", + "methodname": "GetLastPoseForTrackedDeviceIndex", + "returntype": "vr::EVRCompositorError", + "params": [ +{ "paramname": "unDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "pOutputPose" ,"paramtype": "struct vr::TrackedDevicePose_t *"}, +{ "paramname": "pOutputGamePose" ,"paramtype": "struct vr::TrackedDevicePose_t *"} + ] +} ,{ "classname": "vr::IVRCompositor", "methodname": "Submit", @@ -1888,6 +1932,11 @@ "methodname": "CompositorDumpImages", "returntype": "void" } +,{ + "classname": "vr::IVRCompositor", + "methodname": "ShouldAppRenderWithLowResources", + "returntype": "bool" +} ,{ "classname": "vr::IVROverlay", "methodname": "FindOverlay", @@ -2733,6 +2782,16 @@ { "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} ] } +,{ + "classname": "vr::IVRSettings", + "methodname": "RemoveKeyInSection", + "returntype": "void", + "params": [ +{ "paramname": "pchSection" ,"paramtype": "const char *"}, +{ "paramname": "pchSettingsKey" ,"paramtype": "const char *"}, +{ "paramname": "peError" ,"paramtype": "vr::EVRSettingsError *"} + ] +} ,{ "classname": "vr::IVRTrackedCamera", "methodname": "HasCamera", @@ -2881,5 +2940,71 @@ { "paramname": "pProjection" ,"paramtype": "vr::HmdMatrix44_t *"} ] } +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "GetRecommendedCameraUndistortion", + "returntype": "bool", + "params": [ +{ "paramname": "nDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "pUndistortionWidthPixels" ,"paramtype": "uint32_t *"}, +{ "paramname": "pUndistortionHeightPixels" ,"paramtype": "uint32_t *"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "SetCameraUndistortion", + "returntype": "bool", + "params": [ +{ "paramname": "nDeviceIndex" ,"paramtype": "vr::TrackedDeviceIndex_t"}, +{ "paramname": "nUndistortionWidthPixels" ,"paramtype": "uint32_t"}, +{ "paramname": "nUndistortionHeightPixels" ,"paramtype": "uint32_t"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "RequestVideoServicesForTool", + "returntype": "void" +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "ReleaseVideoServicesForTool", + "returntype": "void" +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "GetVideoStreamFrameSharedTextureGL", + "returntype": "bool", + "params": [ +{ "paramname": "bUndistorted" ,"paramtype": "bool"}, +{ "paramname": "pglTextureId" ,"paramtype": "vr::glUInt_t *"}, +{ "paramname": "pglSharedTextureHandle" ,"paramtype": "vr::glSharedTextureHandle_t *"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "ReleaseVideoStreamFrameSharedTextureGL", + "returntype": "bool", + "params": [ +{ "paramname": "glTextureId" ,"paramtype": "vr::glUInt_t"}, +{ "paramname": "glSharedTextureHandle" ,"paramtype": "vr::glSharedTextureHandle_t"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "LockSharedTextureGL", + "returntype": "void", + "params": [ +{ "paramname": "glSharedTextureHandle" ,"paramtype": "vr::glSharedTextureHandle_t"}, +{ "paramname": "pFrameImage" ,"paramtype": "vr::CameraVideoStreamFrame_t *"} + ] +} +,{ + "classname": "vr::IVRTrackedCamera", + "methodname": "UnlockSharedTextureGL", + "returntype": "void", + "params": [ +{ "paramname": "glSharedTextureHandle" ,"paramtype": "vr::glSharedTextureHandle_t"} + ] +} ] } \ No newline at end of file diff --git a/headers/openvr_capi.h b/headers/openvr_capi.h index 14da4a83..6259305d 100644 --- a/headers/openvr_capi.h +++ b/headers/openvr_capi.h @@ -112,10 +112,10 @@ unsigned long k_ulOverlayHandleInvalid = 0; char * IVRSystem_Version = "IVRSystem_011"; char * IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; unsigned int k_unMaxApplicationKeyLength = 128; -char * IVRApplications_Version = "IVRApplications_003"; +char * IVRApplications_Version = "IVRApplications_004"; char * IVRChaperone_Version = "IVRChaperone_003"; char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_005"; -char * IVRCompositor_Version = "IVRCompositor_011"; +char * IVRCompositor_Version = "IVRCompositor_012"; unsigned int k_unVROverlayMaxKeyLength = 128; unsigned int k_unVROverlayMaxNameLength = 128; unsigned int k_unMaxOverlayCount = 32; @@ -150,6 +150,10 @@ char * k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout"; char * k_pch_SteamVR_AutomaticDirectModeEnabled_Bool = "automaticDirectModeEnabled"; char * k_pch_SteamVR_RequestDirectModeEnabled_Bool = "requestDirectModeEnabled"; char * k_pch_SteamVR_RequestDirectModeDisabled_Bool = "requestDirectModeDisabled"; +char * k_pch_SteamVR_RequestDirectModeEdidVid_Int32 = "requestDirectModeEdidVid"; +char * k_pch_SteamVR_RequestDirectModeEdidPid_Int32 = "requestDirectModeEdidPid"; +char * k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; +char * k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; char * k_pch_Lighthouse_Section = "driver_lighthouse"; char * k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; char * k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; @@ -187,6 +191,7 @@ char * k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; char * k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; char * k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; char * k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; +char * k_pch_Perf_TestData_Float = "perfTestData"; char * k_pch_Camera_Section = "camera"; char * IVRSettings_Version = "IVRSettings_001"; char * IVRTrackedCamera_Version = "IVRTrackedCamera_001"; @@ -390,6 +395,8 @@ typedef enum EVREventType EVREventType_VREvent_SceneFocusGained = 403, EVREventType_VREvent_SceneApplicationChanged = 404, EVREventType_VREvent_SceneFocusChanged = 405, + EVREventType_VREvent_HideRenderModels = 410, + EVREventType_VREvent_ShowRenderModels = 411, EVREventType_VREvent_OverlayShown = 500, EVREventType_VREvent_OverlayHidden = 501, EVREventType_VREvent_DashboardActivated = 502, @@ -423,6 +430,7 @@ typedef enum EVREventType 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, @@ -590,6 +598,8 @@ typedef enum EVRInitError EVRInitError_VRInitError_IPC_CompositorInitFailed = 303, EVRInitError_VRInitError_IPC_MutexInitFailed = 304, EVRInitError_VRInitError_IPC_Failed = 305, + EVRInitError_VRInitError_Compositor_Failed = 400, + EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401, EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, @@ -683,6 +693,7 @@ typedef enum EVRCompositorError EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104, EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105, EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106, + EVRCompositorError_VRCompositorError_IndexOutOfRange = 107, } EVRCompositorError; typedef enum VROverlayInputMethod @@ -1022,6 +1033,19 @@ typedef struct CameraVideoStreamFrame_t void * m_pImageData; // void * } CameraVideoStreamFrame_t; +typedef struct COpenVRContext +{ + class IVRSystem * m_pVRSystem; // class vr::IVRSystem * + class IVRChaperone * m_pVRChaperone; // class vr::IVRChaperone * + class IVRChaperoneSetup * m_pVRChaperoneSetup; // class vr::IVRChaperoneSetup * + class IVRCompositor * m_pVRCompositor; // class vr::IVRCompositor * + class IVROverlay * m_pVROverlay; // class vr::IVROverlay * + class IVRRenderModels * m_pVRRenderModels; // class vr::IVRRenderModels * + class IVRExtendedDisplay * m_pVRExtendedDisplay; // class vr::IVRExtendedDisplay * + class IVRSettings * m_pVRSettings; // class vr::IVRSettings * + class IVRApplications * m_pVRApplications; // class vr::IVRApplications * +} COpenVRContext; + @@ -1082,6 +1106,7 @@ S_API EVRApplicationError VR_IVRApplications_GetApplicationKeyByIndex(intptr_t i S_API EVRApplicationError VR_IVRApplications_GetApplicationKeyByProcessId(intptr_t instancePtr, uint32_t unProcessId, char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); S_API EVRApplicationError VR_IVRApplications_LaunchApplication(intptr_t instancePtr, const char * pchAppKey); S_API EVRApplicationError VR_IVRApplications_LaunchDashboardOverlay(intptr_t instancePtr, const char * pchAppKey); +S_API bool VR_IVRApplications_CancelApplicationLaunch(intptr_t instancePtr, const char * pchAppKey); S_API EVRApplicationError VR_IVRApplications_IdentifyApplication(intptr_t instancePtr, uint32_t unProcessId, const char * pchAppKey); S_API uint32_t VR_IVRApplications_GetApplicationProcessId(intptr_t instancePtr, const char * pchAppKey); S_API char * VR_IVRApplications_GetApplicationsErrorNameFromEnum(intptr_t instancePtr, EVRApplicationError error); @@ -1125,6 +1150,7 @@ S_API void VR_IVRCompositor_SetTrackingSpace(intptr_t instancePtr, ETrackingUniv S_API ETrackingUniverseOrigin VR_IVRCompositor_GetTrackingSpace(intptr_t instancePtr); S_API EVRCompositorError VR_IVRCompositor_WaitGetPoses(intptr_t instancePtr, struct TrackedDevicePose_t * pRenderPoseArray, uint32_t unRenderPoseArrayCount, struct TrackedDevicePose_t * pGamePoseArray, uint32_t unGamePoseArrayCount); S_API EVRCompositorError VR_IVRCompositor_GetLastPoses(intptr_t instancePtr, struct TrackedDevicePose_t * pRenderPoseArray, uint32_t unRenderPoseArrayCount, struct TrackedDevicePose_t * pGamePoseArray, uint32_t unGamePoseArrayCount); +S_API EVRCompositorError VR_IVRCompositor_GetLastPoseForTrackedDeviceIndex(intptr_t instancePtr, TrackedDeviceIndex_t unDeviceIndex, struct TrackedDevicePose_t * pOutputPose, struct TrackedDevicePose_t * pOutputGamePose); S_API EVRCompositorError VR_IVRCompositor_Submit(intptr_t instancePtr, EVREye eEye, const struct Texture_t * pTexture, const struct VRTextureBounds_t * pBounds, EVRSubmitFlags nSubmitFlags); S_API void VR_IVRCompositor_ClearLastSubmittedFrame(intptr_t instancePtr); S_API void VR_IVRCompositor_PostPresentHandoff(intptr_t instancePtr); @@ -1145,6 +1171,7 @@ S_API void VR_IVRCompositor_ShowMirrorWindow(intptr_t instancePtr); S_API void VR_IVRCompositor_HideMirrorWindow(intptr_t instancePtr); S_API bool VR_IVRCompositor_IsMirrorWindowVisible(intptr_t instancePtr); S_API void VR_IVRCompositor_CompositorDumpImages(intptr_t instancePtr); +S_API bool VR_IVRCompositor_ShouldAppRenderWithLowResources(intptr_t instancePtr); S_API EVROverlayError VR_IVROverlay_FindOverlay(intptr_t instancePtr, const char * pchOverlayKey, VROverlayHandle_t * pOverlayHandle); S_API EVROverlayError VR_IVROverlay_CreateOverlay(intptr_t instancePtr, const char * pchOverlayKey, const char * pchOverlayFriendlyName, VROverlayHandle_t * pOverlayHandle); S_API EVROverlayError VR_IVROverlay_DestroyOverlay(intptr_t instancePtr, VROverlayHandle_t ulOverlayHandle); @@ -1235,6 +1262,7 @@ S_API void VR_IVRSettings_SetFloat(intptr_t instancePtr, const char * pchSection S_API void VR_IVRSettings_GetString(intptr_t instancePtr, const char * pchSection, const char * pchSettingsKey, char * pchValue, uint32_t unValueLen, const char * pchDefaultValue, EVRSettingsError * peError); S_API void VR_IVRSettings_SetString(intptr_t instancePtr, const char * pchSection, const char * pchSettingsKey, const char * pchValue, EVRSettingsError * peError); S_API void VR_IVRSettings_RemoveSection(intptr_t instancePtr, const char * pchSection, EVRSettingsError * peError); +S_API void VR_IVRSettings_RemoveKeyInSection(intptr_t instancePtr, const char * pchSection, const char * pchSettingsKey, EVRSettingsError * peError); S_API bool VR_IVRTrackedCamera_HasCamera(intptr_t instancePtr, TrackedDeviceIndex_t nDeviceIndex); S_API bool VR_IVRTrackedCamera_GetCameraFirmwareDescription(intptr_t instancePtr, TrackedDeviceIndex_t nDeviceIndex, char * pBuffer, uint32_t nBufferLen); S_API bool VR_IVRTrackedCamera_GetCameraFrameDimensions(intptr_t instancePtr, TrackedDeviceIndex_t nDeviceIndex, ECameraVideoStreamFormat nVideoStreamFormat, uint32_t * pWidth, uint32_t * pHeight); @@ -1257,7 +1285,7 @@ S_API void VR_IVRTrackedCamera_RequestVideoServicesForTool(intptr_t instancePtr) S_API void VR_IVRTrackedCamera_ReleaseVideoServicesForTool(intptr_t instancePtr); S_API bool VR_IVRTrackedCamera_GetVideoStreamFrameSharedTextureGL(intptr_t instancePtr, bool bUndistorted, glUInt_t * pglTextureId, glSharedTextureHandle_t * pglSharedTextureHandle); S_API bool VR_IVRTrackedCamera_ReleaseVideoStreamFrameSharedTextureGL(intptr_t instancePtr, glUInt_t glTextureId, glSharedTextureHandle_t glSharedTextureHandle); -S_API void VR_IVRTrackedCamera_LockSharedTextureGL(intptr_t instancePtr, glSharedTextureHandle_t glSharedTextureHandle); +S_API void VR_IVRTrackedCamera_LockSharedTextureGL(intptr_t instancePtr, glSharedTextureHandle_t glSharedTextureHandle, CameraVideoStreamFrame_t * pFrameImage); S_API void VR_IVRTrackedCamera_UnlockSharedTextureGL(intptr_t instancePtr, glSharedTextureHandle_t glSharedTextureHandle); // Global entry points diff --git a/headers/openvr_driver.h b/headers/openvr_driver.h index 658aa43b..9992f0d7 100644 --- a/headers/openvr_driver.h +++ b/headers/openvr_driver.h @@ -375,6 +375,9 @@ enum EVREventType 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_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_OverlayShown = 500, VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, @@ -416,6 +419,7 @@ enum EVREventType VREvent_KeyboardClosed = 1200, VREvent_KeyboardCharInput = 1201, + VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard VREvent_ApplicationTransitionStarted = 1300, VREvent_ApplicationTransitionAborted = 1301, @@ -818,6 +822,9 @@ enum EVRInitError VRInitError_IPC_MutexInitFailed = 304, VRInitError_IPC_Failed = 305, + VRInitError_Compositor_Failed = 400, + VRInitError_Compositor_D3D11HardwareRequired = 401, + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, @@ -974,7 +981,9 @@ namespace vr virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; virtual void GetString( const char *pchSection, const char *pchSettingsKey, 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; + virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0; + virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; }; //----------------------------------------------------------------------------- @@ -1001,6 +1010,10 @@ namespace vr static const char * const k_pch_SteamVR_AutomaticDirectModeEnabled_Bool = "automaticDirectModeEnabled"; static const char * const k_pch_SteamVR_RequestDirectModeEnabled_Bool = "requestDirectModeEnabled"; static const char * const k_pch_SteamVR_RequestDirectModeDisabled_Bool = "requestDirectModeDisabled"; + static const char * const k_pch_SteamVR_RequestDirectModeEdidVid_Int32 = "requestDirectModeEdidVid"; + static const char * const k_pch_SteamVR_RequestDirectModeEdidPid_Int32 = "requestDirectModeEdidPid"; + static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; + static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; //----------------------------------------------------------------------------- // lighthouse keys @@ -1059,6 +1072,7 @@ namespace vr static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; 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"; //----------------------------------------------------------------------------- // camera keys @@ -1068,9 +1082,6 @@ namespace vr static const char * const IVRSettings_Version = "IVRSettings_001"; - /** Returns the current IVRSettings pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRSettings *VR_CALLTYPE VRSettings(); - } // namespace vr // iservertrackeddevicedriver.h @@ -1276,7 +1287,7 @@ namespace vr /** 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 * pBounds, const vr::HmdMatrix34_t * pPose ) {} + 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 ) {} diff --git a/lib/linux64/libopenvr_api.so b/lib/linux64/libopenvr_api.so index e04b65e6..d4a4ecb3 100755 Binary files a/lib/linux64/libopenvr_api.so and b/lib/linux64/libopenvr_api.so differ diff --git a/lib/osx32/libopenvr_api.dylib b/lib/osx32/libopenvr_api.dylib index ddccc13c..5138526a 100644 Binary files a/lib/osx32/libopenvr_api.dylib and b/lib/osx32/libopenvr_api.dylib differ diff --git a/lib/win32/openvr_api.lib b/lib/win32/openvr_api.lib index 5110ef18..df871e31 100644 Binary files a/lib/win32/openvr_api.lib and b/lib/win32/openvr_api.lib differ diff --git a/lib/win64/openvr_api.lib b/lib/win64/openvr_api.lib index be1ab215..26822320 100644 Binary files a/lib/win64/openvr_api.lib and b/lib/win64/openvr_api.lib differ diff --git a/samples/bin/win32/openvr_api.dll b/samples/bin/win32/openvr_api.dll index 25bdf6dc..8494ad36 100644 Binary files a/samples/bin/win32/openvr_api.dll and b/samples/bin/win32/openvr_api.dll differ diff --git a/samples/bin/win64/openvr_api.dll b/samples/bin/win64/openvr_api.dll index ee01bf53..2df9f2e4 100644 Binary files a/samples/bin/win64/openvr_api.dll and b/samples/bin/win64/openvr_api.dll differ