public ucJoystickChannel(JoyControls c, bool inout) { InitializeComponent(); lblControl.Text = c.ToString(); pbVal.Value = 0; Input = inout; ctrl = c; }
public double GetAxis(JoyControls c, double val) { var amp = 2; var expMax = Math.Exp(1 * amp) - 1; if (c == JoyControls.Throttle) return (Math.Exp(val * amp) - 1) / expMax; else return val; }
public double GetAxis(JoyControls c, double val) { switch(c) { case JoyControls.Clutch: return clutching ? 1 : val; default: return val; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.Clutch: return clutching; default: return false; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.CameraHorizon: return true; default: return false; } }
public double GetAxis(JoyControls c, double val) { if (!Active) return val; switch (c) { case JoyControls.Throttle: return throttle; case JoyControls.Clutch: return clutch; default: return val; } }
public double GetAxis(JoyControls c, double val) { switch (c) { case JoyControls.Throttle: if (Cruising) return Math.Min(1,Math.Max(0,t)); else return val; case JoyControls.Brake: if (Cruising) return Math.Min(1, Math.Max(0, b)); else return val; default: return val; } }
public double GetAxis(JoyControls c, double val) { switch (c) { case JoyControls.Throttle: if (!Active) return val; else if (State == PowerMeterState.Prearm) return preArmThr; else if (State == PowerMeterState.Revup) return 1; else if (State == PowerMeterState.Revdown) return 0; else return val; break; case JoyControls.Clutch: return Active ? 1 : val; default: return val; } }
public bool GetButton(JoyControls c, bool val) { switch(c) { case JoyControls.GearUp: if (val && !ProfileSwitchFrozen) { ProfileSwitchTimeout = DateTime.Now.Add(new TimeSpan(0, 0, 0, 1)); if (Main.Data.Active.Application == "eurotrucks2") { // var ets2miner = (Ets2DataMiner) Main.Data.Active; var ets2telemetry = ets2miner.MyTelemetry; Main.LoadNextProfile(ets2telemetry.Job.Mass); } else { Main.LoadNextProfile(10000); } } return false; break; case JoyControls.GearDown: if(val && !TransmissionReverseFrozen) { TransmissionReverseTimeout = DateTime.Now.Add(new TimeSpan(0, 0, 0, 1)); Transmission.InReverse = !Transmission.InReverse; } return false; break; default: return val; } }
public bool Requires(JoyControls c) { switch(c) { default: return false; case JoyControls.Throttle: return Slipping; } }
public double GetAxis(JoyControls c, double val) { switch (c) { default: return val; case JoyControls.Throttle: var t = (1 - (SlipAngle - 1 - AllowedSlip)/Slope); if (t > 1) t = 1; if (t < 0) t = 0; lastThrottle =t * 0.05 + lastThrottle*0.95; return val*lastThrottle; break; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.Steering: return Active; default: return false; } }
public double GetAxis(JoyControls c, double val) { switch(c) { case JoyControls.Steering: return SteerAngle; default: return val; } }
public bool Requires(JoyControls c) { switch (c) { case JoyControls.Throttle: return Enabled&& Stalling; case JoyControls.Clutch: return Enabled && Stalling; default: return false; } }
public double GetAxis(JoyControls c, double val) { switch (c) { case JoyControls.Throttle: transmissionThrottle = val; if (transmissionThrottle > 1) transmissionThrottle = 1; if (transmissionThrottle < 0) transmissionThrottle = 0; lock (ActiveShiftPattern) { if (!Enabled) return val * ThrottleScale; if (shiftRetry > 0) return 0; if (ShiftFrame >= ActiveShiftPattern.Count) return val * ThrottleScale; var candidateValue= IsShifting ?ActiveShiftPattern.Frames[ShiftFrame].Throttle*val : val; candidateValue *= ThrottleScale; return candidateValue; } case JoyControls.Clutch: lock (ActiveShiftPattern) { if (ShiftFrame >= ActiveShiftPattern.Count) return val; return ActiveShiftPattern.Frames[ShiftFrame].Clutch; } default: return val; } }
public bool GetButton(JoyControls c, bool val) { return val; }
public bool Requires(JoyControls c) { switch (c) { // Only required when changing case JoyControls.Throttle: return Enabled|| true; case JoyControls.Clutch: return Enabled && IsShifting; // All gears. case JoyControls.GearR: case JoyControls.Gear1: case JoyControls.Gear2: case JoyControls.Gear3: case JoyControls.Gear4: case JoyControls.Gear5: case JoyControls.Gear6: return Enabled; case JoyControls.GearRange2: case JoyControls.GearRange1: return Enabled && Main.Data.Active.TransmissionSupportsRanges; case JoyControls.Gear7: case JoyControls.Gear8: return Enabled && !Main.Data.Active.TransmissionSupportsRanges; case JoyControls.GearUp: case JoyControls.GearDown: return Enabled ; default: return false; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.Throttle: case JoyControls.Brake: return Cruising; case JoyControls.CruiseControlMaintain: case JoyControls.CruiseControlUp: case JoyControls.CruiseControlDown: case JoyControls.CruiseControlOnOff: return true; default: return false; } }
public double GetAxis(JoyControls c, double val) { switch(c) { case JoyControls.Throttle: return val*this.limiterFactor; case JoyControls.Brake: return brakeFactor; default: return val; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.Throttle: return true; case JoyControls.Brake: return brakeFactor > 0.005; default: return false; } }
public double GetAxis(JoyControls c, double val) { switch (c) { case JoyControls.Throttle: var error = SpeedCruise - Speed; IntegralTime += error * ISlope; var Differential = (error - PreviousError) * DSlope; PreviousError = error; if (IntegralTime > Imax) IntegralTime = Imax; if (IntegralTime < -Imax) IntegralTime = -Imax; var cruiseVal = error * 3.6*PSlope + IntegralTime+Differential; ManualOverride = val >= cruiseVal; if(Cruising && cruiseVal>val) val = cruiseVal; var t = val; if (t > 1) t = 1; if (t < 0) t = 0; return t; case JoyControls.Brake: if (val > 0.1) Cruising = false; return val; default: return val; } }
public bool Requires(JoyControls c) { return (c == JoyControls.Clutch || c == JoyControls.Throttle); }
public static double GetAxisIn(JoyControls c) { switch(c) { case JoyControls.VstLever: if (VST) return 1-RawJoysticksIn[0].GetAxis(2)/Math.Pow(2, 16); else { return 1; } break; case JoyControls.Steering: if (ps4CtlActive) { var s = RawJoysticksIn[0].GetAxis(0) / Math.Pow(2, 16)-0.5; s *= 2; var wasn = s < 0; s = s * s; s /= 2; if (wasn) s *= -1; s += 0.5; return s; } else if (dskCtlActive) { var steer1 = Controller.GetAxis(3)/Math.Pow(2, 15) - 1; var steer2 = Controller.GetAxis(0)/Math.Pow(2, 15) - 1; if (steer1 < 0) steer1 = steer1*steer1*-1; else steer1 *= steer1; if (steer2 < 0) steer2 = steer2*steer2*-1; else steer2 *= steer2; if (Math.Abs(steer1) > Math.Abs(steer2)) return (steer1 + 1)/2; else return (steer2 + 1)/2; } else return RawJoysticksIn[1].GetAxis(0)/Math.Pow(2, 16); case JoyControls.Throttle: double t = 0; if (ps4CtlActive) { t = RawJoysticksIn[0].GetAxis(4) / Math.Pow(2, 16); t = t*t; return t; } else if (dskCtlActive) { if (VST) { t = 1 - RawJoysticksIn[1].GetAxis(2)/Math.Pow(2, 16); } else { t = (0.5 - (RawJoysticksIn[0].GetAxis(2)/Math.Pow(2, 16)))*2; } } else { t = 1 - RawJoysticksIn[1].GetAxis(2)/Math.Pow(2, 16); } if (t < 0) t = 0; t = t*0.05 + lastThrottle*0.95; lastThrottle = (float)t; return t; case JoyControls.Brake: if (ps4CtlActive) { var b = RawJoysticksIn[0].GetAxis(5)/Math.Pow(2,16); b = b*b; return b; } else if (dskCtlActive) { if (VST) { var b = 1 - RawJoysticksIn[1].GetAxis(3) / Math.Pow(2, 16); if (b < 0) b = 0; if (Main.Data.Active == null || Main.Data.Active.Application == "TestDrive2") return b; return b * b; } else { return ((RawJoysticksIn[0].GetAxis(2) / Math.Pow(2, 16)) - 0.5) * 2; }} else { var b = 1 - RawJoysticksIn[1].GetAxis(3)/Math.Pow(2, 16); if (b < 0) b = 0; if (Main.Data.Active == null || Main.Data.Active.Application == "TestDrive2") return b; return b * b; } case JoyControls.Clutch: if (ps4CtlActive) return 0; else if (dskCtlActive) return 0; else return 1 - RawJoysticksIn[1].GetAxis(4) / Math.Pow(2, 16); case JoyControls.CameraHorizon: return 0; // was only on ps3 controller default: return 0.0; } }
public double GetAxis(JoyControls c, double val) { return val; }
public bool GetButton(JoyControls c, bool val) { switch (c) { case JoyControls.Gear1: return GetShiftButton(1); case JoyControls.Gear2: return GetShiftButton(2); case JoyControls.Gear3: return GetShiftButton(3); case JoyControls.Gear4: return GetShiftButton(4); case JoyControls.Gear5: return GetShiftButton(5); case JoyControls.Gear6: return GetShiftButton(6); case JoyControls.Gear7: return GetShiftButton(7); case JoyControls.Gear8: return GetShiftButton(8); case JoyControls.GearR: return GetShiftButton(-1); case JoyControls.GearRange1: return GetRangeButton(1); case JoyControls.GearRange2: return GetRangeButton(2); default: return val; } }
public double GetAxis(JoyControls c, double val) { switch (c) { case JoyControls.Throttle: if (ReverseAndAccelerate) { return 0; } _throttle = val; return val; if (EngineRpm > AntiStallRpm) val /= 5*(EngineRpm-AntiStallRpm)/AntiStallRpm; _throttle = val; return val; if (Override) return 1; if (!Stalling) return val; if (EngineStalled) { _throttle = val; return val; } if (val < 0.01) { _throttle = 0; return 0; } else { var maxRpm = Main.Drivetrain.StallRpm*1.4; var maxV = 2 - 2*Rpm/(maxRpm); if (maxV > 1) maxV = 1; if (maxV < 0) maxV = 0; _throttle = val; return maxV; } break; case JoyControls.Clutch: if (ReverseAndAccelerate) { return 1; } if (Stalling && _throttle < 0.01) { if (SpeedCutoff >= Speed) return 1; else return 1- (Speed-SpeedCutoff)/0.5f; } var cl = 1 - _throttle*ThrottleSensitivity; // 2 if (cl < MinClutch) cl = MinClutch; // 0.1 cl = Math.Max(cl, val); if (EngineRpm < AntiStallRpm) cl += (AntiStallRpm - EngineRpm) / AntiStallRpm; return cl; default: return val; } }
public double GetAxis(JoyControls c, double val) { switch(c) { case JoyControls.Throttle: return _outThrottle; case JoyControls.Clutch: return _outClutch; default: return val; } }
public bool GetButton(JoyControls c, bool val) { switch(c) { case JoyControls.CruiseControlMaintain: if (val && DateTime.Now.Subtract(CruiseTimeout).TotalMilliseconds > 500) { Cruising = !Cruising; SpeedCruise = Speed; Debug.WriteLine("Cruising set to " + Cruising + " and " + SpeedCruise + " m/s"); CruiseTimeout = DateTime.Now; } return false; break; case JoyControls.CruiseControlUp: if (val && DateTime.Now.Subtract(CruiseTimeout).TotalMilliseconds > 400) { SpeedCruise += 1/3.6f; CruiseTimeout = DateTime.Now; } return false; break; case JoyControls.CruiseControlDown: if (val && DateTime.Now.Subtract(CruiseTimeout).TotalMilliseconds > 400) { SpeedCruise -= 1/3.6f; CruiseTimeout = DateTime.Now; } return false; break; case JoyControls.CruiseControlOnOff: if (val && DateTime.Now.Subtract(CruiseTimeout).TotalMilliseconds > 500) { Cruising = !Cruising; Debug.WriteLine("Cruising set to " + Cruising); CruiseTimeout = DateTime.Now; } return false; break; default: return val; } }
public bool Requires(JoyControls c) { switch (c) { case JoyControls.Throttle: case JoyControls.Clutch: return LaunchControlActive; default: return false; } }
public bool Requires(JoyControls c) { switch(c) { case JoyControls.GearUp: case JoyControls.GearDown: return true; default: return false; } }