Пример #1
0
        private static void IdentifyEditorApplication(bool showLogs = true)
        {
            //bool isInstalled = OpenVR.Applications.IsApplicationInstalled(SteamVR_Settings.instance.editorAppKey);

            string manifestPath = GetManifestFile();

            EVRApplicationError addManifestErr = OpenVR.Applications.AddApplicationManifest(manifestPath, true);

            if (addManifestErr != EVRApplicationError.None)
            {
                Debug.LogError("<b>[SteamVR]</b> Error adding vr manifest file: " + addManifestErr.ToString());
            }
            else
            {
                if (showLogs)
                {
                    Debug.Log("<b>[SteamVR]</b> Successfully added VR manifest to SteamVR");
                }
            }

            int processId = System.Diagnostics.Process.GetCurrentProcess().Id;
            EVRApplicationError applicationIdentifyErr = OpenVR.Applications.IdentifyApplication((uint)processId, SteamVR_Settings.instance.editorAppKey);

            if (applicationIdentifyErr != EVRApplicationError.None)
            {
                Debug.LogError("<b>[SteamVR]</b> Error identifying application: " + applicationIdentifyErr.ToString());
            }
            else
            {
                if (showLogs)
                {
                    Debug.Log(string.Format("<b>[SteamVR]</b> Successfully identified process as editor project to SteamVR ({0})", SteamVR_Settings.instance.editorAppKey));
                }
            }
        }
