Skip to content

Commit

Permalink
Merge pull request #243 from RiddleTime/dev
Browse files Browse the repository at this point in the history
2.2.3.2
Multi-Sim:
 - DSX (DualSense Active Triggers): FFB is remade from scratch, it is now 2 effects, feedback and vibration, which together will feel a lot more nuanced. Additionaly there are new options to customize the FFB.

Assetto Corsa Competizione:
 - Speedometer HUD: Added option to increase RefreshRate up to 60 Hz, additionaly you can now set the background color of the panel and the text color for the bar.
  • Loading branch information
RiddleTime authored Jan 15, 2025
2 parents aee15e2 + 72f82f3 commit 161c5a2
Show file tree
Hide file tree
Showing 21 changed files with 677 additions and 306 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# ![Race Element - Name](https://user-images.githubusercontent.com/4581237/209894151-3f8a5dc5-45de-4d7c-a46a-8c5a2a57cd91.png)


[![Discord](https://badgen.net/discord/members/26AAEW5mUq?icon=discord&color=5562ea&label=Race%20Element)](https://discord.gg/26AAEW5mUq)
[![Hits](https://hits.seeyoufarm.com/api/count/keep/badge.svg?url=https%3A%2F%2Fgithub.com%2FRiddleTime%2FRace-Element&count_bg=%23FF4500&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=Usage%3A+Today+%2F+All-time&edge_flat=false)](https://hits.seeyoufarm.com)

# Solutions for Sim Racing
![Race Element - Name](https://user-images.githubusercontent.com/4581237/209894151-3f8a5dc5-45de-4d7c-a46a-8c5a2a57cd91.png)
# Solutions for Simulators
- HUDs
- Telemetry
- Setups
Expand Down
71 changes: 48 additions & 23 deletions Race Element.HUD.Common/Overlays/Pitwall/DSX/DsxConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ public DsxConfiguration()
GenericConfiguration.AllowRescale = false;
}

[ConfigGrouping("DSX UDP", "Adjust the port DSX uses, 6969 is default.")]
public UdpConfig UDP { get; init; } = new UdpConfig();
public sealed class UdpConfig
{
[ToolTip("Adjust the port used by DSX, 6969 is default.")]
[IntRange(0, 65535, 1)]
public int Port { get; init; } = 6969;
}

[ConfigGrouping("Brake Slip", "Adjust the slip effect whilst applying the brakes.")]
public BrakeSlipHaptics BrakeSlip { get; init; } = new();
Expand All @@ -32,15 +24,27 @@ public sealed class BrakeSlipHaptics
[FloatRange(0.1f, 99f, 0.1f, 1)]
public float BrakeThreshold { get; init; } = 3f;

[ToolTip("Sets the frequency of the slip effect whilst applying the brakes.")]
[IntRange(10, 150, 1)]
public int Frequency { get; init; } = 85;
[FloatRange(0.05f, 6f, 0.002f, 3)]
public float FrontSlipThreshold { get; init; } = 0.25f;

[FloatRange(0.05f, 6f, 0.002f, 3)]
public float RearSlipThreshold { get; init; } = 0.25f;

[ToolTip("Higher is stronger dynamic feedback.")]
[IntRange(5, 8, 1)]
public int FeedbackStrength { get; init; } = 7;

[FloatRange(0.05f, 6f, 0.01f, 2)]
public float FrontSlipThreshold { get; init; } = 0.7f;
[ToolTip("Sets the min frequency of the vibration effect in the trigger.")]
[IntRange(1, 10, 1)]
public int MinFrequency { get; init; } = 3;

[FloatRange(0.05f, 6f, 0.01f, 2)]
public float RearSlipThreshold { get; init; } = 0.6f;
[ToolTip("Sets the max frequency of the vibration effect in the trigger.")]
[IntRange(20, 150, 1)]
public int MaxFrequency { get; init; } = 85;

[ToolTip("Change the amplitude(strength) of the vibration effect in the trigger.")]
[IntRange(5, 8, 1)]
public int Amplitude { get; init; } = 8;
}

[ConfigGrouping("Throttle Slip", "Adjust the slip effect whilst applying the throttle.\nModify the threshold to increase or decrease sensitivity in different situations.")]
Expand All @@ -54,16 +58,37 @@ public sealed class ThrottleSlipHaptics
[FloatRange(0.1f, 99f, 0.1f, 1)]
public float ThrottleThreshold { get; init; } = 3f;

[ToolTip("Sets the frequency of the slip effect whilst applying the throttle.")]
[IntRange(10, 150, 1)]
public int Frequency { get; init; } = 85;

[ToolTip("Decrease this treshold to increase the sensitivity when the front wheels slip (understeer).")]
[FloatRange(0.05f, 6f, 0.01f, 2)]
public float FrontSlipThreshold { get; init; } = 0.6f;
[FloatRange(0.05f, 6f, 0.002f, 3)]
public float FrontSlipThreshold { get; init; } = 0.35f;

[ToolTip("Decrease this treshold to increase the sensitivity when the rear wheels slip (oversteer).")]
[FloatRange(0.05f, 10f, 0.01f, 2)]
public float RearSlipThreshold { get; init; } = 0.5f;
[FloatRange(0.05f, 10f, 0.002f, 3)]
public float RearSlipThreshold { get; init; } = 0.25f;

[ToolTip("Higher is stronger dynamic feedback.")]
[IntRange(5, 8, 1)]
public int FeedbackStrength { get; init; } = 8;

[ToolTip("Sets the min frequency of the vibration effect in the trigger.")]
[IntRange(1, 10, 1)]
public int MinFrequency { get; init; } = 6;

[ToolTip("Sets the max frequency of the vibration effect in the trigger.")]
[IntRange(20, 150, 1)]
public int MaxFrequency { get; init; } = 96;

[ToolTip("Change the amplitude(strength) of the vibration effect in the trigger.")]
[IntRange(5, 8, 1)]
public int Amplitude { get; init; } = 7;
}

[ConfigGrouping("DSX UDP", "Adjust the port DSX uses, 6969 is default.")]
public UdpConfig UDP { get; init; } = new UdpConfig();
public sealed class UdpConfig
{
[ToolTip("Adjust the port used by DSX, 6969 is default.")]
[IntRange(0, 65535, 1)]
public int Port { get; init; } = 6969;
}
}
8 changes: 3 additions & 5 deletions Race Element.HUD.Common/Overlays/Pitwall/DSX/DsxJob.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using RaceElement.Core.Jobs.Loop;
using RaceElement.Data.Common;
using System;
using static RaceElement.HUD.Common.Overlays.Pitwall.DSX.DsxResources;
using static RaceElement.HUD.Common.Overlays.Pitwall.DSX.Resources;

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

Expand All @@ -25,15 +23,15 @@ public sealed override void RunAction()
}
}

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

