Beispiel #1
0
 public static GamePadState GetState(GamePadIndex gamepad_index)
 {
     return(Platform.GetGamePadState(
                (int)gamepad_index,
                GamePadDeadZone.IndependentAxes
                ));
 }
Beispiel #2
0
 public static GamePadState GetState(GamePadIndex gamepad_index, GamePadDeadZone deadZoneMode)
 {
     return(Platform.GetGamePadState(
                (int)gamepad_index,
                deadZoneMode
                ));
 }
Beispiel #3
0
 public static bool SetVibration(GamePadIndex gamepad_index, float leftMotor, float rightMotor)
 {
     return(Platform.SetGamePadVibration(
                (int)gamepad_index,
                leftMotor,
                rightMotor
                ));
 }
Beispiel #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="gamePadIndex"></param>
        /// <param name="deadZone"></param>
        public GamePad(GamePadIndex gamePadIndex, GamePadDeadZone deadZone)
        {
            this.Index = gamePadIndex;
            this.deadZone = deadZone;

            this.controller = new XInput.Controller(ConvertGamePadIndexToUserIndex(this.Index));
            this.state = new XInput.Gamepad();
        }
Beispiel #5
0
 public static bool GamePadStateChanged(GamePadIndex index, Buttons button)
 {
     if (index == GamePadIndex.Any)
     {
         return(gamePads != oldGamePads);
     }
     return(gamePads[(int)index] != oldGamePads[(int)index]);
 }
Beispiel #6
0
 public static bool IsButtonUp(GamePadIndex index, Buttons button)
 {
     if (index == GamePadIndex.Any)
     {
         for (int i = 0; i < 4; i++)
         {
             if (oldGamePads[i].IsButtonUp(button))
             {
                 return(true);
             }
         }
         return(false);
     }
     return(oldGamePads[(int)index].IsButtonUp(button));
 }
Beispiel #7
0
 public static bool IsButtonHeld(GamePadIndex index, Buttons button)
 {
     if (index == GamePadIndex.Any)
     {
         for (int i = 0; i < 4; i++)
         {
             if (gamePads[i].IsButtonDown(button) && gamePads[i].IsButtonDown(button))
             {
                 return(true);
             }
         }
         return(false);
     }
     return(gamePads[(int)index].IsButtonDown(button) && gamePads[(int)index].IsButtonDown(button));
 }
Beispiel #8
0
 public static void SetLightBar(GamePadIndex gamepad_index, Color color)
 {
     Platform.SetGamePadLightBar((int)gamepad_index, color);
 }
Beispiel #9
0
 public static string GetGuid(GamePadIndex gamepad_index)
 {
     return(Platform.GetGamePadGUID((int)gamepad_index));
 }
Beispiel #10
0
 public static GamePadCapabilities GetCapabilities(GamePadIndex gamepad_index)
 {
     return(Platform.GetGamePadCapabilities((int)gamepad_index));
 }
Beispiel #11
0
        /// <summary>
        /// Converts a PlayerIndex to a XInput.UserIndex.
        /// </summary>
        /// <param name="playerIndex"></param>
        /// <returns></returns>
        private static XInput.UserIndex ConvertGamePadIndexToUserIndex(GamePadIndex playerIndex)
        {
            switch (playerIndex)
            {
                case GamePadIndex.One: return XInput.UserIndex.One;
                case GamePadIndex.Two: return XInput.UserIndex.Two;
                case GamePadIndex.Three: return XInput.UserIndex.Three;
                case GamePadIndex.Four: return XInput.UserIndex.Four;
            }

            throw new ArgumentOutOfRangeException("PlayerIndex must be between 1 and 4.");
        }
Beispiel #12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="gamePadIndex"></param>
 public GamePad(GamePadIndex gamePadIndex)
     : this(gamePadIndex, GamePadDeadZone.Default)
 {
 }
Beispiel #13
0
 public static bool GamePadReleased(GamePadButtons button, GamePadIndex player_index = 0)
 {
     return(!gp_current_state[(int)player_index][button] && gp_prev_state[(int)player_index][button]);
 }
Beispiel #14
0
 public static bool GamePadDown(GamePadButtons button, GamePadIndex player_index = 0)
 {
     return(gp_current_state[(int)player_index][button]);
 }
Beispiel #15
0
 public static GamePadState GetGamePadState(GamePadIndex player_index = 0)
 {
     return(gp_current_state[(int)player_index]);
 }
Beispiel #16
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="gamePadIndex"></param>
 public GamePad(GamePadIndex gamePadIndex)
     : this(gamePadIndex, GamePadDeadZone.Standard)
 {
 }