Ejemplo n.º 1
0
        protected short GetAxisPositionMapped(XInputAxis axis, Gamepad gamepad, bool isMappedToPositive)
        {
            short position = GetAxisPosition(axis, gamepad, _thumbDeadZone, _triggerDeadZone);

            if (position == 0 || (axis.PositiveValues && position <= 0) || (!axis.PositiveValues && position >= 0))
            {
                return(0);
            }

            bool shouldInvert = (axis.PositiveValues && !isMappedToPositive) || (!axis.PositiveValues && isMappedToPositive);

            if (shouldInvert)
            {
                position = (short)(-position - 1);
            }
            return(position);
        }
Ejemplo n.º 2
0
        protected static short GetAxisPosition(XInputAxis axis, Gamepad gamepad, short thumbDeadZone, short triggerDeadZone)
        {
            switch (axis.AxisType)
            {
            case XInputAxisType.LeftThumbX:
                return(CheckDeadZone(gamepad.LeftThumbX, thumbDeadZone));

            case XInputAxisType.LeftThumbY:
                return(CheckDeadZone(gamepad.LeftThumbY, thumbDeadZone));

            case XInputAxisType.RightThumbX:
                return(CheckDeadZone(gamepad.RightThumbX, thumbDeadZone));

            case XInputAxisType.RightThumbY:
                return(CheckDeadZone(gamepad.RightThumbY, thumbDeadZone));

            case XInputAxisType.LeftTrigger:
                return(CheckDeadZone(NumericUtils.ScaleByteToShort(gamepad.LeftTrigger), triggerDeadZone));

            case XInputAxisType.RightTrigger:
                return(CheckDeadZone(NumericUtils.ScaleByteToShort(gamepad.RightTrigger), triggerDeadZone));
            }
            return(0);
        }
Ejemplo n.º 3
0
        protected static bool IsAxisPressed(XInputAxis axis, Gamepad gamepad, short thumbDeadZone, short triggerDeadZone)
        {
            short position = GetAxisPosition(axis, gamepad, thumbDeadZone, triggerDeadZone);

            return(axis.PositiveValues ? position > 0 : position < 0);
        }
Ejemplo n.º 4
0
 public static bool IsAxisPressed(XInputAxis axis, Gamepad gamepad)
 {
     return(IsAxisPressed(axis, gamepad, DEFAULT_THUMB_DEADZONE, DEFAULT_TRIGGER_DEADZONE));
 }