This is an budget TrackIR feature for TDU2, designed to look side-ways when a look-around stick is moved. The look side-ways auto centers. Control of camera angle is done with ProcessMemoryWrite access.
Inheritance: IControlChainObj
Exemple #1
0
        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;
        }
Exemple #2
0
        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);
        }