Engines/FlatRedBallXNA/FlatRedBall/Input/Xbox360Gamepad.cs
/// <summary>
/// Returns whether the argument button type is pushed. For analog buttons, such as LeftTrigger 
/// and RightTrigger, the AnalogOnThreshold value is used to determine if the button is pressed.
/// </summary>
/// <param name="button">The button to check.</param>
/// <returns>true if the button is pressed, otherwise false</returns>
Returns whether the argument button type is pushed. For analog buttons, such as LeftTrigger
and RightTrigger, the AnalogOnThreshold value is used to determine if the button is pressed.
Returns whether the argument button type is pushed . For analog buttons such as LeftTrigger and RightTrigger the AnalogOnThreshold value is used to determine if the button is pressed .
public bool ButtonPushed(Button button)
        {
            if (InputManager.mIgnorePushesThisFrame || mButtonsIgnoredForThisFrame[(int)button] || InputManager.CurrentFrameInputSuspended)
                return false;
            bool returnValue = false;
            if (this.mButtonMap != null)
            {
                switch (button)
                {
                    case Button.A:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.A);
                        break;
                    case Button.B:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.B);
                        break;
                    case Button.X:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.X);
                        break;
                    case Button.Y:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.Y);
                        break;
                    case Button.LeftShoulder:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.LeftShoulder);
                        break;
                    case Button.RightShoulder:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.RightShoulder);
                        break;
                    case Button.Back:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.Back);
                        break;
                    case Button.Start:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.Start);
                        break;
                    case Button.LeftStick:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.LeftStick);
                        break;
                    case Button.RightStick:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.RightStick);
                        break;
                    case Button.DPadUp:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.DPadUp);
                        break;
                    case Button.DPadDown:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.DPadDown);
                        break;
                    case Button.DPadLeft:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.DPadLeft);
                        break;
                    case Button.DPadRight:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.DPadRight);
                        break;
                    case Button.LeftTrigger:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.LeftTrigger);
                        break;
                    case Button.RightTrigger:
                        returnValue |= InputManager.Keyboard.KeyPushed(mButtonMap.RightTrigger);
                        break;
                }
            }
            switch (button)
            {
                case Button.A:
                    returnValue |= mGamePadState.Buttons.A == ButtonState.Pressed && mLastGamePadState.Buttons.A == ButtonState.Released;
                    break;
                case Button.B:
                    returnValue |= mGamePadState.Buttons.B == ButtonState.Pressed && mLastGamePadState.Buttons.B == ButtonState.Released;
                    break;
                case Button.X:
                    returnValue |= mGamePadState.Buttons.X == ButtonState.Pressed && mLastGamePadState.Buttons.X == ButtonState.Released;
                    break;
                case Button.Y:
                    returnValue |= mGamePadState.Buttons.Y == ButtonState.Pressed && mLastGamePadState.Buttons.Y == ButtonState.Released;
                    break;
                case Button.LeftShoulder:
                    returnValue |= mGamePadState.Buttons.LeftShoulder == ButtonState.Pressed && mLastGamePadState.Buttons.LeftShoulder == ButtonState.Released;
                    break;
                case Button.RightShoulder:
                    returnValue |= mGamePadState.Buttons.RightShoulder == ButtonState.Pressed && mLastGamePadState.Buttons.RightShoulder == ButtonState.Released;
                    break;
                case Button.Back:
                    returnValue |= mGamePadState.Buttons.Back == ButtonState.Pressed && mLastGamePadState.Buttons.Back == ButtonState.Released;
                    break;
                case Button.Start:
                    returnValue |= mGamePadState.Buttons.Start == ButtonState.Pressed && mLastGamePadState.Buttons.Start == ButtonState.Released;
                    break;
                case Button.LeftStick:
                    returnValue |= mGamePadState.Buttons.LeftStick == ButtonState.Pressed && mLastGamePadState.Buttons.LeftStick == ButtonState.Released;
                    break;
                case Button.RightStick:
                    returnValue |= mGamePadState.Buttons.RightStick == ButtonState.Pressed && mLastGamePadState.Buttons.RightStick == ButtonState.Released;
                    break;
                case Button.DPadUp:
                    returnValue |= mGamePadState.DPad.Up == ButtonState.Pressed && mLastGamePadState.DPad.Up == ButtonState.Released;
                    break;
                case Button.DPadDown:
                    returnValue |= mGamePadState.DPad.Down == ButtonState.Pressed && mLastGamePadState.DPad.Down == ButtonState.Released;
                    break;
                case Button.DPadLeft:
                    returnValue |= mGamePadState.DPad.Left == ButtonState.Pressed && mLastGamePadState.DPad.Left == ButtonState.Released;
                    break;
                case Button.DPadRight:
                    returnValue |= mGamePadState.DPad.Right == ButtonState.Pressed && mLastGamePadState.DPad.Right == ButtonState.Released;
                    break;
                case Button.LeftTrigger:
                    returnValue |= mLeftTrigger.Position >= AnalogOnThreshold && mLeftTrigger.LastPosition < AnalogOnThreshold;
                    break;
                case Button.RightTrigger:
                    returnValue |= mRightTrigger.Position >= AnalogOnThreshold && mRightTrigger.LastPosition < AnalogOnThreshold;
                    break;
            }
            return returnValue;
        }
