> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/opentrack/opentrack/llms.txt
> Use this file to discover all available pages before exploring further.

# Wine

> Run Windows games with head tracking on Linux via Wine or Proton

The Wine protocol enables head tracking for Windows games running on Linux through Wine, Proton, or Steam Play. It bridges FreeTrack-compatible Windows games to OpenTrack running natively on Linux.

## How It Works

The Wine protocol:

1. Creates a shared memory region accessible to Wine processes
2. Launches a wrapper program (`opentrack-wrapper-wine.exe.so`) inside Wine
3. The wrapper acts as a FreeTrack bridge, making tracking data available to Windows games
4. Games running under Wine access tracking data as if on native Windows

### Architecture

```
Linux OpenTrack → Shared Memory → Wine Wrapper → Windows Game
     (native)        (IPC)         (Wine)         (Windows)
```

This allows Windows-only games to use head tracking without dual-booting.

## Compatible Environments

<CardGroup cols={2}>
  <Card title="Wine" icon="wine-glass">
    Run any Windows game with Wine - configure Wine path and prefix
  </Card>

  <Card title="Steam Play (Proton)" icon="steam">
    Automatic Proton games via Steam - specify AppID
  </Card>

  <Card title="Custom Proton" icon="gear">
    Manual Proton setup - specify Proton version and prefix
  </Card>
</CardGroup>

## Prerequisites

### Required Packages

<Steps>
  <Step title="Install Wine">
    Install Wine or Proton on your system:

    **Ubuntu/Debian:**

    ```bash theme={null}
    sudo apt install wine wine64
    ```

    **Fedora:**

    ```bash theme={null}
    sudo dnf install wine
    ```

    **Arch:**

    ```bash theme={null}
    sudo pacman -S wine
    ```
  </Step>

  <Step title="Steam Play setup (optional)">
    If using Steam:

    1. Enable Steam Play in Steam settings
    2. Choose a Proton version
    3. Note the game's AppID (found in Steam URL)
  </Step>

  <Step title="Verify Wine works">
    Test Wine installation:

    ```bash theme={null}
    wine --version
    ```
  </Step>
</Steps>

## Setup Instructions

### Standard Wine Setup

<Steps>
  <Step title="Select Wine protocol">
    In OpenTrack, go to the **Output** dropdown and select **"Wine -- Windows layer for Unix"**.
  </Step>

  <Step title="Configure Wine variant">
    Click the settings button and select **"Wine"** variant.
  </Step>

  <Step title="Choose Wine version">
    **Wine executable path:**

    * **System Wine**: Select "WINE" (uses system default)
    * **Custom Wine**: Select "CUSTOM" and browse to Wine binary
    * **Wine-Staging/TKG**: Enter custom Wine path
  </Step>

  <Step title="Set Wine prefix">
    **Wine prefix**: Location of your Wine virtual Windows installation

    * Default: `~/.wine/`
    * Custom: Any directory containing a Wine prefix
    * Must be an absolute path (not relative)
  </Step>

  <Step title="Configure protocol type">
    **Headtracking Protocol**: Choose FreeTrack compatibility mode

    * Protocol 1: FreeTrack 1.x
    * Protocol 2: FreeTrack 2.0 (recommended)
    * Protocol 3: TrackIR emulation
  </Step>

  <Step title="Enable sync options (optional)">
    * **ESYNC**: Enable for better performance
    * **FSYNC**: Enable if kernel supports it
  </Step>

  <Step title="Start OpenTrack">
    Click **Start**. OpenTrack will:

    * Create shared memory
    * Launch Wine wrapper process
    * Wait for game to start
  </Step>

  <Step title="Launch your game">
    Start your Windows game through Wine:

    ```bash theme={null}
    wine /path/to/game.exe
    ```

    The game should detect FreeTrack/TrackIR automatically.
  </Step>
</Steps>

### Steam Play (Proton) Setup

<Steps>
  <Step title="Enable Proton in OpenTrack">
    In Wine protocol settings:

    * Select **"Proton"** variant
    * Choose **"Steam Play"** mode
  </Step>

  <Step title="Find game AppID">
    Get your game's Steam AppID:

    1. Go to game's store page
    2. Look at URL: `store.steampowered.com/app/[APPID]/`
    3. Or right-click game in Steam library → Properties → Updates
  </Step>

  <Step title="Enter AppID">
    In OpenTrack settings:

    * Enter the game's AppID number
    * OpenTrack will auto-detect Proton version and prefix
  </Step>

  <Step title="Start tracking and game">
    1. Start OpenTrack
    2. Launch game through Steam
    3. Head tracking should work automatically
  </Step>
