HIDAgent: UI Agent control of any HID-Compatible Device
The HIDAgent hardware bridge uses a Raspberry Pi Pico (RP2040) running CircuitPython to act as a USB HID keyboard/mouse for the target device, controlled by serial commands from your computer.
- Raspberry Pi Pico (or any RP2040-based board)
- USB cable (Pico → target device, e.g., iPhone via Lightning/USB-C adapter)
- USB-to-serial adapter (FTDI, CP2102, CH340, etc.) — connects Pico's UART to your control computer
- 3 jumper wires for the UART connection
- HDMI capture card for screen capture from the target device
- Download the CircuitPython
.uf2for your board from https://circuitpython.org/board/raspberry_pi_pico/ - Hold the BOOTSEL button on the Pico, plug it into your Mac via USB
- The Pico mounts as a USB drive named
RPI-RP2 - Drag the
.uf2file onto the drive — the Pico reboots and remounts asCIRCUITPY
- Download the CircuitPython library bundle from https://circuitpython.org/libraries (match your CircuitPython version)
- Copy these from the bundle's
lib/folder toCIRCUITPY/lib/:adafruit_hid/(folder)
Copy circuitpython/code.py to CIRCUITPY/code.py.
The Pico will auto-reload and start running it. The Pico is now ready to
act as a USB HID device.
Connect a USB-to-serial adapter to the Pico:
| Adapter | Pico (RP2040) |
|---|---|
| TX | GP1 (UART0 RX) |
| RX | GP0 (UART0 TX) |
| GND | GND |
The serial adapter should plug into your control computer's USB port and
appear as /dev/tty.usbserial-* (macOS/Linux) or a COM port (Windows).
- Plug the Pico's USB-A side into the target device (e.g., iPhone via Lightning-to-USB or USB-C adapter)
- The target device should recognize the Pico as a keyboard + mouse
- On iPhone, a small gray cursor circle will appear on screen
- On Mac/Windows, a regular mouse cursor appears
Plug the HDMI capture card into your control computer (USB) and into the target device (HDMI). The capture card should appear as a webcam in macOS camera settings.
Run the calibration procedure to learn the mapping between HID coordinates and pixel positions:
python test_calibration.pyThis takes ~5 minutes. The calibration result is saved to
hidagent/calibration.json and is automatically loaded on subsequent runs.
If you switch to a different target device, the calibration is keyed on
screen resolution so previous calibrations are reused automatically.
Install Python dependencies:
pip install -r requirements.txtSet up environment variables in .env:
ANTHROPIC_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
See examples/ for prototype applications:
claude_agent.py— UI agent using Claude Computer Uselocal_agent.py— Local UI agent using Gemma + Omniparserdata_collector.py— Automated UI dataset collectionscreen_reader.py— Web-based accessible interface for any devicehelpful_observer.py— Contextual help based on screen contentcross_device_interaction.py— Tasks spanning multiple devicessocial_media_scroller.py— Automated social media feed recording
You can develop and test HIDAgent examples using the macOS Simulator instead of physical hardware. See hidagent/simulator.py and examples/sim_demo.py.