public StreamEngineTracker(StreamEngineTracker_Description description = null, StreamEngineConnection connection = null)
        {
            if (description == null)
            {
                description = new StreamEngineTracker_Description();
            }

            if (connection == null)
            {
                connection = new StreamEngineConnection(new InteropWrapper());
            }

            LocalLatestData = new TobiiXR_EyeTrackingData();

            _connection = connection;

            if (TryConnectToTracker(_connection, _stopwatch, description) == false)
            {
                throw new Exception("Failed to connect to tracker");
            }

            _nativePointerToSelf = GCHandle.Alloc(this);
            if (SubscribeToWearableData(_connection.Context.Device, GCHandle.ToIntPtr(_nativePointerToSelf)) == false)
            {
                throw new Exception("Failed to subscribe to tracker");
            }

            CheckForCapabilities(_connection.Context.Device);
        }
        public StreamEngineTracker(StreamEngineTracker_Description description = null, StreamEngineConnection connection = null)
        {
            if (description == null)
            {
                description = new StreamEngineTracker_Description();
            }

            if (connection == null)
            {
                connection = new StreamEngineConnection(new InteropWrapper());
            }

            LocalLatestData = new TobiiXR_EyeTrackingData();

            _connection = connection;

            if (TryConnectToTracker(_connection, _stopwatch, description) == false)
            {
                throw new Exception("Failed to connect to tracker");
            }

            _wearableDataCallback = OnWearableData;
            if (SubscribeToWearableData(_connection.Context.Device, _wearableDataCallback) == false)
            {
                throw new Exception("Failed to subscribe to tracker");
            }

            CheckForCapabilities(_connection.Context.Device);
        }
        private static bool TryConnectToTracker(StreamEngineConnection connection, Stopwatch stopwatch, StreamEngineTracker_Description description)
        {
            StartStopwatch(stopwatch);

            if (connection.Open(description) == false)
            {
                return(false);
            }

            var elapsedTime = StopStopwatch(stopwatch);

            UnityEngine.Debug.Log(string.Format("Connected to SE tracker: {0} and it took {1}ms", connection.Context.Url, elapsedTime));
            return(true);
        }
예제 #4
0
        private static bool TryConnectToTracker(FieldOfUse fieldOfUse, StreamEngineConnection connection, Stopwatch stopwatch, StreamEngineTracker_Description description)
        {
            StartStopwatch(stopwatch);

            try
            {
                if (connection.Open(fieldOfUse, description) == false)
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogError("Error connecting to eye tracker: " + e.ToString());
                return(false);
            }

            var elapsedTime = StopStopwatch(stopwatch);

            UnityEngine.Debug.Log(string.Format("Connected to SE tracker: {0} and it took {1}ms", connection.Context.Url, elapsedTime));
            return(true);
        }