</Steps>

### External Proton Setup

<Steps>
  <Step title="Select external Proton">
    In Wine protocol settings:

    * Select **"Proton"** variant
    * Choose **"External Proton"** mode
  </Step>

  <Step title="Set Proton path">
    **Proton version path**: Location of Proton installation

    Typical locations:

    ```
    ~/.steam/steam/steamapps/common/Proton 8.0/
    ~/.local/share/Steam/compatibilitytools.d/proton-ge-custom/
    ```
  </Step>

  <Step title="Set prefix path">
    **Proton prefix**: Game's compatibility data folder

    Format:

    ```
    ~/.steam/steam/steamapps/compatdata/[APPID]/pfx/
    ```
  </Step>

  <Step title="Launch game">
    Start OpenTrack, then launch game with Proton manually or via Steam.
  </Step>
</Steps>

## Configuration Options

### Wine Settings

| Option      | Description                  | Default     |
| ----------- | ---------------------------- | ----------- |
| Wine Path   | Path to Wine binary          | System Wine |
| Wine Prefix | Windows environment location | `~/.wine/`  |
| ESYNC       | Event synchronization        | Enabled     |
| FSYNC       | File synchronization         | Enabled     |
| Protocol    | FreeTrack version            | Protocol 2  |

### Proton Settings

| Option          | Description                 |
| --------------- | --------------------------- |
| Proton Version  | Path to Proton installation |
| Steam Play      | Auto-detect from AppID      |
| External Proton | Manual Proton configuration |
| AppID           | Steam game application ID   |
| Proton Prefix   | Compatibility data location |

## Environment Variables

The protocol sets these environment variables:

```bash theme={null}
# Wine/Proton selection
WINEPREFIX=/path/to/prefix

# Performance options  
WINEESYNC=1    # Enable ESYNC
WINEFSYNC=1    # Enable FSYNC

# Protocol selection
OTR_WINE_PROTO=2  # FreeTrack protocol version (1-3)
```

## Troubleshooting

### "Failed to start Wine!"

**Cause**: Wine binary not found or not executable.

**Solution**:

1. Verify Wine is installed: `wine --version`
2. Check Wine path in settings is correct
3. Ensure Wine binary is executable
4. Try using system Wine instead of custom path

### "Prefix has not been defined!"

**Cause**: Wine prefix path is empty.

**Solution**:

1. Enter absolute path to Wine prefix (e.g., `/home/user/.wine/`)
2. Create prefix if it doesn't exist:
   ```bash theme={null}
   WINEPREFIX=~/.wine wine wineboot
   ```
3. Verify prefix directory exists and is valid

### "Must specify application id for Proton"

**Cause**: Using Steam Play mode without AppID.

**Solution**:

1. Find game's AppID from Steam store page URL
2. Enter AppID in OpenTrack settings
3. Or switch to External Proton mode and specify paths manually

### Game Doesn't Detect Tracking

**Symptoms**: Game runs but head tracking doesn't work.

**Solution**:

1. **Check wrapper is running**:
   ```bash theme={null}
   ps aux | grep opentrack-wrapper-wine
   ```
2. **Verify shared memory**:
   ```bash theme={null}
   ls -l /dev/shm/ | grep wine
   ```
3. **Check protocol version**: Try different protocol settings (1, 2, or 3)
4. **Game compatibility**: Ensure game supports FreeTrack/TrackIR
5. **Wine/Proton version**: Some games work better with specific versions

### Wrapper Process Crashes

**Symptoms**: OpenTrack starts but wrapper exits immediately.

**Solution**:

1. Check OpenTrack logs for error messages
2. Verify Wine prefix is valid:
   ```bash theme={null}
   WINEPREFIX=~/.wine wine wineboot
   ```
3. Install required Wine dependencies:
   ```bash theme={null}
   winetricks vcrun2019 dotnet48
   ```
4. Try different Wine version (Wine-Staging, Wine-GE, Proton-GE)

### "Can't open shared memory mapping"

**Cause**: Shared memory creation failed.

**Solution**:

