예제 #1
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);
    }
예제 #2
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);
        }