Пример #2
0
        public string GetCurrentGame()
        {
            uint processId = OpenVR.Applications.GetCurrentSceneProcessId();

            Console.WriteLine("Current Process ID: " + processId);

            if (processId != 0)
            {
                try
                {
                    StringBuilder stringBuilder = new StringBuilder()
                    {
                        Length = (int)byte.MaxValue
                    };
                    EVRApplicationError error =
                        OpenVR.Applications.GetApplicationKeyByProcessId(processId, stringBuilder, (uint)byte.MaxValue);
                    if (error == EVRApplicationError.None)
                    {
                        string appKey = stringBuilder.ToString();
                        Console.WriteLine("App Key: " + appKey);
                        if (appKey.Length > 0)
                        {
                            OpenVR.Applications.GetApplicationPropertyString(appKey, EVRApplicationProperty.Name_String,
                                                                             stringBuilder, (uint)byte.MaxValue, ref error);
                            if (error != EVRApplicationError.None)
                            {
                                Console.WriteLine("GetApplicationPropertyString Error:");
                                Console.WriteLine(error);
                                return(appKey);
                            }
                            string appName = stringBuilder.ToString();

                            Console.WriteLine("App Name: " + appName);
                            return(appName);
                        }
                    }
                    else
                    {
                        Console.WriteLine(error);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to get app name via OpenVR");
                    Console.WriteLine(ex);
                }
            }

            var process = Process.GetProcessById((int)processId);

            Console.WriteLine(process.ProcessName);
            Console.WriteLine(process.MainWindowTitle);

            if (process.MainWindowTitle.Length > 0)
            {
                return(process.MainWindowTitle);
            }

            return(process.ProcessName);
        }
Пример #3
0
        private static void IdentifyEditorApplication(bool showLogs = true)
        {
            var    manifestFI   = new FileInfo("unityProject.vrmanifest");
            string manifestPath = manifestFI.FullName;

            EVRApplicationError addManifestErr = OpenVR.Applications.AddApplicationManifest(manifestPath, true);

            if (addManifestErr != EVRApplicationError.None)
            {
                Debug.LogError("<b>[SteamVR]</b> Error adding vr manifest file: " + addManifestErr.ToString());
            }
            else
            {
                if (showLogs)
                {
                    Debug.Log("<b>[SteamVR]</b> Successfully added VR manifest to SteamVR");
                }
            }

            int processId = System.Diagnostics.Process.GetCurrentProcess().Id;
            var appkey    = string.Format("application.generated.unity.{0}.exe", GenerateCleanProductName());
            EVRApplicationError applicationIdentifyErr = OpenVR.Applications.IdentifyApplication((uint)processId, appkey);

            if (applicationIdentifyErr != EVRApplicationError.None)
            {
                Debug.LogError("<b>[SteamVR]</b> Error identifying application: " + applicationIdentifyErr.ToString());
            }
            else
            {
                if (showLogs)
                {
                    Debug.Log(string.Format("<b>[SteamVR]</b> Successfully identified process as editor project to SteamVR ({0})", appkey));
                }
            }
        }
Пример #4
0
        private static void IdentifyEditorApplication(bool showLogs = true)
        {
            if (string.IsNullOrEmpty(SteamVR_Settings.instance.editorAppKey))
            {
                UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Critical Error identifying application. EditorAppKey is null or empty. Input may not work.");
                return;
            }
            string manifestFile = SteamVR.GetManifestFile();
            EVRApplicationError evrapplicationError = OpenVR.Applications.AddApplicationManifest(manifestFile, true);

            if (evrapplicationError != EVRApplicationError.None)
            {
                UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Error adding vr manifest file: " + evrapplicationError.ToString());
            }
            else if (showLogs)
            {
                UnityEngine.Debug.Log("<b>[SteamVR_Standalone]</b> Successfully added VR manifest to SteamVR_Standalone");
            }
            int id = Process.GetCurrentProcess().Id;
            EVRApplicationError evrapplicationError2 = OpenVR.Applications.IdentifyApplication((uint)id, SteamVR_Settings.instance.editorAppKey);

            if (evrapplicationError2 != EVRApplicationError.None)
            {
                UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Error identifying application: " + evrapplicationError2.ToString());
                return;
            }
            if (showLogs)
            {
                UnityEngine.Debug.Log(string.Format("<b>[SteamVR_Standalone]</b> Successfully identified process as editor project to SteamVR_Standalone ({0})", SteamVR_Settings.instance.editorAppKey));
            }
        }
        /// <summary>
        /// Sets the autostart property.
        /// </summary>
        /// <param name="value">If true, the application will start with SteamVR</param>
        public void SetAutoStartEnabled(bool value)
        {
            EVRApplicationError error = OpenVR.Applications.SetApplicationAutoLaunch(_applicationKey, value);

            if (error != EVRApplicationError.None)
            {
                Console.WriteLine("Could not set auto start: " + error.ToString());
            }
        }
        /// <summary>
        /// Installs/Registers the application. This does not copy any files, but instead points OpenVR to the current working directory.
        /// </summary>
        /// <param name="cleanInstall">If an existing installation is found, setting cleanInstall to true will remove the old registration first (no files are deleted).</param>
        /// <param name="autoStart">If true, the registered application will start with SteamVR</param>
        public void InstallManifest(bool cleanInstall = false, bool autoStart = true)
        {
            if (File.Exists(_manifestFullPath))
            {
                bool alreadyInstalled = false;
                if (OpenVR.Applications.IsApplicationInstalled(_applicationKey))
                {
                    Console.WriteLine("Found existing installation.");
                    if (cleanInstall)
                    {
                        StringBuilder       buffer   = new StringBuilder(1024);
                        EVRApplicationError appError = new EVRApplicationError();
                        OpenVR.Applications.GetApplicationPropertyString(_applicationKey, EVRApplicationProperty.WorkingDirectory_String, buffer, 1024, ref appError);

                        if (appError == EVRApplicationError.None)
                        {
                            string oldManifestPath = Path.Combine(buffer.ToString(), _manifestFileName);
                            if (!_manifestFullPath.Equals(oldManifestPath))
                            {
                                Console.WriteLine("Clean install: Removing old manifest.");
                                OpenVR.Applications.RemoveApplicationManifest(oldManifestPath);
                                Console.WriteLine(oldManifestPath);
                            }
                            else
                            {
                                alreadyInstalled = true;
                            }
                        }
                    }
                    else
                    {
                        alreadyInstalled = true;
                    }
                }
                else
                {
                    Console.WriteLine("Could not find existing installation. Installing now...");
                }
                EVRApplicationError error = OpenVR.Applications.AddApplicationManifest(_manifestFullPath, false);
                if (error != EVRApplicationError.None)
                {
                    throw new Exception("Could not add application manifest: " + error.ToString());
                }
                else if (autoStart && (!alreadyInstalled || cleanInstall))
                {
                    error = OpenVR.Applications.SetApplicationAutoLaunch(_applicationKey, true);
                    if (error != EVRApplicationError.None)
                    {
                        throw new Exception("Could not set autostart: " + error.ToString());
                    }
                }
            }
            else
            {
                throw new Exception("Could not find application manifest: " + _manifestFullPath);
            }
        }
Пример #7
0
    bool ErrorCheck(EVRApplicationError err)
    {
        bool e = err != EVRApplicationError.None;

        if (e)
        {
            Debug.Log("App Error: " + handler.Applications.GetApplicationsErrorNameFromEnum(err));
        }

        return(e);
    }
Пример #8
0
    private RunningGameInfo GetRunningGames()
    {
        RunningGameInfo runningGameInfo = new RunningGameInfo();

        List <AppInfo> lAppInfo = new List <AppInfo>();


        CVRApplications app          = OpenVR.Applications;
        StringBuilder   sbAppkey     = new System.Text.StringBuilder((int)OpenVR.k_unMaxApplicationKeyLength);
        StringBuilder   sbLaunchType = new System.Text.StringBuilder((Int32)OpenVR.k_unMaxPropertyStringSize);
        StringBuilder   sbBinaryPath = new System.Text.StringBuilder((int)OpenVR.k_unMaxApplicationKeyLength);

        uint appCount = app.GetApplicationCount();

        for (uint i = 0; i < appCount; i++)
        {
            sbAppkey.Length     = 0; sbAppkey.Capacity = 0;
            sbLaunchType.Length = 0; sbLaunchType.Capacity = 0;
            sbAppkey            = new StringBuilder((int)OpenVR.k_unMaxApplicationKeyLength);
            sbLaunchType        = new StringBuilder((Int32)OpenVR.k_unMaxPropertyStringSize);
            sbBinaryPath        = new System.Text.StringBuilder((int)OpenVR.k_unMaxApplicationKeyLength);

            EVRApplicationError err = app.GetApplicationKeyByIndex(i, sbAppkey, OpenVR.k_unMaxApplicationKeyLength);

            string appkey = sbAppkey.ToString();

            uint procId = app.GetApplicationProcessId(appkey);

            app.GetApplicationPropertyString(appkey, EVRApplicationProperty.LaunchType_String, sbLaunchType, OpenVR.k_unMaxPropertyStringSize, ref err);
            app.GetApplicationPropertyString(appkey, EVRApplicationProperty.BinaryPath_String, sbBinaryPath, OpenVR.k_unMaxPropertyStringSize, ref err);

            bool isDashboard = app.GetApplicationPropertyBool(appkey, EVRApplicationProperty.IsDashboardOverlay_Bool, ref err);

            string selfName = Process.GetCurrentProcess().MainModule.FileName;

            if (sbLaunchType.ToString() == "binary" && !isDashboard && procId > 0 && sbBinaryPath.ToString() != selfName)
            {
                //fileN = Process.GetProcessById((int)procId).MainModule.FileName;
                //Debug.Log(appkey + "|||" + procId + "|||" + sbBinaryPath.ToString() + "|||" + fileN);

                AppInfo appInfo = new AppInfo((int)procId, sbBinaryPath.ToString());

                lAppInfo.Add(appInfo);
            }
        }

        runningGameInfo.RunningGames = lAppInfo;

        return(runningGameInfo);
    }
 /// <summary>
 /// Uninstalls/Unregisters the application. No files are deleted.
 /// </summary>
 public void RemoveManifest()
 {
     if (File.Exists(_manifestFullPath))
     {
         if (OpenVR.Applications.IsApplicationInstalled(_applicationKey))
         {
             EVRApplicationError error = OpenVR.Applications.RemoveApplicationManifest(_manifestFullPath);
             if (error != EVRApplicationError.None)
             {
                 throw new Exception("Could not remove application manifest: " + error.ToString());
             }
         }
     }
     else
     {
         throw new Exception("Could not find application manifest: " + _manifestFullPath);
     }
 }
Пример #10
0
            public string GetPropertyString(EVRApplicationProperty prop)
            {
                EVRApplicationError err            = EVRApplicationError.None;
                StringBuilder       propertyBuffer = new StringBuilder(255);

                OpenVR.Applications.GetApplicationPropertyString(AppKey, prop, propertyBuffer, 255, ref err);

#if DEBUG
                if (err != EVRApplicationError.None)
                {
                    Console.WriteLine("EVRApplicationError on " + AppKey + " property " + prop.ToString() + ": " + err.ToString());
                }
#endif

                //Console.WriteLine(propertyBuffer.ToString());

                return(propertyBuffer.ToString());
            }
Пример #11
0
        public string GetApplicationsList()
        {
            List <Application> apps = new List <Application>();

            StringBuilder       keyBuffer = new StringBuilder(255);
            EVRApplicationError err       = EVRApplicationError.None;

            for (int i = 0; i < _applicationsInstance.GetApplicationCount(); i++)
            {
                err = _applicationsInstance.GetApplicationKeyByIndex((uint)i, keyBuffer, 255);

                if (err != EVRApplicationError.None)
                {
                    throw new Exception("EVRApplicationError: " + err.ToString());
                }

                Application newApp = new Application(keyBuffer.ToString());
                apps.Add(newApp);
            }

            string ret = JsonConvert.SerializeObject(apps);

            return(ret);
        }
Пример #12
0
	public abstract ulong GetApplicationPropertyUint64(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError);
Пример #13
0
 public ulong GetApplicationPropertyUint64(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError)
 {
     return(this.FnTable.GetApplicationPropertyUint64(pchAppKey, eProperty, ref peError));
 }
Пример #14
0
        /// <summary>
        /// Checks if it can connect to OpenVR.
        /// </summary>
        /// <returns></returns>
        private bool AttemptOpenVRConnection(ref CVRSystem system)
        {
            system = null;

            EVRInitError eie = new EVRInitError();

            try
            {
                system = OpenVR.Init(ref eie, EVRApplicationType.VRApplication_Background);
            }
            catch (Exception ex)
            {
                system = null;
                //MessageBox.Show("Err 1: " + ex.Message);
            }

            if (eie == EVRInitError.Init_NoServerForBackgroundApp)
            {
                system = null;
                return(true);
            }
            if (system == null)
            {
                return(false);
            }

            this._useLegacyInput = true;

            EVRApplicationError appError = OpenVR.Applications.AddApplicationManifest(Path.GetFullPath("./manifest/app.vrmanifest"), false);

            if (appError != EVRApplicationError.None)
            {
                return(true); //Will use legacy input
            }

            EVRInputError ioError = OpenVR.Input.SetActionManifestPath(Path.GetFullPath("./manifest/actions.json"));

            if (ioError != EVRInputError.None)
            {
                return(true); //Will use legacy input
            }

            if (!LoadAction("/actions/default/in/reset_viewport", ref this.actionResetViewport))
            {
                return(true); //Will use legacy input
            }
            if (!LoadAction("/actions/default/in/reset_viewport_leftgrip", ref this.actionResetViewportLeftGrip))
            {
                return(true); //Will use legacy input
            }
            if (!LoadAction("/actions/default/in/reset_viewport_rightgrip", ref this.actionResetViewportRightGrip))
            {
                return(true); //Will use legacy input
            }

            if (OpenVR.Input.GetActionSetHandle("/actions/default", ref this.actionHandle) != EVRInputError.None)
            {
                return(true);             //Will use legacy input
            }
            this._useLegacyInput = false; //Actions loaded successfully, we can use the modern input.

            return(true);
        }
Пример #15
0
 public string GetApplicationsErrorNameFromEnum(EVRApplicationError error) => default;                                                                                                                          // 0x00000001811DC570-0x00000001811DC5F0
 public uint GetApplicationPropertyString(string pchAppKey, EVRApplicationProperty eProperty, StringBuilder pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError) => default; // 0x00000001811DC4E0-0x00000001811DC510
Пример #16
0
	public override string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
	{
		CheckIfUsable();
		IntPtr result = VRNativeEntrypoints.VR_IVRApplications_GetApplicationsErrorNameFromEnum(m_pVRApplications,error);
		return (string) Marshal.PtrToStructure(result, typeof(string));
	}
Пример #17
0
 public ulong GetApplicationPropertyUint64(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError)
 {
     return this.FnTable.GetApplicationPropertyUint64(pchAppKey, eProperty, ref peError);
 }
Пример #18
0
	public bool GetApplicationPropertyBool(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError)
	{
		bool result = FnTable.GetApplicationPropertyBool(pchAppKey,eProperty,ref peError);
		return result;
	}
Пример #19
0
	public string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
	{
		IntPtr result = FnTable.GetApplicationsErrorNameFromEnum(error);
		return (string) Marshal.PtrToStructure(result, typeof(string));
	}
Пример #20
0
    // Token: 0x06005F2C RID: 24364 RVA: 0x00215578 File Offset: 0x00213978
    private IEnumerator LoadLevel()
    {
        if (this.loadingScreen != null && this.loadingScreenDistance > 0f)
        {
            SteamVR_Controller.Device hmd = SteamVR_Controller.Input(0);
            while (!hmd.hasTracking)
            {
                yield return(null);
            }
            SteamVR_Utils.RigidTransform tloading = hmd.transform;
            tloading.rot  = Quaternion.Euler(0f, tloading.rot.eulerAngles.y, 0f);
            tloading.pos += tloading.rot * new Vector3(0f, 0f, this.loadingScreenDistance);
            Transform t = (!(this.loadingScreenTransform != null)) ? base.transform : this.loadingScreenTransform;
            t.position = tloading.pos;
            t.rotation = tloading.rot;
        }
        SteamVR_LoadLevel._active = this;
        SteamVR_Events.Loading.Send(true);
        if (this.loadingScreenFadeInTime > 0f)
        {
            this.fadeRate = 1f / this.loadingScreenFadeInTime;
        }
        else
        {
            this.alpha = 1f;
        }
        CVROverlay overlay = OpenVR.Overlay;

        if (this.loadingScreen != null && overlay != null)
        {
            this.loadingScreenOverlayHandle = this.GetOverlayHandle("loadingScreen", (!(this.loadingScreenTransform != null)) ? base.transform : this.loadingScreenTransform, this.loadingScreenWidthInMeters);
            if (this.loadingScreenOverlayHandle != 0UL)
            {
                Texture_t texture_t = default(Texture_t);
                texture_t.handle      = this.loadingScreen.GetNativeTexturePtr();
                texture_t.eType       = SteamVR.instance.textureType;
                texture_t.eColorSpace = EColorSpace.Auto;
                overlay.SetOverlayTexture(this.loadingScreenOverlayHandle, ref texture_t);
            }
        }
        bool fadedForeground = false;

        SteamVR_Events.LoadingFadeOut.Send(this.fadeOutTime);
        CVRCompositor compositor = OpenVR.Compositor;

        if (compositor != null)
        {
            if (this.front != null)
            {
                SteamVR_Skybox.SetOverride(this.front, this.back, this.left, this.right, this.top, this.bottom);
                compositor.FadeGrid(this.fadeOutTime, true);
                yield return(new WaitForSeconds(this.fadeOutTime));
            }
            else if (this.backgroundColor != Color.clear)
            {
                if (this.showGrid)
                {
                    compositor.FadeToColor(0f, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, true);
                    compositor.FadeGrid(this.fadeOutTime, true);
                    yield return(new WaitForSeconds(this.fadeOutTime));
                }
                else
                {
                    compositor.FadeToColor(this.fadeOutTime, this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a, false);
                    yield return(new WaitForSeconds(this.fadeOutTime + 0.1f));

                    compositor.FadeGrid(0f, true);
                    fadedForeground = true;
                }
            }
        }
        SteamVR_Render.pauseRendering = true;
        while (this.alpha < 1f)
        {
            yield return(null);
        }
        base.transform.parent = null;
        UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
        if (!string.IsNullOrEmpty(this.internalProcessPath))
        {
            UnityEngine.Debug.Log("Launching external application...");
            CVRApplications applications = OpenVR.Applications;
            if (applications == null)
            {
                UnityEngine.Debug.Log("Failed to get OpenVR.Applications interface!");
            }
            else
            {
                string currentDirectory = Directory.GetCurrentDirectory();
                string text             = Path.Combine(currentDirectory, this.internalProcessPath);
                UnityEngine.Debug.Log("LaunchingInternalProcess");
                UnityEngine.Debug.Log("ExternalAppPath = " + this.internalProcessPath);
                UnityEngine.Debug.Log("FullPath = " + text);
                UnityEngine.Debug.Log("ExternalAppArgs = " + this.internalProcessArgs);
                UnityEngine.Debug.Log("WorkingDirectory = " + currentDirectory);
                EVRApplicationError evrapplicationError = applications.LaunchInternalProcess(text, this.internalProcessArgs, currentDirectory);
                UnityEngine.Debug.Log("LaunchInternalProcessError: " + evrapplicationError);
                Process.GetCurrentProcess().Kill();
            }
        }
        else
        {
            LoadSceneMode mode = (!this.loadAdditive) ? LoadSceneMode.Single : LoadSceneMode.Additive;
            if (this.loadAsync)
            {
                Application.backgroundLoadingPriority = ThreadPriority.Low;
                this.async = SceneManager.LoadSceneAsync(this.levelName, mode);
                while (!this.async.isDone)
                {
                    yield return(null);
                }
            }
            else
            {
                SceneManager.LoadScene(this.levelName, mode);
            }
        }
        yield return(null);

        GC.Collect();
        yield return(null);

        Shader.WarmupAllShaders();
        yield return(new WaitForSeconds(this.postLoadSettleTime));

        SteamVR_Render.pauseRendering = false;
        if (this.loadingScreenFadeOutTime > 0f)
        {
            this.fadeRate = -1f / this.loadingScreenFadeOutTime;
        }
        else
        {
            this.alpha = 0f;
        }
        SteamVR_Events.LoadingFadeIn.Send(this.fadeInTime);
        if (compositor != null)
        {
            if (fadedForeground)
            {
                compositor.FadeGrid(0f, false);
                compositor.FadeToColor(this.fadeInTime, 0f, 0f, 0f, 0f, false);
                yield return(new WaitForSeconds(this.fadeInTime));
            }
            else
            {
                compositor.FadeGrid(this.fadeInTime, false);
                yield return(new WaitForSeconds(this.fadeInTime));

                if (this.front != null)
                {
                    SteamVR_Skybox.ClearOverride();
                }
            }
        }
        while (this.alpha > 0f)
        {
            yield return(null);
        }
        if (overlay != null)
        {
            if (this.progressBarOverlayHandle != 0UL)
            {
                overlay.HideOverlay(this.progressBarOverlayHandle);
            }
            if (this.loadingScreenOverlayHandle != 0UL)
            {
                overlay.HideOverlay(this.loadingScreenOverlayHandle);
            }
        }
        UnityEngine.Object.Destroy(base.gameObject);
        SteamVR_LoadLevel._active = null;
        SteamVR_Events.Loading.Send(false);
        yield break;
    }
Пример #21
0
	internal static extern ulong VR_IVRApplications_GetApplicationPropertyUint64(IntPtr instancePtr, string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError);
Пример #22
0
 // Token: 0x06001F22 RID: 7970 RVA: 0x0009D084 File Offset: 0x0009B284
 public string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
 {
     return(Marshal.PtrToStringAnsi(this.FnTable.GetApplicationsErrorNameFromEnum(error)));
 }
Пример #23
0
 public bool GetApplicationPropertyBool(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError) => default;                                                                        // 0x00000001811DC4B0-0x00000001811DC4E0
 public ulong GetApplicationPropertyUint64(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError) => default;                                                                     // 0x00000001811DC510-0x00000001811DC540
Пример #24
0
 public uint GetApplicationPropertyString(string pchAppKey, EVRApplicationProperty eProperty, StringBuilder pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError) => default; // 0x00000001811DC4E0-0x00000001811DC510
 public bool GetApplicationPropertyBool(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError) => default;                                                                        // 0x00000001811DC4B0-0x00000001811DC4E0
Пример #25
0
 private static SteamVR CreateInstance()
 {
     SteamVR.initializedState = SteamVR.InitializedStates.Initializing;
     try
     {
         EVRInitError evrinitError = EVRInitError.None;
         OpenVR.GetGenericInterface("IVRCompositor_022", ref evrinitError);
         OpenVR.Init(ref evrinitError, EVRApplicationType.VRApplication_Scene, "");
         CVRSystem           system              = OpenVR.System;
         string              manifestFile        = SteamVR.GetManifestFile();
         EVRApplicationError evrapplicationError = OpenVR.Applications.AddApplicationManifest(manifestFile, true);
         if (evrapplicationError != EVRApplicationError.None)
         {
             UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> Error adding vr manifest file: " + evrapplicationError.ToString());
         }
         int id = Process.GetCurrentProcess().Id;
         OpenVR.Applications.IdentifyApplication((uint)id, SteamVR_Settings.instance.editorAppKey);
         UnityEngine.Debug.Log("Is HMD here? " + OpenVR.IsHmdPresent().ToString());
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR.ReportGeneralErrors();
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVROverlay_021", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         OpenVR.GetGenericInterface("IVRInput_007", ref evrinitError);
         if (evrinitError != EVRInitError.None)
         {
             SteamVR.initializedState = SteamVR.InitializedStates.InitializeFailure;
             SteamVR.ReportError(evrinitError);
             SteamVR_Events.Initializing.Send(false);
             return(null);
         }
         SteamVR.settings = SteamVR_Settings.instance;
         if (Application.isEditor)
         {
             SteamVR.IdentifyEditorApplication(true);
         }
         SteamVR_Input.IdentifyActionsFile(true);
         if (SteamVR_Settings.instance.inputUpdateMode != SteamVR_UpdateModes.Nothing || SteamVR_Settings.instance.poseUpdateMode != SteamVR_UpdateModes.Nothing)
         {
             SteamVR_Input.Initialize(false);
         }
     }
     catch (Exception arg)
     {
         UnityEngine.Debug.LogError("<b>[SteamVR_Standalone]</b> " + arg);
         SteamVR_Events.Initializing.Send(false);
         return(null);
     }
     SteamVR._enabled         = true;
     SteamVR.initializedState = SteamVR.InitializedStates.InitializeSuccess;
     SteamVR_Events.Initializing.Send(true);
     return(new SteamVR());
 }
Пример #26
0
	public override bool GetApplicationPropertyBool(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError)
	{
		CheckIfUsable();
		bool result = VRNativeEntrypoints.VR_IVRApplications_GetApplicationPropertyBool(m_pVRApplications,pchAppKey,eProperty,ref peError);
		return result;
	}
Пример #27
0
	public uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,string pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError)
	{
		uint result = FnTable.GetApplicationPropertyString(pchAppKey,eProperty,pchPropertyValueBuffer,unPropertyValueBufferLen,ref peError);
		return result;
	}
