Beispiel #1
0
        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();
        }
        static void Main( string[] args )
        {
            SampleListener listener = new SampleListener();
            Controller leap = new Controller();
            leap.AddListener( listener );

            Console.WriteLine( "Press Enter to quit..." );
            Console.ReadLine();

            leap.RemoveListener( listener );
        }
        static void Main(string[] args)
        {
            ReportingListener listener = new ReportingListener(new Reporter());
            Controller controller = new Controller();
            controller.AddListener(listener);

            Console.WriteLine("Listening! Press any key when you're finished to exit.");
            Console.ReadKey();

            controller.RemoveListener(listener);
            controller.Dispose();
        }
Beispiel #4
0
        public AppModel()
        {
            var controller = new Controller();
            var listener = new FrameListener();
            controller.AddListener(listener);

            AppDomain.CurrentDomain.ProcessExit += (o, e) =>
            {
                controller.RemoveListener(listener);
                listener.Dispose();
                controller.Dispose();
            };

            listener.FrameArrived += listener_FrameArrived;
        }
        public static void Main()
        {
            // Create a sample listener and controller
            var listener = new LeapListener();
            var controller = new Controller();

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

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
Beispiel #6
0
        public static void Main()
        {
            using (UniListener listener = new UniListener())
            {
                using (Controller controller = new Controller())
                {
                    controller.SetPolicyFlags(Controller.PolicyFlag.POLICY_BACKGROUND_FRAMES);

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

                    // Keep this process running until Enter is pressed
                    Console.WriteLine("Press Enter to quit...");
                    string result = Console.ReadLine();

                    // Remove the listener when done
                    controller.RemoveListener(listener);
                }
            }
        }
        public static void Main()
        {
            // Create a sample listener and controller
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();

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

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            //used to keep things running when set to windows application build mode.
            while (listener != null)
            {

            }
            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
Beispiel #8
0
        void Read( ref SampleListener Listener, ref Controller Controller)
        {
            // Have the sample listener receive events from the controller
            Controller.AddListener(Listener);

            while (!StopRead)
            {
                //Do thing here
                //The listener class is gathering our data
            }

            // Remove the sample listener when done
            Controller.RemoveListener(Listener);
            Controller.Dispose();
            Listener.Dispose();
        }
 void Exit()
 {
     controller.RemoveListener(listener);
     controller.Dispose();
 }
Beispiel #10
0
        static void Main(string[] args)
        {
            // Create a sample listener and controller
            GestureListener listener = new GestureListener();
            Controller controller = new Controller();

            listener.Gestures.GestureReceived += Gestures_GestureReceived;

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

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");

            while (true)
            {
                var key = Console.ReadKey(true);

                if (key.Key == ConsoleKey.Enter)
                {
                    break;
                }

                switch (key.Key)
                {
                    case ConsoleKey.D1:
                        listener.Gestures.StartTraining();
                        Console.WriteLine("Training...");
                        break;

                    case ConsoleKey.D2:
                        listener.Gestures.StopTraining();
                        Console.WriteLine("Recorded gesture.");
                        break;

                    case ConsoleKey.D3:
                        var model = listener.Gestures.FinishTrainingSession();
                        Console.WriteLine("Enter a name for this gesture:");
                        var name = Console.ReadLine();
                        model.Name = name;
                        Console.WriteLine(String.Format("Completed training of gesture {0}.", name));
                        break;

                    case ConsoleKey.D4:
                        listener.Gestures.StartRecognition();
                        Console.WriteLine("Recognizing...");
                        break;

                    case ConsoleKey.D5:
                        listener.Gestures.StopRecognition();
                        break;
                }
            }

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
Beispiel #11
0
        public void Read(string path)
        {
            RecordListener listener = new RecordListener();
            listener.Initialization(numOfFramesPerRead, this);
            Controller controller = new Controller();
            controller.AddListener(listener);

            actualNumOfReads = 0;
            Console.WriteLine("Press enter to start reading frames to file " + path);
            Console.ReadLine();
            state = RecorderState.Idle;

            while (state != RecorderState.Saving)
            {
                Console.WriteLine("num: " + (actualNumOfReads + 1) + " in " + numOfReads);
                if (!isAuto)
                {
                    Console.ReadLine();
                }
                state = RecorderState.Reading;
                Console.WriteLine("Reading...");

                while (state == RecorderState.Reading)
                {
                    if (numOfFramesPerRead == 0)
                    {
                        Console.ReadLine();
                        listener.GetSequence();
                    }
                }
                while (state == RecorderState.Storing) { }
            }

            while (state != RecorderState.Saving) { }

            Utils.SaveListListFrame(sequencesToRead, path);

            controller.RemoveListener(listener);
            controller.Dispose();
        }