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);
        }
Beispiel #2
0
        internal TobiiTrackerBase(ApiContext api, bool isWearable)
        {
            _device = api
                      .GetDeviceUrls()
                      .Select(u => new DeviceContext(api.Handle, u))
                      .FirstOrDefault(d => d.IsWearable == isWearable);

            if (_device != null)
            {
                if (isWearable)
                {
                    var result = Interop.tobii_stream_supported(_device.Handle, tobii_stream_t.TOBII_STREAM_WEARABLE, out var wearableSupported);
                    if (result == tobii_error_t.TOBII_ERROR_NO_ERROR && wearableSupported)
                    {
                        _wearableCallbackInstance = WearableCallback;
                        result = Interop.tobii_wearable_data_subscribe(_device.Handle, _wearableCallbackInstance);
                    }
                }
                else
                {
                    var result = Interop.tobii_stream_supported(_device.Handle, tobii_stream_t.TOBII_STREAM_GAZE_POINT, out var gazePointSupported);
                    if (result == tobii_error_t.TOBII_ERROR_NO_ERROR && gazePointSupported)
                    {
                        _gazePointCallbackInstance = GazePointCallback;
                        result = Interop.tobii_gaze_point_subscribe(_device.Handle, _gazePointCallbackInstance);
                    }
                }

                _thread = new Thread(DataPump);
                _thread.IsBackground = true;
                _thread.Name         = $"Data pump for {_device.SerialNumber}";
                _thread.Start();
            }
        }
Beispiel #3
0
        private static bool SubscribeToWearableData(IntPtr context, tobii_wearable_data_callback_t wearableDataCallback)
        {
            var result = Interop.tobii_wearable_data_subscribe(context, wearableDataCallback);

            if (result == tobii_error_t.TOBII_ERROR_NO_ERROR)
            {
                return(true);
            }

            UnityEngine.Debug.LogError("Failed to subscribe to wearable stream." + result);
            return(false);
        }
Beispiel #4
0
        public StreamEngineTracker()
        {
            if (TryConnectToTracker(ref _streamEngineContext, _stopwatch) == false)
            {
                throw new Exception("Failed to connect to tracker");
            }

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

            LocalLatestData = new TobiiXR_EyeTrackingData();
        }
Beispiel #5
0
 public void Dispose()
 {
     _continue = false;
     if (_gazePointCallbackInstance != null)
     {
         Interop.tobii_gaze_point_unsubscribe(_device.Handle);
     }
     if (_wearableCallbackInstance != null)
     {
         Interop.tobii_wearable_data_unsubscribe(_device.Handle);
     }
     _device.Dispose();
     _thread.Join(300);
     _gazePointCallbackInstance = null;
     _wearableCallbackInstance  = null;
 }
Beispiel #6
0
 public static extern tobii_error_t tobii_wearable_data_subscribe(IntPtr device, tobii_wearable_data_callback_t callback);