Skip to content

Commit

Permalink
Merge pull request #18 from cosmii02/portfix
Browse files Browse the repository at this point in the history
V0.5.3 | Port fix drama
  • Loading branch information
cosmii02 authored Mar 13, 2023
2 parents a4b472f + 8ab7a1a commit e5d5e3b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 63 deletions.
55 changes: 24 additions & 31 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,33 @@ name: Release Candidate

on:
push:
branches: [ "main" ]
#branches: [ "main" ]
pull_request:
branches: [ "main" ]
#branches: [ "main" ]

jobs:

package:

runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2.1.1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Package
run: dotnet dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained false -c Release --output ./forza/devrel
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.0
with:
# Artifact name
name: ForzaDSX-RC
# A file, directory or wildcard pattern that describes what to upload
path: ./forza/devrel
# The desired behavior if no files are found using the provided path.
#Available Options:
#warn: Output a warning but do not fail the action
#error: Fail the action with an error message
#ignore: Do not output any warnings or errors, the action does not fail

if-no-files-found: error

# Duration after which artifact will expire in days. 0 means using default retention.
retention-days: 4
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Package
run: dotnet dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained false -c Release --output ./forza/devrel
- name: Compress Artifact
run: Compress-Archive -Path ./forza/devrel -DestinationPath ./forza/devrel/ForzaDSX-RC.zip
- name: Upload Release
uses: ncipollo/release-action@v1
with:
name: ForzaDSX-RC
artifacts: ./forza/devrel/ForzaDSX-RC.zip
tag: latest-candidate
prerelease: true
allowUpdates: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
54 changes: 23 additions & 31 deletions ForzaDSXWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void SendData(DataPacket data)

p.instructions = new Instruction[] { LightBar, LeftTrigger, RightTrigger };

//Send the commands to DualSenseX
//Send the commands to DSX
Send(p);
}
else
Expand Down Expand Up @@ -311,7 +311,7 @@ void SendData(DataPacket data)

p.instructions = new Instruction[] { RightTrigger };

//Send the commands to DualSenseX
//Send the commands to DSX
Send(p);
#endregion
#region Left Trigger
Expand Down Expand Up @@ -367,7 +367,7 @@ void SendData(DataPacket data)

p.instructions = new Instruction[] { LeftTrigger};

//Send the commands to DualSenseX
//Send the commands to DSX
Send(p);
#endregion

Expand All @@ -394,7 +394,7 @@ void SendData(DataPacket data)

p.instructions = new Instruction[] { LightBar };

//Send the commands to DualSenseX
//Send the commands to DSX
Send(p);
#endregion
}
Expand All @@ -418,42 +418,33 @@ public float Map(float x, float in_min, float in_max, float out_min, float out_m
static UdpClient senderClient;
static IPEndPoint endPoint;

//Connect to DualSenseX
// Connect to DSX
void Connect()
{
senderClient = new UdpClient();
int portNumber = 6969;
var portNumber = settings.DSX_PORT;

if (progressReporter != null)
{
progressReporter.Report(new ForzaDSXReportStruct("DSX is using port " + portNumber + ". Attempting to connect.." ));
progressReporter.Report(new ForzaDSXReportStruct("DSX is using port " + portNumber + ". Attempting to connect.."));
}

int portNum = settings.DSX_PORT;
if (portNumber != null)
int portNum;

if (!int.TryParse(portNumber.ToString(), out portNum))
{
try
{
portNum = Convert.ToInt32(portNumber);
}
catch (FormatException e)
{
if (progressReporter != null)
{
progressReporter.Report(new ForzaDSXReportStruct($"DSX provided a non numerical Port! Using configured default({settings.DSX_PORT})." ));
}
portNum = settings.DSX_PORT;
}
// handle parse failure
}
else
{
if (progressReporter != null)
{
progressReporter.Report(new ForzaDSXReportStruct($"DSX did not provided a port value. Using configured default({settings.DSX_PORT})" ));
progressReporter.Report(new ForzaDSXReportStruct($"DSX provided a non-numerical port! Using configured default ({settings.DSX_PORT})."));
}
portNum = settings.DSX_PORT;
}

endPoint = new IPEndPoint(Triggers.localhost, Convert.ToInt32(portNumber));
endPoint = new IPEndPoint(Triggers.localhost, portNum);

try
{
senderClient.Connect(endPoint);
Expand All @@ -462,25 +453,26 @@ void Connect()
{
if (progressReporter != null)
{
progressReporter.Report(new ForzaDSXReportStruct("Error Connecting: "));
progressReporter.Report(new ForzaDSXReportStruct("Error connecting: " + e.Message));

if (e is SocketException)
{
progressReporter.Report(new ForzaDSXReportStruct("Couldn't Access Port. " + e.Message ));
progressReporter.Report(new ForzaDSXReportStruct("Couldn't access port. " + e.Message));
}
else if (e is ObjectDisposedException)
{
progressReporter.Report(new ForzaDSXReportStruct("Connection Object Closed. Restart the Application." ));
progressReporter.Report(new ForzaDSXReportStruct("Connection object closed. Restart the application."));
}
else
{
progressReporter.Report(new ForzaDSXReportStruct("Unknown Error: " + e.Message));
progressReporter.Report(new ForzaDSXReportStruct("Unknown error: " + e.Message));
}
}
}
}

//Send Data to DualSenseX

//Send Data to DSX
void Send(Packet data)
{
if (settings.Verbose > 1
Expand Down Expand Up @@ -594,7 +586,7 @@ public void Run()
progressReporter.Report(new ForzaDSXReportStruct("Data Parsed"));
}

//Process and send data to DualSenseX
//Process and send data to DSX
SendData(data);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ForzaDSX

public class Program
{
public const String VERSION = "0.5.2";
public const String VERSION = "0.5.3";

[STAThread]
static void Main(string[] args)
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Step by step instructions:
![image](https://user-images.githubusercontent.com/27782168/183418210-145b6701-f1f7-4783-91ba-7a1893294601.png)
8. In DSX make sure UDP is enabled, go to settings, click controller and then click networking. UDP has to be enabled and must be listening to port 6969


-----------------------------------------------------------------------------------------------------------------------------------------
Note for Forza Motorsport 7
1. Launch the game and head to the HUD options menu
Expand Down

0 comments on commit e5d5e3b

Please sign in to comment.