Пример #28
0
	internal static extern uint VR_IVRApplications_GetApplicationPropertyString(IntPtr instancePtr, string pchAppKey, EVRApplicationProperty eProperty, string pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError);
Пример #29
0
	public ulong GetApplicationPropertyUint64(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError)
	{
		ulong result = FnTable.GetApplicationPropertyUint64(pchAppKey,eProperty,ref peError);
		return result;
	}
Пример #30
0
	public abstract string GetApplicationsErrorNameFromEnum(EVRApplicationError error);
Пример #31
0
 public bool GetApplicationPropertyBool(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError)
 {
     return this.FnTable.GetApplicationPropertyBool(pchAppKey, eProperty, ref peError);
 }
Пример #32
0
	public abstract bool GetApplicationPropertyBool(string pchAppKey,EVRApplicationProperty eProperty,ref EVRApplicationError peError);
Пример #33
0
	public override uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,string pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError)
	{
		CheckIfUsable();
		uint result = VRNativeEntrypoints.VR_IVRApplications_GetApplicationPropertyString(m_pVRApplications,pchAppKey,eProperty,pchPropertyValueBuffer,unPropertyValueBufferLen,ref peError);
		return result;
	}
Пример #34
0
 public uint GetApplicationProcessId(string pchAppKey) => default;                                                                                                                                              // 0x00000001811DC490-0x00000001811DC4B0
 public string GetApplicationsErrorNameFromEnum(EVRApplicationError error) => default;                                                                                                                          // 0x00000001811DC570-0x00000001811DC5F0