public bool ButtonPushed ( Button button ) { if ( InputManager . mIgnorePushesThisFrame || mButtonsIgnoredForThisFrame [ ( int ) button ] || InputManager . CurrentFrameInputSuspended ) return false ; bool returnValue = false ; if ( this . mButtonMap != null ) { switch ( button ) { case Button . A : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . A ) ; break ; case Button . B : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . B ) ; break ; case Button . X : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . X ) ; break ; case Button . Y : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . Y ) ; break ; case Button . LeftShoulder : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . LeftShoulder ) ; break ; case Button . RightShoulder : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . RightShoulder ) ; break ; case Button . Back : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . Back ) ; break ; case Button . Start : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . Start ) ; break ; case Button . LeftStick : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . LeftStick ) ; break ; case Button . RightStick : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . RightStick ) ; break ; case Button . DPadUp : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . DPadUp ) ; break ; case Button . DPadDown : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . DPadDown ) ; break ; case Button . DPadLeft : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . DPadLeft ) ; break ; case Button . DPadRight : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . DPadRight ) ; break ; case Button . LeftTrigger : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . LeftTrigger ) ; break ; case Button . RightTrigger : returnValue |= InputManager . Keyboard . KeyPushed ( mButtonMap . RightTrigger ) ; break ; } } switch ( button ) { case Button . A : returnValue |= mGamePadState . Buttons . A == ButtonState . Pressed && mLastGamePadState . Buttons . A == ButtonState . Released ; break ; case Button . B : returnValue |= mGamePadState . Buttons . B == ButtonState . Pressed && mLastGamePadState . Buttons . B == ButtonState . Released ; break ; case Button . X : returnValue |= mGamePadState . Buttons . X == ButtonState . Pressed && mLastGamePadState . Buttons . X == ButtonState . Released ; break ; case Button . Y : returnValue |= mGamePadState . Buttons . Y == ButtonState . Pressed && mLastGamePadState . Buttons . Y == ButtonState . Released ; break ; case Button . LeftShoulder : returnValue |= mGamePadState . Buttons . LeftShoulder == ButtonState . Pressed && mLastGamePadState . Buttons . LeftShoulder == ButtonState . Released ; break ; case Button . RightShoulder : returnValue |= mGamePadState . Buttons . RightShoulder == ButtonState . Pressed && mLastGamePadState . Buttons . RightShoulder == ButtonState . Released ; break ; case Button . Back : returnValue |= mGamePadState . Buttons . Back == ButtonState . Pressed && mLastGamePadState . Buttons . Back == ButtonState . Released ; break ; case Button . Start : returnValue |= mGamePadState . Buttons . Start == ButtonState . Pressed && mLastGamePadState . Buttons . Start == ButtonState . Released ; break ; case Button . LeftStick : returnValue |= mGamePadState . Buttons . LeftStick == ButtonState . Pressed && mLastGamePadState . Buttons . LeftStick == ButtonState . Released ; break ; case Button . RightStick : returnValue |= mGamePadState . Buttons . RightStick == ButtonState . Pressed && mLastGamePadState . Buttons . RightStick == ButtonState . Released ; break ; case Button . DPadUp : returnValue |= mGamePadState . DPad . Up == ButtonState . Pressed && mLastGamePadState . DPad . Up == ButtonState . Released ; break ; case Button . DPadDown : returnValue |= mGamePadState . DPad . Down == ButtonState . Pressed && mLastGamePadState . DPad . Down == ButtonState . Released ; break ; case Button . DPadLeft : returnValue |= mGamePadState . DPad . Left == ButtonState . Pressed && mLastGamePadState . DPad . Left == ButtonState . Released ; break ; case Button . DPadRight : returnValue |= mGamePadState . DPad . Right == ButtonState . Pressed && mLastGamePadState . DPad . Right == ButtonState . Released ; break ; case Button . LeftTrigger : returnValue |= mLeftTrigger . Position >= AnalogOnThreshold && mLeftTrigger . LastPosition < AnalogOnThreshold ; break ; case Button . RightTrigger : returnValue |= mRightTrigger . Position >= AnalogOnThreshold && mRightTrigger . LastPosition < AnalogOnThreshold ; break ; } return returnValue ; }
Returns whether the argument button type is pushed.
Returns whether the argument button type is pushed .
true if the button is pressed, otherwise false
true if the button is pressed otherwise false
button
Button
The button to check.
The button to check .