-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from patmagauran/main
[In Testing / WiP] Add support for multiple profiles and Non-Forza Games
- Loading branch information
Showing
34 changed files
with
5,441 additions
and
3,331 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public class BrakeSettings | ||
{ | ||
public TriggerMode TriggerMode { get; set; } = TriggerMode.Vibration; | ||
|
||
public float EffectIntensity { get; set; } = 0.7f; | ||
|
||
public float GripLossValue { get; set; } = 0.5f; | ||
public int VibrationStart { get; set; } = 20; | ||
public int VibrationModeStart { get; set; } = 10; | ||
public int MinVibration { get; set; } = 3; | ||
public int MaxVibration { get; set; } = 35; | ||
public float VibrationSmoothing { get; set; } = 1f; | ||
public int MinStiffness { get; set; } = 200; | ||
public int MaxStiffness { get; set; } = 1; | ||
public int MinResistance { get; set; } = 1; | ||
public int MaxResistance { get; set; } = 6; | ||
public float ResistanceSmoothing { get; set; } = 1f; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public class Config | ||
{ | ||
public bool DisableAppCheck { get; set; } | ||
public VerboseLevel VerboseLevel { get; set; } = VerboseLevel.Off; | ||
public Dictionary<String, Profile> Profiles { get; set; } = new Dictionary<String, Profile>(); | ||
[JsonIgnore] | ||
public Profile ActiveProfile { get; set; } = null; | ||
|
||
public int DSXPort { get; set; } = 6900; | ||
|
||
public String DefaultProfile { get; set; } = "Forza"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using ForzaDSX.GameParsers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public class ConfigHandler | ||
{ | ||
//Methods to read config file | ||
//Method to initialize config file (Using default values), need to account for the different default profiles | ||
//Method to write config file | ||
//Singleton access to config data | ||
private static readonly String configFilePath = "RacingDSX.json"; | ||
private static Config configData; | ||
|
||
private static void InitializeConfig() | ||
{ | ||
configData ??= ReadConfigFromDisk(); | ||
configData ??= new Config(); | ||
configData = AddDefaultProfiles(configData); | ||
SaveConfig(); | ||
} | ||
|
||
|
||
|
||
|
||
private static Config AddDefaultProfiles(Config config) | ||
{ | ||
config.Profiles ??= new Dictionary<string, Profile>(); | ||
if (!config.Profiles.ContainsKey("Forza")) | ||
{ | ||
Profile profile = new Profile | ||
{ | ||
Name = "Forza", | ||
gameUDPPort = 5300, | ||
GameType = GameTypes.Forza, | ||
}; | ||
profile.executableNames.AddRange(new string[] { "ForzaHorizon5", "ForzaHorizon4", "ForzaMotorsport7", "forza_gaming.desktop.x64_release_final", "forza_steamworks_release_final" }); | ||
config.Profiles.Add("Forza", profile); | ||
} | ||
if (!config.Profiles.ContainsKey("Dirt")) | ||
{ | ||
Profile profile = new Profile | ||
{ | ||
Name = "Dirt", | ||
gameUDPPort = 5300, | ||
GameType = GameTypes.Dirt | ||
}; | ||
profile.throttleSettings.GripLossValue = 0.4f; | ||
profile.executableNames.AddRange(new string[] { "drt"}); | ||
config.Profiles.Add("Dirt", profile); | ||
} | ||
|
||
return config; | ||
} | ||
|
||
private static Config ReadConfigFromDisk() | ||
{ | ||
|
||
try | ||
{ | ||
if (!File.Exists(configFilePath)) { | ||
return null; | ||
} | ||
string jsonString = File.ReadAllText(configFilePath); | ||
|
||
Config config = JsonSerializer.Deserialize<Config>(jsonString); | ||
return config; | ||
} | ||
catch (Exception) | ||
{ | ||
return null; | ||
} | ||
|
||
} | ||
private static void WriteConfigToDisk() | ||
{ | ||
try | ||
{ | ||
string jsonString = JsonSerializer.Serialize(configData); | ||
File.WriteAllText(configFilePath, jsonString); | ||
} catch (Exception) | ||
{ | ||
|
||
} | ||
} | ||
|
||
public static void SaveConfig() | ||
{ | ||
WriteConfigToDisk(); | ||
|
||
} | ||
|
||
public static Config GetConfig() | ||
{ | ||
if (configData == null) | ||
{ | ||
InitializeConfig(); | ||
} | ||
return configData; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using ForzaDSX.GameParsers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public class Profile | ||
{ | ||
public GameTypes GameType { get; set; } = GameTypes.None; | ||
public bool IsEnabled { get; set; } = true; | ||
public string Name { get; set; } | ||
public int gameUDPPort { get; set; } | ||
public List<string> executableNames { get; set; } = new List<string>(); | ||
public ThrottleSettings throttleSettings { get; set; } = new ThrottleSettings(); | ||
public BrakeSettings brakeSettings { get; set; } = new BrakeSettings(); | ||
|
||
public float RPMRedlineRatio { get; set; } = 0.9f; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public class ThrottleSettings | ||
{ | ||
public TriggerMode TriggerMode { get; set; } = TriggerMode.Vibration; | ||
public float GripLossValue { get; set; } = 0.2f; | ||
public float EffectIntensity { get; set; } = 0.9f; | ||
public float TurnAccelerationScale { get; set; } = 0.5f; | ||
public float ForwardAccelerationScale { get; set; } = 1.0f; | ||
public int AccelerationLimit { get; set; } = 10; | ||
public int VibrationModeStart { get; set; } = 5; | ||
public int MinVibration { get; set; } = 3; | ||
public int MaxVibration { get; set; } = 35; | ||
public float VibrationSmoothing { get; set; } = 0.5f; | ||
public int MinStiffness { get; set; } = 200; | ||
public int MaxStiffness { get; set; } = 75; | ||
public int MinResistance { get; set; } = 1; | ||
public int MaxResistance { get; set; } = 6; | ||
public float ResistanceSmoothing { get; set; } = 0.01f; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public enum TriggerMode : sbyte | ||
{ | ||
Off, | ||
Resistance, | ||
Vibration | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ForzaDSX.Config | ||
{ | ||
public enum VerboseLevel | ||
{ | ||
Off = 0, | ||
Limited, | ||
Full | ||
} | ||
} |
Oops, something went wrong.