Exemplo n.º 1
0
        public RecordForm(Drone drone, InputManager inputManager)
        {
            this.drone = drone;
            this.inputManager = inputManager;

            InitializeComponent();
        }
Exemplo n.º 2
0
        public void Update(InputManager manager)
        {
            if (!UpdateState())
                return;

            if (CheckButtonPressed(2))
                manager.SendClear();

            if (CheckButtonPressed(1))
                manager.StopDrone();

            if (CheckButtonPressed(0))
                manager.ArmDrone();

            if (CheckButtonReleased(0))
                manager.DisarmDrone();

            float deadZone = 0.075f;
            if (!manager.DeadZone)
                deadZone = 0;

            const int maxValue = UInt16.MaxValue / 2;
            TargetData target = new TargetData();
            target.Roll = DeadZone.Compute(currentState.X - maxValue, maxValue, deadZone);
            target.Pitch = DeadZone.Compute(currentState.Y - maxValue, maxValue, deadZone);
            target.RotationalSpeed = DeadZone.Compute(currentState.RotationZ - maxValue, maxValue, deadZone);
            target.Thrust = DeadZone.Compute(UInt16.MaxValue - currentState.Z, UInt16.MaxValue, deadZone);

            manager.SendTargetData(target);

            lastState = currentState;
        }
Exemplo n.º 3
0
        public DebugForm(Drone drone, InputManager inputManager)
        {
            if (drone == null)
                throw new ArgumentNullException(nameof(drone));

            InitializeComponent();

            this.Drone = drone;
            this.Drone.OnDebugDataChange += Drone_OnDebugDataChange;
            this.InputManager = inputManager;

            UpdateDebugData(drone.DebugData);
        }
Exemplo n.º 4
0
        public void Init(Drone drone)
        {
            if (drone == null)
                throw new ArgumentNullException(nameof(drone));

            this.drone = drone;
            this.InputManager = new InputManager(drone);
            this.InputManager.OnDeviceInfoChanged += InputManager_OnDeviceInfoChanged;
            this.InputManager.OnTargetDataChanged += InputManager_OnTargetDataChanged;

            this.drone.OnDebugDataChange += Drone_OnDebugDataChange;

            SearchInputDevices();
            UpdateTargetData();
            UpdateDeviceInfo();
            UpdateInputConfig();
        }
Exemplo n.º 5
0
        public void Update(InputManager manager)
        {
            if (!IsConnected)
                return;

            currentState = controller.GetState();

            if (CheckButtonPressed(GamepadButtonFlags.A))
                manager.SendClear();

            if (CheckButtonPressed(GamepadButtonFlags.B))
                manager.StopDrone();

            if (CheckButtonPressed(GamepadButtonFlags.Y))
                manager.ToogleArmStatus();

            float deadZone = 0.075f;
            if (!manager.DeadZone)
                deadZone = 0;

            TargetData target = new TargetData();
            target.Roll = DeadZone.Compute(currentState.Gamepad.LeftThumbX, short.MaxValue, deadZone);
            target.Pitch = -DeadZone.Compute(currentState.Gamepad.LeftThumbY, short.MaxValue, deadZone);
            target.RotationalSpeed = DeadZone.Compute(currentState.Gamepad.RightThumbX, short.MaxValue, deadZone);
            target.Thrust = DeadZone.Compute(currentState.Gamepad.RightThumbY + short.MaxValue, short.MaxValue * 2, deadZone);

            float x = GetButtonValue(GamepadButtonFlags.DPadRight) - GetButtonValue(GamepadButtonFlags.DPadLeft);
            float y = -GetButtonValue(GamepadButtonFlags.DPadDown) - GetButtonValue(GamepadButtonFlags.DPadUp);
            target.Roll += x * 0.1f;
            target.Pitch += y * 0.1f;


            manager.SendTargetData(target);

            lastState = currentState;
            firstUpdate = false;
        }