Пример #35
0
	internal static extern IntPtr VR_IVRApplications_GetApplicationsErrorNameFromEnum(IntPtr instancePtr, EVRApplicationError error);
Пример #36
0
	public string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
	{
		IntPtr result = FnTable.GetApplicationsErrorNameFromEnum(error);
		return Marshal.PtrToStringAnsi(result);
	}
Пример #37
0
	internal static extern bool VR_IVRApplications_GetApplicationPropertyBool(IntPtr instancePtr, string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError);
Пример #38
0
        public string GetApplicationsErrorNameFromEnum(EVRApplicationError error)
        {
            IntPtr ptr = this.FnTable.GetApplicationsErrorNameFromEnum(error);

            return((string)Marshal.PtrToStructure(ptr, typeof(string)));
        }
Пример #39
0
	public abstract uint GetApplicationPropertyString(string pchAppKey,EVRApplicationProperty eProperty,string pchPropertyValueBuffer,uint unPropertyValueBufferLen,ref EVRApplicationError peError);
Пример #40
0
 public uint GetApplicationPropertyString(string pchAppKey, EVRApplicationProperty eProperty, string pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError)
 {
     return(this.FnTable.GetApplicationPropertyString(pchAppKey, eProperty, pchPropertyValueBuffer, unPropertyValueBufferLen, ref peError));
 }
