How wiredopposite/ogx-mini works
Purpose and Targets
OGX-Mini is embedded firmware that converts wired or Bluetooth game controllers into console-facing USB gamepad emulations. Its primary target is RP2040/RP2350 boards, with an ESP32 companion firmware for Bluetooth-capable hybrid builds. Supported output modes include Original Xbox, PS3, Switch, XInput, PlayStation Classic, DInput, and WebApp configuration mode.
Build and Firmware Entry Points
RP2040 builds are CMake projects selected by OGXM_BOARD and MAX_GAMEPADS; the executable begins at Firmware/RP2040/src/main.cpp. Board-specific compilation and SDK/submodule setup originate in Firmware/RP2040/CMakeLists.txt and Firmware/FWDefines.cmake.
ESP32 is an ESP-IDF project with its application entry points at Firmware/ESP32/main/main.c and Firmware/ESP32/main/main.cpp; its component wiring is in Firmware/ESP32/CMakeLists.txt.
RP2040 Runtime Orchestration
The RP2040 firmware coordinates board initialization, controller inputs, output emulation, persistent configuration, and deferred work. Firmware/RP2040/src/OGXMini/OGXMini.cpp is the product-level coordinator; Firmware/RP2040/src/TaskQueue/TaskQueue.cpp provides queued task execution. The board abstraction isolates physical variants, including native USB-host boards, Wi-Fi boards, RGB LEDs, ESP32 bridges, and four-channel setups: Firmware/RP2040/src/Board/board_api.cpp, Firmware/RP2040/src/OGXMini/Board/PicoW.cpp, and Firmware/RP2040/src/OGXMini/Board/ESP32_Bluepad32_I2C.cpp.
Controller Input Pipeline
Wired controllers enter through TinyUSB host callbacks, are identified/parsing-dispatched, then normalized into the shared gamepad model. Core boundaries are Firmware/RP2040/src/USBHost/tuh_callbacks.cpp, Firmware/RP2040/src/USBHost/HostDriver/HostDriver.h, and Firmware/RP2040/src/Gamepad/Gamepad.h. Protocol-specific host drivers cover Xbox/XInput, PlayStation, Switch, N64, DInput, and generic HID. Generic HID handling includes descriptor parsing under Firmware/RP2040/src/USBHost/HIDParser/HIDReportDescriptor.cpp.
Bluetooth and Companion Connectivity
Bluetooth-capable RP2040 variants use Bluepad32/BTstack integration, represented by Firmware/RP2040/src/Bluepad32/Bluepad32.cpp and Firmware/RP2040/src/btstack_config.h. Hybrid hardware can delegate Bluetooth to ESP32 over I2C through Firmware/RP2040/src/Board/esp32_api.cpp. The ESP32 firmware owns Bluetooth manager/server responsibilities in Firmware/ESP32/main/BTManager/BTManager.cpp and Firmware/ESP32/main/BLEServer/BLEServer.cpp, using ESP-IDF, BTstack, and Bluepad32-related dependencies.
Output Emulation and USB Device Boundary
Normalized gamepad state is converted into a selected USB device personality. Firmware/RP2040/src/USBDevice/DeviceManager.cpp selects and manages the active device driver; Firmware/RP2040/src/USBDevice/tud_callbacks.cpp connects it to TinyUSB device events. Concrete output implementations include XInput, Xbox OG, PS3, Switch, DInput, PlayStation Classic, UART bridge, and WebApp mode, e.g. Firmware/RP2040/src/USBDevice/DeviceDriver/XInput/XInput.cpp, Firmware/RP2040/src/USBDevice/DeviceDriver/XboxOG/XboxOG_GP.cpp, and Firmware/RP2040/src/USBDevice/DeviceDriver/WebApp/WebApp.cpp.
Configuration and External Interfaces
User profiles persist platform selection, mappings, dead zones, triggers, and up to multiple saved profiles. The central settings boundary is Firmware/RP2040/src/UserSettings/UserSettings.cpp, with profile serialization in Firmware/RP2040/src/UserSettings/UserProfile.cpp. The separately hosted WebApp communicates through the firmware’s WebApp USB/Bluetooth mode; its source is not present beyond the WebApp directory placeholder. Build infrastructure fetches and patches Pico SDK, TinyUSB, Bluepad32, BTstack, and Pico-PIO-USB dependencies under Firmware/external and Firmware/cmake.
Main entry points: OGXMini.cpp OGX-Mini coordinator · DeviceManager.cpp Device manager · Gamepad.h Normalized gamepad · UserSettings.cpp User settings
Components 22
Build
- RP2040 build · Selects board and gamepad capacity.
Firmware/RP2040/CMakeLists.txt - Firmware definitions · Sets shared SDK and dependency setup.
Firmware/FWDefines.cmake - ESP32 build
Firmware/ESP32/CMakeLists.txt
RP2040 firmware
- RP2040 entry
Firmware/RP2040/src/main.cpp - OGX-Mini coordinator · Coordinates board, inputs, outputs, and settings.
Firmware/RP2040/src/OGXMini/OGXMini.cpp - Board abstraction
Firmware/RP2040/src/Board/board_api.cpp - Board variants · Covers Pico W and ESP32 Bluepad32 I2C variants.
Firmware/RP2040/src/OGXMini/Board/PicoW.cpp - Deferred work queue
Firmware/RP2040/src/TaskQueue/TaskQueue.cpp - User settings · Stores profiles, mappings, and selected platform.
Firmware/RP2040/src/UserSettings/UserSettings.cpp - Profile serialization
Firmware/RP2040/src/UserSettings/UserProfile.cpp
Controller input
- TinyUSB host callbacks
Firmware/RP2040/src/USBHost/tuh_callbacks.cpp - Protocol host drivers · Handles Xbox, PlayStation, Switch, N64, DInput, and HID.
Firmware/RP2040/src/USBHost/HostDriver/HostDriver.h - HID descriptor parser
Firmware/RP2040/src/USBHost/HIDParser/HIDReportDescriptor.cpp - Normalized gamepad
Firmware/RP2040/src/Gamepad/Gamepad.h - Bluepad32 integration · Uses BTstack for Bluetooth-capable RP2040 variants.
Firmware/RP2040/src/Bluepad32/Bluepad32.cpp - ESP32 I2C bridge
Firmware/RP2040/src/Board/esp32_api.cpp
USB output
- Device manager · Selects the active USB gamepad personality.
Firmware/RP2040/src/USBDevice/DeviceManager.cpp - TinyUSB device callbacks
Firmware/RP2040/src/USBDevice/tud_callbacks.cpp - Output device drivers · Includes XInput, Xbox OG, PS3, Switch, DInput, PlayStation Classic, UART, and WebApp.
Firmware/RP2040/src/USBDevice/DeviceDriver/XInput/XInput.cpp
ESP32 companion
- ESP32 application
Firmware/ESP32/main/main.cpp - Bluetooth manager
Firmware/ESP32/main/BTManager/BTManager.cpp - BLE server
Firmware/ESP32/main/BLEServer/BLEServer.cpp
Connections 24
- Firmware definitions → RP2040 build: shared setup
- RP2040 build → RP2040 entry: builds
- RP2040 entry → OGX-Mini coordinator: starts
- OGX-Mini coordinator → Board abstraction: initializes
- Board abstraction → Board variants: implements
- OGX-Mini coordinator → Deferred work queue: defers work to
- OGX-Mini coordinator → User settings: loads and saves
- User settings → Profile serialization: serializes
- TinyUSB host callbacks → Protocol host drivers: dispatches reports
- Protocol host drivers → HID descriptor parser: parses generic HID
- Protocol host drivers → Normalized gamepad: normalizes to
- Bluepad32 integration → Normalized gamepad: normalizes to
- OGX-Mini coordinator → TinyUSB host callbacks: coordinates input
- OGX-Mini coordinator → Bluepad32 integration: enables Bluetooth
- ESP32 I2C bridge → Normalized gamepad: receives controller state
- OGX-Mini coordinator → ESP32 I2C bridge: uses on hybrid boards
- Normalized gamepad → Device manager: supplies state
- User settings → Device manager: selects mode
- Device manager → Output device drivers: activates
- Device manager → TinyUSB device callbacks: manages
- ESP32 build → ESP32 application: builds
- ESP32 application → Bluetooth manager: starts
- Bluetooth manager → BLE server: serves BLE
- Bluetooth manager → ESP32 I2C bridge: forwards over I2C