DEV Community

luminia210
luminia210

Posted on

I built a C library to inject multitouch into Android over USB — no root, no ADB, no app

Background

I'm 14, and I wanted to automate touch input on Android from a PC
with as little latency as possible — mainly for game automation
and key mapping.

After researching, I found that AOA (Android Open Accessory)
HID-only mode was the right approach. It's much lower latency
than adb input tap because it bypasses the ADB stack entirely
and sends raw HID reports directly over USB.

I found existing projects for mouse and keyboard HID over AOA,
but nothing for touch panels. So I first built a small program
that reads touch events from a CSV and replays them via AOA HID.
Once that worked, I realized the transport layer could be useful
for a lot of other things, so I extracted it into a library.

What it does

libaoa_hid registers a virtual HID digitizer on Android over
a plain USB cable and streams raw touch reports to it.

  • No root
  • No ADB
  • No companion app on the Android side
  • Up to 16 simultaneous touch points
  • Works on Linux, macOS, and Windows (MinGW-w64)
  • Requires Android 4.1+

The library is a pure transport pipe — no retry logic, no sleep
calls. Timing and error handling are left entirely to the caller.

How it works

AOA 2.0 allows a USB host to register a HID device on Android
without any app on the Android side. The tricky part was getting
the HID descriptor right for a multitouch digitizer — Android
has specific requirements around contact count reporting and
hybrid mode that aren't well documented.

Quick example

AoaDevice *dev = aoa_hid_connect(1600, 2560, 10);
sleep_ms(500); // wait for Android to register the HID device

HidReport r;
memset(&r, 0, sizeof(r));
r.report_id                 = 1;
r.finger[0].tip_inrange_pad = AOA_FINGER_DOWN;
r.finger[0].contact_id      = 0;
r.finger[0].x               = 400;
r.finger[0].y               = 800;
r.contact_count             = 1;
aoa_hid_send_report(dev, &r);

aoa_hid_disconnect(dev);
Enter fullscreen mode Exit fullscreen mode

Use cases

  • Game automation and key mapping
  • UI test automation
  • Robotics / embedded setups that need to drive an Android display

Coming soon

I'm currently working on a companion tool that records tap events
via ADB, converts them to CSV, and replays them through
libaoa_hid — so you can record any interaction and reproduce it
exactly. Will be released when it's ready.

Links

GitHub: https://github.com/luminia210/android-hid-multitouch

Feedback on the API design very welcome.

Top comments (0)