Packet absPacket = TriggerHaptics.HandleBraking(overlay._config);
DsxPacket absPacket = TriggerHaptics.HandleBraking(overlay._config);
if (absPacket != null)
{
overlay.Send(absPacket);
Expand Down
45 changes: 26 additions & 19 deletions Race Element.HUD.Common/Overlays/Pitwall/DSX/DsxOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using Newtonsoft.Json;
using RaceElement.Data.Games;
using RaceElement.Data.Games;
using RaceElement.HUD.Overlay.Internal;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Text;
using static RaceElement.HUD.Common.Overlays.Pitwall.DSX.DsxResources;
using System.Text.Json;
using static RaceElement.HUD.Common.Overlays.Pitwall.DSX.Resources;

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

[Overlay(Name = "DSX",
Description = "Adds active triggers for the DualSense 5 controller using DSX on steam.\n See Guide in the Discord of Race Element for instructions.",
Description = "Adds active triggers for the DualSense Controller using DSX on steam.\n See Guide in the Discord of Race Element for instructions.",
OverlayCategory = OverlayCategory.Inputs,
OverlayType = OverlayType.Pitwall,
Game = Game.RaceRoom | Game.AssettoCorsa1,
Expand All @@ -34,14 +33,14 @@ public DsxOverlay(Rectangle rectangle) : base(rectangle, "DSX")
AllowReposition = false;
}

public override void BeforeStart()
public sealed override void BeforeStart()
{
if (IsPreviewing) return;

_dsxJob = new DsxJob(this) { IntervalMillis = 1000 / 200 };
_dsxJob.Run();
}
public override void BeforeStop()
public sealed override void BeforeStop()
{
if (IsPreviewing) return;

Expand All @@ -50,23 +49,27 @@ public override void BeforeStop()
_client?.Dispose();
}

public override bool ShouldRender() => DefaultShouldRender() && !IsPreviewing;
public sealed override bool ShouldRender() => DefaultShouldRender() && !IsPreviewing;

public override void Render(Graphics g) { }
public sealed override void Render(Graphics g) { }

internal void SetLighting()
{
Debug.WriteLine("Changing RGB");
Packet p = new();

int controllerIndex = 0;

p.instructions = new Instruction[1]; // send only 1 instruction
p.instructions[0].type = InstructionType.RGBUpdate;
p.instructions[0].parameters = [controllerIndex, 255, 69, 0];
DsxPacket p = new()
{
Instructions = [new() { Type = InstructionType.RGBUpdate, Parameters = [controllerIndex, 255, 69, 0] }]
};

Send(p);
ServerResponse lightingReponse = Receive();
HandleResponse(lightingReponse);
if (lightingReponse != null)
{
HandleResponse(lightingReponse);
}
}

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

internal void Send(Packet data)
internal void Send(DsxPacket data)
{
var RequestData = Encoding.ASCII.GetBytes(Triggers.PacketToJson(data));
_client?.Send(RequestData, RequestData.Length, _endPoint);
string packet = Triggers.PacketToJson(data);
if (packet == null)
return;

var requestData = Encoding.ASCII.GetBytes(packet);
_client?.Send(requestData, requestData.Length, _endPoint);
_timeSent = DateTime.Now;
}

private ServerResponse Receive()
private ServerResponse? Receive()
{
byte[] bytesReceivedFromServer = _client.Receive(ref _endPoint);

if (bytesReceivedFromServer.Length > 0)
{
ServerResponse ServerResponseJson = JsonConvert.DeserializeObject<ServerResponse>($"{Encoding.ASCII.GetString(bytesReceivedFromServer, 0, bytesReceivedFromServer.Length)}");
ServerResponse? ServerResponseJson = JsonSerializer.Deserialize<ServerResponse>($"{Encoding.ASCII.GetString(bytesReceivedFromServer, 0, bytesReceivedFromServer.Length)}");
return ServerResponseJson;
}

Expand Down
Loading

0 comments on commit 161c5a2

Please sign in to comment.