Skip to content

Commit 0746dd0

Browse files
committed
Update R3E shared memory mapping to latest spec.
1 parent 50c5d9d commit 0746dd0

File tree

2 files changed

+78
-23
lines changed

2 files changed

+78
-23
lines changed

Models/R3E.cs

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Runtime.InteropServices;
23

34
namespace R3E
@@ -9,13 +10,26 @@ public class Constant
910
public enum VersionMajor
1011
{
1112
// Major version number to test against
12-
R3E_VERSION_MAJOR = 2
13+
R3E_VERSION_MAJOR = 3
1314
};
1415

1516
public enum VersionMinor
1617
{
1718
// Minor version number to test against
18-
R3E_VERSION_MINOR = 14
19+
R3E_VERSION_MINOR = 4
20+
};
21+
22+
public enum GameMode
23+
{
24+
Unavailable = -1,
25+
TrackTest = 0,
26+
LeaderboardChallenge = 1,
27+
Competition = 2,
28+
SingleRace = 3,
29+
Championship = 4,
30+
Multiplayer = 5,
31+
MultiplayerRanked = 6, // not impl currently
32+
TryBeforeYouBuy = 7,
1933
};
2034

2135
public enum Session
@@ -153,16 +167,17 @@ public enum PitMenuSelection
153167
Fuel = 3,
154168
Fronttires = 4,
155169
Reartires = 5,
156-
Frontwing = 6,
157-
Rearwing = 7,
158-
Suspension = 8,
170+
Body = 6,
171+
Frontwing = 7,
172+
Rearwing = 8,
173+
Suspension = 9,
159174

160175
// Pit menu buttons
161-
ButtonTop = 9,
162-
ButtonBottom = 10,
176+
ButtonTop = 10,
177+
ButtonBottom = 11,
163178

164179
// Pit menu nothing selected
165-
Max = 11
180+
Max = 12
166181
};
167182

168183
public enum TireType
@@ -238,6 +253,9 @@ public struct SectorStarts<T>
238253
[StructLayout(LayoutKind.Sequential, Pack = 1)]
239254
public struct PlayerData
240255
{
256+
// Player user id
257+
public Int32 userId;
258+
241259
// Virtual physics time
242260
// Unit: Ticks (1 tick = 1/400th of a second)
243261
public Int32 gameSimulationTicks;
@@ -319,6 +337,8 @@ public struct PlayerData
319337

320338
// Reserved data
321339
public Double unused1;
340+
public Double unused2;
341+
public Double unused3;
322342
}
323343

324344
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -441,6 +461,7 @@ public struct PitMenuState
441461
public Int32 fuel;
442462
public Int32 frontTires;
443463
public Int32 rearTires;
464+
public Int32 body;
444465
public Int32 frontWing;
445466
public Int32 rearWing;
446467
public Int32 suspension;
@@ -453,11 +474,12 @@ public struct PitMenuState
453474
[StructLayout(LayoutKind.Sequential, Pack = 1)]
454475
public struct CutTrackPenalties
455476
{
456-
public Int32 driveThrough;
457-
public Int32 stopAndGo;
458-
public Int32 pitStop;
459-
public Int32 timeDeduction;
460-
public Int32 slowDown;
477+
// -1.0 = none pending, otherwise penalty time dep on penalty type (drive-through active = 0.0, stop-and-go = time to stay, slow-down = time left to give back etc))
478+
public Single driveThrough;
479+
public Single stopAndGo;
480+
public Single pitStop;
481+
public Single timeDeduction;
482+
public Single slowDown;
461483
}
462484

463485
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -555,6 +577,12 @@ public struct DriverInfo
555577
public Int32 engineType;
556578
public Single carWidth;
557579
public Single carLength;
580+
public Single rating;
581+
public Single reputation;
582+
583+
// Reserved data
584+
public Single unused1;
585+
public Single unused2;
558586
}
559587

560588
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -567,6 +595,7 @@ public struct DriverData
567595
// Based on performance index
568596
public Int32 placeClass;
569597
public Single lapDistance;
598+
public Single lapDistanceFraction;
570599
public Vector3<Single> position;
571600
public Int32 trackSector;
572601
public Int32 completedLaps;
@@ -600,6 +629,9 @@ public struct DriverData
600629
public Int32 drsState;
601630
public Int32 ptpState;
602631

632+
// -1.0 unavailable, 0.0 - 1.0 tank factor
633+
public Single virtualEnergy;
634+
603635
// -1 unavailable, DriveThrough = 0, StopAndGo = 1, Pitstop = 2, Time = 3, Slowdown = 4, Disqualify = 5,
604636
public Int32 penaltyType;
605637

@@ -621,7 +653,8 @@ public struct DriverData
621653
// StopAndGoPenaltyCutTrack1st = 1,
622654
// StopAndGoPenaltyCutTrackMult = 2,
623655
// StopAndGoPenaltyYellowFlagOvertake = 3,
624-
// StopAndGoPenaltyMax = 4
656+
// StopAndGoPenaltyVirtualEnergy = 4,
657+
// StopAndGoPenaltyMax = 5
625658

