# RCWeb Flight Control App

The **RCWeb Flight Control App** (`app/flight-c`) operates in tandem with the 3D Flight Simulator, providing a native **Asymmetric Pattern** tilt-stick controller.

## Screenshot
![screenshot](screenshot.png "Flight Control App")

## What it does

- **Virtual Flight Yoke**: Maps raw phone inclination directly to traditional aircraft control surfaces. Front/back rotation maps to the Elevator (pitch), Left/Right tilt to Ailerons (roll), and Z-axis pivoting to Rudder (yaw).
- **On-screen Muxing**: Outputs live formatted text readouts depicting exactly what `-1.0` to `1.0` percentage authority is currently being passed to each virtual control surface over the socket.
- **Dynamic Rescue Buttons**: If the host detects the browser prohibits `DeviceOrientation` (common on restricted mobile VPNs or desktops), it instantly strips the UI and swaps to a hardcoded layout of continuous-fire manual override buttons.

## How it works

The logic primarily revolves around math-heavy interpolation and latency optimization.

- **Baseline Normalization**: The script captures extreme edge cases of orientation angles (-180 to 180 degrees) securely tracking `beta`, `gamma`, and `alpha` baselines natively via `deltaAngle` normalization so the user doesn't physically strain their wrists.
- **Frequency Throttling**: Broadly limits WebSocket floods by strictly enforcing a `SEND_INTERVAL_MS = 70` heartbeat, transmitting merely ~14 lightweight string-encoded JSON payloads per second.
- **Button Capture Mechanics**: Manual control UI elements rely on strict `pointerdown/up` and `setPointerCapture(event.pointerId)` DOM implementations ensuring the user can slide their thumbs safely off buttons without the game failing to register the release command.
