Listen to the Leap Motion device and manage the functions linked to the controller.
Inheritance: Listener
Example #1
0
 /// <summary>
 /// Create the Leap Motion's controller and register its events
 /// </summary>
 private void InitLeapMotionController(KeyboardListener keyListener)
 {
     using (Controller controller = new Controller())
     {
         LeapMotionListener leapMotionListener = new LeapMotionListener(keyListener);
         leapMotionListener.OnShowInformations             += new LeapMotionCustomEvents.LeapMotionEventHandler(ShowLeapMotionMessage);
         leapMotionListener.OnDeviceConnectionStateChanged += new LeapMotionCustomEvents.LeapMotionDeviceEventHandler(IsLeapMotionDeviceConnected);
         controller.Connect       += leapMotionListener.OnServiceConnect;
         controller.Disconnect    += leapMotionListener.OnServiceDisconnect;
         controller.Device        += leapMotionListener.OnConnect;
         controller.DeviceLost    += leapMotionListener.OnDisconnect;
         controller.DeviceFailure += leapMotionListener.OnDeviceFailure;
         controller.FrameReady    += leapMotionListener.OnFrame;
         controller.LogMessage    += leapMotionListener.OnLogMessage;
     }
 }
        public LeapMotionManager()
        {
            deviceStatusArgs = new KineapStatusChangedArgs();

            if (listener == null)
            {
                if (leapMotionConverter == null)
                {
                    leapMotionConverter = new LeapMotionConverter();
                    listener = new LeapMotionListener(leapMotionConverter, this);
                    AssimpConverter = leapMotionConverter;
                }
                if (controller == null)
                    controller = new Controller();
                controller.AddListener(listener);
            }
        }
Example #3
0
        /// <summary>
        /// FunciĆ³n que inicializa el listener del Arduino
        /// </summary>
        /// <param name="args">No arguments needed</param>
        static void Main(string[] args)
        {
            using (Leap.IController controller = new Leap.Controller())
            {
                controller.SetPolicy(Leap.Controller.PolicyFlag.POLICY_ALLOW_PAUSE_RESUME);

                // Iniciar el listener
                LeapMotionListener listener = new LeapMotionListener();
                controller.Connect       += listener.OnServiceConnect;
                controller.Disconnect    += listener.OnServiceDisconnect;
                controller.FrameReady    += listener.OnFrame;
                controller.Device        += listener.OnConnect;
                controller.DeviceLost    += listener.OnDisconnect;
                controller.DeviceFailure += listener.OnDeviceFailure;
                controller.LogMessage    += listener.OnLogMessage;

                // Mantener el programa hasta que se pulse una tecla
                Console.WriteLine(string.Format("Press any key to quit..."));
                Console.ReadLine();
            }
        }