Exemple #1
0
        public void SetGamma(ColorConfiguration configuration)
        {
            if (!IsGammaStale() && !IsSignificantChange(configuration))
            {
                return;
            }

            if (VRSettings == null)
            {
                Debug.LogError("VR Settings is not initialized. Make sure a compatible VR headet is plugged in.");
                return;
            }

            //EnsureValidDeviceContext();

            EVRSettingsError vrSettingsError = EVRSettingsError.None;

            Color color = GetColor(configuration);

            VRSettings.SetFloat(OpenVR.k_pch_SteamVR_Section, k_pch_SteamVR_HmdDisplayColorGainR_Float, color.r, ref vrSettingsError);
            VRSettings.SetFloat(OpenVR.k_pch_SteamVR_Section, k_pch_SteamVR_HmdDisplayColorGainG_Float, color.g, ref vrSettingsError);
            VRSettings.SetFloat(OpenVR.k_pch_SteamVR_Section, k_pch_SteamVR_HmdDisplayColorGainB_Float, color.b, ref vrSettingsError);

            if (vrSettingsError != EVRSettingsError.None)
            {
                Debug.LogError("SetFloat Error [HmdDisplayColorGain]: " + vrSettingsError.ToString());
            }

            _isGammaValid        = true;
            _lastConfiguration   = configuration;
            _lastUpdateTimestamp = DateTimeOffset.Now;
            //Debug.Log($"Updated gamma to {configuration}.");
        }
        public void SetBrightness(float brightness)
        {
            var gain = (float)Math.Pow(brightness, 2.2);

            var error = EVRSettingsError.None;

            vrSettings.SetFloat("steamvr", "analogGain", gain, ref error);

            if (error != EVRSettingsError.None)
            {
                var message = vrSettings.GetSettingsErrorNameFromEnum(error);
                throw new Exception($"Failed to set display brightness: {message}");
            }
        }