Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.15)
project(simapi VERSION 1.0.1 DESCRIPTION "Telemetry Mapping Library for Racing Sims")
include(GNUInstallDirs)
add_library(simapi SHARED simapi/simmapper.c simapi/getpid.c simapi/mapping/acmapper.c simapi/mapping/pcars2mapper.c simapi/mapping/rf2mapper.c simapi/mapping/scs2mapper.c simapi/mapping/outgaugemapper.c)
add_library(simapi SHARED simapi/simmapper.c simapi/getpid.c simapi/mapping/acmapper.c simapi/mapping/pcars2mapper.c simapi/mapping/rf2mapper.c simapi/mapping/scs2mapper.c simapi/mapping/outgaugemapper.c simapi/mapping/dirt2mapper.c)

set(SIMAPI_PUBLIC_HEADERS
"simapi/simmapper.h"
Expand All @@ -25,3 +25,6 @@ option(BUILD_SIMD "Build the simd tool" ON)
if(BUILD_SIMD)
add_subdirectory(simd)
endif()

add_executable(view_telemetry tests/view_telemetry.c)
target_link_libraries(view_telemetry simapi m)
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ use the functions within simmapper.c to open and map the memory mapped file.
## Building

To compile the shared library with the CMakeLists.txt in the root of the repo...
```bash
cmake -B build
cmake --build build
```
mkdir build; cd build
cmake ..
make clean; make; make install
You will need sudo to install, which will place the library and public headers into `/usr/local`:
```bash
sudo cmake --install build
```
You will need sudo for the make install, which will place the dll and public headers into /usr/local.

## Supported Sims
the closest to documentation found for each sim
Expand Down
58 changes: 29 additions & 29 deletions include/acdata.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,43 @@ ACC_FLAG_TYPE;

typedef int ACC_PENALTY_TYPE;
#define ACC_NONE = 0,
#define ACC_DRIVETHROUGH_CUTTING = 1,
#define ACC_STOPANDGO_10_CUTTING = 2,
#define ACC_STOPANDGO_20_CUTTING = 3,
#define ACC_STOPANDGO_30_CUTTING = 4,
#define ACC_DISQUALIFIED_CUTTING = 5,
#define ACC_REMOVEBESTLAPTIME_CUTTING = 6,
#define ACC_DRIVETHROUGH_PITSPEEDING = 7,
#define ACC_STOPANDGO_10_PITSPEEDING = 8,
#define ACC_STOPANDGO_20_PITSPEEDING = 9,
#define ACC_STOPANDGO_30_PITSPEEDING = 10,
#define ACC_DISQUALIFIED_PITSPEEDING = 11,
#define ACC_REMOVEBESTLAPTIME_PITSPEEDING = 12,
#define ACC_DISQUALIFIED_IGNOREDMANDATORYPIT = 13,
#define ACC_POSTRACETIME = 14,
#define ACC_DISQUALIFIED_TROLLING = 15,
#define ACC_DISQUALIFIED_PITENTRY = 16,
#define ACC_DISQUALIFIED_PITEXIT = 17,
#define ACC_DISQUALIFIED_WRONGWAY = 18,
#define ACC_DRIVETHROUGH_IGNOREDDRIVERSTINT = 19,
#define ACC_DISQUALIFIED_IGNOREDDRIVERSTINT = 20,
#define ACC_DRIVETHROUGH_CUTTING = 1,
#define ACC_STOPANDGO_10_CUTTING = 2,
#define ACC_STOPANDGO_20_CUTTING = 3,
#define ACC_STOPANDGO_30_CUTTING = 4,
#define ACC_DISQUALIFIED_CUTTING = 5,
#define ACC_REMOVEBESTLAPTIME_CUTTING = 6,
#define ACC_DRIVETHROUGH_PITSPEEDING = 7,
#define ACC_STOPANDGO_10_PITSPEEDING = 8,
#define ACC_STOPANDGO_20_PITSPEEDING = 9,
#define ACC_STOPANDGO_30_PITSPEEDING = 10,
#define ACC_DISQUALIFIED_PITSPEEDING = 11,
#define ACC_REMOVEBESTLAPTIME_PITSPEEDING = 12,
#define ACC_DISQUALIFIED_IGNOREDMANDATORYPIT = 13,
#define ACC_POSTRACETIME = 14,
#define ACC_DISQUALIFIED_TROLLING = 15,
#define ACC_DISQUALIFIED_PITENTRY = 16,
#define ACC_DISQUALIFIED_PITEXIT = 17,
#define ACC_DISQUALIFIED_WRONGWAY = 18,
#define ACC_DRIVETHROUGH_IGNOREDDRIVERSTINT = 19,
#define ACC_DISQUALIFIED_IGNOREDDRIVERSTINT = 20,
#define ACC_DISQUALIFIED_EXCEEDEDDRIVERSTINTLIMIT = 21

typedef int ACC_TRACK_GRIP_STATUS;
#define ACC_GREEN = 0,
#define ACC_FAST = 1,
#define ACC_OPTIMUM = 2,
#define ACC_GREASY = 3,
#define ACC_DAMP = 4,
#define ACC_WET = 5,
#define ACC_FAST = 1,
#define ACC_OPTIMUM = 2,
#define ACC_GREASY = 3,
#define ACC_DAMP = 4,
#define ACC_WET = 5,
#define ACC_FLOODED = 6

typedef int ACC_RAIN_INTENSITY;
#define ACC_NO_RAIN = 0,
#define ACC_DRIZZLE = 1,
#define ACC_LIGHT_RAIN = 2,
#define ACC_MEDIUM_RAIN = 3,
#define ACC_HEAVY_RAIN = 4,
#define ACC_DRIZZLE = 1,
#define ACC_LIGHT_RAIN = 2,
#define ACC_MEDIUM_RAIN = 3,
#define ACC_HEAVY_RAIN = 4,
#define ACC_THUNDERSTORM = 5

#pragma pack(push)
Expand Down
106 changes: 106 additions & 0 deletions include/dirt2data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#ifndef _DIRT2DATA_H
#define _DIRT2DATA_H

#include <stdint.h>

#pragma pack(push, 1)

// DiRT Rally 2.0 UDP packet structure (extradata=3)
// 66 floats (264 bytes)
/**
* @struct DR2_UDP_ExtraData3
* @brief DiRT Rally 2.0 UDP packet structure for "extradata=3".
*
* This structure contains 66 floating point values (264 bytes total).
* Data is sent in little-endian format.
*/
typedef struct
{
float runTime; /**< Total time the session has been running
(seconds) */
float lapTime; /**< Current lap time (seconds) */
float distance; /**< [UNVERIFIED] Total distance travelled in the session
(meters) */
float progress; /**< Current lap progress (0.0 to 1.0, accumulative for each
lap) */
float posX; /**< World position X (East/West) */
float posY; /**< World position Y (Up/Down) */
float posZ; /**< World position Z (North/South) */
float speed; /**< Speed (m/s) */
float velX; /**< Velocity in world X direction */
float velY; /**< Velocity in world Y direction */
float velZ; /**< Velocity in world Z direction */
float rightX; /**< Local right vector X component */
float rightY; /**< Local right vector Y component */
float rightZ; /**< Local right vector Z component */
float forwardX; /**< Local forward vector X component */
float forwardY; /**< Local forward vector Y component */
float forwardZ; /**< Local forward vector Z component */
float suspRL; /**< Suspension position Rear Left */
float suspRR; /**< Suspension position Rear Right */
float suspFL; /**< Suspension position Front Left */
float suspFR; /**< Suspension position Front Right */
float suspVelRL; /**< Suspension velocity Rear Left */
float suspVelRR; /**< Suspension velocity Rear Right */
float suspVelFL; /**< Suspension velocity Front Left */
float suspVelFR; /**< Suspension velocity Front Right */
float wheelSpeedRL; /**< Wheel speed Rear Left (m/s) */
float wheelSpeedRR; /**< Wheel speed Rear Right (m/s) */
float wheelSpeedFL; /**< Wheel speed Front Left (m/s) */
float wheelSpeedFR; /**< Wheel speed Front Right (m/s) */
float throttle; /**< Throttle input (0.0 to 1.0) */
float steering; /**< Steering input (-1.0 to 1.0) */
float brake; /**< Brake input (0.0 to 1.0) */
float clutch; /**< Clutch input (0.0 to 1.0) */
float gear; /**< Current gear (0=neutral, 1-10=gears, -1=reverse) */
float gForceLat; /**< Lateral G-Force (Field 34) */
float gForceLon; /**< Longitudinal G-Force (Field 35) */
float lap; /**< Current lap number */
float engineRPM; /**< Engine RPM (raw value is RPM / 10) */
float sliProSupport; /**< [UNVERIFIED] Sli-Pro support data */
float racePos; /**< Current race position */
float kersLevel; /**< [UNVERIFIED] KERS level (likely unused in DR2) */
float kersMaxLevel; /**< [UNVERIFIED] KERS max level (likely unused in DR2) */
float drs; /**< [UNVERIFIED] DRS status (likely unused in DR2) */
float tractionControl; /**< [UNVERIFIED] Traction control setting/activity */
float antiLockBrakes; /**< [UNVERIFIED] ABS setting/activity */
float fuelInTank; /**< Current fuel in tank (liters) (always 0.0) */
float fuelCapacity; /**< Fuel tank capacity (liters) (always 0.0) */
float inPit; /**< [UNVERIFIED] Pit lane status (0=on track, 1=in pit) */
float sector; /**< Current sector index */
float sector1Time; /**< Time for sector 1 (seconds) */
float sector2Time; /**< Time for sector 2 (seconds) */
float brakesTempRL; /**< Brake temperature Rear Left (Celsius) */
float brakesTempRR; /**< Brake temperature Rear Right (Celsius) */
float brakesTempFL; /**< Brake temperature Front Left (Celsius) */
float brakesTempFR; /**< Brake temperature Front Right (Celsius) */
float tyrePressureRL; /**< Tyre pressure Rear Left (always 0.0) */
float tyrePressureRR; /**< Tyre pressure Rear Right (always 0.0) */
float tyrePressureFL; /**< Tyre pressure Front Left (always 0.0) */
float tyrePressureFR; /**< Tyre pressure Front Right (always 0.0) */
float lapsCompleted; /**< Number of laps completed */
float totalLaps; /**< Total laps in session */
float trackLength; /**< Track length (meters) */
float lastLapTime; /**< Duration of the last completed lap (seconds) */
float maxRPM; /**< Maximum engine RPM (raw value is RPM / 10) */
float idleRPM; /**< Idle engine RPM (raw value is RPM / 10) */
float maxGears; /**< Maximum number of gears */
} DR2_UDP_ExtraData3;

// Main packet structure using a union for both named field access and array
// access
struct dirt2_udp_packet
{
union
{
float data[66];
DR2_UDP_ExtraData3 fields;
};
};

#pragma pack(pop)

// Note: This structure is based on DiRT Rally 2.0 extradata=3 specification.
// Gear mapping: 0=neutral, 1-10=gears, -1=reverse.

#endif
22 changes: 22 additions & 0 deletions simapi/dirt2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef _DIRT2_H
#define _DIRT2_H

#include <stdbool.h>
#include "../include/dirt2data.h"

#define DIRT_RALLY_2_EXE "dirtrally2.exe"

typedef struct
{
bool has_telemetry;
struct dirt2_udp_packet dirt2_telemetry;
float last_velX;
float last_velY;
float last_velZ;
float last_runTime;
bool has_last_vel;
}
Dirt2Map;

#endif

Loading