public async Task <string> Calibrate(Window parentWindow) { Log.Info("Attempting to calibrate using the Tobii EyeX engine."); var taskCompletionSource = new TaskCompletionSource <string>(); //Used to make this method awaitable on the InteractionRequest callback if (EyeXHost != null) { EyeXHost.LaunchRecalibration(); EyeXHost.EyeTrackingDeviceStatusChanged += (s, e) => { if (e.Value == EyeTrackingDeviceStatus.Tracking) { Log.Info("Calibration ended."); taskCompletionSource.SetResult(Resources.TOBII_EYEX_CALIBRATION_SUCCESS); } }; } else { throw new ApplicationException(Resources.THE_EYE_TRIBE_UNABLE_TO_CALIBRATE_NO_ENGINE); } return(await taskCompletionSource.Task); }
private void OnGUI() { // Draw the title. GuiHelpers.DrawText("CALIBRATION", new Vector2(10, 10), 36, GuiHelpers.Magenta); if (IsSupportedEngineVersion()) { // Draw the "Recalibrate" button. if (GUI.Button(new Rect(10, 70, 150, 30), "Recalibrate")) { StartWaitingForCalibration(); _host.LaunchRecalibration(); } // Draw the "Test calibration" button. if (GUI.Button(new Rect(10, 110, 150, 30), "Test calibration")) { _host.LaunchCalibrationTesting(); } } else { // The current engine is not supported. GuiHelpers.DrawRequiredEngineVersionError("1.1"); } }
/// <summary> /// Starts EyeX engine callibration /// </summary> override public bool Execute(Context context) { if (context.Recognized == Pattern.Calibrate) { Engine.EyeTrackingDeviceStatusChanged += OnStatusChanged; Console.WriteLine("starts calibration"); Engine.LaunchRecalibration(); IsRunning = true; return(true); } return(false); }
void Update() { if (timeCounter - startingTime > counter && counter < timeCalibrationStarts) { textCountdown.GetComponent <UnityEngine.UI.Text> ().text = (timeCalibrationStarts - counter - 1).ToString(); counter++; } timeCounter += Time.deltaTime; if (timeCounter > this.timeCalibrationStarts && didStartCalibration == false) { didStartCalibration = true; textGO.GetComponent <UnityEngine.UI.Text> ().text = ""; Destroy(textGOSkip); Destroy(textCountdown); StartWaitingForCalibration(); _host.LaunchRecalibration(); textGO.GetComponent <UnityEngine.UI.Text> ().text = "If you see this screen, Tobii EyeX could not be found.\n\nIt is recommended to install Tobii EyeX, otherwise you cannot play the game proberly.\n\nPress E to continue or Space to get back into the menu central."; print("doing"); } if (_waitingState == WaitingState.WaitingForCalibrationToStart && _host.EyeTrackingDeviceStatus == EyeXDeviceStatus.Pending) { print("Waiting for calibration to finish"); _waitingState = WaitingState.WaitingForCalibrationToFinish; } else if (_waitingState == WaitingState.WaitingForCalibrationToFinish && _host.EyeTrackingDeviceStatus == EyeXDeviceStatus.Tracking) { print("Calibration finished. Bring back focus to application"); WindowHelpers.ShowCurrentWindow(); StopWaitingForCalibration(); } if (Input.GetKeyDown(KeyCode.E)) { AutoFade.LoadLevel("Level 1", 1, 1, Color.black); } if (timeCounter > this.timeCalibrationStarts && Input.GetKeyDown(KeyCode.Space)) { AutoFade.LoadLevel("Central", 1, 1, Color.black); } }
public void LaunchRecalibration() { { var start = new ThreadStart(() => { Thread.Sleep(5000); SendKeys.SendWait("{ENTER}"); }); var thread = new Thread(start); thread.Start(); } { var start = new ThreadStart(() => _eyeXHost.LaunchRecalibration()); var thread = new Thread(start); thread.Start(); } }
public static void Main(string[] args) { using (var eyeXHost = new EyeXHost()) { eyeXHost.Start(); Console.WriteLine("EYEX CONFIGURATION TOOLS"); Console.WriteLine("========================"); Console.WriteLine(); Console.WriteLine("T) Test calibration"); Console.WriteLine("G) Guest calibration"); Console.WriteLine("R) Recalibrate"); Console.WriteLine("D) Display Setup"); Console.WriteLine("P) Create Profile"); var key = Console.ReadKey(true).Key; switch (key) { case ConsoleKey.T: eyeXHost.LaunchCalibrationTesting(); break; case ConsoleKey.G: eyeXHost.LaunchGuestCalibration(); break; case ConsoleKey.R: eyeXHost.LaunchRecalibration(); break; case ConsoleKey.D: eyeXHost.LaunchDisplaySetup(); break; case ConsoleKey.P: eyeXHost.LaunchProfileCreation(); break; } } }
private void OnGUI() { if (!IsSupportedEngineVersion()) { var content = new GUIContent("This functionality requires EyeX Engine version 1.1 or higher."); // Create the font style. var style = new GUIStyle(); style.alignment = TextAnchor.MiddleCenter; style.fontSize = 18; style.normal.textColor = new Color(0.953f, 0.569f, 0.039f, 1f); // Calculate the boundaries. var height = style.CalcHeight(content, 700) + 30; var bounds = new Rect((Screen.width - 700) / 2f, Screen.height / 2f - (height / 2), 700, height); // Draw the label. GUI.Label(bounds, content, style); return; } // Draw the box surrounding the buttons. GUI.Box(new Rect(10, 10, 170, 110), "Calibration"); // Draw the "Recalibrate" button. if (GUI.Button(new Rect(20, 40, 150, 30), "Recalibrate")) { StartWaitingForCalibration(); _host.LaunchRecalibration(); } // Draw the "Test calibration" button. if (GUI.Button(new Rect(20, 80, 150, 30), "Test calibration")) { _host.LaunchCalibrationTesting(); } }
public async Task <string> Calibrate(Window parentWindow) { Log.Info("Attempting to calibrate using the Tobii EyeX engine."); var taskCompletionSource = new TaskCompletionSource <string>(); //Used to make this method awaitable on the InteractionRequest callback if (EyeXHost != null) { EyeXHost.LaunchRecalibration(); EyeXHost.EyeTrackingDeviceStatusChanged += (s, e) => { if (e.IsValid && e.Value == EyeTrackingDeviceStatus.Tracking) { taskCompletionSource.SetResult("Calibration completed, or possibly cancelled, but everything is working again!"); } }; } else { throw new ApplicationException("Unable to attempt a calibration as no EyeX engine is available."); } return(await taskCompletionSource.Task); }