コード例 #1
0
        public void Init()
        {
            Console.CancelKeyPress += CancelKeyPressed;

            var initError = EVRInitError.None;

            vrSystem = OpenVR.Init(ref initError, EVRApplicationType.VRApplication_Background);
            if (initError != EVRInitError.None)
            {
                var message = OpenVR.GetStringForHmdError(initError);
                throw new Exception($"Failed to initialize OpenVR: {message}");
            }

            vrInput    = OpenVR.Input;
            vrSettings = OpenVR.Settings;

            var appDir       = AppDomain.CurrentDomain.BaseDirectory;
            var manifestPath = Path.Combine(appDir, "action_manifest.json");

            var inputError = vrInput.SetActionManifestPath(manifestPath);

            if (inputError != EVRInputError.None)
            {
                var message = inputError.ToString();
                throw new Exception($"Failed to set action manifest path: {message}");
            }

            inputError = vrInput.GetActionSetHandle("/actions/main", ref inputSet);
            if (inputError != EVRInputError.None)
            {
                var message = inputError.ToString();
                throw new Exception($"Failed to action set handle: {message}");
            }

            inputError = vrInput.GetActionHandle("/actions/main/in/activate", ref inputActivate);
            if (inputError != EVRInputError.None)
            {
                var message = inputError.ToString();
                throw new Exception($"Failed to get action handle for Activate: {message}");
            }

            inputError = vrInput.GetActionHandle("/actions/main/in/reset-auto", ref inputResetAuto);
            if (inputError != EVRInputError.None)
            {
                var message = inputError.ToString();
                throw new Exception($"Failed to get action handle for Reset (Auto): {message}");
            }

            inputError = vrInput.GetActionHandle("/actions/main/in/reset", ref inputResetHold);
            if (inputError != EVRInputError.None)
            {
                var message = inputError.ToString();
                throw new Exception($"Failed to get action handle for Reset (Hold): {message}");
            }

            activateSound = new SoundPlayer(Path.Combine(appDir, "activate.wav"));
            resetSound    = new SoundPlayer(Path.Combine(appDir, "reset.wav"));
        }
コード例 #2
0
        /*
         * //今まで一度もトラッキングされたことがないかどうかをチェックする(True=全く位置情報がない, False=過去一度でも位置情報がある)
         * public bool GetNeverTracked(uint deviceIndex)
         * {
         *  if (openVR == null)
         *  {
         *      return true;
         *  }
         *
         *  var error = default(ETrackedPropertyError);
         *  //Prop_NeverTracked_Bool取得
         *  bool NeverTracked = openVR.GetBoolTrackedDeviceProperty(deviceIndex, ETrackedDeviceProperty.Prop_NeverTracked_Bool, ref error);
         *  if (error != ETrackedPropertyError.TrackedProp_Success) return true;
         *  return NeverTracked;
         * }
         */

        public bool GetIsSafeMode()
        {
            if (openVR == null)
            {
                return(false);
            }

            CVRSettings      cVRSettings      = OpenVR.Settings;
            EVRSettingsError eVRSettingsError = EVRSettingsError.None;
            bool             en = cVRSettings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_EnableSafeMode, ref eVRSettingsError);

            if (eVRSettingsError != EVRSettingsError.None)
            {
                Debug.LogError("GetIsSafeMode Failed: " + eVRSettingsError.ToString());
                return(false);
            }
            return(en);
        }
コード例 #3
0
    // Token: 0x06005ED9 RID: 24281 RVA: 0x00213320 File Offset: 0x00211720
    private void OnEnable()
    {
        this.usingSpeakers = false;
        CVRSettings settings = OpenVR.Settings;

        if (settings != null)
        {
            EVRSettingsError evrsettingsError = EVRSettingsError.None;
            if (settings.GetBool("steamvr", "usingSpeakers", ref evrsettingsError))
            {
                this.usingSpeakers = true;
                float @float = settings.GetFloat("steamvr", "speakersForwardYawOffsetDegrees", ref evrsettingsError);
                this.offset = Quaternion.Euler(0f, @float, 0f);
            }
        }
        if (this.usingSpeakers)
        {
            SteamVR_Events.NewPosesApplied.Listen(new UnityAction(this.OnNewPosesApplied));
        }
    }
コード例 #4
0
        public void Deinit()
        {
            if (vrSettings != null)
            {
                TriggerReset();
            }

            if (vrSystem != null)
            {
                OpenVR.Shutdown();
                vrInput    = null;
                vrSettings = null;
                vrSystem   = null;

                inputActivate  = 0;
                inputResetAuto = 0;
                inputResetHold = 0;
                inputSet       = 0;
            }
        }
コード例 #5
0
    private void OnEnable()
    {
        this.usingSpeakers = false;
        CVRSettings settings = OpenVR.Settings;

        if (settings != null)
        {
            EVRSettingsError eVRSettingsError = EVRSettingsError.None;
            if (settings.GetBool("steamvr", "usingSpeakers", false, ref eVRSettingsError))
            {
                this.usingSpeakers = true;
                float @float = settings.GetFloat("steamvr", "speakersForwardYawOffsetDegrees", 0f, ref eVRSettingsError);
                this.offset = Quaternion.Euler(0f, @float, 0f);
            }
        }
        if (this.usingSpeakers)
        {
            SteamVR_Utils.Event.Listen("new_poses_applied", new SteamVR_Utils.Event.Handler(this.OnNewPosesApplied));
        }
    }
コード例 #6
0
ファイル: GammaService.cs プロジェクト: egemenertugrul/LuxVR
 public GammaService(SettingsService settingsService, CVRSettings ovrSettings)
 {
     _settingsService = settingsService;
     VRSettings       = ovrSettings;
 }