Пример #41
0
 public bool GetApplicationPropertyBool(string pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError)
 {
     return(this.FnTable.GetApplicationPropertyBool(pchAppKey, eProperty, ref peError));
 }
Пример #42
0
        public void PopulateDPGamesLibrary(bool refreshAll = false)
        {
            if (!CheckSteamValid())
            {
                return;
            }

            List <LibraryGameData> allGames = libraryApp.config.opts.games;

            if (refreshAll)
            {
                allGames.Clear();
            }

            List <string> openVRAppKeys = new List <string>();

            //Loop over all the OpenVR applications:
            for (int i = 0; i < OpenVR.Applications.GetApplicationCount(); i++)
            {
                StringBuilder sb = new StringBuilder((int)OpenVR.k_unMaxApplicationKeyLength);

                OpenVR.Applications.GetApplicationKeyByIndex((uint)i, sb, OpenVR.k_unMaxApplicationKeyLength);

                openVRAppKeys.Add(sb.ToString());

                //Debug.Log(sb);
            }


            foreach (string key in openVRAppKeys)
            {
                //Get the application type and it's ID.
                LibraryGameType type = LibraryGameType.Application;

                int testID = 0;
                Int32.TryParse(key.Replace("steam.app.", ""), out testID);

                if (testID == 0)
                {
                    Int32.TryParse(key.Replace("steam.overlay.", ""), out testID);
                    if (testID != 0)
                    {
                        type = LibraryGameType.Overlay;
                    }

                    //If all those checks failed, see if it's a revive game:
                    else if (key.StartsWith("revive.app."))
                    {
                        type   = LibraryGameType.Revive;
                        testID = -1;
                    }
                }

                //If it's not an app, overlay, or revive game, we skip it.
                if (testID == 0)
                {
                    continue;
                }


                EVRApplicationError evrError = new EVRApplicationError();



                bool exists = allGames.Exists(x => x.appKey == key);

                //We skip this game, but we need to refresh the last launched time:
                if (exists && !refreshAll)
                {
                    ulong tempLaunchTime = OpenVR.Applications.GetApplicationPropertyUint64(key, EVRApplicationProperty.LastLaunchTime_Uint64, ref evrError);
                    allGames.Find(x => x.appKey == key).lastPlayedDate = UnixTimeStampToDateTime(tempLaunchTime);

                    continue;
                }


                //Else, we go as normal and fetch all the app data

                //Get the app launch URL:
                StringBuilder launchString = new StringBuilder(128);
                OpenVR.Applications.GetApplicationPropertyString(key, EVRApplicationProperty.URL_String, launchString, 128, ref evrError);


                //Get the binary path:
                StringBuilder binaryString = new StringBuilder(512);
                OpenVR.Applications.GetApplicationPropertyString(key, EVRApplicationProperty.BinaryPath_String, binaryString, 512, ref evrError);

                //Get the name of the game:
                StringBuilder nameString = new StringBuilder(128);
                OpenVR.Applications.GetApplicationPropertyString(key, EVRApplicationProperty.Name_String, nameString, 128, ref evrError);

                //Get the name of the game:
                StringBuilder imageString = new StringBuilder(512);
                OpenVR.Applications.GetApplicationPropertyString(key, EVRApplicationProperty.ImagePath_String, imageString, 512, ref evrError);


                //Get last played time:
                ulong lastLaunchLong = OpenVR.Applications.GetApplicationPropertyUint64(key, EVRApplicationProperty.LastLaunchTime_Uint64, ref evrError);



                LibraryGameData gameData = new LibraryGameData()
                {
                    appID          = testID,
                    name           = nameString.ToString(),
                    launchURL      = launchString.ToString(),
                    binaryPath     = binaryString.ToString(),
                    imagePath      = imageString.ToString().Replace("file:///", "").Replace("%20", " "),
                    lastPlayedDate = UnixTimeStampToDateTime(lastLaunchLong),
                    gameType       = type,
                    appKey         = key,
                    isInstalled    = OpenVR.Applications.IsApplicationInstalled(key)
                };

                allGames.Add(gameData);
            }

            //StartCoroutine(LoadGameLibraryImages(refreshAll));

            libraryApp.config.SaveSettings();

            onLoaded?.Invoke();
        }