Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public static extern tobii_error_t tobii_gaze_point_subscribe(IntPtr device, tobii_gaze_point_callback_t callback);