From 8594733f9f39af8a147c9da87d351db272453541 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 18 Sep 2026 17:58:49 -0500 Subject: [PATCH 1/2] fix(switch_pro): bcdDevice is 0x0210; add max_power_ma / remote_wakeup identity constants A real Pro Controller reports device release 2.10 (not 2.00), 500 mA bMaxPower and remote wakeup. Correct bcd_device and add the other two as constants so emulators have one source of truth; the example feeds all three into espp::UsbDevice::Config (bcd_device / max_power_ma / remote_wakeup, #796). Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU --- components/switch_pro/README.md | 5 +++-- components/switch_pro/example/main/switch_pro_example.cpp | 4 ++++ components/switch_pro/include/switch_pro.hpp | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/switch_pro/README.md b/components/switch_pro/README.md index 4d3eff6ea1..16bdb3275c 100644 --- a/components/switch_pro/README.md +++ b/components/switch_pro/README.md @@ -70,8 +70,9 @@ Key class: `espp::SwitchPro` (`switch_pro.hpp`) report setters. - `is_ready()` — whether the host has enabled input reports. - `set_battery_level()`, `set_trigger_elapsed_times()`. -- Identity constants: `vid`, `pid`, `bcd_device`, `bcd_usb`, `manufacturer_name`, - `product_name`, `input_report_id()`. +- Identity constants: `vid`, `pid`, `bcd_device` (2.10), `bcd_usb`, `max_power_ma` + (500), `remote_wakeup`, `manufacturer_name`, `product_name`, `input_report_id()` — + what a real Pro Controller reports; feed them to `espp::UsbDevice::Config`. ## Example diff --git a/components/switch_pro/example/main/switch_pro_example.cpp b/components/switch_pro/example/main/switch_pro_example.cpp index 2e271f360d..ed4c5193fc 100644 --- a/components/switch_pro/example/main/switch_pro_example.cpp +++ b/components/switch_pro/example/main/switch_pro_example.cpp @@ -51,6 +51,10 @@ extern "C" void app_main(void) { usb_cfg.pid = espp::SwitchPro::pid; usb_cfg.manufacturer = espp::SwitchPro::manufacturer_name; usb_cfg.product = espp::SwitchPro::product_name; + // descriptor details a Switch compares against a real Pro Controller + usb_cfg.bcd_device = espp::SwitchPro::bcd_device; + usb_cfg.max_power_ma = espp::SwitchPro::max_power_ma; + usb_cfg.remote_wakeup = espp::SwitchPro::remote_wakeup; usb_cfg.log_level = espp::Logger::Verbosity::WARN; espp::UsbDevice::HidFunction hid; diff --git a/components/switch_pro/include/switch_pro.hpp b/components/switch_pro/include/switch_pro.hpp index 376e39ae57..9b6396e19c 100644 --- a/components/switch_pro/include/switch_pro.hpp +++ b/components/switch_pro/include/switch_pro.hpp @@ -59,8 +59,10 @@ class SwitchPro : public espp::BaseComponent { // --- Nintendo Switch Pro USB identity (EMULATION ONLY; see the class note) --- static constexpr uint16_t vid = 0x057E; ///< Nintendo USB VID. static constexpr uint16_t pid = 0x2009; ///< Switch Pro Controller USB PID. - static constexpr uint16_t bcd_device = 0x0200; ///< bcdDevice. + static constexpr uint16_t bcd_device = 0x0210; ///< bcdDevice: a real Pro Controller reports 2.10. static constexpr uint16_t bcd_usb = 0x0200; ///< bcdUSB (USB 2.0). + static constexpr uint16_t max_power_ma = 500; ///< bMaxPower a real Pro Controller reports. + static constexpr bool remote_wakeup = true; ///< The configuration advertises remote wakeup. static constexpr const char *manufacturer_name = "Nintendo Co., Ltd."; ///< iManufacturer. static constexpr const char *product_name = "Pro Controller"; ///< iProduct. From 487afd532920fd29106a64d17649f19f7a851a18 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 18 Sep 2026 18:26:02 -0500 Subject: [PATCH 2/2] docs(switch_pro): document the USB identity constants in the example README and Sphinx page Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU --- components/switch_pro/example/README.md | 6 ++++++ doc/en/hid/switch_pro.rst | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/components/switch_pro/example/README.md b/components/switch_pro/example/README.md index 7eab713981..df2cbec33d 100644 --- a/components/switch_pro/example/README.md +++ b/components/switch_pro/example/README.md @@ -14,6 +14,12 @@ sweeping the left stick so a connected Switch shows live input. > (`0x057E` / `0x2009`) so a real Switch will bind it. Use it to test against a > Switch you own. +The USB device descriptor is filled from the `espp::SwitchPro` identity +constants: VID/PID, manufacturer / product strings, and the details a Switch +compares against a real controller — `bcd_device` (device release 2.10), +`max_power_ma` (500 mA) and `remote_wakeup` — passed to +`espp::UsbDevice::Config::bcd_device` / `max_power_ma` / `remote_wakeup`. + ## How to use ### Hardware Required diff --git a/doc/en/hid/switch_pro.rst b/doc/en/hid/switch_pro.rst index d513b88bce..61bc2972bd 100644 --- a/doc/en/hid/switch_pro.rst +++ b/doc/en/hid/switch_pro.rst @@ -20,6 +20,17 @@ descriptor and report packing come from the ``hid-rp`` component. (exposed as ``espp::SwitchPro`` constants). Use these to emulate / test against a Switch you own; do not ship a product impersonating Nintendo hardware. +USB identity constants +---------------------- + +``espp::SwitchPro`` carries everything the USB device descriptor needs to look +like a real Pro Controller, so an emulator has one source of truth: ``vid``, +``pid``, ``bcd_usb``, ``manufacturer_name``, ``product_name``, plus the details a +Switch compares against the original -- ``bcd_device`` (device release 2.10), +``max_power_ma`` (500 mA bus power) and ``remote_wakeup``. Feed them to +``espp::UsbDevice::Config`` (``vid`` / ``pid`` / ``manufacturer`` / ``product`` / +``bcd_device`` / ``max_power_ma`` / ``remote_wakeup``), as the example does. + .. ------------------------------- Example ------------------------------------- .. toctree::