public Profile(Profiles car, string file) { Name = file; Car = car; var phFile = string.Format(car.PatternFile, file); if (!File.Exists(phFile)) { Debug.WriteLine("Cannot find file " + phFile + " - creating defaults"); Antistall = "easy"; CruiseControl = "easy"; switch (file) { case "Performance": ShiftCurve = "Performance.5kmh.slow"; break; case "Efficiency": ShiftCurve = "Efficiency.5kmh.slow"; break; case "Economy": ShiftCurve = "Economy.5kmh.slow"; break; } SpeedLimiter = "nolimit"; TractionControl = "notc"; ShiftPattern = new List<ConfigurableShiftPattern>(); ShiftPattern.Add(new ConfigurableShiftPattern("up_1thr", "normal")); ShiftPattern.Add(new ConfigurableShiftPattern("up_0thr", "normal")); ShiftPattern.Add(new ConfigurableShiftPattern("down_1thr", "normal")); ShiftPattern.Add(new ConfigurableShiftPattern("down_0thr", "normal")); var iniExport = ExportParameters(); Main.Store(iniExport, phFile); Loaded = true; } else { Loaded = true; } Main.Load(this, phFile); }
public static bool Setup() { if (requiresSetup) { requiresSetup = false; JoystickInput deskCtrl, g25Wheel, ps4Ctrl; // Joysticks var dskObj = JoystickInputDevice.Search("Hotas").FirstOrDefault(); deskCtrl = dskObj == null ? default(JoystickInput) : new JoystickInput(dskObj); var ps4Obj = JoystickInputDevice.Search("Wireless Controller").FirstOrDefault(); ps4Ctrl = ps4Obj== null ? default(JoystickInput) : new JoystickInput(ps4Obj); var g25Obj = JoystickInputDevice.Search("G25").FirstOrDefault(); g25Wheel = g25Obj == null ? default(JoystickInput) : new JoystickInput(g25Obj); var vJoy = new JoystickOutput(); // add main controller: if (dskCtlActive) RawJoysticksIn.Add(deskCtrl); else if (ps4CtlActive) RawJoysticksIn.Add(ps4Ctrl); else RawJoysticksIn.Add(default(JoystickInput)); RawJoysticksIn.Add(g25Wheel); RawJoysticksOut.Add(vJoy); // Data source Data = new DataArbiter(); Data.CarChanged += (s, e) => { if (Data.Active.Application == "eurotrucks2") Drivetrain = new Ets2Drivetrain(); else Drivetrain = new GenericDrivetrain(); // reset all modules Antistall.ResetParameters(); CruiseControl.ResetParameters(); Drivetrain.ResetParameters(); Transmission.ResetParameters(); TractionControl.ResetParameters(); Speedlimiter.ResetParameters(); CarProfile = new Profiles(Data.Active.Application, Data.Telemetry.Car); LoadNextProfile(10000); }; // TODO: Temporary.. Data.AppActive += (s, e) => { CameraHorizon.CameraHackEnabled = Data.Active.Application == "TestDrive2"; }; if (deskCtrl == null && g25Wheel == null && ps4Ctrl == null) { //MessageBox.Show("No controllers found"); return false; } // Modules Antistall = new Antistall(); ACC = new ACC(); CruiseControl = new CruiseControl(); Drivetrain = new GenericDrivetrain(); Transmission = new Transmission(); TractionControl = new TractionControl(); ProfileSwitcher = new ProfileSwitcher(); Speedlimiter = new Speedlimiter(); LaunchControl = new LaunchControl(); DrivetrainCalibrator = new DrivetrainCalibrator(); TransmissionCalibrator = new TransmissionCalibrator(); LaneAssistance = new LaneAssistance(); VariableSpeedControl = new VariableSpeedTransmission(); CameraHorizon = new CameraHorizon(); // Controls Controls = new ControlChain(); Data.Run(); return true; } return false; }