# Remote Control

The Remote Control Interface (RCI) lets you control DR Sim Manager from any device on your local network — such as a phone, tablet, or another PC — using a built-in web interface. This is ideal for cockpit and rig setups where the main PC is not easily accessible.

## Architecture Overview

The Remote Control Interface runs a WebSocket server directly within DR Sim Manager. When enabled, it:

* Serves a built-in **web interface** accessible from any modern browser.
* Accepts **WebSocket connections** for real-time, low-latency communication.
* Optionally encrypts all traffic with **HTTPS** using a self-signed certificate.
* Supports up to **5 simultaneous client connections**.

No additional software or apps need to be installed on your phone, tablet, or other device — just a web browser.

***

## What You Can Do

From the web interface, you can:

* **Start, stop, pause, and resume** motion.
* **Browse and switch** between games and profiles.
* **Adjust global gain and input gain** remotely.
* **View and edit cue settings** for the active profile.
* **See real-time motion state** (active, paused, stopped).

***

## Enabling Remote Control

1. Go to the **Settings** tab in DR Sim Manager.
2. Scroll down to the **Remote Control** section.
3. Check **Enable Remote Control Interface**.
4. Note the **port number** (default: 8000).
5. Start motion or restart the application — the server starts automatically when the setting is enabled.

Once running, the application log will display the URL to access the web interface (e.g., `https://192.168.1.100:8000`).

***

## Connection Settings

### **Mode:**

* **HTTPS** (default) — Encrypted connection using a self-signed SSL certificate. Your browser may show a certificate warning — this is normal and safe to accept on your local network.
* **HTTP** — Unencrypted connection. Use this if you have trouble connecting with HTTPS, or if your device does not handle self-signed certificates well.

### **Remote Control Port:**

* The port the server listens on. Default is **8000**. Valid range is **1024 – 65535**. Change this if the port conflicts with another service on your PC.

### **Require Password:**

* When enabled, clients must enter a password to connect. Click **Set** to create or change the password.
* When disabled, anyone on your local network can connect without authentication.
* Passwords are hashed before storage — they are never stored in plain text.

{% hint style="warning" %}
If password protection is disabled, anyone on your local network can control your simulator. Enable password protection if you are on a shared or public network.
{% endhint %}

***

## Connecting from a Device

1. Make sure your device (phone, tablet, etc.) is on the **same local network** (Wi-Fi or Ethernet) as the PC running DR Sim Manager.
2. Open a web browser on your device.
3. Navigate to the address shown in the DR Sim Manager log — typically `https://<your-pc-ip>:8000` or `http://<your-pc-ip>:8000` depending on your mode setting.
4. If password protection is enabled, enter the password when prompted.
5. The web interface loads with controls for motion, game/profile selection, and gain adjustment.

{% hint style="info" %}
If using HTTPS mode, your browser will show a security warning because the certificate is self-signed. Click **Advanced** → **Proceed** (or equivalent) to continue. This only needs to be done once per browser.
{% endhint %}

***

## Authentication

When password protection is enabled:

1. The client connects to the WebSocket server.
2. The server waits for an authentication message containing the password.
3. If the password is correct, the connection is accepted and the client receives the current state (motion status, profile list, gain settings).
4. If the password is incorrect or not provided within 5 seconds, the connection is rejected.

The authentication flow is automatic when using the built-in web interface — users simply enter the password in a dialog when the page loads.

***

## Connection Limits

The Remote Control Interface supports up to **5 simultaneous connections**. If the limit is reached, additional connections will be rejected until an existing connection disconnects.

***

## Available API Commands

The RCI uses a JSON-based command protocol over WebSockets. The following commands are available:

### Motion Control

| Command         | Description                                  |
| --------------- | -------------------------------------------- |
| `start_motion`  | Starts the motion simulation                 |
| `stop_motion`   | Stops the motion simulation                  |
| `pause_motion`  | Pauses the motion (simulator holds position) |
| `resume_motion` | Resumes motion after a pause                 |

### Profile Management

| Command                 | Description                                                                 |
| ----------------------- | --------------------------------------------------------------------------- |
| `get_profile_list`      | Retrieves the list of all games and their profiles                          |
| `set_game_profile`      | Selects a game and profile (requires `game_id` and `profile_id` parameters) |
| `get_current_selection` | Gets the currently selected game and profile                                |

### Settings

| Command           | Description                                                         |
| ----------------- | ------------------------------------------------------------------- |
| `get_settings`    | Retrieves current global gain and input gain values                 |
| `update_settings` | Updates gain settings (accepts `globalgain` and `inputgain` values) |

### Cue Configuration

| Command             | Description                                       |
| ------------------- | ------------------------------------------------- |
| `get_cue_config`    | Retrieves the current cue (profile) configuration |
| `update_cue_config` | Updates the cue configuration with new values     |

### Real-Time Broadcasts

The server automatically pushes state changes to all connected clients:

* **Motion state** — Sent whenever motion starts, stops, pauses, or resumes.
* **Pause state** — Sent when the motion is paused or resumed.
* **Profile list updates** — Sent when the game/profile list changes.
* **Settings updates** — Sent when gain values change from any source (UI, shortcuts, or another RCI client).
* **Cue config updates** — Sent when the active profile's cue settings change.

