private byte?ModifyAnalog(JoystickButtons joystickButtons, State state) { switch (joystickButtons.AnalogType) { case AnalogType.None: break; case AnalogType.AnalogJoystick: { return(AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile)); } case AnalogType.AnalogJoystickReverse: { return((byte)~AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile)); } case AnalogType.Gas: case AnalogType.Brake: return(AnalogHelper.CalculateAxisOrTriggerGasBrakeXinput(joystickButtons.XInputButton, state)); case AnalogType.Wheel: { var wheelPos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, _useSto0Z, _stoozPercent, _gameProfile); if (_gameProfile.EmulationProfile == EmulationProfile.TaitoTypeXBattleGear || _gameProfile.EmulationProfile == EmulationProfile.VirtuaRLimit) { JvsHelper.StateView.Write(4, wheelPos); } return(wheelPos); } } return(null); }
private byte?ModifyAnalog(JoystickButtons joystickButtons, State state, int index) { if (joystickButtons.XInputButton?.XInputIndex != index) { return(null); } switch (joystickButtons.AnalogType) { case AnalogType.None: break; case AnalogType.AnalogJoystick: { var analogPos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile); if (_gameProfile.EmulationProfile == EmulationProfile.Mballblitz) { if (joystickButtons.InputMapping == InputMapping.Analog0) { JvsHelper.StateView.Write(8, analogPos); } if (joystickButtons.InputMapping == InputMapping.Analog2) { JvsHelper.StateView.Write(12, analogPos); } } return(analogPos); } case AnalogType.AnalogJoystickReverse: { return((byte)~AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile)); } case AnalogType.Gas: case AnalogType.Brake: return(AnalogHelper.CalculateAxisOrTriggerGasBrakeXinput(joystickButtons.XInputButton, state)); case AnalogType.SWThrottle: return(AnalogHelper.CalculateSWThrottleXinput(joystickButtons.XInputButton, state)); case AnalogType.Wheel: { var wheelPos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, _useSto0Z, _stoozPercent, _gameProfile); if (_gameProfile.EmulationProfile == EmulationProfile.TaitoTypeXBattleGear || _gameProfile.EmulationProfile == EmulationProfile.VirtuaRLimit) { JvsHelper.StateView.Write(4, wheelPos); } return(wheelPos); } } return(null); }
private static void AnalogueModeCommand(string[] args) { if (Enum.TryParse(args[0], true, out AnalogueMode mode)) { short limitShort = short.MaxValue; if (args.Length >= 2) { if (float.TryParse(args[1], out float limit)) { limitShort = (short)Calc.Clamp(limit * short.MaxValue, AnalogHelper.Lowerbound, short.MaxValue); } } AnalogHelper.AnalogModeChange(mode, limitShort); } }
public static bool TryParse(string line, int studioLine, out InputFrame inputFrame) { int index = line.IndexOf(",", StringComparison.Ordinal); string framesStr; if (index == -1) { framesStr = line; index = 0; } else { framesStr = line.Substring(0, index); } if (!int.TryParse(framesStr, out int frames)) { inputFrame = null; return(false); } frames = Math.Min(frames, 9999); inputFrame = new InputFrame { Line = studioLine, Frames = frames }; while (index < line.Length) { char c = line[index]; switch (char.ToUpper(c)) { case 'L': inputFrame.Actions ^= Actions.Left; break; case 'R': inputFrame.Actions ^= Actions.Right; break; case 'U': inputFrame.Actions ^= Actions.Up; break; case 'D': inputFrame.Actions ^= Actions.Down; break; case 'J': inputFrame.Actions ^= Actions.Jump; break; case 'X': inputFrame.Actions ^= Actions.Dash; break; case 'G': inputFrame.Actions ^= Actions.Grab; break; case 'S': inputFrame.Actions ^= Actions.Start; break; case 'Q': inputFrame.Actions ^= Actions.Restart; break; case 'N': inputFrame.Actions ^= Actions.Journal; break; case 'K': inputFrame.Actions ^= Actions.Jump2; break; case 'C': inputFrame.Actions ^= Actions.Dash2; break; case 'O': inputFrame.Actions ^= Actions.Confirm; break; case 'Z': inputFrame.Actions ^= Actions.DemoDash; break; case 'F': inputFrame.Actions ^= Actions.Feather; index++; string angleAndUpperLimit = line.Substring(index + 1).Trim(); if (angleAndUpperLimit.IsNotNullOrEmpty()) { string[] args = angleAndUpperLimit.Split(','); string angle = args[0]; if (float.TryParse(angle, out float angleFloat)) { inputFrame.Angle = angleFloat; } if (args.Length >= 2 && float.TryParse(args[1], out float upperLimitFloat)) { inputFrame.UpperLimit = upperLimitFloat; } } inputFrame.AngleVector2 = AnalogHelper.ComputeAngleVector2(inputFrame, out Vector2Short angleVector2Short); inputFrame.AngleVector2Short = angleVector2Short; continue; } index++; } LibTasHelper.WriteLibTasFrame(inputFrame); return(true); }