Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b19ab61
refacto common shift bar overlay
RiddleTime Dec 9, 2025
36fc6bb
Update contributors list (excluding GitHub-Action)
actions-user Dec 14, 2025
50d55ab
Update contributors list (excluding GitHub-Action)
actions-user Dec 14, 2025
174a485
Update InfoPanel.cs
RiddleTime Dec 18, 2025
44f2536
Common DSX: add reset packet when game is not running
RiddleTime Dec 18, 2025
973f845
Merge branch 'dev' of https://github.com/RiddleTime/Race-Element into…
RiddleTime Dec 18, 2025
3ffc97e
refactor of common dsx hud
RiddleTime Dec 18, 2025
0ca8bb6
update releasenotes
RiddleTime Dec 18, 2025
e63c723
Update ReleaseNotes.cs
RiddleTime Dec 18, 2025
b6e4865
bump version to release
RiddleTime Dec 20, 2025
2aada86
Update ReleaseNotes.cs
RiddleTime Dec 20, 2025
8cf80d8
bump .net packages to 10.0.1
RiddleTime Dec 20, 2025
b456040
Merge pull request #286 from RiddleTime/dev
RiddleTime Dec 20, 2025
497e000
refactor
RiddleTime Dec 23, 2025
e20ff65
Create AccelerationTester.cs
RiddleTime Dec 23, 2025
8834610
Update AccelerationTester.cs
RiddleTime Dec 23, 2025
f638c5e
Update AccelerationTester.cs
RiddleTime Dec 23, 2025
d9e9387
Update AccelerationTester.cs
RiddleTime Dec 23, 2025
0a69ba1
Update AccelerationTester.cs
RiddleTime Dec 23, 2025
9d31859
Update AccelerationTester.cs
RiddleTime Dec 24, 2025
e91e63c
Update AccelerationTester.cs
RiddleTime Dec 24, 2025
cf8c2d9
bump version to beta
RiddleTime Dec 24, 2025
f2d1188
Update BroadcastConfig.cs
RiddleTime Jan 3, 2026
59e34b2
Merge branch 'RiddleTime:dev' into dev
ConnorMolz Jan 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Free code signing provided by [SignPath.io](https://signpath.io?utm_source=found
- [iFuSiiOnzZ](https://github.com/iFuSiiOnzZ)
- [KrisV147](https://github.com/KrisV147)
- [floriwan](https://github.com/floriwan)
- [ConnorMolz](https://github.com/ConnorMolz)
- [Andrei-Jianu](https://github.com/Andrei-Jianu)
- [Dirk](https://github.com/Dirk)
- [Florian](https://github.com/Florian)
- [ConnorMolz](https://github.com/ConnorMolz)
- [goeflo](https://github.com/goeflo)
- [GitHub-Action](https://github.com/GitHub-Action)
- [Andi-Maier](https://github.com/Andi-Maier)
Expand Down
2 changes: 1 addition & 1 deletion Race Element.Core/Race Element.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.Drawing.Common" Version="10.0.0" />
<PackageReference Include="System.Drawing.Common" Version="10.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
using RaceElement.Core.Jobs.Loop;
using RaceElement.Data.Common;
using RaceElement.HUD.Overlay.Internal;
using RaceElement.HUD.Overlay.Util;
using System.Drawing;

namespace RaceElement.HUD.Common.Overlays.Driving.AccelerationTester;

[Overlay(
Name = "Acceleration Tester",
Description = "Ready? Set! Go! The Acceleration Tester." +
"\nPrecision is Limited to Simulator Specification.",
Authors = ["Reinier Klarenberg"]
)]
internal sealed class AccelerationTester : CommonAbstractOverlay
{
private readonly InfoPanel _infoPanel;
private readonly AccelerationTimingJob _timingJob;

public AccelerationTester(Rectangle rectangle) : base(rectangle, "Acceleration Tester")
{
Width = 400;
Height = 200;

_infoPanel = new InfoPanel(12, 400);
_timingJob = new AccelerationTimingJob() { IntervalMillis = 5 };
}

public sealed override void BeforeStart() => _timingJob?.Run();

public sealed override void BeforeStop()
{
_infoPanel?.Dispose();
_timingJob?.CancelJoin();
}

public sealed override void Render(Graphics g)
{
if (_timingJob == null)
return;

_infoPanel.AddLine("Phase", _timingJob?.PhaseDescriptions[_timingJob.Phase]);

TimeSpan previous = TimeSpan.Zero;
foreach (var accType in Enum.GetValues<AccelerationTypes>())
{
TimeSpan fromZero = _timingJob.RecordedTimes[accType];
TimeSpan fromPrevious = fromZero - previous;
if (accType != AccelerationTypes.ZeroToHundred) // show delta times
_infoPanel.AddLine(_timingJob.DeltaAccelerationTypeDescriptions[accType], _timingJob.RecordedTimes[accType] == default ? "-" : fromPrevious.ToString(@"s\.fff") + " s");

_infoPanel.AddLine(_timingJob.ZeroToAccelerationTypeDescriptions[accType], _timingJob.RecordedTimes[accType] == default ? "-" : fromZero.ToString(@"s\.fff") + " s");
previous += fromPrevious;
}

_infoPanel.Draw(g);
}

internal enum AccelerationPhase
{
Reset,
HandbrakePulled,
Ready,
Accelerating,
Completed
}

internal enum AccelerationTypes
{
ZeroToHundred,
HundredToTwoHundred,
TwoHundredToThreeHundred,
ThreeHundredToFourHundred,
}

private sealed class AccelerationTimingJob : AbstractLoopJob
{
private long _lastHandbrakePullTime = default;
private long _accelerationStartTime = default;
private static bool IsHandBrakePulled { get => SimDataProvider.LocalCar.Inputs.HandBrake > 0; }

public AccelerationPhase Phase = AccelerationPhase.Reset;

public Dictionary<AccelerationPhase, string> PhaseDescriptions = new()
{
{ AccelerationPhase.Reset, "Stop car & Hold Handbrake" },
{ AccelerationPhase.HandbrakePulled, "Hold Handbrake for 1 Sec" },
{ AccelerationPhase.Ready, "Ready? Release Handbrake!" },
{ AccelerationPhase.Accelerating, "Accelerating..." },
{ AccelerationPhase.Completed, "Completed!" }
};

public Dictionary<AccelerationTypes, string> DeltaAccelerationTypeDescriptions = new()
{
{ AccelerationTypes.ZeroToHundred, "0-100 km/h" },
{ AccelerationTypes.HundredToTwoHundred, "100-200 km/h" },
{ AccelerationTypes.TwoHundredToThreeHundred, "200-300 km/h" },
{ AccelerationTypes.ThreeHundredToFourHundred, "300-400 km/h" },
};

public Dictionary<AccelerationTypes, string> ZeroToAccelerationTypeDescriptions = new()
{
{ AccelerationTypes.ZeroToHundred, "0-100 km/h" },
{ AccelerationTypes.HundredToTwoHundred, "0-200 km/h" },
{ AccelerationTypes.TwoHundredToThreeHundred, "0-300 km/h" },
{ AccelerationTypes.ThreeHundredToFourHundred, "0-400 km/h" },
};

public Dictionary<AccelerationTypes, TimeSpan> RecordedTimes = new()
{
{ AccelerationTypes.ZeroToHundred, default },
{ AccelerationTypes.HundredToTwoHundred, default },
{ AccelerationTypes.TwoHundredToThreeHundred, default },
{ AccelerationTypes.ThreeHundredToFourHundred, default },
};

public Dictionary<AccelerationTypes, float> AccelerationTresholds = new()
{
{ AccelerationTypes.ZeroToHundred, 100 },
{ AccelerationTypes.HundredToTwoHundred, 200 },
{ AccelerationTypes.TwoHundredToThreeHundred, 300 },
{ AccelerationTypes.ThreeHundredToFourHundred, 400 },
};

public sealed override void RunAction()
{
switch (Phase)
{
case AccelerationPhase.Reset:
{
foreach (var accType in Enum.GetValues<AccelerationTypes>())
RecordedTimes[accType] = default;

if (IsHandBrakePulled && SimDataProvider.LocalCar.Physics.Velocity < 0.5f)
{
_lastHandbrakePullTime = TimeProvider.System.GetTimestamp();
Phase = AccelerationPhase.HandbrakePulled;
}

break;
}
case AccelerationPhase.HandbrakePulled:
{
if (!IsHandBrakePulled)
{
_lastHandbrakePullTime = default;
Phase = AccelerationPhase.Reset;
}

if (SimDataProvider.LocalCar.Physics.Velocity < 0.1f)
{
if (TimeProvider.System.GetElapsedTime(_lastHandbrakePullTime) >= TimeSpan.FromSeconds(1))
Phase = AccelerationPhase.Ready;
}
break;
}
case AccelerationPhase.Ready:
{
if (!IsHandBrakePulled && SimDataProvider.LocalCar.Physics.Velocity > 0.1f)
{
Phase = AccelerationPhase.Accelerating;
_accelerationStartTime = TimeProvider.System.GetTimestamp();
break;
}

break;
}
case AccelerationPhase.Accelerating:
{
if (SimDataProvider.LocalCar.Physics.Velocity < 1 && IsHandBrakePulled)
{
Phase = AccelerationPhase.Reset;
}

foreach (var accType in Enum.GetValues<AccelerationTypes>())
foreach (var treshold in AccelerationTresholds)
if (accType == treshold.Key && RecordedTimes[accType] == default && SimDataProvider.LocalCar.Physics.Velocity >= treshold.Value)
RecordedTimes[accType] = TimeProvider.System.GetElapsedTime(_accelerationStartTime);

if (SimDataProvider.LocalCar.Inputs.Brake > 0)
Phase = AccelerationPhase.Completed;

break;
}
case AccelerationPhase.Completed:
{
if (SimDataProvider.LocalCar.Physics.Velocity < 1 && IsHandBrakePulled)
{
Phase = AccelerationPhase.Reset;
}
break;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Drawing;
using System.Drawing.Drawing2D;

namespace RaceElement.HUD.Common.Overlays.Driving.Accellerometer;
namespace RaceElement.HUD.Common.Overlays.Driving.Accelerometer;

[Overlay(
Name = "Accelerometer",
Expand Down
42 changes: 28 additions & 14 deletions Race Element.HUD.Common/Overlays/Driving/DSX/DsxJob.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,61 @@
using RaceElement.Core.Jobs.Loop;
using RaceElement.Data.Games;
using System.Diagnostics;
using static RaceElement.HUD.Common.Overlays.Driving.DSX.Resources;

namespace RaceElement.HUD.Common.Overlays.Driving.DSX;

internal sealed class DsxJob(DsxOverlay overlay) : AbstractLoopJob
internal sealed class DsxJob(DsxOverlay? overlay) : AbstractLoopJob
{
public sealed override void RunAction()
{
//if (!overlay.ShouldRender())
// return;
if (overlay == null)
return;

if (overlay._client == null)
if (!GameManager.IsGameRunning)
{
if (overlay._hasSetLighting)
{
overlay?.StopClient();
}

return;
}

if (overlay?._client == null)
{
try
{
overlay.CreateEndPoint();
overlay.SetLighting();
overlay?.CreateEndPoint();
overlay?.SetLighting();
}
catch (Exception)
catch (Exception e)
{
// let's not cause an app crash, shall we?
Debug.WriteLine(e);
}
Debug.WriteLine("Created enpoint and set lighting!");
return;
}

DsxPacket tcPacket = TriggerHaptics.HandleAcceleration(overlay._config);
DsxPacket tcPacket = TriggerHaptics.HandleAcceleration(overlay?._config);
if (tcPacket != null)
{
overlay.Send(tcPacket);
overlay?.Send(tcPacket);
//ServerResponse response = Receive();
//HandleResponse(response);
}

DsxPacket absPacket = TriggerHaptics.HandleBraking(overlay._config);
DsxPacket absPacket = TriggerHaptics.HandleBraking(overlay?._config);
if (absPacket != null)
{
overlay.Send(absPacket);
overlay?.Send(absPacket);
//ServerResponse response = Receive();
//HandleResponse(response);
}
}

public override void AfterCancel()
{
overlay?._client?.Close();
overlay?._client?.Dispose();
overlay?.StopClient();
}
}
15 changes: 15 additions & 0 deletions Race Element.HUD.Common/Overlays/Driving/DSX/DsxOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ internal sealed class DsxOverlay : CommonAbstractOverlay
internal UdpClient _client;
internal IPEndPoint _endPoint;

internal bool _hasSetLighting = false;

public DsxOverlay(Rectangle rectangle) : base(rectangle, "DSX")
{
Width = 1; Height = 1;
Expand Down Expand Up @@ -70,6 +72,7 @@ internal void SetLighting()
{
HandleResponse(lightingReponse);
}
_hasSetLighting = true;
}

internal void CreateEndPoint()
Expand All @@ -78,6 +81,18 @@ internal void CreateEndPoint()
_endPoint = new IPEndPoint(Triggers.localhost, _config.UDP.Port);
}

internal void StopClient()
{
_hasSetLighting = false;
DsxPacket resetPacket = new();
resetPacket.AddResetToPacket(0);
Send(resetPacket);

_client?.Close();
_client?.Dispose();
_client = null;
}

internal void Send(DsxPacket data)
{
string packet = Triggers.PacketToJson(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,43 +179,14 @@ public sealed override void BeforeStop()
_upshiftDataPanel?.Dispose();
}

// demo stuff
private int shiftsDone = 0;
private bool up = true;
// demo stuff

public sealed override void Render(Graphics g)
{

if (!IsPreviewing)
{ // SET MODEL: Before release, uncomment line below and remove everything in-between the test data. it emulates the rpm going up
{
_model.Rpm = SimDataProvider.LocalCar.Engine.Rpm;
_model.MaxRpm = SimDataProvider.LocalCar.Engine.MaxRpm;

// test data ------------
//_model.MaxRpm = 10000;
//if (_model.Rpm < _model.MaxRpm / 3) _model.Rpm = _model.MaxRpm / 3;
//int increment = Random.Shared.Next(0, 2) == 1 ? Random.Shared.Next(0, 43) : -7;
//if (!up) increment *= -4;
//_model.Rpm = _model.Rpm + increment;
//if (up && _model.Rpm > _model.MaxRpm)
//{
// _model.Rpm = _model.MaxRpm - _model.MaxRpm / 4;
// shiftsDone++;
//}
//if (!up && _model.Rpm < _model.MaxRpm * _config.Upshift.EarlyPercentage / 100f - _model.MaxRpm / 5f)
//{
// _model.Rpm = _model.MaxRpm;
// shiftsDone++;
//}
//if (shiftsDone > 3)
//{
// up = !up;
// shiftsDone = 0;
//}

// test data ------------

if (_model.Rpm < 0) _model.Rpm = 0;
if (_model.Rpm > _model.MaxRpm) _model.Rpm = _model.MaxRpm;
}
Expand All @@ -237,9 +208,8 @@ public sealed override void Render(Graphics g)
}
}


/// <summary>
///
/// Secret sauce to hide a certain amount of RPM from the bar.
/// </summary>
/// <param name="currentRpm"></param>
/// <param name="maxRpm"></param>
Expand Down
Loading