public bool InitializeWithLicense(string licenseKey, bool enableAdvanced)
        {
            var createInfo = new StreamEngineTracker_Description();

            if (!string.IsNullOrEmpty(licenseKey))
            {
                createInfo.License = new[] { licenseKey };
            }

            try
            {
                _hmdToWorldTransformer = new HmdToWorldTransformer(estimatedEyeTrackerLatency_s: 0.012f);
                _streamEngineTracker   = new StreamEngineTracker(createInfo);

                // Subscribe to relevant streams
                var startInfo = new StreamEngineTrackerStartInfo();
                if (enableAdvanced)
                {
                    startInfo.WearableAdvancedDataCallback = OnAdvancedWearableData;
                }
                else
                {
                    startInfo.WearableDataCallback = OnWearableData;
                }
                _streamEngineTracker.Start(startInfo);

                return(true);
            }
            catch (Exception e)
            {
                Debug.Log(e.Message);
                return(false);
            }
        }
Example #2
0
        public void Start(StreamEngineTrackerStartInfo startInfo)
        {
            // Subscribe to requested streams
            tobii_error_t result;

            if (startInfo.WearableDataCallback != null)
            {
                _wearableDataCallbackPointer = GCHandle.Alloc(startInfo.WearableDataCallback);
                result = Interop.tobii_wearable_consumer_data_subscribe(Context.Device, WearableDataCallback, GCHandle.ToIntPtr(_wearableDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }

            if (startInfo.WearableAdvancedDataCallback != null)
            {
                _wearableAdvancedDataCallbackPointer = GCHandle.Alloc(startInfo.WearableAdvancedDataCallback);
                result = Interop.tobii_wearable_advanced_data_subscribe(Context.Device, AdvancedWearableDataCallback, GCHandle.ToIntPtr(_wearableAdvancedDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }

            if (startInfo.WearableFoveatedDataCallback != null)
            {
                _wearableFoveatedDataCallbackPointer = GCHandle.Alloc(startInfo.WearableFoveatedDataCallback);
                result = Interop.tobii_wearable_foveated_gaze_subscribe(Context.Device, WearableFoveatedGazeCallback, GCHandle.ToIntPtr(_wearableFoveatedDataCallbackPointer));
                if (result != tobii_error_t.TOBII_ERROR_NO_ERROR)
                {
                    throw new Exception("Failed to subscribe to eye tracking data: " + result);
                }
            }
        }