Skip to content

BillyMRX1/deskflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeskFlow

License: MIT Python 3.11+

Use your Windows laptop keyboard and mouse to control your Android phone — like Samsung Multi Control, but for any Android device.

Press a hotkey to toggle: your keyboard types on the phone, your mouse moves the phone cursor. Press it again to switch back.

How It Works

Windows Laptop                    Android Phone
+----------------+    WiFi/USB    +----------------+
| Python App     | ------------> | UHID Server    |
| - Captures     |   ADB + TCP   | - Virtual Mouse|
|   keyboard &   |               | - Virtual      |
|   mouse input  |               |   Keyboard     |
| - Hotkey toggle|               | - /dev/uhid    |
+----------------+               +----------------+

Requirements

  • Windows 10/11 laptop
  • Android 10+ phone
  • Python 3.11+
  • ADB (Android Debug Bridge) — comes with Android SDK Platform Tools
  • Zig (for building the Android binary) — pip install ziglang or download

Installation

cd deskflow
python -m venv .venv
source .venv/Scripts/activate   # Windows Git Bash
pip install -e ".[dev]"
pip install pywin32 ziglang

Build the Android binary (cross-compiles C to ARM64 using Zig):

cd android
bash build.sh    # outputs: android/uhid_server (aarch64, statically linked)
cd ..

Note: The build targets aarch64-linux-musl for static linking. This works on all ARM64 Android 10+ devices. If your phone uses a different architecture, modify the -target flag in build.sh.

Connecting Your Phone

Option A: WiFi (Wireless Debugging)

Step 1: Enable Developer Options

  1. Go to Settings > About phone
  2. Tap "Build number" 7 times until it says "You are now a developer"

Step 2: Enable Wireless Debugging

  1. Go to Settings > System > Developer Options
  2. Turn on "Wireless debugging"
  3. Tap into "Wireless debugging" to see the IP & port

Step 3: Pair (one-time)

  1. On your phone, tap "Pair device with pairing code"
  2. Note the pairing address:port and 6-digit code
  3. On your laptop terminal:
    adb pair <ip>:<pairing-port>
    # Enter the 6-digit code when prompted
  4. You should see: Successfully paired

Step 4: Connect

  1. On your phone's Wireless Debugging screen, note the IP & port at the top (NOT the pairing port)
  2. On your laptop:
    adb connect <ip>:<port>
  3. Verify:
    adb devices
    # Should show your device as "device"

Troubleshooting WiFi:

  • Phone and laptop must be on the same WiFi network
  • Some corporate/public networks block ADB — use a different network or USB
  • If adb pair fails with "protocol fault", run adb kill-server and retry
  • The pairing code expires quickly — get a fresh one if it fails
  • The wireless debugging port changes each time you toggle it

Option B: USB Cable

  1. Plug your phone into your laptop via USB
  2. On your phone, tap "Allow USB debugging" when prompted
  3. Verify: adb devices

This is the simplest option and has the lowest latency.

Option C: Phone Hotspot

If your WiFi blocks ADB:

  1. Turn on your phone's mobile hotspot
  2. Connect your laptop to the hotspot
  3. Follow the WiFi steps above (pair + connect)

Usage

1. Make sure ADB is connected (see above)

2. Start the app:

cd deskflow
source .venv/Scripts/activate
python -m deskflow.main

3. Connect: Right-click the tray icon (bottom-right of taskbar, may be in overflow) > Connect

4. Toggle input: Press Ctrl + Alt + K

  • Input goes to your phone (keyboard + mouse)
  • Your PC screen gets a transparent overlay to block accidental clicks

5. Toggle back: Press Ctrl + Alt + K again

  • Input returns to your laptop

6. Quit: Right-click tray icon > Exit (or Ctrl+C in terminal)

Configuration

Config file: ~/.deskflow/config.json

{
  "phone_ip": "192.168.0.101",
  "adb_port": 37745,
  "hotkey_toggle": "ctrl+alt+k",
  "mouse_sensitivity": 1.0,
  "scroll_sensitivity": 1.0
}
Setting Description
phone_ip Your phone's IP address
adb_port Wireless debugging port (or 5555 for USB)
hotkey_toggle Key combo to toggle input (default: ctrl+alt+k)
mouse_sensitivity Mouse speed multiplier (default: 1.0)
scroll_sensitivity Scroll speed multiplier (default: 1.0)

Known Limitations (v1)

  • Keyboard goes to both PC and phone — keys aren't suppressed on the PC side yet
  • Win key, Alt+Tab trigger Windows actions — these system hotkeys can't be intercepted
  • Wireless debugging port changes — you may need to reconnect after toggling wireless debugging
  • Android 10+ required — older versions may not grant /dev/uhid access

Project Structure

deskflow/
  android/
    uhid_server.c      # C server that creates virtual HID devices on Android
    build.sh           # Cross-compile script (uses Zig)
  src/deskflow/
    main.py            # Entry point, wires everything together
    config.py          # Config load/save
    controller.py      # Orchestrates input capture + forwarding
    toggle.py          # Hotkey toggle state machine
    input_hooks.py     # pynput hooks, Win32 cursor control, overlay
    sender.py          # TCP client sending input to phone
    protocol.py        # Binary protocol for mouse/keyboard events
    adb.py             # ADB connection management
    tray.py            # System tray icon
  tests/               # Unit and integration tests
  docs/plans/          # Design and implementation docs

Tech Stack

  • Python (pynput, pystray, pywin32) — Windows app
  • C (cross-compiled with Zig) — Android UHID server
  • ADB — connection and port forwarding
  • UHID (/dev/uhid) — virtual HID devices on Android

License

MIT — Brilian Ade Putra

About

Use your laptop keyboard and mouse on your Android phone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors