Home Forums Software Development Unity SDK – eyetracker IsConnected/Disconnected

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2901
    Peter Olthof
    Participant

    Hi 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

    #2917
    Jenny [Tobii]
    Participant

    Hi 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 to EyeXEngineAvailability.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.

    #7019
    GoodSpeed
    Participant

    since 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?

    #7024
    Alex [Tobii]
    Participant

    Hi!

    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.

    #7029
    GoodSpeed
    Participant

    Thank 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?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.