/// <summary>
 /// Handles notification of buttons changed of the xinput controller.
 /// </summary>
 /// <param name="buttons"></param>
 void OnButtonsChanged(xinput.ButtonsChanged buttons)
 {
     if (buttons.Body.Y)
     {
         _drivePort.SetDrivePower(0.5, 0.5);
     }
     else if (buttons.Body.A)
     {
         _drivePort.SetDrivePower(-0.5, -0.5);
     }
     else if (buttons.Body.X)
     {
         _drivePort.SetDrivePower(-0.3, 0.3);
     }
     else if (buttons.Body.B)
     {
         _drivePort.SetDrivePower(0.3, -0.3);
     }
     else if (buttons.Body.RightShoulder)
     {
         _drivePort.SetDrivePower(0.0, 0.0);
     }
     else if (buttons.Body.LeftShoulder)
     {
         _followMe = !_followMe;
         if (!_followMe)
         {
             _drivePort.SetDrivePower(0.0, 0.0);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Handles state changes of buttons of the controller
        /// </summary>
        /// <param name="buttons">The button states of the controller</param>
        void OnGamePadButtonsChanged(xinput.ButtonsChanged buttons)
        {
            // If the A-Button is pressed toggle the attitude stabilization
            if (buttons.Body.A)
            {
                Globals.GlobalWinFormsServicePort.FormInvoke(
                    delegate()
                {
                    _windowControl.ToggleCheckBoxKeepAttitude();
                }
                    );
            }

            // If the B-Button is pressed toggle the attitude stabilization
            if (buttons.Body.B)
            {
                Globals.GlobalWinFormsServicePort.FormInvoke(
                    delegate()
                {
                    _windowControl.ToggleCheckBoxKeepAltitude();
                }
                    );
            }

            if (buttons.Body.X)
            {
            }

            if (buttons.Body.Y)
            {
            }

            // If the LS-Button is clicked start zooming the camera in
            if (buttons.Body.LeftShoulder)
            {
                _pursuitCameraEntity.zoomChange = 0.01f;
            }
            // If the RS-Button ist clicked start zooming the camera out
            else if (buttons.Body.RightShoulder)
            {
                _pursuitCameraEntity.zoomChange = -0.01f;
            }
            // If none of the Shoulder buttons is pressed stop zooming
            else
            {
                _pursuitCameraEntity.zoomChange = 0.0f;
            }

            if (buttons.Body.LeftStick)
            {
            }

            if (buttons.Body.RightStick)
            {
            }

            // If the Reset button is clicked reset the multicopter
            if (buttons.Body.Start)
            {
                _multicopterEntity.Reset();
            }

            // If the Back button is clicked change the camera mode
            if (buttons.Body.Back)
            {
                _windowControlEventsPort.Post(new WindowControl.OnAction(WindowControl.OnActionActions.ACTION_TOGGLE_CAMERAMODE));
            }
        }