static void Main(string[] args) { ClientContext.PreloadNativeLibraries(true); var jointClientOptions = new JointClientOptions(); //jointClientOptions.AddString("/display", "displays/OSVR_HDK_1_1.json"); jointClientOptions.LoadPlugin("com_osvr_example_EyeTracker"); jointClientOptions.TriggerHardwareDetect(); using (var context = JointClientOptions.InitContext(ref jointClientOptions, "com.osvr.Examples.JointClientKit")) { if (context == null) { Console.WriteLine("Failed to create a joint client context."); return; } context.update(); var leftEye = EyeTracker2DInterface.GetInterface(context, "/me/eyes/left"); leftEye.StateChanged += leftEye_StateChanged; for (var i = 0; i < 15; i++) { context.update(); Thread.Sleep(200); } } }
static void Main(string[] args) { ClientContext.PreloadNativeLibraries(); using (ServerAutoStarter serverAutoStarter = new ServerAutoStarter()) using (OSVR.ClientKit.ClientContext context = new OSVR.ClientKit.ClientContext("com.osvr.exampleclients.managed.EyeTracker")) { // there are three types of interfaces for eye tracking, 2D, 3D, and blinking #if NET20 using (var eyeTracker2D = EyeTracker2DInterface.GetInterface(context, EyeTrackerPath)) using (var eyeTracker3D = EyeTracker3DInterface.GetInterface(context, EyeTrackerPath)) using (var eyeTrackerBlink = EyeTrackerBlinkInterface.GetInterface(context, EyeTrackerPath)) #else using (var eyeTracker2D = context.GetEyeTracker2DInterface(EyeTrackerPath)) using (var eyeTracker3D = context.GetEyeTracker3DInterface(EyeTrackerPath)) using (var eyeTrackerBlink = context.GetEyeTrackerBlinkInterface(EyeTrackerPath)) #endif { eyeTracker2D.StateChanged += eyeTracker2D_StateChanged; eyeTracker3D.StateChanged += eyeTracker3D_StateChanged; eyeTrackerBlink.StateChanged += eyeTrackerBlink_StateChanged; // Pretend that this is your application's main loop for (int i = 0; i < 1000000; ++i) { context.update(); var eyeTracker2DState = eyeTracker2D.GetState(); var eyeTracker3DState = eyeTracker3D.GetState(); var eyeTrackerBlinkState = eyeTrackerBlink.GetState(); Console.WriteLine("Getting state:"); Console.WriteLine("EyeTracker2D: {0}", FormatEyeTracker2DReport(eyeTracker2DState.Value)); Console.WriteLine("EyeTracker3D: {0}", FormatEyeTracker3DReport(eyeTracker3DState.Value)); Console.WriteLine("EyeTrackerBlink: {0}", eyeTrackerBlinkState.Value); } Console.WriteLine("Library shut down; exiting."); } } }