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);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Initialize the library, starting up a "joint" context that also
        /// contains a server. This version of InitContext performs the default
        /// server operation: loading of all autoload-enabled plugins, and a hardware
        /// detection.
        /// </summary>
        /// <param name="options">The configuration options object for starting the joint server
        /// operations. Pass null for default operation: loading of all
        /// autoload-enabled plugins, and a hardware detection. If a non-null pointer is
        /// passed, the enqueued operations will be performed in-order (the default
        /// operations will not be performed). Any exceptions thrown will cause the
        /// initialization to fail, returning a null context.</param>
        /// <param name="applicationIdentifier">A string identifying your
        /// application. Reverse DNS format strongly suggested.</param>
        /// <returns>null, if initialization failed, else a ClientContext.</returns>
        public static ClientContext InitContext(ref JointClientOptions options, string applicationIdentifier)
        {
            if (options == null)
            {
                return(InitContext(applicationIdentifier));
            }

            var clientContextHandle = JointClientKitNative.osvrJointClientInit(applicationIdentifier, options.mHandle);

            options = null; // options can't be re-used after Init is called.
            if (clientContextHandle.IsInvalid)
            {
                return(null);
            }

            return(new ClientContext(clientContextHandle));
        }
        /// <summary>
        /// Initialize the library, starting up a "joint" context that also
        /// contains a server. This version of InitContext performs the default
        /// server operation: loading of all autoload-enabled plugins, and a hardware
        /// detection.
        /// </summary>
        /// <param name="options">The configuration options object for starting the joint server
        /// operations. Pass null for default operation: loading of all
        /// autoload-enabled plugins, and a hardware detection. If a non-null pointer is
        /// passed, the enqueued operations will be performed in-order (the default
        /// operations will not be performed). Any exceptions thrown will cause the
        /// initialization to fail, returning a null context.</param>
        /// <param name="applicationIdentifier">A string identifying your
        /// application. Reverse DNS format strongly suggested.</param>
        /// <returns>null, if initialization failed, else a ClientContext.</returns>
        public static ClientContext InitContext(ref JointClientOptions options, string applicationIdentifier)
        {
            if(options == null)
            {
                return InitContext(applicationIdentifier);
            }

            var clientContextHandle = JointClientKitNative.osvrJointClientInit(applicationIdentifier, options.mHandle);
            options = null; // options can't be re-used after Init is called.
            if(clientContextHandle.IsInvalid)
            {
                return null;
            }

            return new ClientContext(clientContextHandle);
        }