Home Forums Software Development C# WPF project Question Reply To: C# WPF project Question

Robert [Tobii]


Here is an example of a simple C# command line application that just moves the mouse cursor around to where you are looking. Note that, because of the characteristics of the eyes, it is hard to build a user interface based on just replacing the mouse cursor with the gaze position. But the code below should give you something to start with.

using EyeXFramework;
using System;
using System.Runtime.InteropServices;
using Tobii.EyeX.Framework;

public static class Program
    static extern bool SetCursorPos(int X, int Y);

    public static void Main(string[] args)
        var eyeXHost = new EyeXHost();

        var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
        lightlyFilteredGazeDataStream.Next += (s, e) => MoveMouse(e.X, e.Y);

        var eyePositionDataStream = eyeXHost.CreateEyePositionDataStream();
        //TODO: Listen for blinks using the eye position data stream

        // Let it run until a key is pressed.


    private static void MoveMouse(double x, double y)
        // TODO: Filtering of gaze point data
        SetCursorPos((int)x, (int)y);