static public bool CreateSession(out IntPtr sessionHandle)
        {
            SRDCorePlugin.ShowNativeLog();
            if (SRDProjectSettings.IsRunWithoutSRDisplayMode())
            {
                sessionHandle = IntPtr.Zero;
                return(true);
            }
            SrdXrResult xrResult = SRDCorePlugin.CreateSession(out sessionHandle);

            if (xrResult == SrdXrResult.SUCCESS)
            {
                return(true);
            }

            var errorToMessage = new Dictionary <SrdXrResult, string>()
            {
                { SrdXrResult.ERROR_DISPLAY_NOT_FOUND, SRDHelper.SRDMessages.DisplayConnectionError },
                { SrdXrResult.ERROR_FORM_FACTOR_UNAVAILABLE, SRDHelper.SRDMessages.DisplayConnectionError },
                { SrdXrResult.ERROR_RUNTIME_NOT_FOUND, SRDHelper.SRDMessages.DLLNotFoundError },
            };
            // Should be set all possible message to the dict
            var msg = errorToMessage.ContainsKey(xrResult) ? errorToMessage[xrResult] : string.Format("Fail to create seesion {0}", xrResult);

            SRDHelper.PopupMessageAndForceToTerminate(msg);
            if (DestroySession(sessionHandle))
            {
                sessionHandle = IntPtr.Zero;
            }
            return(false);
        }
        static public bool BeginSession(IntPtr sessionHandle)
        {
            if (SRDProjectSettings.IsRunWithoutSRDisplayMode())
            {
                return(true);
            }
            if (sessionHandle == IntPtr.Zero)
            {
                return(false);
            }

            SrdXrResult xrResult = SRDCorePlugin.BeginSession(sessionHandle);

            if (xrResult == SrdXrResult.SUCCESS)
            {
                SRDCorePlugin.SetGraphicsAPI(sessionHandle, SystemInfo.graphicsDeviceType);
                SRDCorePlugin.SetColorSpaceSettings(sessionHandle, QualitySettings.desiredColorSpace);
                return(true);
            }

            var errorToMessage = new Dictionary <SrdXrResult, string>()
            {
                { SrdXrResult.ERROR_USB_NOT_CONNECTED, SRDHelper.SRDMessages.DeviceConnectionError },
                { SrdXrResult.ERROR_DEVICE_NOT_FOUND, SRDHelper.SRDMessages.DeviceNotFoundError },
                { SrdXrResult.ERROR_SESSION_RUNNING, SRDHelper.SRDMessages.AppConflictionError },
                { SrdXrResult.ERROR_USB_3_NOT_CONNECTED, SRDHelper.SRDMessages.USB3ConnectionError },
            };
            var msg = errorToMessage.ContainsKey(xrResult) ? errorToMessage[xrResult] : string.Format("Fail to begin seesion {0}", xrResult);

            SRDHelper.PopupMessageAndForceToTerminate(msg);
            return(false);
        }
Exemplo n.º 3
0
        void Awake()
        {
            UpdateSettings();
            foreach (var cond in GetForceQuitConditions())
            {
                if (cond.IsForceQuit)
                {
                    ForceQuitWithAssertion(cond.ForceQuitMessage);
                }
            }

            if (SRDProjectSettings.IsRunWithoutSRDisplayMode())
            {
                _description = new SRDSystemDescription(FaceTrackerSystem.Mouse,
                                                        EyeViewRendererSystem.UnityRenderCam,
                                                        StereoCompositerSystem.PassThrough);
            }
            else
            {
                _description = new SRDSystemDescription(FaceTrackerSystem.SRD,
                                                        EyeViewRendererSystem.UnityRenderCam,
                                                        StereoCompositerSystem.SRD);
            }

            _srdCoreRenderer = new SRDCoreRenderer(_description);
            _srdCoreRenderer.OnSRDFaceTrackStateEvent += (bool result) =>
            {
#if DEVELOPMENT_BUILD
                //Debug.LogWarning("No data from FaceRecognition: See the DebugWindow with F10");
#endif
                if (OnFaceTrackStateEvent != null)
                {
                    OnFaceTrackStateEvent.Invoke(result);
                }
            };

            SRDSessionHandler.Instance.CreateSession();

            _srdCrosstalkCorrection = new SRDCrosstalkCorrection();
        }