# Running DEA + the tracker entirely on Linux, under Wine This is a third path beyond the two in the README: DEA and the `Kinect10.dll` shim run under **Wine** on Linux, but the tracker runs as a **native Linux process**, outside Wine. ## Why not just run `kinect-tracker.exe` under Wine too `tracker-native/` captures the webcam through Windows Media Foundation (`MFEnumDeviceSources` + `IMFSourceReader`). Wine's `mf.dll` has video-capture device enumeration as a hard stub (confirmed directly in Wine's source, `dlls/mf/main.c::MFEnumDeviceSources`): ```c if (IsEqualGUID(&source_type, &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID)) { FIXME("Not implemented for video capture devices.\n"); *ret_count = 0; return S_OK; } ``` It always reports zero devices - no camera ever shows up, and `kinect-tracker.exe` null-derefs downstream of that empty list (the `Unhandled page fault ... address 00006FFFFE9A8C34` crash you get running it under Wine is this). This isn't fixable from our side; it's a gap in Wine's Media Foundation implementation. ## The fix: bridge the already-verified Linux tracker through a real file The shim's shared-memory region is normally an **anonymous**, Wine-private pagefile section (`CreateFileMappingW(INVALID_HANDLE_VALUE, ...)`), invisible outside that one Wine instance. The Python tracker (`tracker/`), which already has full native webcam access (verified Linux path, `docs/setup-linux.md`), publishes through `multiprocessing.shared_memory`, which on Linux is backed by a **real file** at `/dev/shm/`. The shim now supports opening that real file directly as a **file-backed** mapping (`KINECT_SHIM_SHM_FILE` env var, `fallback/windows-nui/src/frame_source.cpp::open_file`) instead of the named anonymous section. Since Wine's default `Z:` drive maps the whole host filesystem, `/dev/shm/virtual_kinect_frames` on Linux is `Z:\dev\shm\virtual_kinect_frames` from inside Wine - so the Wine-hosted shim and the native-Linux tracker end up mapping the exact same tmpfs file. No Wine camera support needed at all. ``` webcam --(V4L2)--> tracker/ (Python, native Linux process) | writes multiprocessing.shared_memory "virtual_kinect_frames" v /dev/shm/virtual_kinect_frames (a real file, same on both sides) ^ | CreateFileW + file-backed CreateFileMappingW Kinect10.dll shim (inside Wine, inside the DEA process) --> game ``` ## Steps 1. **Build the shim** (already done in this repo as of this change; rebuild if you pull newer source): ```sh ./fallback/windows-nui/build.sh ``` Copy `fallback/windows-nui/build/Kinect10-x86.dll` (or `-x64`, matching DEA's bitness) into the DEA `contents` folder next to `gamekdm.dll`, as `Kinect10.dll` - same as `docs/setup-windows.md` step 2. 2. **Set up the Linux tracker environment** per `docs/setup-linux.md` steps 0-2 (with Nix, `nix develop` does this in one shot - no venv, no manual `libGLESv2.so.2` staging; without Nix, the uv/Python 3.12 venv path). You do **not** need the OpenNI2 steps (3-5) for this path - those are for the separate Linux/OpenNI2 target, not DEA. 3. **Confirm your Wine `Z:` drive maps to `/`** (the default): ```sh ls -la ~/.wine/dosdevices/z: # expect a symlink to / ``` If it's remapped or you use a non-default `WINEPREFIX`, adjust the path in step 5 accordingly (or add your own `Z:`-equivalent drive mapping to `/dev/shm`). 4. **Run the Linux tracker.** The shm name (`virtual_kinect_frames`) is baked into the flake itself (`kDefaultShmName` in `flake.nix`) and passed automatically - no flag needed: ```sh # with Nix: nix run .#tracker -- --source 0 --depth-size 640x480 # without Nix: export LD_LIBRARY_PATH="$HOME/.cache/kinect/gllibs:$LD_LIBRARY_PATH" # if needed tracker/.venv/bin/python -m tracker.tracker --source 0 \ --depth-size 640x480 --shm-name virtual_kinect_frames ``` This creates `/dev/shm/virtual_kinect_frames` and keeps publishing live frames into it. 5. **Launch DEA with `KINECT_SHIM_SHM_FILE` (and, once calibrated, `KINECT_SHIM_CONFIG`) set**, pointing at those files through the `Z:` drive. Get the exact, ready-to-paste values - computed from the flake's own shm name and your `$HOME`, no manual path translation - with: ```sh nix run .#launch-options ``` Plain Wine, set the same assignments before the command: ```sh WINEPREFIX=/path/to/your/prefix \ KINECT_SHIM_SHM_FILE='Z:\dev\shm\virtual_kinect_frames' \ wine spice2x.exe # (or however you normally launch it) ``` Steam Proton (add spice2x/DEA as a non-Steam game, force a Proton version in Properties -> Compatibility): paste `nix run .#launch-options`'s output line into **Properties -> General -> Launch Options** as-is (it already ends in `%command%`). The shim reads `KINECT_SHIM_SHM_FILE` once at `NuiInitialize` and, when set, opens that path as a file-backed mapping instead of looking for the named Wine section. Check `kinect_shim.log` for a `shm-file='...' open=1` line to confirm it attached. 6. **Calibrate the cursor** - required on Linux, there is no built-in default that fits every camera. With the tracker set up, run: ```sh nix run .#tracker -- --calibrate --source 0 ``` and raise your right arm as prompted; it writes to the same path `nix run .#launch-options` already put in `KINECT_SHIM_CONFIG` above, so no further coordination is needed - just relaunch. See `docs/calibration.md` for the full guide and the exact env var to set. Everything downstream works the same as the Windows path - the shim doesn't care whether the bytes came from a Windows tracker or this Linux one, only that the contract layout matches (it's `#pragma pack(1)` and already cross-checked against the Python struct by the core test suite). ## If it still doesn't attach - `kinect_shim.log` shows `shm-file='...' open=0 (err=2)`: file not found - the tracker isn't running yet, the `--shm-name` doesn't match the path in `KINECT_SHIM_SHM_FILE`, or your `Z:` drive doesn't map where you think. Run `winepath -w /dev/shm/virtual_kinect_frames` from inside the prefix to get the exact Windows-side path Wine expects. - The shim attaches but the game shows no skeleton: this is the same validity/tracking pipeline as the Windows path - see `docs/troubleshooting.md` and `docs/game-internals.md`. Nothing about the file-backed bridge changes that logic; it's purely a transport swap.