Ejemplo n.º 1
0
        static void FlyDroneJoystick()
        {
            var joystick = new JoystickDevice();

            joystick.Initialize("/dev/input/js0");

            while (true)
            {
                joystick.ProcessEvents();
                var pitch = -joystick.AxisValues[0];
                var roll  = joystick.AxisValues[1];
                var gaz   = joystick.AxisValues[2];
                var yaw   = joystick.AxisValues[3];

                drone.Progress(FlightMode.Progressive, roll, pitch, yaw, gaz);
                Thread.Sleep(200);
            }
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            joystick = new JoystickDevice();
            joystick.Initialize("/dev/input/js0");
            joystick.InputReceived +=
                (sender, e) =>
            {
                //LastCommand = new Vector2D(e.Axis[(int)0], e.Axis[(int)1]);

                if (CommandReceived != null)
                {
                    CommandReceived(this, new CommandEventArgs {
                        Command = LastCommand
                    });
                }
            };

            new Thread(() =>
            {
                joystick.ProcessEvents();
            }).Start();
        }