diff --git a/OpenVR-SpaceCalibrator/Calibration.cpp b/OpenVR-SpaceCalibrator/Calibration.cpp index 9a53bb2..b93b526 100644 --- a/OpenVR-SpaceCalibrator/Calibration.cpp +++ b/OpenVR-SpaceCalibrator/Calibration.cpp @@ -298,7 +298,7 @@ void ScanAndApplyProfile(CalibrationContext &ctx) continue; } - if (deviceClass == vr::TrackedDeviceClass_TrackingReference || deviceClass == vr::TrackedDeviceClass_HMD) + if (/*deviceClass == vr::TrackedDeviceClass_TrackingReference ||*/ deviceClass == vr::TrackedDeviceClass_HMD) { //auto p = ctx.devicePoses[id].mDeviceToAbsoluteTracking.m; //printf("REF %d: %f %f %f\n", id, p[0][3], p[1][3], p[2][3]); diff --git a/OpenVR-SpaceCalibrator/Configuration.cpp b/OpenVR-SpaceCalibrator/Configuration.cpp index ec903a0..8bc8f41 100644 --- a/OpenVR-SpaceCalibrator/Configuration.cpp +++ b/OpenVR-SpaceCalibrator/Configuration.cpp @@ -14,7 +14,10 @@ static void ParseProfileV2(CalibrationContext &ctx, std::istream &stream); static std::string ConfigFileName() { - std::string vrRuntimeConfigName = vr::VR_RuntimePath(); + char cruntimePath[MAX_PATH] = { 0 }; + unsigned int pathLen; + vr::VR_GetRuntimePath(cruntimePath, MAX_PATH, &pathLen); + std::string vrRuntimeConfigName(cruntimePath); return vrRuntimeConfigName + "\\..\\..\\..\\config\\01spacecalibrator\\calibration.json"; } @@ -200,9 +203,7 @@ static void UpgradeProfileV1(CalibrationContext &ctx) void WriteActivateMultipleDriversToConfig() { - std::string configPath = vr::VR_RuntimePath(); - configPath += "\\..\\..\\..\\config\\steamvr.vrsettings"; - + std::string configPath = ConfigFileName(); std::ifstream ifile(configPath); if (!ifile.good()) throw std::runtime_error("failed to read steamvr.vrsettings"); diff --git a/OpenVR-SpaceCalibrator/OpenVR-SpaceCalibrator.cpp b/OpenVR-SpaceCalibrator/OpenVR-SpaceCalibrator.cpp index 1c44da5..5e53c1b 100644 --- a/OpenVR-SpaceCalibrator/OpenVR-SpaceCalibrator.cpp +++ b/OpenVR-SpaceCalibrator/OpenVR-SpaceCalibrator.cpp @@ -119,7 +119,7 @@ void TryCreateVROverlay() vr::VROverlay()->SetOverlayWidthInMeters(overlayMainHandle, 3.0f); vr::VROverlay()->SetOverlayInputMethod(overlayMainHandle, vr::VROverlayInputMethod_Mouse); - vr::VROverlay()->SetOverlayFlag(overlayMainHandle, vr::VROverlayFlags_SendVRScrollEvents, true); + vr::VROverlay()->SetOverlayFlag(overlayMainHandle, vr::VROverlayFlags_SendVRDiscreteScrollEvents, true); std::string iconPath = cwd; iconPath += "\\icon.png"; @@ -148,6 +148,27 @@ void InitVR() { throw std::runtime_error("OpenVR error: Outdated IVROverlay_Version"); } + + vr::EVRSettingsError vrSettingsError; + bool multipledrivers = vr::VRSettings()->GetBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, + &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) + { + std::string err = "Could not read \"" + + std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool) + + "\" setting: " + + vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + throw std::runtime_error(err); + } + if (!multipledrivers) + { + vr::VRSettings()->SetBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, + true); + } } void RunLoop() @@ -192,10 +213,11 @@ void RunLoop() char buf[0x400]; ImGui::GetActiveText(buf, sizeof buf); buf[0x3ff] = 0; + uint32_t unFlags = 0; // EKeyboardFlags vr::VROverlay()->ShowKeyboardForOverlay( overlayMainHandle, vr::k_EGamepadTextInputModeNormal, vr::k_EGamepadTextInputLineModeSingleLine, - "Space Calibrator Overlay", sizeof buf, buf, false, 0 + unFlags, "Space Calibrator Overlay", sizeof buf, buf, 0 ); keyboardOpen = true; } @@ -214,7 +236,7 @@ void RunLoop() case vr::VREvent_MouseButtonUp: io.MouseDown[vrEvent.data.mouse.button == vr::VRMouseButton_Left ? 0 : 1] = false; break; - case vr::VREvent_Scroll: + case vr::VREvent_ScrollDiscrete: io.MouseWheelH += vrEvent.data.scroll.xdelta * 360.0f * 8.0f; io.MouseWheel += vrEvent.data.scroll.ydelta * 360.0f * 8.0f; break; @@ -342,7 +364,11 @@ static void HandleCommandLine(LPWSTR lpCmdLine) vr::VR_Init(&vrErr, vr::VRApplication_Utility); if (vrErr == vr::VRInitError_None) { - printf("%s", vr::VR_RuntimePath()); + char cruntimePath[MAX_PATH] = { 0 }; + unsigned int pathLen; + vr::VR_GetRuntimePath(cruntimePath, MAX_PATH, &pathLen); + + printf("%s", cruntimePath); vr::VR_Shutdown(); exit(0); } @@ -412,7 +438,7 @@ static void HandleCommandLine(LPWSTR lpCmdLine) vr::VR_Shutdown(); exit(-2); } - else if (lstrcmp(lpCmdLine, L"-activatemultipledrivers") == 0) + else if (lstrcmp(lpCmdLine, L"-activatemultipledriversManual") == 0) { int ret = -2; auto vrErr = vr::VRInitError_None; @@ -436,4 +462,40 @@ static void HandleCommandLine(LPWSTR lpCmdLine) vr::VR_Shutdown(); exit(ret); } + else if (lstrcmp(lpCmdLine, L"-activatemultipledrivers") == 0) + { + int ret = -2; + auto vrErr = vr::VRInitError_None; + vr::VR_Init(&vrErr, vr::VRApplication_Utility); + if (vrErr == vr::VRInitError_None) + { + vr::EVRSettingsError vrSettingsError; + bool multipledrivers = vr::VRSettings()->GetBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, + &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) + { + std::string err = "Could not read \"" + + std::string(vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool) + + "\" setting: " + + vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + std::cerr << "Failed to set activateMultipleDrivers: " << err << std::endl; + } + else if (!multipledrivers) + { + vr::VRSettings()->SetBool( + vr::k_pch_SteamVR_Section, + vr::k_pch_SteamVR_ActivateMultipleDrivers_Bool, + true); + ret = 0; + } + } + else + { + fprintf(stderr, "Failed to initialize OpenVR: %s\n", vr::VR_GetVRInitErrorAsEnglishDescription(vrErr)); + } + vr::VR_Shutdown(); + exit(ret); + } } diff --git a/OpenVR-SpaceCalibrator/UserInterface.cpp b/OpenVR-SpaceCalibrator/UserInterface.cpp index f9d6b18..8110823 100644 --- a/OpenVR-SpaceCalibrator/UserInterface.cpp +++ b/OpenVR-SpaceCalibrator/UserInterface.cpp @@ -9,7 +9,7 @@ #include #include -#define VERSION_STRING "0.8" +#define VERSION_STRING "0.8.1" struct VRDevice { diff --git a/lib/openvr/lib/win32/openvr_api.lib b/lib/openvr/lib/win32/openvr_api.lib index 2ae7254..ae1721f 100644 Binary files a/lib/openvr/lib/win32/openvr_api.lib and b/lib/openvr/lib/win32/openvr_api.lib differ diff --git a/lib/openvr/lib/win64/openvr_api.lib b/lib/openvr/lib/win64/openvr_api.lib index 62de19d..60c1c01 100644 Binary files a/lib/openvr/lib/win64/openvr_api.lib and b/lib/openvr/lib/win64/openvr_api.lib differ diff --git a/lib/openvr/openvr.h b/lib/openvr/openvr.h index 4ad9486..7f593f3 100644 --- a/lib/openvr/openvr.h +++ b/lib/openvr/openvr.h @@ -11,6 +11,14 @@ +// version.h +namespace vr +{ + static const uint32_t k_nSteamVRVersionMajor = 1; + static const uint32_t k_nSteamVRVersionMinor = 10; + static const uint32_t k_nSteamVRVersionBuild = 30; +} // namespace vr + // vrtypes.h #ifndef _INCLUDE_VRTYPES_H #define _INCLUDE_VRTYPES_H @@ -29,6 +37,10 @@ namespace vr { #pragma pack( push, 8 ) +/** 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; typedef uint32_t glUInt_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; @@ -107,11 +129,17 @@ enum EVREye enum ETextureType { + 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 + 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 @@ -141,6 +169,8 @@ enum ETrackingResult TrackingResult_Running_OK = 200, TrackingResult_Running_OutOfRange = 201, + + TrackingResult_Fallback_RotationOnly = 300, }; typedef uint32_t DriverId_t; @@ -164,6 +194,8 @@ enum ETrackedDeviceClass 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_Max }; @@ -173,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 { @@ -199,6 +250,17 @@ enum ETrackingUniverseOrigin 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; @@ -206,23 +268,36 @@ 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; @@ -272,7 +347,21 @@ enum ETrackedDeviceProperty Prop_ParentDriver_Uint64 = 1034, Prop_ResourceRoot_String = 1035, Prop_RegisteredDeviceType_String = 1036, - Prop_InputProfileName_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_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, @@ -327,7 +416,60 @@ enum ETrackedDeviceProperty 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, + 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, @@ -347,6 +489,8 @@ 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. @@ -358,11 +502,13 @@ enum ETrackedDeviceProperty 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, @@ -372,10 +518,18 @@ enum ETrackedDeviceProperty 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 */ @@ -397,8 +551,30 @@ enum ETrackedPropertyError 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 @@ -413,6 +589,23 @@ 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 { @@ -431,11 +624,21 @@ enum EVRSubmitFlags 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, }; /** Data required for passing Vulkan textures to IVRCompositor::Submit. -* Be sure to call OpenVR_Shutdown before destroying these resources. */ +* 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 @@ -495,36 +698,44 @@ enum EVREventType VREvent_ButtonTouch = 202, // data is controller VREvent_ButtonUntouch = 203, // data is controller - VREvent_DualAnalog_Press = 250, // data is dualAnalog - VREvent_DualAnalog_Unpress = 251, // data is dualAnalog - VREvent_DualAnalog_Touch = 252, // data is dualAnalog - VREvent_DualAnalog_Untouch = 253, // data is dualAnalog - VREvent_DualAnalog_Move = 254, // data is dualAnalog - VREvent_DualAnalog_ModeSwitch1 = 255, // data is dualAnalog - VREvent_DualAnalog_ModeSwitch2 = 256, // data is dualAnalog - VREvent_DualAnalog_Cancel = 257, // data is dualAnalog + // 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, @@ -532,7 +743,7 @@ enum EVREventType VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, VREvent_DashboardDeactivated = 503, - VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay + //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 @@ -542,11 +753,12 @@ enum EVREventType 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_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 @@ -556,6 +768,10 @@ enum EVREventType 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, @@ -564,36 +780,47 @@ enum EVREventType VREvent_Quit = 700, // data is process VREvent_ProcessQuit = 701, // data is process - VREvent_QuitAborted_UserPrompt = 702, // 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, + VREvent_ChaperoneDataHasChanged = 800, // this will never happen with the new chaperone system VREvent_ChaperoneUniverseHasChanged = 801, - VREvent_ChaperoneTempDataHasChanged = 802, + 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_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_StatusUpdate = 900, + VREvent_WebInterface_InstallDriverCompleted = 950, + VREvent_MCImageUpdated = 1000, VREvent_FirmwareUpdateStarted = 1100, @@ -603,19 +830,27 @@ enum EVREventType VREvent_KeyboardCharInput = 1201, VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard - VREvent_ApplicationTransitionStarted = 1300, - VREvent_ApplicationTransitionAborted = 1301, - VREvent_ApplicationTransitionNewAppStarted = 1302, + //VREvent_ApplicationTransitionStarted = 1300, + //VREvent_ApplicationTransitionAborted = 1301, + //VREvent_ApplicationTransitionNewAppStarted = 1302, VREvent_ApplicationListUpdated = 1303, VREvent_ApplicationMimeTypeLoad = 1304, - VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, + // VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, VREvent_ProcessConnected = 1306, VREvent_ProcessDisconnected = 1307, - VREvent_Compositor_MirrorWindowShown = 1400, - VREvent_Compositor_MirrorWindowHidden = 1401, + //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, @@ -630,6 +865,26 @@ enum EVREventType 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, @@ -648,6 +903,7 @@ enum EDeviceActivityLevel 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, }; @@ -677,6 +933,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 }; @@ -705,11 +965,12 @@ 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 @@ -746,6 +1007,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; }; @@ -753,6 +1016,7 @@ struct VREvent_Process_t struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; }; @@ -785,6 +1049,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 @@ -831,21 +1099,87 @@ struct VREvent_Property_t ETrackedDeviceProperty prop; }; -enum EDualAnalogWhich +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 { - k_EDualAnalog_Left = 0, - k_EDualAnalog_Right = 1, + EShowUIType eType; }; -struct VREvent_DualAnalog_t +struct VREvent_ShowDevTools_t { - float x, y; // coordinates are -1..1 analog values - float transformedX, transformedY; // transformed by the center and radius numbers provided by the overlay - EDualAnalogWhich which; + 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; +}; -/** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ typedef union { VREvent_Reserved_t reserved; @@ -868,7 +1202,16 @@ typedef union VREvent_EditingCameraSurface_t cameraSurface; VREvent_MessageOverlay_t messageOverlay; VREvent_Property_t property; - VREvent_DualAnalog_t dualAnalog; + 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; @@ -892,6 +1235,71 @@ struct VREvent_t #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. * This mesh draws on all the pixels that will be hidden after distortion. @@ -988,17 +1396,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; @@ -1029,6 +1426,9 @@ enum EVROverlayError 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 @@ -1044,7 +1444,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, // Start up SteamVR + VRApplication_Bootstrapper = 7, // reserved for vrstartup + VRApplication_WebHelper = 8, // reserved for vrwebhelper VRApplication_Max }; @@ -1070,6 +1471,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 @@ -1119,6 +1567,12 @@ enum EVRInitError 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, @@ -1133,6 +1587,8 @@ enum EVRInitError // 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, @@ -1143,14 +1599,101 @@ enum EVRInitError 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_Compositor_UnableToCreateDevice = 405, - + 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, @@ -1167,8 +1710,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 @@ -1208,6 +1755,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. @@ -1216,6 +1771,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) @@ -1229,7 +1794,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 @@ -1237,6 +1804,82 @@ 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 { @@ -1247,34 +1890,76 @@ struct DriverDirectMode_FrameTiming 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 @@ -1368,7 +2053,12 @@ class IVRSystem * 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] - * Returns an id that should be used by the application. + * 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; @@ -1441,10 +2131,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; // ------------------------------------ @@ -1477,6 +2167,11 @@ 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 @@ -1523,44 +2218,39 @@ class IVRSystem // ------------------------------------ /** Fills the supplied struct with the current state of the controller. Returns false if the controller index - * is invalid. */ + * 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. */ + * 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; - - /** 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 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; - /** Returns true if input focus is captured by another process. */ - virtual bool IsInputFocusCapturedByAnotherProcess() = 0; + /** 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; - // ------------------------------------ - // Debug Methods - // ------------------------------------ + /** 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; - /** 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 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 @@ -1581,14 +2271,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_017"; +static const char * const IVRSystem_Version = "IVRSystem_021"; } @@ -1643,27 +2348,25 @@ namespace vr VRApplicationProperty_NewsURL_String = 51, VRApplicationProperty_ImagePath_String = 52, VRApplicationProperty_Source_String = 53, - VRApplicationProperty_ActionManifestPath_String = 54, - VRApplicationProperty_ActionBindingPath_String = 55, + 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 @@ -1702,7 +2405,7 @@ namespace vr /** 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. */ @@ -1756,24 +2459,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. @@ -1787,10 +2490,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 @@ -1805,11 +2505,13 @@ namespace vr 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 @@ -1830,9 +2532,6 @@ 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 void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; @@ -1850,7 +2549,83 @@ namespace vr }; //----------------------------------------------------------------------------- - static const char * const IVRSettings_Version = "IVRSettings_002"; + 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 @@ -1871,23 +2646,28 @@ namespace vr static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; 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_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_SupersampleScale_Float = "supersampleScale"; - static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; - static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; - static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + 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_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; @@ -1897,18 +2677,50 @@ namespace vr 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"; + + //----------------------------------------------------------------------------- + // 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_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 @@ -1929,6 +2741,7 @@ namespace vr 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"; @@ -1951,13 +2764,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_LinuxGPUProfiling_Bool = "linuxGPUProfiling"; + static const char * const k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; //----------------------------------------------------------------------------- // collision bounds keys @@ -1971,6 +2782,7 @@ namespace vr 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 @@ -1984,15 +2796,24 @@ namespace vr 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_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; //----------------------------------------------------------------------------- @@ -2010,6 +2831,10 @@ namespace vr 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_UseWebSettings = "useWebSettings"; + 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 @@ -2018,6 +2843,62 @@ 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"; + + //----------------------------------------------------------------------------- + // 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"; + + //----------------------------------------------------------------------------- + // 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 @@ -2155,6 +3036,9 @@ class IVRChaperoneSetup /** Sets the Collision Bounds in the working copy. */ 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; @@ -2167,17 +3051,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"; } @@ -2203,6 +3092,7 @@ enum EVRCompositorError VRCompositorError_IndexOutOfRange = 107, VRCompositorError_AlreadySubmitted = 108, VRCompositorError_InvalidBounds = 109, + VRCompositorError_AlreadySet = 110, }; /** Timing mode passed to SetExplicitTimingMode(); see that function for documentation */ @@ -2213,56 +3103,6 @@ enum EVRCompositorTimingMode VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2, }; -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. - -/** 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 -}; - /** Cumulative stats for current application. These are not cleared until a new app connects, * but they do stop accumulating once the associated app disconnects. */ struct Compositor_CumulativeStats @@ -2293,6 +3133,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 */ @@ -2313,8 +3199,8 @@ class IVRCompositor * - 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; + 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, @@ -2359,7 +3245,7 @@ class IVRCompositor /** 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; + 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. */ @@ -2414,16 +3300,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. */ @@ -2486,14 +3373,102 @@ class IVRCompositor * 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_022"; +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 { @@ -2509,7 +3484,7 @@ struct NotificationBitmap_t , m_nHeight( 0 ) , m_nBytesPerPixel( 0 ) { - }; + } void *m_pImageData; int32_t m_nWidth; @@ -2594,7 +3569,7 @@ 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; @@ -2604,61 +3579,79 @@ namespace vr { 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, // Analog inputs from tracked controllers are turned into DualAnalog events + // 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, + VROverlayFlags_NoDashboardTab = 1 << 3, - // Set this flag on a dashboard that is able to deal with gamepad focus events - VROverlayFlags_AcceptsGamepadEvents = 4, + // When this is set the overlay will receive VREvent_ScrollDiscrete events like a mouse wheel. + // Requires mouse input mode. + VROverlayFlags_SendVRDiscreteScrollEvents = 1 << 6, - // Indicates that the overlay should dim/brighten to show gamepad focus - VROverlayFlags_ShowGamepadFocus = 5, - - // 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, // If set, the overlay will be shown in the dashboard, otherwise it will be hidden. - VROverlayFlags_VisibleInDashboard = 15, + 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 @@ -2702,17 +3695,6 @@ namespace vr k_EGamepadTextInputLineModeMultipleLines = 1 }; - /** Directions for changing focus between overlays with the gamepad */ - enum EOverlayDirection - { - OverlayDirection_Up = 0, - OverlayDirection_Down = 1, - OverlayDirection_Left = 2, - OverlayDirection_Right = 3, - - OverlayDirection_Count = 4, - }; - enum EVROverlayIntersectionMaskPrimitiveType { OverlayIntersectionPrimitiveType_Rectangle, @@ -2747,6 +3729,13 @@ namespace vr 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: @@ -2765,17 +3754,6 @@ namespace vr * 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; @@ -2812,6 +3790,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; @@ -2850,13 +3831,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. */ @@ -2871,13 +3851,6 @@ namespace vr /** Gets the part of the texture to use for the overlay. UV Min is the upper left corner and UV Max is the lower right corner. */ virtual EVROverlayError GetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, VRTextureBounds_t *pOverlayTextureBounds ) = 0; - /** Gets render model to draw behind this overlay */ - virtual uint32_t GetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, char *pchValue, uint32_t unBufferSize, HmdColor_t *pColor, vr::EVROverlayError *pError ) = 0; - - /** Sets render model to draw behind this overlay and the vertex color to use, pass null for pColor to match the overlays vertex color. - The model is scaled by the same amount as the overlay, with a default of 1m. */ - virtual vr::EVROverlayError SetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, const char *pchRenderModel, const HmdColor_t *pColor ) = 0; - /** Returns the transform type of this overlay. */ virtual EVROverlayError GetOverlayTransformType( VROverlayHandle_t ulOverlayHandle, VROverlayTransformType *peTransformType ) = 0; @@ -2898,7 +3871,7 @@ 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; @@ -2906,6 +3879,13 @@ namespace vr /** 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; @@ -2944,37 +3924,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 the current Gamepad focus overlay */ - virtual EVROverlayError SetGamepadFocusOverlay( VROverlayHandle_t ulNewFocusOverlay ) = 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; - /** 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; + /** 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; - /** 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; + /** 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 the analog input to Dual Analog coordinate scale for the specified overlay. */ - virtual EVROverlayError SetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, const HmdVector2_t & vCenter, float fRadius ) = 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; - /** Gets the analog input to Dual Analog coordinate scale for the specified overlay. */ - virtual EVROverlayError GetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, HmdVector2_t *pvCenter, float *pfRadius ) = 0; + /** Clears the override cursor position for this overlay */ + virtual EVROverlayError ClearOverlayCursorPositionOverride( VROverlayHandle_t ulOverlayHandle ) = 0; // --------------------------------------------- // Overlay texture methods @@ -2992,7 +3961,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 */ @@ -3047,10 +4016,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; @@ -3064,16 +4039,6 @@ 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; - // --------------------------------------------- - // Overlay input methods - // --------------------------------------------- - - /** 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; - - virtual EVROverlayError GetOverlayFlags( VROverlayHandle_t ulOverlayHandle, uint32_t *pFlags ) = 0; - // --------------------------------------------- // Message box methods // --------------------------------------------- @@ -3085,10 +4050,87 @@ namespace vr virtual void CloseMessageOverlay() = 0; }; - static const char * const IVROverlay_Version = "IVROverlay_017"; + 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 { @@ -3120,25 +4162,6 @@ 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 -{ - 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; -}; - /** A single vertex in a render model */ struct RenderModel_Vertex_t { @@ -3273,6 +4296,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 */ @@ -3290,7 +4316,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"; } @@ -3340,9 +4366,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 GetCameraIntrinsics( 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. @@ -3372,9 +4398,11 @@ class IVRTrackedCamera /** 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 @@ -3505,7 +4533,7 @@ 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"; @@ -3523,6 +4551,10 @@ class IVRDriverManager /** 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"; @@ -3530,13 +4562,512 @@ 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. @@ -3562,8 +5093,8 @@ 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 ); @@ -3676,6 +5207,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(); @@ -3764,12 +5317,68 @@ namespace vr return m_pVRDriverManager; } + IVRInput *VRInput() + { + CheckClear(); + if ( !m_pVRInput ) + { + EVRInitError eError; + m_pVRInput = (IVRInput *)VR_GetGenericInterface( IVRInput_Version, &eError ); + } + return m_pVRInput; + } + + IVRIOBuffer *VRIOBuffer() + { + if ( !m_pVRIOBuffer ) + { + EVRInitError eError; + m_pVRIOBuffer = ( IVRIOBuffer * )VR_GetGenericInterface( IVRIOBuffer_Version, &eError ); + } + return m_pVRIOBuffer; + } + + 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; @@ -3778,6 +5387,11 @@ namespace vr 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() @@ -3791,6 +5405,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(); } @@ -3799,6 +5415,11 @@ namespace vr inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); } inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); } inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleContext().VRDriverManager(); } + inline IVRInput *VR_CALLTYPE VRInput() { return OpenVRInternal_ModuleContext().VRInput(); } + inline IVRIOBuffer *VR_CALLTYPE VRIOBuffer() { return OpenVRInternal_ModuleContext().VRIOBuffer(); } + inline 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() { @@ -3807,6 +5428,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; @@ -3815,6 +5438,11 @@ namespace vr 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_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo ); @@ -3854,4 +5482,6 @@ namespace vr { VR_ShutdownInternal(); } + +#endif // OPENVR_INTERFACE_INTERNAL } diff --git a/lib/openvr/openvr_driver.h b/lib/openvr/openvr_driver.h index e032bca..e2a757c 100644 --- a/lib/openvr/openvr_driver.h +++ b/lib/openvr/openvr_driver.h @@ -11,6 +11,14 @@ +// version.h +namespace vr +{ + static const uint32_t k_nSteamVRVersionMajor = 1; + static const uint32_t k_nSteamVRVersionMinor = 10; + static const uint32_t k_nSteamVRVersionBuild = 30; +} // namespace vr + // vrtypes.h #ifndef _INCLUDE_VRTYPES_H #define _INCLUDE_VRTYPES_H @@ -29,6 +37,10 @@ namespace vr { #pragma pack( push, 8 ) +/** 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; typedef uint32_t glUInt_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; @@ -107,11 +129,17 @@ enum EVREye enum ETextureType { + 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 + 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 @@ -141,6 +169,8 @@ enum ETrackingResult TrackingResult_Running_OK = 200, TrackingResult_Running_OutOfRange = 201, + + TrackingResult_Fallback_RotationOnly = 300, }; typedef uint32_t DriverId_t; @@ -164,6 +194,8 @@ enum ETrackedDeviceClass 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_Max }; @@ -173,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 { @@ -199,6 +250,17 @@ enum ETrackingUniverseOrigin 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; @@ -206,23 +268,36 @@ 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; @@ -272,7 +347,21 @@ enum ETrackedDeviceProperty Prop_ParentDriver_Uint64 = 1034, Prop_ResourceRoot_String = 1035, Prop_RegisteredDeviceType_String = 1036, - Prop_InputProfileName_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_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, @@ -327,7 +416,60 @@ enum ETrackedDeviceProperty 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, + 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, @@ -347,6 +489,8 @@ 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. @@ -358,11 +502,13 @@ enum ETrackedDeviceProperty 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, @@ -372,10 +518,18 @@ enum ETrackedDeviceProperty 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 */ @@ -397,8 +551,30 @@ enum ETrackedPropertyError 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 @@ -413,6 +589,23 @@ 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 { @@ -431,11 +624,21 @@ enum EVRSubmitFlags 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, }; /** Data required for passing Vulkan textures to IVRCompositor::Submit. -* Be sure to call OpenVR_Shutdown before destroying these resources. */ +* 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 @@ -495,36 +698,44 @@ enum EVREventType VREvent_ButtonTouch = 202, // data is controller VREvent_ButtonUntouch = 203, // data is controller - VREvent_DualAnalog_Press = 250, // data is dualAnalog - VREvent_DualAnalog_Unpress = 251, // data is dualAnalog - VREvent_DualAnalog_Touch = 252, // data is dualAnalog - VREvent_DualAnalog_Untouch = 253, // data is dualAnalog - VREvent_DualAnalog_Move = 254, // data is dualAnalog - VREvent_DualAnalog_ModeSwitch1 = 255, // data is dualAnalog - VREvent_DualAnalog_ModeSwitch2 = 256, // data is dualAnalog - VREvent_DualAnalog_Cancel = 257, // data is dualAnalog + // 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, @@ -532,7 +743,7 @@ enum EVREventType VREvent_OverlayHidden = 501, VREvent_DashboardActivated = 502, VREvent_DashboardDeactivated = 503, - VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay + //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 @@ -542,11 +753,12 @@ enum EVREventType 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_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 @@ -556,6 +768,10 @@ enum EVREventType 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, @@ -564,36 +780,47 @@ enum EVREventType VREvent_Quit = 700, // data is process VREvent_ProcessQuit = 701, // data is process - VREvent_QuitAborted_UserPrompt = 702, // 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, + VREvent_ChaperoneDataHasChanged = 800, // this will never happen with the new chaperone system VREvent_ChaperoneUniverseHasChanged = 801, - VREvent_ChaperoneTempDataHasChanged = 802, + 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_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_StatusUpdate = 900, + VREvent_WebInterface_InstallDriverCompleted = 950, + VREvent_MCImageUpdated = 1000, VREvent_FirmwareUpdateStarted = 1100, @@ -603,19 +830,27 @@ enum EVREventType VREvent_KeyboardCharInput = 1201, VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard - VREvent_ApplicationTransitionStarted = 1300, - VREvent_ApplicationTransitionAborted = 1301, - VREvent_ApplicationTransitionNewAppStarted = 1302, + //VREvent_ApplicationTransitionStarted = 1300, + //VREvent_ApplicationTransitionAborted = 1301, + //VREvent_ApplicationTransitionNewAppStarted = 1302, VREvent_ApplicationListUpdated = 1303, VREvent_ApplicationMimeTypeLoad = 1304, - VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, + // VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, VREvent_ProcessConnected = 1306, VREvent_ProcessDisconnected = 1307, - VREvent_Compositor_MirrorWindowShown = 1400, - VREvent_Compositor_MirrorWindowHidden = 1401, + //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, @@ -630,6 +865,26 @@ enum EVREventType 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, @@ -648,6 +903,7 @@ enum EDeviceActivityLevel 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, }; @@ -677,6 +933,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 }; @@ -705,11 +965,12 @@ 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 @@ -746,6 +1007,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; }; @@ -753,6 +1016,7 @@ struct VREvent_Process_t struct VREvent_Overlay_t { uint64_t overlayHandle; + uint64_t devicePath; }; @@ -785,6 +1049,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 @@ -831,21 +1099,87 @@ struct VREvent_Property_t ETrackedDeviceProperty prop; }; -enum EDualAnalogWhich +struct VREvent_HapticVibration_t { - k_EDualAnalog_Left = 0, - k_EDualAnalog_Right = 1, + 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_DualAnalog_t +struct VREvent_WebConsole_t { - float x, y; // coordinates are -1..1 analog values - float transformedX, transformedY; // transformed by the center and radius numbers provided by the overlay - EDualAnalogWhich which; + 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; +}; -/** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ typedef union { VREvent_Reserved_t reserved; @@ -868,7 +1202,16 @@ typedef union VREvent_EditingCameraSurface_t cameraSurface; VREvent_MessageOverlay_t messageOverlay; VREvent_Property_t property; - VREvent_DualAnalog_t dualAnalog; + 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; @@ -892,6 +1235,71 @@ struct VREvent_t #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. * This mesh draws on all the pixels that will be hidden after distortion. @@ -988,17 +1396,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; @@ -1029,6 +1426,9 @@ enum EVROverlayError 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 @@ -1044,7 +1444,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, // Start up SteamVR + VRApplication_Bootstrapper = 7, // reserved for vrstartup + VRApplication_WebHelper = 8, // reserved for vrwebhelper VRApplication_Max }; @@ -1070,6 +1471,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 @@ -1119,6 +1567,12 @@ enum EVRInitError 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, @@ -1133,6 +1587,8 @@ enum EVRInitError // 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, @@ -1143,14 +1599,101 @@ enum EVRInitError 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_Compositor_UnableToCreateDevice = 405, - + 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, @@ -1167,8 +1710,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 @@ -1208,6 +1755,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. @@ -1216,6 +1771,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) @@ -1229,7 +1794,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 @@ -1237,6 +1804,82 @@ 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 { @@ -1247,34 +1890,76 @@ struct DriverDirectMode_FrameTiming 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 @@ -1317,34 +2002,49 @@ enum ECameraVideoStreamFormat 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 { @@ -1381,7 +2081,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; }; @@ -1392,6 +2092,8 @@ VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t #endif // _VRTRACKEDCAMERATYPES_H // ivrsettings.h +#include + namespace vr { enum EVRSettingsError @@ -1412,9 +2114,6 @@ 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 void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; @@ -1432,7 +2131,83 @@ namespace vr }; //----------------------------------------------------------------------------- - static const char * const IVRSettings_Version = "IVRSettings_002"; + 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 @@ -1453,23 +2228,28 @@ namespace vr static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; 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_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_SupersampleScale_Float = "supersampleScale"; - static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; - static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; - static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; + 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_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; @@ -1479,18 +2259,50 @@ namespace vr 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"; + + //----------------------------------------------------------------------------- + // 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_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 @@ -1511,6 +2323,7 @@ namespace vr 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"; @@ -1533,13 +2346,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_LinuxGPUProfiling_Bool = "linuxGPUProfiling"; + static const char * const k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; //----------------------------------------------------------------------------- // collision bounds keys @@ -1553,6 +2364,7 @@ namespace vr 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 @@ -1566,15 +2378,24 @@ namespace vr 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_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; //----------------------------------------------------------------------------- @@ -1592,6 +2413,10 @@ namespace vr 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_UseWebSettings = "useWebSettings"; + 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 @@ -1600,6 +2425,62 @@ 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"; + + //----------------------------------------------------------------------------- + // 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"; + + //----------------------------------------------------------------------------- + // 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 @@ -1789,7 +2670,14 @@ 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, vr::SharedTextureHandle_t( *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( vr::SharedTextureHandle_t sharedTextureHandle ) {} @@ -1802,7 +2690,18 @@ 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( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], const vr::VRTextureBounds_t( &bounds )[ 2 ], const vr::HmdMatrix34_t *pPose ) {} + 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; + + // Projection matrix used to render the depth buffer. + vr::HmdMatrix44_t mProjection; + }; + virtual void SubmitLayer( const SubmitLayerPerEye_t( &perEye )[ 2 ], const vr::HmdMatrix34_t *pPose ) {} /** Submits queued layers for display. */ virtual void Present( vr::SharedTextureHandle_t syncTexture ) {} @@ -1814,39 +2713,10 @@ namespace vr virtual void GetFrameTiming( DriverDirectMode_FrameTiming *pFrameTiming ) {} }; - static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_004"; + static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_005"; } -// ivrcontrollercomponent.h -namespace vr -{ - - - // ---------------------------------------------------------------------------------------------- - // Purpose: Controller access on a single tracked device. - // ---------------------------------------------------------------------------------------------- - class IVRControllerComponent - { - public: - - // ------------------------------------ - // Controller Methods - // ------------------------------------ - - /** Gets the current state of a controller. */ - virtual VRControllerState_t GetControllerState( ) = 0; - - /** 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; - - }; - - - - static const char *IVRControllerComponent_Version = "IVRControllerComponent_001"; - -} // ivrcameracomponent.h namespace vr { @@ -1880,17 +2750,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 @@ -1899,7 +2769,6 @@ namespace vr class ITrackedDeviceServerDriver; struct TrackedDeviceDriverInfo_t; struct DriverPose_t; -typedef PropertyContainerHandle_t DriverHandle_t; /** This interface is provided by vrserver to allow the driver to notify * the system when something changes about a device. These changes must @@ -1976,13 +2845,42 @@ class IVRWatchdogProvider static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001"; + + + +/** 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; + + /** cleans up the driver right before it is unloaded */ + virtual void Cleanup() = 0; + + /** Returns the versions of interfaces used by this driver */ + virtual const char * const *GetInterfaceVersions() = 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, @@ -2028,7 +2926,6 @@ class IVRProperties /** 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"; @@ -2044,6 +2941,10 @@ class CVRPropertyHelpers 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 @@ -2060,11 +2961,19 @@ class CVRPropertyHelpers * return an empty string. */ std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr ); + /** 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 ); + /** 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 ); @@ -2081,6 +2990,12 @@ class CVRPropertyHelpers /* 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 ); @@ -2236,12 +3151,16 @@ inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulCon 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 ); @@ -2252,6 +3171,24 @@ inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t 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 ); @@ -2262,6 +3199,11 @@ inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyConta 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 ); @@ -2272,6 +3214,21 @@ inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyCont 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 ) { @@ -2298,9 +3255,117 @@ inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContaine } +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 { @@ -2343,24 +3408,6 @@ class IVRServerDriverHost * 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; - - /** 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; @@ -2379,9 +3426,32 @@ class IVRServerDriverHost /** 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_004"; +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"; } @@ -2450,10 +3520,10 @@ 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() = 0; + virtual void WatchdogWakeUp( vr::ETrackedDeviceClass eDeviceClass ) = 0; }; -static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001"; +static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_002"; }; @@ -2462,6 +3532,14 @@ static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001"; // 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). // ---------------------------------------------------------------------------------------------- @@ -2470,7 +3548,7 @@ namespace vr public: /** Submits final backbuffer for display. */ - virtual void Present( vr::SharedTextureHandle_t backbufferTextureHandle ) = 0; + virtual void Present( const PresentInfo_t *pPresentInfo, uint32_t unPresentInfoSize ) = 0; /** Block until the last presented buffer start scanning out. */ virtual void WaitForPresent() = 0; @@ -2479,10 +3557,7 @@ namespace vr virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0; }; - static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_001"; - - /** Returns the current IVRVirtualDisplay pointer or NULL the interface could not be found. */ - VR_INTERFACE vr::IVRVirtualDisplay *VR_CALLTYPE VRVirtualDisplay(); + static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_002"; } @@ -2505,13 +3580,66 @@ 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"; } +// 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 { @@ -2523,6 +3651,10 @@ class IVRDriverManager /** 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"; @@ -2531,23 +3663,116 @@ static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; +// 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, - IVRControllerComponent_Version, IVRCameraComponent_Version, IServerTrackedDeviceProvider_Version, IVRWatchdogProvider_Version, IVRVirtualDisplay_Version, IVRDriverManager_Version, IVRResources_Version, + IVRCompositorPluginProvider_Version, nullptr }; @@ -2565,6 +3790,7 @@ namespace vr EVRInitError InitServer(); EVRInitError InitWatchdog(); + EVRInitError InitCompositor(); IVRSettings *VRSettings() { @@ -2620,6 +3846,16 @@ namespace vr 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 ) @@ -2655,6 +3891,36 @@ namespace vr 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; @@ -2663,9 +3929,13 @@ namespace vr 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() @@ -2681,19 +3951,27 @@ namespace vr 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_pVRDriverLog = 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() @@ -2719,6 +3997,19 @@ namespace vr 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; @@ -2731,6 +4022,12 @@ namespace vr return OpenVRInternal_ModuleServerDriverContext().InitWatchdog(); } + inline EVRInitError InitCompositorDriverContext( IVRDriverContext *pContext ) + { + VRDriverContext() = pContext; + return OpenVRInternal_ModuleServerDriverContext().InitCompositor(); + } + inline void CleanupDriverContext() { VRDriverContext() = nullptr; @@ -2756,6 +4053,20 @@ namespace vr #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