public bool Open(FieldOfUse fieldOfUse, StreamEngineTracker_Description description) { IntPtr apiContext; if (Context != null) { throw new InvalidOperationException("There is already an instantiated connection"); } if (CreateApiContext(_interop, out apiContext, _customLog) == false) { return(false); } List <string> connectedDevices; if (GetAvailableTrackers(_interop, apiContext, out connectedDevices) == false) { DestroyApiContext(_interop, apiContext); return(false); } IntPtr deviceContext; string hmdEyeTrackerUrl; var interopFieldOfUse = fieldOfUse == FieldOfUse.Interactive ? Interop.tobii_field_of_use_t.TOBII_FIELD_OF_USE_INTERACTIVE : Interop.tobii_field_of_use_t.TOBII_FIELD_OF_USE_ANALYTICAL; if (GetFirstSupportedTracker(_interop, apiContext, interopFieldOfUse, connectedDevices, description, out deviceContext, out hmdEyeTrackerUrl) == false) { DestroyApiContext(_interop, apiContext); return(false); } Context = new StreamEngineContext(apiContext, deviceContext, hmdEyeTrackerUrl); return(true); }
public void Destroy() { if (_streamEngineContext == null) { return; } var result = Interop.tobii_device_destroy(_streamEngineContext.Device); if (result != tobii_error_t.TOBII_ERROR_NO_ERROR) { UnityEngine.Debug.LogError(string.Format("Failed to destroy device context. Error {0}", result)); } result = Interop.tobii_api_destroy(_streamEngineContext.Api); if (result != tobii_error_t.TOBII_ERROR_NO_ERROR) { UnityEngine.Debug.LogError(string.Format("Failed to destroy api context. Error {0}", result)); } UnityEngine.Debug.Log(string.Format("Destroyed SE tracker {0}", _streamEngineContext.Url)); _streamEngineContext = null; _stopwatch = null; }
public bool Open(StreamEngineTracker_Description description) { IntPtr apiContext; if (Context != null) { throw new InvalidOperationException("There is already an instantiated connection"); } if (CreateApiContext(_interop, out apiContext, _customLog) == false) { return(false); } List <string> connectedDevices; if (GetAvailableTrackers(_interop, apiContext, out connectedDevices) == false) { DestroyApiContext(_interop, apiContext); return(false); } IntPtr deviceContext; string hmdEyeTrackerUrl; if (GetFirstSupportedTracker(_interop, apiContext, connectedDevices, description, out deviceContext, out hmdEyeTrackerUrl) == false) { DestroyApiContext(_interop, apiContext); return(false); } Context = new StreamEngineContext(apiContext, deviceContext, hmdEyeTrackerUrl); return(true); }
public static void Disconnect(IStreamEngineInterop interop, StreamEngineContext context) { if (context == null) { return; } DestroyDeviceContext(interop, context.Device); DestroyApiContext(interop, context.Api); }
public void Close() { if (Context == null) { return; } DestroyDeviceContext(_interop, Context.Device); DestroyApiContext(_interop, Context.Api); Context = null; }
public static bool TryConnect(IStreamEngineInterop interop, StreamEngineTracker_Description description, out StreamEngineContext context, tobii_custom_log_t customLog = null) { _stopwatch.Reset(); _stopwatch.Start(); context = null; IntPtr apiContext; if (CreateApiContext(interop, out apiContext, customLog) == false) { return(false); } try { List <string> connectedDevices; if (GetAvailableTrackers(interop, apiContext, out connectedDevices) == false) { DestroyApiContext(interop, apiContext); return(false); } IntPtr deviceContext; string hmdEyeTrackerUrl; if (GetFirstSupportedTracker(interop, apiContext, connectedDevices, description, out deviceContext, out hmdEyeTrackerUrl) == false) { DestroyApiContext(interop, apiContext); return(false); } context = new StreamEngineContext(apiContext, deviceContext, hmdEyeTrackerUrl); _stopwatch.Stop(); UnityEngine.Debug.Log(string.Format("Connected to SE tracker: {0} and it took {1}ms", context.Url, _stopwatch.ElapsedMilliseconds)); return(true); } catch (Exception e) { UnityEngine.Debug.LogError("Error connecting to eye tracker: " + e.ToString()); return(false); } }
private static bool TryConnectToTracker(ref StreamEngineContext streamEngineContext, Stopwatch stopwatch) { StartStopwatch(stopwatch); IntPtr apiContext; if (CreateApiContext(out apiContext) == false) { return(false); } List <string> connectedDevices; if (GetAvailableTrackers(apiContext, out connectedDevices) == false) { return(false); } string hmdEyeTrackerUrl; if (GetUrlForHmdTracker(connectedDevices, out hmdEyeTrackerUrl) == false) { return(false); } IntPtr deviceContext; if (CreateDevice(hmdEyeTrackerUrl, apiContext, out deviceContext) == false) { return(false); } streamEngineContext = new StreamEngineContext(apiContext, deviceContext, hmdEyeTrackerUrl); var elapsedTime = StopStopwatch(stopwatch); UnityEngine.Debug.Log(string.Format("Connected to SE tracker: {0} and it took {1}ms", hmdEyeTrackerUrl, elapsedTime)); return(true); }