Exemplo n.º 1
0
        public static short GetAxisPosition(HidAxis axis, HidState state)
        {
            HidAxisState axisState;

            if (!state.AxisStates.TryGetValue(axis.Axis, out axisState))
            {
                return(0);
            }
            return(NumericUtils.UIntToShort(axisState.Value));
        }
Exemplo n.º 2
0
        public static bool IsAxisPressed(HidAxis axis, HidState state, short deadZone)
        {
            HidAxisState axisState;

            if (!state.AxisStates.TryGetValue(axis.Axis, out axisState))
            {
                return(false);
            }
            short value = NumericUtils.UIntToShort(axisState.Value);

            return(axis.PositiveValues ? value > deadZone : value < -deadZone);
        }
Exemplo n.º 3
0
        public static short GetAxisPositionMapped(HidAxis axis, HidState state, bool isMappedToPositive)
        {
            short position = GetAxisPosition(axis, state);

            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);
        }