Medius - Native APIHardware

Ports

The three USB ports and how to cable them

Wire the box once at first plug-in; after that everything is software.

Inside are two ESP32-S3 microcontrollers and a CH343 USB-serial bridge. Your program only ever speaks to the CH343 serial port; the two chips talk over an internal 5 Mbaud link you never touch, separate from the 4 Mbaud control link.

PortConnects toRole
USB1Game PCThe clone (device chip), a copy of the mouse's USB identity, so the PC sees the same device it would if the mouse were plugged in directly.
USB2Control PCCH343 serial control, the /dev/ttyACM* port your program opens
USB3MouseReal mouse (host chip)

USB3 power hazard

The one wiring pairing to avoid

⚠️ USB1 and USB3 must never both connect to the same machine.

The USB3 5V rail can't be pulled low in firmware, so wiring both to one machine back-feeds power and can force a shutdown or drain the battery. Keep them on separate machines per the port table above.

Disconnecting

No power switch, just unplug

The box is USB bus-powered: no battery, no power button, nothing to power down. Turning it off means unplugging it, and that is safe at any moment. Injected input never outlives the program that sent it, so a button or move can't get stuck.

You unplugWhat happens
USB2 (control), or the program stopsAfter 1 s of silence the box clears all injection and falls back to pure passthrough. The real mouse keeps working.
USB1 (clone)The game PC sees an ordinary mouse unplug; the box drops its injection state.
USB3 (mouse)The box tears down the captured mouse cleanly and reports it detached.

To return to passthrough instantly instead of waiting out the silence timeout, send a RESET before unplugging (the library's reset). Dropping the Device stops its threads, after which the same timeout clears the box. Port order otherwise does not matter.

The one rule: USB1 and USB3 must not share a machine at any point, plugging in or unplugging. See the power hazard.