Beispiel #1
0
 public Analog(GamePadStick _stick, bool _vertical, double _threshold = 0.1)
 {
     this._Stick     = _stick;
     this._InputType = 1;
     this._Vertical  = _vertical;
     this._Threshold = _threshold;
 }
Beispiel #2
0
        public Vector2 GetPadStickPosition(GamePadStick stick, float deadZone = 0f)
        {
            if (m_isCleared)
            {
                return(Vector2.Zero);
            }
            Vector2 zero = Vector2.Zero;

            for (int i = 0; i < 4; i++)
            {
                if (((int)Devices & (8 << i)) != 0)
                {
                    zero += GamePad.GetStickPosition(i, stick, deadZone);
                }
            }
            if (!(zero.LengthSquared() > 1f))
            {
                return(zero);
            }
            return(Vector2.Normalize(zero));
        }
Beispiel #3
0
 public static Vector2 GetStickPosition(int gamePadIndex, GamePadStick stick, float deadZone = 0f)
 {
     if (deadZone < 0f || deadZone >= 1f)
     {
         throw new ArgumentOutOfRangeException("deadZone");
     }
     if (IsConnected(gamePadIndex))
     {
         Vector2 result = m_states[gamePadIndex].Sticks[(int)stick];
         if (deadZone > 0f)
         {
             float num = result.Length();
             if (num > 0f)
             {
                 float num2 = ApplyDeadZone(num, deadZone);
                 result *= num2 / num;
             }
         }
         return(result);
     }
     return(Vector2.Zero);
 }
Beispiel #4
0
 public Analog(GamePadStick _stick, double _threshold = 0.1)
 {
     this._Stick     = _stick;
     this._InputType = 2;
     this._Threshold = _threshold;
 }