Exemplo n.º 1
0
 private void DebugState(GamePadState tmpState)
 {
     if (!tmpState.Equals(state))
     {
         Debug.WriteLine($"GamePad State:\t{tmpState}");
     }
 }
Exemplo n.º 2
0
 public bool Equals(InputState other)
 {
     return(_isNotDefault == other._isNotDefault &&
            _mouseState.Equals(other._mouseState) &&
            _touchState.Equals(other._touchState) &&
            _keyboardState.Equals(other._keyboardState) &&
            GamePadState.Equals(other.GamePadState));
 }
        private void PollGamepadState()
        {
            if (window.Focused)
            {
                var newGamePadState = GamePad.GetState(0);
                if (!oldGamePadState.Equals(newGamePadState))
                {
                    if ((newGamePadState.Buttons.Back != oldGamePadState.Buttons.Back) &&
                        newGamePadState.Buttons.Back.Equals(ButtonState.Released))
                    {
                        InputReceived?.Invoke(InputType.EXIT);
                    }

                    if ((newGamePadState.Buttons.B != oldGamePadState.Buttons.B) &&
                        newGamePadState.Buttons.B.Equals(ButtonState.Released))
                    {
                        InputReceived?.Invoke(InputType.BACK);
                    }

                    if ((newGamePadState.Buttons.A != oldGamePadState.Buttons.A) &&
                        newGamePadState.Buttons.A.Equals(ButtonState.Released))
                    {
                        InputReceived?.Invoke(InputType.SELECT);
                    }

                    if ((newGamePadState.DPad.Left != oldGamePadState.DPad.Left) &&
                        newGamePadState.DPad.Left.Equals(ButtonState.Released))
                    {
                        InputReceived?.Invoke(InputType.LEFT);
                    }

                    if ((newGamePadState.DPad.Right != oldGamePadState.DPad.Right) &&
                        newGamePadState.DPad.Right.Equals(ButtonState.Released))
                    {
                        InputReceived?.Invoke(InputType.RIGHT);
                    }
                }

                oldGamePadState = newGamePadState;
            }
        }