Skip to content

Commit

Permalink
Migrating from NewtonsoftJSON to System.Text.Json
Browse files Browse the repository at this point in the history
The app seems to work but my dsx refuses to work so can't test
  • Loading branch information
cosmii02 committed Dec 4, 2024
1 parent 6ad3032 commit 45084ef
Show file tree
Hide file tree
Showing 6 changed files with 392 additions and 361 deletions.
80 changes: 28 additions & 52 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,78 +1,55 @@
using Newtonsoft.Json;
using System;
using System;
using System.Net;
using System.Text.Json;
using System.Windows.Forms;

namespace RacingDSX
{
public class Program
{
public const String VERSION = "0.6.3";
public const String VERSION = "0.6.4";

[STAThread]
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
string arg = args[i];

switch (arg)
{
case "-v":
{
//Console.WriteLine($"RacingDSX Version {VERSION}");
return;
}
//case "--Program.verbose":
// {
// Console.WriteLine("_verbose Mode Enabled!");
// verbose = true;
// break;
// }
//case "--csv":
// {
// logToCsv = true;
// i++;
// if (i >= args.Length)
// {
// Console.WriteLine("No Path Entered for Csv file output!! Exiting");
// return;
// }
// csvFileName = args[i];
// break;
// }
default:
{

break;
}
}
}
[STAThread]
static void Main(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
string arg = args[i];

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new UI());
}
switch (arg)
{
case "-v":
{
return;
}
default:
{
break;
}
}
}

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new UI());
}
}

//Needed to communicate with DualSenseX
public static class Triggers
{
public static IPAddress localhost = new IPAddress(new byte[] { 127, 0, 0, 1 });

public static string PacketToJson(Packet packet)
{
return Newtonsoft.Json.JsonConvert.SerializeObject(packet);
return JsonSerializer.Serialize(packet);
}

public static Packet JsonToPacket(string json)
{
return JsonConvert.DeserializeObject<Packet>(json);
return JsonSerializer.Deserialize<Packet>(json);
}
}

//The different trigger Modes. These correlate the values in the DualSenseX UI
public enum TriggerMode
{
Normal = 0,
Expand All @@ -96,7 +73,6 @@ public enum TriggerMode
Machine = 18
}

//Custom Trigger Values. These correspond to the values in the DualSenseX UI
public enum CustomTriggerValueMode
{
OFF = 0,
Expand Down Expand Up @@ -148,4 +124,4 @@ public class Packet
{
public Instruction[] instructions;
}
}
}
10 changes: 5 additions & 5 deletions RacingDSX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="CsvHelper" Version="27.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="CsvHelper" Version="33.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 45084ef

Please sign in to comment.