# Le Mans Ultimate

DR Sim Manager uses the rF2SharedMemoryMapPlugin developed by [The Iron Wolf](https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin). The rFactor2 plugin is compatible with **Le Mans Ultimate**.

## Steps to Enable Telemetry Output

1. **Copy the Plugin DLL**\
   The required plugin DLL is already packaged with **DR Sim Manager**.
   * Navigate to:\
     `C:\Users\UserName\AppData\Local\DRSimManager\Plugins\rFactor2\`
   * Copy:\
     `rFactor2SharedMemoryMapPlugin64.dll`
   * Paste it into:\
     `C:\Program Files (x86)\Steam\steamapps\common\Le Mans Ultimate\Plugins\`
2. **Launch and Close Le Mans Ultimate**
   * Start **Le Mans Ultimate** once to allow the game to initialize the plugin settings.
   * Shut down the game.
3. **Edit Custom Plugin Settings**
   * Open the file in a text editor:\
     `C:\Program Files (x86)\Steam\steamapps\common\Le Mans Ultimate\UserData\player\CustomPluginVariables.JSON`
   * Locate the entry for `rFactor2SharedMemoryMapPlugin64.dll`.
   * Change the `" Enabled"` key from `0` to `1`:

     ```json
     "rFactor2SharedMemoryMapPlugin64.dll":{
         " Enabled":1
     }
     ```
   * Save and close the file.
4. **Relaunch Le Mans Ultimate**
   * Start **Le Mans Ultimate** again, and telemetry data should now be available for **DR Sim Manager**.

## Debugging the rFactor‑2/Le Mans Ultimate telemetry plug‑in

The *rFactor2SharedMemoryMap* plug‑in used by Le Mans Ultimate exposes a number of debugging switches via the `CustomPluginVariables.json` file (usually in `<SteamRoot>\steamapps\common\Le Mans Ultimate\UserData\player`). These control the amount of logging the plug‑in does and which parts of the game’s API it uses. The important flags are summarised below.

### Debug flags

* **`DebugOutputLevel`** – a bit‑mask specifying which severities are written to `UserData\Log\RF2SMMP_DebugOutput.txt`. The header defines the values: `Errors` (1), `CriticalInfo` (2), `DevInfo` (4), `Warnings` (8), `Synchronization` (16), `Perf` (32), `Timing` (64) and `Verbose` (128):contentReference\[oaicite:0]{index=0}. For example, a value of **15** (1 + 2 + 4 + 8) enables errors, critical info, developer info and warnings:contentReference\[oaicite:1]{index=1}. To capture only errors and warnings use **9** (1 + 8).
* **`DebugOutputSource`** – filters messages by origin. Each subsystem has a bit value: `General` = 1, `DMR` = 2, `Telemetry`/`MappedBuffer` = 4, `Scoring` = 8, `Rules` = 16, `MultiRules` = 32, `ForceFeedback` = 64, `Graphics` = 128, `Weather` = 256, `Extended` = 512, and input buffers (`HWControlInput` = 1024, `WeatherControlInput` = 2048, `RulesControlInput` = 4096, `PluginControlInput` = 8192):contentReference\[oaicite:2]{index=2}. Set this to the sum of the sources you need; `32767` enables all of them:contentReference\[oaicite:3]{index=3}.
* **`DebugISIInternals`** – when enabled, the plug‑in writes the raw `TelemInfoV01` and `ScoringInfoV01` structures to `UserData\Log\RF2SMMP_InternalsTelemetryOutput.txt` and `RF2SMMP_InternalsScoringOutput.txt`:contentReference\[oaicite:4]{index=4}. Useful for development, but the log files can be large.
* **`DedicatedServerMapGlobally`** – normally, shared‑memory buffers created on a dedicated server include the server process ID. Setting this to 1 causes the plug‑in to create its buffers in the global namespace so that clients running under other Windows accounts can access them. The server’s user account must have the “Create Global Objects” permission:contentReference\[oaicite:5]{index=5}.
* **`EnableDirectMemoryAccess`** – turns on the plug‑in’s *DMA* mode. When enabled the plug‑in reads additional state (message‑centre messages, global status, pit‑lane speed, etc.) directly from the game’s memory via `DirectMemoryReader`:contentReference\[oaicite:6]{index=6}:contentReference\[oaicite:7]{index=7}. It is off by default because memory scanning can be brittle; enable only if you need those extra fields.
* **`EnableHWControlInput`**, **`EnableWeatherControlInput`** and **`EnableRulesControlInput`** – these flags enable the corresponding input buffers.
  * `HWControl` lets external apps send limited control commands to the game (useful for pit‑menu interaction):contentReference\[oaicite:8]{index=8}.
  * `WeatherControl` allows an app to adjust the in‑game weather:contentReference\[oaicite:9]{index=9}.
  * `RulesControl` is experimental; it lets a client send rules inputs but may introduce timing issues:contentReference\[oaicite:10]{index=10}.\
    Only `HWControl` is enabled by default; the others must be set to 1 in the JSON file:contentReference\[oaicite:11]{index=11}.
* **`UnsubscribedBuffersMask`** – a bit‑mask that tells the plug‑in not to update certain output buffers. The values correspond to `Telemetry` = 1, `Scoring` = 2, `Rules` = 4, `MultiRules` = 8, `ForceFeedback` = 16, `Graphics` = 32, `PitInfo` = 64 and `Weather` = 128:contentReference\[oaicite:12]{index=12}. The default value of **160** (32 + 128) unsubscribes the Graphics and Weather buffers. Note that unsubscribing from `Scoring` disables the `PluginControl` input buffer:contentReference\[oaicite:13]{index=13}.

#### Recommended settings

For most users wanting to see **errors and warnings**, set:

```json
{
  "DebugOutputLevel": 9,
  "DebugOutputSource": 32767
}
```

This will log error and warning messages from all plug‑in components while avoiding verbose timing or performance data. Leave the other debug flags at their defaults unless you need the specialized functionality described above.

## Notes

* Ensure **Le Mans Ultimate** is fully closed before modifying `CustomPluginVariables.JSON`.
* If the file does not exist, launch the game once and exit to generate it.
