Turn your Android device into a professional USB Human Interface Device.
This Magisk module enables your rooted Android device to function as a Keyboard, Mouse, and Media Remote for any connected computer. It features a powerful, dependency-free Text-Based User Interface (TUI) that runs right in your terminal.
- Zero Dependencies: Built with
musllibc and statically linked. No external libraries required. - Cross-Platform: Runs on any Android version (Magisk/KSU) and standard Linux distros.
- Auto-Recovery: Intelligently detects HID failures and re-initializes the gadget driver automatically via
su.
The star of the show (hid-tui). A fully-featured GUI running inside your terminal:
- ⌨️ Laptop-Style Keyboard: Full 75% layout with clickable keys and visual press feedback.
- 🖱️ "Radar" Analog Mouse: Virtual analog stick with aspect-ratio corrected movement and "Velocity Tap" precision. Magnitude = Speed.
- 🤏 Drag & Drop: Dedicated
[HL],[HM],[HR]buttons to latch clicks for dragging. (Turns Magenta when locked). - 🎮 Media Deck: Full 14-key remote control (
PLAY,VOL,MUTE,BRIGHTNESS...). - 🌈 Visual Feedback: Keys flash and buttons light up when pressed.
- Shorthand CLI: Convenience wrappers (
hid-keyboard,hid-mouse) for automation scripting. - Sticky Modifiers: Smart handling of
CTRL,ALT,SHIFT,WINfor complex shortcuts. - DuckyScript 3.0: Fully compliant automation engine for sophisticated HID injection payloads.
- Download the latest
hid-gadget-module-v1.38.1.zip. - Open Magisk or KernelSU > Modules > Install from Storage.
- Select the zip file and reboot.
Launch it from any root terminal (Termux or adb shell):
su -c hid-tui- Top Bar: Media Controls (
PLAY,MUTE,VOL+, etc.). Tap to control playback. - Middle: The Radar Zone
[+].- Tap Center (
+) or perform a quick tap for a Left Click. - Move: Drag from center. Distance from center determines move speed (Velocity-Sensitive).
- Tap Center (
- Controls:
[ L ][ M ][ R ]: Standard clicks.[ HL ][ HM ][ HR ]: Hold toggles. Tap once to "lock" the button down. Ideal for dragging windows!SENS: Adjust mouse sensitivity (1x to 20x).
- Bottom: Full QWERTY keyboard with sticky modifiers.
If the gadget doesn't auto-start, run the setup script:
su -c hid-setupAutomate key presses and mouse movements from scripts.
Keyboard:
hid-keyboard "Hello World" # Type text
hid-keyboard CTRL-ALT-DEL # Send combo
hid-keyboard --hold SHIFT "hello" # Type with held modifier
hid-keyboard --release # Reset all statesMouse:
hid-mouse move 100 -50 # Move X=100, Y=-50
hid-mouse click left # Click left button
hid-mouse down right # Latch right buttonConsumer (Media):
hid-consumer VOL+ # Volume Up
hid-consumer PLAY # Play/Pause
hid-consumer BRIGHTNESS+ # Screen BrightnessWhile this module implements the 100% Core Specification, there are some platform-specific limitations:
- No
STORAGECommand: Unlike a physical USB Rubber Ducky, this module cannot mount a local SD card as a Mass Storage device via DuckyScript. You must use Android's native MTP/Storage features. HID_SYNC/WAIT_FOR_BUTTON: These commands are currently stubs. Synchronizing with target LED states (e.g., waiting for CapsLock) depends heavily on the Android UDC driver support, which is inconsistent across devices.- Extensions: Custom Hak5 vendor extensions (non-core) are not supported.
- UDC Drivers: Not all Android kernels support ConfigFS HID gadgets. If
hid-setupfails, your kernel may lackCONFIG_USB_CONFIGFS_F_HID. - USB Conflicts: Enabling the HID gadget may temporarily disconnect other USB functions like ADB or MTP on some devices, depending on how your specific kernel handles USB compositions.
- OTG Requirement: You must use a high-quality USB-C to USB-A (or equivalent) cable. Some "charging-only" cables lack the necessary data lines for HID communication.
We provide an automated build script that handles versioning, cross-compilation, and packaging.
Prerequisites: zig (v0.11+), make, zip.
# Clone the repo
git clone https://github.com/kelexine/hid-gadget-module
cd hid-gadget-module
# Build artifacts and create zip
./scripts/build_release.sh autoThis will create hid-gadget-module-v1.38.1.zip for all 4 architectures (arm64, arm, x86_64, x86).
This project is a collaborative effort to bring the best HID experience to Android.
- kelexine: Original Author & Core Architecture.
- rexackermann: Contributor, TUI Rewrite (v1.30+), & DuckyScript 3.0 Implementation.
License: MIT