# rFactor 2

DR Sim Manager uses the **rF2SharedMemoryMapPlugin** developed by The Iron Wolf:\
[GitHub Repository](https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin)

The plugin DLL is packaged with DR Sim Manager.

## Installation Steps

1. **Copy the Plugin DLL**
   * Navigate to the DR Sim Manager plugins folder:

     ```
     C:\Users\UserName\AppData\Local\DRSimManager\Plugins\rFactor2
     ```
   * Copy the file:

     ```
     rFactor2SharedMemoryMapPlugin64.dll
     ```
   * Paste it into the rFactor 2 plugins folder:

     ```
     \rFactor 2\Bin64\Plugins\
     ```
   * For the Steam version, the default plugin path is:

     ```
     C:\Program Files (x86)\Steam\steamapps\common\rFactor 2\Bin64\Plugins\
     ```
2. **Enable the Plugin in rFactor 2**
   * Launch **rFactor 2**.
   * Go to **Settings**.
   * Under **Plugins**, enable the **rFactor2SharedMemoryMapPlugin64**.

Once enabled, DR Sim Manager should be able to read telemetry data from rFactor 2.

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

The *rFactor2SharedMemoryMap* plug‑in used by rFactor2 exposes a number of debugging switches via the `CustomPluginVariables.json` file (usually in `<SteamRoot>\steamapps\common\rFactor 2\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.