***

## Using with Stream Deck or Automation Tools

DR Sim Manager includes a **PowerShell command-line client** that makes it easy to integrate with automation tools like Stream Deck, Touch Portal, VoiceAttack, or any system that can execute commands.

The script is located at:

```
%userprofile%\AppData\Local\DRSimManager\RemoteControl\DRSM-WebSocket-Client.ps1
```

### Available Script Commands

| Command               | Example                                                                                                         |
| --------------------- | --------------------------------------------------------------------------------------------------------------- |
| Start motion          | `.\DRSM-WebSocket-Client.ps1 -Command "start"`                                                                  |
| Stop motion           | `.\DRSM-WebSocket-Client.ps1 -Command "stop"`                                                                   |
| Pause motion          | `.\DRSM-WebSocket-Client.ps1 -Command "pause"`                                                                  |
| Resume motion         | `.\DRSM-WebSocket-Client.ps1 -Command "resume"`                                                                 |
| List games & profiles | `.\DRSM-WebSocket-Client.ps1 -Command "list"`                                                                   |
| Select game & profile | `.\DRSM-WebSocket-Client.ps1 -Command "select" -Game "DCS World" -Profile "Default"`                            |
| Get current status    | `.\DRSM-WebSocket-Client.ps1 -Command "status"`                                                                 |
| Get settings          | `.\DRSM-WebSocket-Client.ps1 -Command "settings"`                                                               |
| Set gain values       | `.\DRSM-WebSocket-Client.ps1 -Command "set-gain" -GlobalGain 0.8 -InputGain 1.0`                                |
| Get cue config        | `.\DRSM-WebSocket-Client.ps1 -Command "get-cue-config"`                                                         |
| Set cue parameter     | `.\DRSM-WebSocket-Client.ps1 -Command "set-cue-param" -Cue "Primary" -Axis "sway" -Parameter "gain" -Value 7.5` |
| Enable/disable cue    | `.\DRSM-WebSocket-Client.ps1 -Command "enable-cue" -Cue "Primary" -Enabled $true`                               |
| Test connection       | `.\DRSM-WebSocket-Client.ps1 -Command "test-connection"`                                                        |

### Script Configuration

Open the script in a text editor and update the configuration section near the top:

* **`$ServerIP`** — The IP address of your DRSM PC (default: `127.0.0.1` for same machine).
* **`$ServerPort`** — The RCI port (default: `8000`).
* **`$UseHTTPS`** — Set to `$true` or `$false` to match your RCI mode setting.
* **`$Password`** — Your RCI password (leave empty if password protection is disabled).

### Stream Deck Setup

1. Add a **System > Open** action to a button.
2. Set the application to `powershell`.
3. Set the arguments to the script path and command, e.g.:

   ```
   "%userprofile%\AppData\Local\DRSimManager\RemoteControl\DRSM-WebSocket-Client.ps1" -Command "start"
   ```

### Custom WebSocket Integration

For custom integrations, you can connect directly to the WebSocket endpoint:

* **HTTP mode:** `ws://<server-ip>:<port>/ws`
* **HTTPS mode:** `wss://<server-ip>:<port>/ws`

Send JSON-formatted commands as described in the API Commands section above.

***

## Network Configuration

### Firewall

If you cannot connect from another device, you may need to allow the RCI port through Windows Firewall:

1. Open **Windows Defender Firewall with Advanced Security**.
2. Click **Inbound Rules** → **New Rule…**.
3. Select **Port**, click **Next**.
4. Select **TCP**, enter the port number (default: **8000**), click **Next**.
5. Select **Allow the connection**, click **Next**.
6. Check **Private** (and **Domain** if on a domain network), click **Next**.
7. Name it "DR Sim Manager Remote Control", click **Finish**.

### Port Forwarding

The RCI is designed for **local network use only**. Exposing it to the internet via port forwarding is not recommended due to the self-signed certificate and potential security risks.

***

## Security Considerations

* **Self-signed certificate:** The HTTPS certificate is self-signed, meaning browsers will display a warning. This is expected and safe for local network use.
* **Password hashing:** RCI passwords are hashed with SHA-256 and a pepper before storage. They are never stored or transmitted in plain text.
* **Timing-safe comparison:** Password verification uses constant-time comparison to prevent timing attacks.
* **Connection limits:** Maximum 5 simultaneous connections prevents resource exhaustion.
* **Local network only:** The server binds to `0.0.0.0` (all interfaces) but is intended for use within your local network only.

***

## Troubleshooting

* **Can't connect?** Make sure both devices are on the same network, the port is not blocked by your firewall, and the Remote Control Interface is enabled in Settings. Check the DR Sim Manager log for the server URL.
* **HTTPS not working?** Try switching to HTTP mode in Settings. Some devices or browsers may have issues with self-signed certificates.
* **Controls not responding?** Verify that a game and profile are selected in DR Sim Manager. Motion commands require a valid game/profile selection.
* **Connection rejected?** You may have reached the 5-connection limit. Close unused browser tabs or connections.
* **Mode change not taking effect?** Changing between HTTP and HTTPS requires the server to restart. The restart happens automatically — check the log for confirmation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.departedreality.com/dr-sim-manager/advanced/remote-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
