Opensource firmware for NRF52840 Pro Micro that copycats the Steam Controller 2 Puck and adds an Xbox and Switch mode
openpuck ARCHITECTURE.md

# OpenPuck Architecture This document is the map of the firmware. It explains what the device *is*, how the code is laid out, how data flows through it, and how to extend it. If you only read one thing before touching the code, read this. ## What the device is OpenPuck turns an **nRF52840 Pro Micro** into a clone of the Steam Controller 2 "puck" — the little USB radio dongle the controller pairs with. It does three jobs at once: 1. **Speaks the puck's RF protocol** to a real Steam Controller 2 ("Triton") over a bare-metal nRF radio (no SoftDevice, no BLE stack). It bonds controllers, transmits the host frame they reconnect on, and polls them for input at ~250 Hz. 2. **Presents a USB personality** to the host PC/console. The same controller input can be re-dressed as the Valve puck (for Steam), an Xbox 360 pad, a Switch controller, a PS5 DualSense, or a DS4 — selected at boot. 3. **Exposes config surfaces** — a WebUSB channel for the browser panel and a CDC serial console for debugging and the protocol reverse-engineering tooling. It runs as a **single-threaded `loop()`** plus **USB interrupt callbacks**. There is no RTOS task switching in our code; concurrency is cooperative. The only preemption is the USB stack's ISR (which calls our HID report callbacks) and the radio's hardware events (which we poll, never interrupt on). ## The big picture ``` ┌──────────────────────── host PC / console ────────────────────────┐ │ USB: one personality at a time (puck / xbox / switch / ps5 / ds4) │ └───────────────▲─────────────────────────────────▲──────────────────┘ │ HID reports │ WebUSB / CDC │ │ ┌────────────────────────┴─────────────┐ ┌──────────┴───────────┐ │ controllers.h (IController vtable) │ │ webusb_config │ │ mode_*.cpp — one per personality │ │ serial_console │…