Example #1
0
        private bool TryGetLastGazePoints(out IEnumerable <GazePoint> gazePoints)
        {
            if (!IsInitialized)
            {
                gazePoints = new List <GazePoint>();
                return(false);
            }

            if (_useMouseEmulation)
            {
                var host = EyeTrackingHost.GetInstance() as EyeTrackingHost;
                if (host)
                {
                    var gazePoint = new GazePoint(Input.mousePosition, (double)Time.time / 1000.0f, Time.time);
                    gazePoints = new List <GazePoint>()
                    {
                        gazePoint
                    };
                    return(true);
                }
            }

            gazePoints = _gazePointDataProvider.GetDataPointsSince(_lastHandledGazePoint);
            UpdateLastHandledGazePoint(gazePoints);

            return(gazePoints.Any());
        }
Example #2
0
        //--------------------------------------------------------------------
        // Singleton Accessor
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the singleton EyeTrackingHost instance.
        /// Always use this method to access the EyeTrackingHost
        /// </summary>
        /// <returns>The instance.</returns>
        public static IEyeTrackingHost GetInstance()
        {
            if (_isShuttingDown)
            {
                return(new EyeTrackingHostStub());
            }

            if (_instance == null)
            {
                // create a game object with a new instance of this class attached as a component.
                // (there's no need to keep a reference to the game object, because game objects are not garbage collected.)
                var container = new GameObject("EyeTrackingHostContainer");
                DontDestroyOnLoad(container);
                _instance = (EyeTrackingHost)container.AddComponent(typeof(EyeTrackingHost));
            }

            return(_instance);
        }
Example #3
0
        private bool TryGetGazePoint(out GazePoint gazePoint)
        {
            if (!IsInitialized)
            {
                gazePoint = GazePoint.Invalid;
                return(false);
            }

            if (_useMouseEmulation)
            {
                var host = EyeTrackingHost.GetInstance() as EyeTrackingHost;
                if (host)
                {
                    gazePoint = new GazePoint(Input.mousePosition, (double)Time.time / 1000.0f, Time.time);
                    return(true);
                }
            }

            gazePoint = GetLastGazePoint();
            return(gazePoint.IsWithinScreenBounds);
        }
Example #4
0
        }                                                           // TODO: make internal?

        //---------------------------------------------------------------------
        // Private methods
        //---------------------------------------------------------------------

        private void Initialize()
        {
            if (_gazePointDataProvider == null)
            {
                ReloadSettings();
                _gazePointDataProvider = EyeTrackingHost.GetInstance().GetGazePointDataProvider();
                _gazePointDataProvider.Start(_identifier.GetInstanceID());
            }

            if (Scorer == null)
            {
                //Scorer = new SingleRayCastNoScore();
                Scorer = new SingleRaycastHistoricHitScore();
                //Scorer = new MultiRaycastHistoricHitScore();
            }
            if (_multiScorer == null)
            {
                _multiScorer = new MultiRaycastHistoricHitScore();
            }

            _isInitialized = true;
        }
Example #5
0
 private IRegisterGazeFocusable GazeFocusHandler()
 {
     return((IRegisterGazeFocusable)EyeTrackingHost.GetInstance().GazeFocus);
 }