1. Check `/dev/shm` permissions:
   ```bash theme={null}
   ls -ld /dev/shm
   ```
2. Ensure sufficient space in `/dev/shm`
3. Verify SELinux/AppArmor isn't blocking
4. Try running OpenTrack with elevated permissions

### Performance Issues

**Symptoms**: Game or tracking is laggy under Wine.

**Solution**:

* Enable ESYNC and FSYNC
* Use Wine-Staging or Wine-TKG for better performance
* Check CPU usage - Wine adds overhead
* Consider using Proton instead of plain Wine
* Update graphics drivers

## Game-Specific Notes

### DCS World on Linux

DCS has native Linux support via Steam, but for standalone:

```bash theme={null}
# Set Wine prefix
export WINEPREFIX=~/.wine-dcs
# Start OpenTrack with protocol 2
# Launch DCS through Wine
```

### Elite Dangerous

Works well with Proton:

1. Use Steam Play mode
2. AppID: 359320
3. Protocol 2 (FreeTrack 2.0)
4. Enable FSYNC for best performance

### X-Plane

For X-Plane on Wine:

1. Install X-Camera plugin in Wine prefix
2. Use protocol 2
3. Ensure plugin DLLs are in correct Wine architecture (32 vs 64-bit)

## Advanced Configuration

### Custom Wine Builds

Optimized Wine builds for gaming:

**Wine-Staging:**

```bash theme={null}
# Install Wine-Staging
sudo apt install wine-staging
# Use in OpenTrack
Wine Path: /opt/wine-staging/bin/wine
```

**Wine-GE / Wine-TKG:**

```bash theme={null}
# Download from GitHub
# Extract to ~/wine-ge/
# Use in OpenTrack
Wine Path: ~/wine-ge/bin/wine
```

**Proton-GE:**

```bash theme={null}
# Install via ProtonUp-Qt or manually
# Place in ~/.steam/compatibilitytools.d/
# Select in OpenTrack Proton path
```

### Multiple Wine Prefixes

Manage separate prefixes per game:

```bash theme={null}
# Create game-specific prefixes
WINEPREFIX=~/.wine-dcs wineboot
WINEPREFIX=~/.wine-elite wineboot

# Configure in OpenTrack per profile
Profile 1: DCS → Prefix: ~/.wine-dcs
Profile 2: Elite → Prefix: ~/.wine-elite
```

### Debug Logging

Enable Wine debug output:

```bash theme={null}
export WINEDEBUG=+relay,+seh,+tid
WINEPREFIX=~/.wine wine game.exe
```

Check OpenTrack logs:

```bash theme={null}
~/.config/opentrack-2.3/log.txt
```

## Technical Details

### Shared Memory Structure

```cpp theme={null}
struct WineSHM {
    double data[6];      // X, Y, Z, Pitch, Yaw, Roll
    int gameid;          // Game identifier
    int gameid2;         // Confirmed game ID
    unsigned char table[8];  // Game-specific data
    volatile bool stop;  // Shutdown signal
};
```

### Coordinate Transformations

```cpp theme={null}
// Position (cm to mm)
shm->data[0] = headpose[TX] * 10;
shm->data[1] = headpose[TY] * 10;
shm->data[2] = headpose[TZ] * 10;

// Rotation (degrees to radians)
shm->data[3] = (headpose[Pitch] * M_PI) / 180;
shm->data[4] = (headpose[Yaw] * M_PI) / 180;
shm->data[5] = (headpose[Roll] * M_PI) / 180;
```

### Wrapper Process

The wrapper executable:

* Runs inside Wine environment
* Creates FreeTrack shared memory visible to Windows games
* Bridges Linux shared memory to Windows memory
* Handles game detection and protocol translation

<Note>
  The Wine protocol brings Windows-exclusive head tracking games to Linux. While it adds some complexity compared to native protocols, it enables gaming on Linux without dual-booting or virtualization.
</Note>

## Alternatives for Linux Gaming

### Native Linux Games

Some games have native Linux versions with head tracking:

* **X-Plane 11/12**: Native Linux, use FreeTrack protocol
* **War Thunder**: Native Linux support
* **FlightGear**: Native, use FlightGear protocol

### Dual-Boot Option

For maximum compatibility, consider dual-booting Windows for gaming.

### Virtual Machine

Pass-through GPU to VM for near-native performance (advanced setup).
