examples/dual/host_hid_to_device_cdc/README.md
A dual-role bridge: the board acts as a USB host on one root-hub port and a USB device on another at the same time, forwarding input from a connected HID keyboard/mouse to the host PC as text over a virtual serial port.
[addr] LMR x y wheel text lines. HID mount/unmount events are also announced over the CDC port. Data received from the PC on the CDC port is read and discarded (LED control is a TODO).(DEVICE-side interfaces only)
| Interface | Class driver |
|---|---|
| 0–1 | CDC (virtual serial) |
Notable tusb_config.h settings:
#define CFG_TUD_CDC 1
#define CFG_TUH_HUB 1
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
#define CFG_TUH_HID (3*CFG_TUH_DEVICE_MAX)
#define CFG_TUH_ENUMERATION_BUFSIZE 256
The board needs two usable USB ports: one acting as host (for the HID device) and one acting as device (to the PC).
CMake:
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
Make:
make BOARD=raspberry_pi_pico all
/dev/ttyACMx on Linux, a COM port on Windows).[1] L-- 3 -2 0 appear. Connecting or removing a HID device prints a mount/unmount message.