626659
// PitstopPenaltyInvalid = 0,
627660
// PitstopPenaltyIgnoredPitstopWindow = 1,
@@ -655,12 +688,17 @@ public struct DriverData
655688
// DisqualifyPenaltyMax = 14
656689
public Int32 penaltyReason;
657690

658-
// -1 unavailable, 0 = ignition off, 1 = ignition on but not running, 2 = ignition on and running
691+
// -1 unavailable, 0 = ignition off, 1 = ignition on but not running, 2 = ignition on and starter running, 3 = ignition on and running
659692
public Int32 engineState;
660693

661694
// Car body orientation
662695
// Unit: Euler angles
663696
public Vector3<Single> orientation;
697+
698+
// Reserved data
699+
public Single unused1;
700+
public Single unused2;
701+
public Single unused3;
664702
}
665703

666704
[StructLayout(LayoutKind.Sequential, Pack = 1)]
@@ -678,6 +716,7 @@ public struct R3EData
678716
// Game State
679717
//////////////////////////////////////////////////////////////////////////
680718

719+
public Int32 gameMode; // Note: See the R3E.Constant.GameMode enum
681720
public Int32 gamePaused;
682721
public Int32 gameInMenus;
683722
public Int32 gameInReplay;
@@ -729,7 +768,7 @@ public struct R3EData
729768

730769
// If the session is time based, lap based or time based with an extra lap at the end
731770
public Int32 sessionLengthFormat;
732-
771+
733772
// Unit: Meter per second (m/s)
734773
public Single sessionPitSpeedLimit;
735774

@@ -770,6 +809,7 @@ public struct R3EData
770809
public Int32 maxIncidentPoints;
771810

772811
// Reserved data
812+
public Single eventUnused1;
773813
public Single eventUnused2;
774814

775815
//////////////////////////////////////////////////////////////////////////
@@ -881,10 +921,13 @@ public struct R3EData
881921

882922
// -1 = N/A, 0 = this and next lap valid, 1 = this lap invalid, 2 = this and next lap invalid
883923
public Int32 lapValidState;
924+
// -1 = N/A, 0 = invalid, 1 = valid
925+
public Int32 prevLapValid;
884926

885927
// Reserved data
886-
public Single scoreUnused1;
887-
public Single scoreUnused2;
928+
public Single unused1;
929+
public Single unused2;
930+
public Single unused3;
888931

889932
//////////////////////////////////////////////////////////////////////////
890933
// Vehicle information
@@ -934,9 +977,15 @@ public struct R3EData
934977
public Single fuelLeft;
935978
public Single fuelCapacity;
936979
public Single fuelPerLap;
980+
// Unit: Mega-Joule (MJ)
981+
// Note: -1.0f when not enough data, then max recorded virtual energy per lap
982+
// Note: Not valid for remote players
983+
public Single virtualEnergyLeft;
984+
public Single virtualEnergyCapacity;
985+
public Single virtualEnergyPerLap;
937986
// Unit: Celsius (C)
938987
// Note: Not valid for AI or remote players
939-
public Single engineWaterTemp;
988+
public Single engineTemp;
940989
public Single engineOilTemp;
941990
// Unit: Kilopascals (KPa)
942991
// Note: Not valid for AI or remote players
@@ -1004,8 +1053,14 @@ public struct R3EData
10041053
// Unit: Liters (l)
10051054
public Single waterLeft;
10061055

1056+
// -1.0 = N/A
1057+
public Int32 absSetting;
1058+
1059+
// -1 = N/A or dont exist on car, 0 = ignition off or headlights off, 1 = on, 2 = strobing
1060+
public Int32 headLights;
1061+
10071062
// Reserved data
1008-
Orientation<Single> VehicleUnused1;
1063+
public Single vehicleUnused1;
10091064

10101065
//////////////////////////////////////////////////////////////////////////
10111066
// Tires
@@ -1048,7 +1103,7 @@ public struct R3EData
10481103
public Int32 tireTypeRear;
10491104
// Which subtype of tires the car has
10501105
// Note: See the R3E.Constant.TireSubtype enum
1051-
public Int32 tireSubtypeFront;
1106+
public Int32 tireSubtypeFront;
10521107
public Int32 tireSubtypeRear;
10531108

10541109
// Current brake temperature (-1.0 = N/A)
@@ -1063,7 +1118,7 @@ public struct R3EData
10631118
// Note: Not valid for AI or remote players
10641119
public TireData<Single> brakePressure;
10651120

1066-
// Reserved data
1121+
// -1.0 = N/A
10671122
public Int32 tractionControlSetting;
10681123
public Int32 engineMapSetting;
10691124
public Int32 engineBrakeSetting;

electron.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"appId": "com.yuvix.rehud",
1212
"productName": "ReHUD",
1313
"copyright": "Copyright © 2023",
14-
"buildVersion": "0.11.4-beta",
14+
"buildVersion": "0.11.5-beta",
1515
"win": {
1616
"icon": "../../../wwwroot/ReHUD.png"
1717
},

0 commit comments

Comments
 (0)