Skip to content

Peterc3-dev/phonekb

Repository files navigation

PhoneKB

Turn your rooted Android phone into a USB keyboard + trackpad. Plug into any computer via USB cable, open the app, type.

Features

  • Ortholinear keyboard — full QWERTY grid layout, F-keys, modifiers, arrows, nav keys
  • Trackpad — swipe to move cursor, tap for left click, two-finger swipe for scroll
  • L/M/R click buttons below trackpad
  • Text blast — type into the text field and hit Send to output a string as keystrokes
  • Side swap — tap ⇄ to move trackpad between left/right side
  • Landscape-only, fullscreen, immersive
  • 21KB APK, zero dependencies

Requirements

  • Rooted Android phone (KernelSU, Magisk, etc.)
  • USB gadget configfs support (most phones have this)
  • SELinux permissive (or appropriate policy for /dev/hidg0)

How it works

The app configures a USB HID composite gadget via configfs with two Report IDs:

  • Report ID 1: Keyboard (8-byte boot protocol)
  • Report ID 2: Mouse (buttons + relative X/Y/wheel)

Both go through a single /dev/hidg0 device. The host computer sees a standard USB keyboard and mouse — no drivers needed.

Build

# Requires Android SDK (build-tools + a platform android-34 or newer).
# build.sh auto-detects the newest installed build-tools/platform; pin with
# BUILD_TOOLS_VERSION / COMPILE_SDK if you need a specific pair.
bash build.sh
# Output: build/PhoneKB.apk

Test

Pure (framework-independent) logic — the HID keymap, modifier bitmask, and mouse-delta clamping in com.phonekb.HidMap — has JUnit tests that run on a plain JDK with no Android SDK, emulator, or device:

bash run-tests.sh

This fetches JUnit 4 into .testlibs/ (gitignored) on first run. UI / Activity / Bluetooth code is not covered — that would need an instrumented device test, which isn't part of this suite.

CI

.github/workflows/ci.yml runs the unit tests and builds a debug APK on every push and pull request (uploaded as a build artifact). This is the first environment that compiles the app from source in CI.

Install

adb install PhoneKB.apk

First-time setup

The HID gadget must be configured once per boot (requires root):

# Via ADB or Termux with root:
su -c 'sh setup-hid.sh'

The app attempts this automatically on launch if su is available.

License

MIT

About

Turn your rooted Android phone into a USB keyboard + trackpad. 21KB APK.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors