-
-
Notifications
You must be signed in to change notification settings - Fork 23
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 #245 from RiddleTime/dev
2.2.4.0 Assetto Corsa EVO Early Access - Added initial support for a few basic HUDs, like shift bar, shift rpm, input trace, g-force trace, and wheel slip. - DSX (DualSense Active Triggers): Added support for AC EVO.
- Loading branch information
Showing
20 changed files
with
1,158 additions
and
80 deletions.
There are no files selected for viewing
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
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
80 changes: 80 additions & 0 deletions
80
Race Element.Data/Games/AssettoCorsaEvo/AssettoCorsaEvoDataProvider.cs
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,80 @@ | ||
using RaceElement.Data.Common; | ||
using RaceElement.Data.Common.SimulatorData; | ||
using RaceElement.Data.Common.SimulatorData.LocalCar; | ||
using RaceElement.Data.Games.AssettoCorsaEvo.DataMapper; | ||
using RaceElement.Data.Games.AssettoCorsaEvo.SharedMemory; | ||
using System.Drawing; | ||
|
||
namespace RaceElement.Data.Games.AssettoCorsaEvo; | ||
|
||
internal sealed class AssettoCorsaEvoDataProvider : AbstractSimDataProvider | ||
{ | ||
static int lastPhysicsPacketId = -1; | ||
|
||
// AC1 seems to have only one class. Or at least no race class info in the telemetry. | ||
static string dummyCarClass = "Race"; | ||
List<string> classes = [dummyCarClass]; | ||
|
||
internal override int PollingRate() => 200; | ||
|
||
private static string GameName => Game.AssettoCorsaEvo.ToShortName(); | ||
|
||
public sealed override void Update(ref LocalCarData localCar, ref SessionData sessionData, ref GameData gameData) | ||
{ | ||
var physicsPage = AcEvoSharedMemory.Instance.ReadPhysicsPageFile(); | ||
if (lastPhysicsPacketId == physicsPage.PacketId) // no need to remap the physics page if packet is the same | ||
{ | ||
SimDataProvider.GameData.IsGamePaused = true; | ||
return; | ||
} | ||
else | ||
{ | ||
SimDataProvider.GameData.IsGamePaused = false; | ||
} | ||
|
||
LocalCarMapper.AddPhysics(ref physicsPage, ref localCar, ref sessionData); | ||
|
||
gameData.Name = GameName; | ||
|
||
|
||
// For now only physics page works, so no need to map other pages. | ||
|
||
//var graphicsPage = AcEvoSharedMemory.Instance.ReadGraphicsPageFile(); | ||
//var staticPage = AcEvoSharedMemory.Instance.ReadStaticPageFile(); | ||
//LocalCarMapper.AddGraphics(ref graphicsPage, ref localCar, ref sessionData); | ||
|
||
//SessionData.Instance.PlayerCarIndex = graphicsPage.PlayerCarID; | ||
//SimDataProvider.LocalCar.CarModel.CarClass = dummyCarClass; | ||
|
||
} | ||
|
||
public override List<string> GetCarClasses() | ||
{ | ||
return classes; | ||
} | ||
|
||
public override bool HasTelemetry() | ||
{ | ||
return lastPhysicsPacketId > 0; | ||
} | ||
|
||
internal override void Stop() | ||
{ | ||
// No-op | ||
} | ||
|
||
public override bool IsSpectating(int playerCarIndex, int focusedIndex) | ||
{ | ||
// TODO: Can we spectate other cars in the pits in AC1? | ||
return false; | ||
} | ||
|
||
public override Color GetColorForCategory(string category) | ||
{ | ||
return Color.White; | ||
} | ||
|
||
internal sealed override void Start() | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Race Element.Data/Games/AssettoCorsaEvo/DataMapper/GameDataMapper.cs
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,14 @@ | ||
using RaceElement.Data.Common.SimulatorData; | ||
using Riok.Mapperly.Abstractions; | ||
using static RaceElement.Data.Games.AssettoCorsaEvo.SharedMemory.AcEvoSharedMemory; | ||
|
||
namespace RaceElement.Data.Games.AssettoCorsaEvo.DataMapper; | ||
|
||
[Mapper] | ||
internal static partial class GameDataMapper | ||
{ | ||
public static void WithStaticPage(SPageFileStatic pageStatic, GameData gameData) | ||
{ | ||
gameData.Version = pageStatic.AssettoCorsaVersion; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Race Element.Data/Games/AssettoCorsaEvo/DataMapper/LocalCar/PhysicsDataMapper.cs
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,17 @@ | ||
using RaceElement.Data.Common.SimulatorData.LocalCar; | ||
using Riok.Mapperly.Abstractions; | ||
using System.Numerics; | ||
using static RaceElement.Data.Games.AssettoCorsa.SharedMemory.AcSharedMemory; | ||
|
||
namespace RaceElement.Data.Games.AssettoCorsaEvo.DataMapper.LocalCar; | ||
|
||
[Mapper] | ||
internal static partial class PhysicsDataMapper | ||
{ | ||
internal static void InsertPhysicsPage(ref PageFilePhysics pagePhysics, PhysicsData commonData) | ||
{ | ||
commonData.Velocity = pagePhysics.SpeedKmh; | ||
commonData.Acceleration = new(pagePhysics.AccG[0], pagePhysics.AccG[2], pagePhysics.AccG[1]); | ||
commonData.Rotation = Quaternion.CreateFromYawPitchRoll(pagePhysics.Heading, pagePhysics.Pitch, pagePhysics.Roll); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Race Element.Data/Games/AssettoCorsaEvo/DataMapper/LocalCarMapper.cs
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,62 @@ | ||
using RaceElement.Data.Common.SimulatorData.LocalCar; | ||
using Riok.Mapperly.Abstractions; | ||
using System.Numerics; | ||
using RaceElement.Data.Common.SimulatorData; | ||
using static RaceElement.Data.Games.AssettoCorsaEvo.SharedMemory.AcEvoSharedMemory; | ||
|
||
namespace RaceElement.Data.Games.AssettoCorsaEvo.DataMapper; | ||
|
||
[Mapper] | ||
internal static partial class LocalCarMapper | ||
{ | ||
internal static void AddPhysics(ref SPageFilePhysics pagePhysics, ref LocalCarData commonData, ref SessionData sessionData) | ||
{ | ||
commonData.Physics.Acceleration = new(pagePhysics.AccG[0], pagePhysics.AccG[1], pagePhysics.AccG[2]); | ||
commonData.Engine.IsPitLimiterOn = pagePhysics.PitLimiterOn; | ||
commonData.Engine.MaxRpm = pagePhysics.CurrentMaxRpm; | ||
commonData.Engine.Rpm = pagePhysics.Rpms; | ||
|
||
commonData.Engine.IsRunning = commonData.Engine.Rpm > 0; | ||
|
||
commonData.Inputs.Steering = pagePhysics.SteerAngle; | ||
commonData.Inputs.Clutch = pagePhysics.Clutch; | ||
commonData.Inputs.Throttle = pagePhysics.Gas; | ||
commonData.Inputs.Brake = pagePhysics.Brake; | ||
commonData.Inputs.Gear = pagePhysics.Gear; | ||
|
||
commonData.Tyres.CoreTemperature = pagePhysics.TyreCoreTemperature; | ||
commonData.Tyres.Pressure = pagePhysics.WheelPressure; | ||
commonData.Tyres.SlipRatio = pagePhysics.WheelSlip; | ||
commonData.Tyres.Velocity = pagePhysics.Velocity; | ||
|
||
commonData.Brakes.DiscTemperature = pagePhysics.BrakeTemperature; | ||
commonData.Brakes.Pressure = pagePhysics.brakePressure; | ||
|
||
commonData.Electronics.TractionControlLevel = (int)pagePhysics.TC; | ||
commonData.Electronics.AbsLevel = (int)pagePhysics.Abs; | ||
commonData.Engine.FuelLiters = pagePhysics.Fuel; | ||
|
||
/// | ||
sessionData.Weather.AirTemperature = pagePhysics.AirTemp; | ||
} | ||
|
||
internal static void AddGraphics(ref SPageFileGraphic pageGraphics, ref LocalCarData commonData, ref SessionData sessionData) | ||
{ | ||
if (pageGraphics.CarCoordinates.Length >= pageGraphics.PlayerCarID) | ||
{ | ||
var coords = pageGraphics.CarCoordinates[pageGraphics.PlayerCarID]; | ||
commonData.Physics.Location = new Vector3(coords.X * 10f, coords.Y, coords.Z); | ||
} | ||
|
||
switch (pageGraphics.SessionType) | ||
{ | ||
case AcSessionType.AC_HOTLAPSUPERPOLE: sessionData.SessionType = RaceSessionType.HotlapSuperpole; break; | ||
case AcSessionType.AC_QUALIFY: sessionData.SessionType = RaceSessionType.Qualifying; break; | ||
case AcSessionType.AC_HOTSTINT: sessionData.SessionType = RaceSessionType.Hotstint; break; | ||
case AcSessionType.AC_PRACTICE: sessionData.SessionType = RaceSessionType.Practice; break; | ||
case AcSessionType.AC_HOTLAP: sessionData.SessionType = RaceSessionType.Hotlap; break; | ||
case AcSessionType.AC_RACE: sessionData.SessionType = RaceSessionType.Race; break; | ||
default: sessionData.SessionType = RaceSessionType.Unknown; break; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Race Element.Data/Games/AssettoCorsaEvo/DataMapper/SessionDataMapper.cs
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,10 @@ | ||
using Riok.Mapperly.Abstractions; | ||
using RaceElement.Data.Common.SimulatorData; | ||
using static RaceElement.Data.Games.AssettoCorsaEvo.SharedMemory.AcEvoSharedMemory; | ||
|
||
namespace RaceElement.Data.Games.AssettoCorsaEvo.DataMapper; | ||
|
||
[Mapper] | ||
internal static partial class SessionDataMapper | ||
{ | ||
} |
Oops, something went wrong.