Home › Forums › Software Development › Unity SDK – eyetracker IsConnected/Disconnected
Tagged: connected, eyetracking, sdk
- This topic has 4 replies, 4 voices, and was last updated 6 years, 3 months ago by
GoodSpeed.
- AuthorPosts
- 25/04/2015 at 12:49 #2901
Peter Olthof
ParticipantHi there!
I would like to see a C# for unity code example of how to make a check if the eyetracker is connected, or disconnected. So I can easily make the game switch to mouse input or eyetracker input.
I can’t seem to get it done, even though I recieve a debug.log stating that the EyeX is running, but it doesn’t check for eyetracker connected state. It would be really nice to see a code example, so I can make our eyetracking game more user friendly!
Thanks in advance
30/04/2015 at 14:59 #2917Jenny [Tobii]
ParticipantHi Peter,
What you need is two levels of checks: 1) if there is an EyeX Engine running on the machine, and 2) if the eye tracker is up and running tracking the user’s eyes.
Here are some code snippets how to perform these checks.
1) There is a static property on the EyeXHost to check if the EyeXEngine is running:
EyeXHost.EyeXAvailability
Check if it is equal toEyeXEngineAvailability.Running
2) Here is what you need to add in a mono behavior class to (continously) check if the eye tracker is up and running and tracking the user’s eyes:
private EyeXHost _eyeXHost; void Start() { _eyeXHost = EyeXHost.GetInstance(); } void Update() { var eyeTrackerDeviceStatus = _eyexHost.EyeTrackingDeviceStatus; if(eyeTrackerDeviceStatus == EyeXDeviceStatus.Tracking) { // use EyeX } else { // use mouse } }
I hope this gives you enough to adapt to do something appropriate for your game.
12/06/2017 at 20:15 #7019GoodSpeed
Participantsince the SDK update, i can use userPresent function to detect user is there or not.
but I have a question…
when some other thing happens, such as USB disconnected or crash
the userPresent can’t update status.
does there any way to know if it is forced crash or disconnected?13/06/2017 at 00:49 #7024Alex [Tobii]
ParticipantHi!
The best way to design eye tracking interactions is to disable them on timeout. You can use IsRecent() on GazePoint to determine when was the last time the tracker was providing data.
13/06/2017 at 06:32 #7029GoodSpeed
ParticipantThank you Alex,
IsRecent() works fine, thank you.
another question,
if i’m not using eyetracker (IsRecent should return false) for a while,
and something wrong(maybe eyetracker is forced unplug or crash)
IsRecent still return false, right?
how do i know the eyetracker still alive? - AuthorPosts
- You must be logged in to reply to this topic.