コード例 #1
0
ファイル: Program.cs プロジェクト: ufouz1990/LeapMousion
        static void Main(string[] args)
        {
            Console.Title = "Leap Mousion v2.0";
            Console.WriteLine("Leap Mousion v2.0 by TangoChen    :)\r\n------------------------------------\r\nBlog: TangoChen.com\r\nYoutube Channel: www.youtube.com/tan9ochen\r\n--------------------\r\nTwitter:\ttwitter.com/tangochen\t@TangoChen\r\n微博(Weibo):\tweibo.com/tangochen\t@TangoChen\r\n--------------------\r\nPress any key to exit...\r\n--------------------");

            // Create a sample listener and controller
            SampleListener listener   = new SampleListener();
            Controller     controller = new Controller();

            foreach (string arg in args)
            {
                switch (arg.Substring(0, 1).ToLower())
                {
                case "l":     // L = Set isLeftHanded = true;
                    listener.isLeftHanded = true;
                    break;

                case "s":     // Scale
                    float.TryParse(arg.Substring(1), out listener.moveScale);
                    break;

                case "r":     // Reverse Orientation
                    /*
                     * It won't just reverse the horizontal axes but also change the fingerIndex...
                     * So this is used when the device get reversed horizontal axes
                     * and you don't want to click the [Reverse Orientation] inside the [Leap Motion Controller Settings] or
                     * rotate the device...
                     */
                    listener.isReversed = true;
                    break;

                case "c":     // Click-Only
                    listener.isClickOnly = true;
                    break;
                }
            }

            Console.WriteLine(
                "Speed: " + listener.moveScale.ToString() +
                "\r\nClick-Only: " + listener.isClickOnly.ToString() +
                "\r\nReversed: " + listener.isReversed.ToString() +
                "\r\nLeft Handed Mode: " + (listener.isLeftHanded ? "Enabled" : "Disabled") +
                "\r\n--------------------"
                );

            // Receive frames of tracking data while in the background
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until any key is pressed
            Console.ReadKey(true); //System.Diagnostics.Process.Start("pause"); Won't work...

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: TangoChen/LeapMousion
        static void Main(string[] args)
        {
            Console.Title = "Leap Mousion v2.0";
            Console.WriteLine("Leap Mousion v2.0 by TangoChen    :)\r\n------------------------------------\r\nBlog: TangoChen.com\r\nYoutube Channel: www.youtube.com/tan9ochen\r\n--------------------\r\nTwitter:\ttwitter.com/tangochen\t@TangoChen\r\n微博(Weibo):\tweibo.com/tangochen\t@TangoChen\r\n--------------------\r\nPress any key to exit...\r\n--------------------");

            // Create a sample listener and controller
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();

            foreach (string arg in args)
            {
                switch (arg.Substring(0, 1).ToLower())
                {
                    case "l": // L = Set isLeftHanded = true;
                        listener.isLeftHanded = true;
                        break;
                    case "s": // Scale
                        float.TryParse(arg.Substring(1), out listener.moveScale);
                        break;
                    case "r": // Reverse Orientation
                        /*
                         * It won't just reverse the horizontal axes but also change the fingerIndex...
                         * So this is used when the device get reversed horizontal axes
                         * and you don't want to click the [Reverse Orientation] inside the [Leap Motion Controller Settings] or
                         * rotate the device...
                         */
                        listener.isReversed = true;
                        break;
                    case "c": // Click-Only
                        listener.isClickOnly = true;
                        break;
                }
            }

            Console.WriteLine(
                "Speed: " + listener.moveScale.ToString() +
                "\r\nClick-Only: " + listener.isClickOnly.ToString() +
                "\r\nReversed: " + listener.isReversed.ToString() +
                "\r\nLeft Handed Mode: " + (listener.isLeftHanded ? "Enabled" : "Disabled") +
                "\r\n--------------------"
                );

            // Receive frames of tracking data while in the background
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until any key is pressed
            Console.ReadKey(true); //System.Diagnostics.Process.Start("pause"); Won't work...

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }