Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/switch_pro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions components/switch_pro/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions components/switch_pro/example/main/switch_pro_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
finger563 marked this conversation as resolved.
usb_cfg.log_level = espp::Logger::Verbosity::WARN;

espp::UsbDevice::HidFunction hid;
Expand Down
4 changes: 3 additions & 1 deletion components/switch_pro/include/switch_pro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
finger563 marked this conversation as resolved.
static constexpr const char *manufacturer_name = "Nintendo Co., Ltd."; ///< iManufacturer.
static constexpr const char *product_name = "Pro Controller"; ///< iProduct.

Expand Down
11 changes: 11 additions & 0 deletions doc/en/hid/switch_pro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
Loading