public static byte CalculateSWThrottleXinput(XInputButton button, State state)
        {
            if (button.IsButton)
            {
                var btnPress = DigitalHelper.GetButtonPressXinput(button, state, 0);
                if (btnPress == true)
                {
                    return(0xFF);
                }
                return(0x00);
            }

            if (button.IsLeftThumbY)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.LeftThumbY, false, false));
            }

            if (button.IsRightThumbY)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.RightThumbY, false, false));
            }

            if (button.IsLeftTrigger)
            {
                return(state.Gamepad.LeftTrigger);
            }

            if (button.IsRightTrigger)
            {
                return(state.Gamepad.RightTrigger);
            }
            return(0);
        }
Example #2
0
        public static byte CalculateAxisOrTriggerGasBrakeXinput(XInputButton button, State state, byte minVal = 0, byte maxVal = 255)
        {
            if (button.IsButton)
            {
                var btnPress = DigitalHelper.GetButtonPressXinput(button, state, 0);
                if (btnPress == true)
                {
                    return(0xFF);
                }
                return(0x00);
            }

            if (button.IsLeftThumbX)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.LeftThumbX, true, false, minVal, maxVal));
            }

            if (button.IsLeftThumbY)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.LeftThumbY, true, false, minVal, maxVal));
            }

            if (button.IsRightThumbX)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.RightThumbX, true, false, minVal, maxVal));
            }

            if (button.IsRightThumbY)
            {
                return(JvsHelper.CalculateGasPos(state.Gamepad.RightThumbY, true, false, minVal, maxVal));
            }

            byte result = 0;

            if (button.IsLeftTrigger)
            {
                result = state.Gamepad.LeftTrigger;
            }

            if (button.IsRightTrigger)
            {
                result = state.Gamepad.RightTrigger;
            }

            if (result < minVal)
            {
                result = minVal;
            }
            if (result > maxVal)
            {
                result = maxVal;
            }
            return(result);
        }