# RCWeb Tetris Control App

The **RCWeb Tetris Control App** (`app/tetris-c`) is the dedicated smart-gamepad designed specifically for the Tetris application. Operating within the **Asymmetric Pattern**, it provides tactile button inputs mapped directly to game events.

![icon](pwa-512x512.png "Tetris Control App Icon")

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

## What it does

- **Dedicated Controls**: Offers a simple, thumb-optimized layout specifically for directional movement, rotation, and hard-dropping blocks.
- **Dynamic Theming**: The interface changes color visually (turning neon Red or Blue) instantly when the main game assigns the connection a player slot.
- **Haptic Feedback**: Triggers short physical vibration pulses (`navigator.vibrate(20)`) upon every button press to provide physical confirmation of an action without requiring the player to look down.

## How it works

The internal `script.js` focuses on latency-free event binding.

- **Passive Polling**: Rather than the host querying clients, the controller enters a safe loop natively (`setInterval(..., 1000)`) passively checking `rc.send("tetris.join(" + player + ");", "tetris")` until the main screen explicitly accepts the payload and replies with a theme adjustment.
- **Event Binding**: Binds to both `touchstart` and `mousedown` simultaneously to ensure zero-latency tap recognition across both iOS and Android WebView environments.
- **Keyboard Fallback**: The controller transparently catches desktop keyboard events (`window.addEventListener("keydown")`), allowing a user to open the URL on a laptop and play using arrow keys if they lack a mobile device.
