# Engine integrations

The developer-owned ControllerHost is the common network endpoint. Engine clients connect with host authority, receive each phone's input and send private views. Physical controllers continue through the engine or the SDK's input manager.

## Godot 4

Copy `addons/controller_plus` into the project and enable the plugin. The autoload provides:

```gdscript
ControllerPlus.connect_host(endpoint, room_id, temporary_host_token)
var movement = ControllerPlus.move_vector("p1")
if ControllerPlus.pressed("p1", "primary"):
    jump()
ControllerPlus.set_private_view("p1", {
    "kind": "waiting",
    "title": "Your game",
    "text": "Waiting for the next round."
})
```

Use `assign_physical` to attach a physical pad to a player and `remap` for button positions. The installed-engine action/disconnect check passes. Network and hardware checks are separate.

## Unity

Add the UPM folder, place `ControllerPlusInput` on a uniquely named GameObject, then call `Connect(endpoint, room, token)` at runtime. Phones appear as regular Input System gamepads. Pair them with your players through `ControllerJoined`; keep using the game's InputAction assets and normal physical controller support.

`SetPrivateView`, `Haptic` and `PlayerEventJson` handle private phone interaction. The package contains a WebGL bridge as well as the native .NET WebSocket path. The minimum package API was checked against Input System 1.7.0.

## Unreal

Put the `ControllerPlus` plugin in the project's `Plugins` directory. Blueprint functions are grouped under **Controller+**. Connect the game host, create the game's local players, and use `AssignPlayerIndex` to route each phone to the intended player.

The input device feeds normal controller events into Unreal/Enhanced Input. `SetPrivateViewJson`, `PublishStateJson` and `DrainPlayerEvents` carry game-specific interaction. Force-feedback requests can be forwarded to phone haptics.

Unity and Unreal source packages are prepared locally. Editor compilation and play tests require large engine downloads here and are deliberately skipped. Check the release matrix before treating either package as editor-validated.

## Native C/C++

The C99 core provides `tr_state`, a device hub, profiles, stale-input handling and bounded host-frame decoding. Pass text received by your WebSocket library to `tr_decode_host_frame`; apply the result to `tr_hub`. Feed physical-controller samples through `tr_hub_update` so the rest of the game reads the same state type.

This core does not choose a network stack or install a driver. Its parser/profile/timeout/codec tests run locally. The optional compact input codec requires explicit negotiation.

## Local integration packages

The local release folder includes a JavaScript npm archive, a Unity UPM tarball and separate Godot, Unreal and native C/C++ source archives. Unity/Unreal archives are installable source packages, not claims of an editor build. Each carries the SDK license. The native archive includes its tests so its CMake configuration remains self-contained.
