Per-repo documentation — each repo's docs/ and README, ingested and associated with the repo. Rendered through the <<<RepoDocs>>> tag.
← serial_keyboard docs · README.md
Turn a Raspberry Pi into a USB HID keyboard driven over serial / TCP / stdin — type keystrokes into whatever host the Pi is plugged into. Sibling of squashpi's g_ether: same dwc2 USB-gadget path, but the g_hid function makes the Pi a keyboard instead of an ethernet device.
- keymap.py — US boot-keyboard map (char -> HID usage + shift) + decode() for inspection/tests. - hid.py — output backends: HidgHID (writes to /dev/hidg0), MockHID (captures reports; runs on a Mac). - service.py — KeyboardService.type(text) / .key(name) / .run_lines(reader). - gadget.py — setup_script() generates the libcomposite HID-gadget configfs setup for the Pi.
# config.txt: dtoverlay=dwc2
sudo bash <(python3 -c "from serial_keyboard.gadget import setup_script; print(setup_script())")
# then drive it:
python3 -m serial_keyboard --serial /dev/ttyGS0 # or --tcp 8099, or pipe to stdin
python3 -m serial_keyboard --text "hello world\n"
On any other machine it falls back to a mock HID, so the logic is fully testable without hardware.