v2.1 MIT · open source Root required 100% local

Bring the S Pen back to life on your rooted Note

SPGF (SPenGestureFix) is a local-first toolkit that restores programmable barrel-button gestures and a classic Air Command wheel on AOSP/LineageOS Notes, streams the Wacom digitizer to your PC, and drives it all from a portable Windows panel — no Samsung framework, no cloud, no telemetry.

—
APK downloads
—
GitHub stars
0
languages
0
mapped actions
14:57

Tap the pen to open Air Command

Why it exists

Custom ROMs kill the pen.
This brings it back.

The problem

Flash AOSP or LineageOS on a Galaxy Note and Samsung's entire S Pen framework disappears. Air Command is gone, the barrel button goes dead, and one of the best Wacom digitizers ever shipped in a phone becomes just another input node nobody listens to.

The solution

SPGF talks to the kernel directly. A root shell reads raw events from sec_e-pen and the w1 presence switch, a state machine decodes clicks and hovers, and a foreground service drives overlays, actions and a normalized tablet stream. The Windows side mirrors the desktop and injects pen input back. No Samsung framework, no cloud, no telemetry.

Product capabilities

Everything the pen should do

All running locally on your devices, with nothing phoning home.

Programmable side button

Single click, double click and long press each run an independent action — remap them anytime from the dashboard.

Air Command wheel

A configurable radial fan anchored lower-right like classic Note Air Command — up to seven slots in the classic skin, custom accent color, real color picker, open/close sounds, optional open-on-extraction.

The classic skin opens with the original 18-frame SpenCommand animation — bitmaps extracted from Samsung's own APK, replayed at the authentic 20 ms per frame (360 ms), and reversed on close. The modern arc springs open with an overshoot ease instead.

Quick Notes

Fully offline notes with editing, search, copy, sharing, character counting, phone-number dialing and Maps lookup.

Screen tools

Annotate a screenshot with Screen Write, or crop a precise rectangle with Smart Select — both use coordinate-correct bitmap mapping.

Wacom Mode

Tunable pressure curves, monitor-matched orientation, smoothing, haptics, configurable pen button — plus a normalized TCP stream for the PC.

Portable Windows panel

A single SPGF_WacomGUI.exe — no installer, no Python — with a live desktop mirror, adb detection, every streaming option, a filterable log and a photo card for each detected Note generation.

Modern UI · 17 languages

Jetpack Compose + Material 3, localized into English, Italian, Spanish, French, German, Portuguese, Dutch, Polish, Turkish, Russian, Ukrainian, Chinese, Japanese, Korean, Arabic, Hindi and Indonesian.

Local-first by design

No accounts, no analytics, no network calls beyond your own LAN stream. Every byte is parsed on-device from your kernel's input stream.

Interactive demo

The barrel button, reborn

Pick a gesture to see how a real mapping behaves. Every gesture is fully remappable in-app.

Single click
Screenshot
Captured into Pictures/SPenScreenshots
Hardware architecture

From kernel events to actions

Phone Wacom drivers surface as Linux input devices, not reliable USB HID gadgets — so the service reads getevent -l through a root shell and owns every layer of the pipeline.

  1. 1

    Kernel devices

    sec_e-pen carries absolute X/Y, pressure, hover, tip and barrel-button events. The separate w1 node reports physical S Pen insertion/removal through a device-specific switch code.

  2. 2

    Isolated readers

    Each device gets its own EPenInputReader process running exec getevent. Stopping one reader never kills another process — a lesson learned the hard way.

  3. 3

    State machine

    PenGestureAnalyzer decodes single/double/long presses and hover transitions without ever blocking the digitizer stream.

  4. 4

    Orchestrator

    SPenGestureService, an Android foreground service, routes results to overlays, broadcasts, mapped actions and the tablet capture pipeline. Overlay operations run only on the main thread.

  5. 5

    Exclusive Wacom Mode ownership

    Entering Wacom Mode pauses the normal reader and takes exclusive ownership of sec_e-pen, handing it back on exit. Two readers never compete for the same kernel stream — and a back event can't leave Wacom Mode accidentally.

Smart presence detection

Some ROMs never report the live switch, so presence also follows real activity: any pen event marks it extracted, and 5 seconds of silence marks it inserted again. This never gates the digitizer pipeline.

Discovery fallbacks

Devices are found via /proc/bus/input/devices, falling back to getevent -lp because some ROMs deny the proc file even to root. Initial slot state can come from driver nodes like epen_connection (OK/NG).

Clean overlay scope

Compose pointer input stays local to a screen or the compact wheel window. The service never intercepts Android MotionEvent dispatch, so normal touch keeps working everywhere else.

Wacom Mode

Your Note becomes a drawing tablet

Stream pressure-aware pen input straight into any desktop app on your PC — over ADB or Wi-Fi.

  • Tunable pressure curves with JVM-tested math
  • Monitor-matched orientation with a forced landscape default for horizontal monitors
  • Physical display metrics detection plus a one-tap resolution reset after rotation or monitor override
  • Manual monitor override for unusual setups
  • Haptics feedback and configurable input smoothing
  • Pen button maps to right-click, middle-click, eraser or disabled
  • Normalized TCP stream on port 7654 for any client

Wire protocol

stream format · tcp://phone:7654
# optional newline-terminated metadata record:
#SPEN_TABLET 1 1920 1080 1 landscape

# then one record per frame:
X,Y,P,FLAGS
Frame flag bits
BitMeaning
1Tip pressed
2Right / barrel button
4Eraser end
8In-range (hover)
16Middle button

Axis mapping happens once on the phone; the Windows client only re-orients when its monitor aspect differs from the source metadata. Legacy clients can safely ignore the comment line.

Connect your PC

Two ways in: the classic console scripts/SPGF_Wacom.py for terminal lovers, or the graphical SPGF_WacomGUI.exe with the live mirror below. Both drive the same engine — DPI-aware cursor injection over SendInput, or the TCP stream over Wi-Fi.

terminal
# discover devices and real axis limits
python scripts\SPGF_Wacom.py --list

# ADB mode over USB
python scripts\SPGF_Wacom.py --screen-w 1920 --screen-h 1080

# or just run the portable panel and press Start
SPGF_WacomGUI.exe
New in v2.x · Windows

The desktop control panel

One portable exe that mirrors, configures and monitors the whole stream — built for people who never want to open a terminal.

The SPGF Windows panel: sidebar, live mirror, stat tiles and controls
Dashboard page — live mirror of exactly what the phone receives, stat tiles and session controls.

Five focused pages

Dashboard (mirror + controls), Phone (detection + photo database), Options (connection, quality, capture), Log and Guide — keyboard shortcuts included.

Knows your Note

adb detection matches the model code to the generation — from the 2011 Note to the Note20 Ultra, Note Edge and Note7 included — and shows a real photo with author and licence credits.

Portable by design

No installer, no Python, no registry: one exe, settings in a JSON file next to it, fonts resolved at runtime, window clamped to the screen. Copy the folder to a USB stick and it just works.

Live encoder feedback

FPS, JPEG quality, scale and frame counters update in real time; the mirror frame turns green when live and amber when paused, and the adaptive encoder degrades gracefully on weak Wi-Fi.

Action library

Twelve actions. Infinite combos.

Assign any action to any side-button gesture or any wheel slot.

Open app

Launches a selected launcher application.

Open S Pen Wheel

Opens or closes Air Command.

Screenshot

Captures into Pictures/SPenScreenshots.

Screen Write

Captures and annotates a screenshot.

Smart Select

Crops a selected rectangle from a screenshot.

Quick Note

Opens the offline note editor.

App search

Searches launcher applications and opens one.

Pen Window

Starts a selected app in an experimental freeform window.

Flashlight

Toggles the available camera torch.

Wi-Fi / Bluetooth

Runs the corresponding rooted svc command.

Mute / Lock screen

Sends the relevant rooted key event.

Custom root command

Runs an explicitly configured root command.

Changelog

How the project grew

The milestones, newest first — full details in the README release notes.

  1. 2.1

    Desktop panel polish · MIT

    Dark Windows titlebar, branded empty state and live border on the mirror, gallery selection ring, focus rings, status icons — and the project relicensed under MIT with a mandatory attribution clause. The app is now simply named SPGF.

  2. 2.0

    The portable Windows panel

    The desktop panel was rewritten around five pages with a graphite theme, real photos for all eleven Note generations (fetched from Wikimedia Commons with credits), proportional hero renders, and a single-file portable exe — no Python needed on the target machine. Fixed a startup crash that kept the old panel in smoke-test mode forever.

  3. 1.7

    Hub dashboard & wheel overhaul

    Hub dashboard with section tiles, classic wheel up to seven slots with pixel-perfect bitmap discs, real HSV color picker, wheel sounds fixed for both styles — and the classic skin now opens with Samsung's original 18-frame SpenCommand animation (20 ms per frame, reversed on close).

  4. 1.6

    Desktop Duplication capture & app-gated input

    Preview streaming gained a DXGI capture path with GDI fallback, input injection became app-gated, and runtime channels landed.

  5. 1.2

    Preview mode

    Screen mirroring from Windows to the phone via ADB while keeping the stylus working — you see on the Note exactly what the PC sends, at real quality.

  6. 1.0

    First public release

    Rooted barrel-button gestures, Air Command wheel, Quick Notes, screen tools and the first ADB-first Wacom emulator for Windows.

Gallery

Straight from the devices

Real captures from the tested hardware and the desktop panel.

The SPGF Windows panel dashboard with the live mirror and controls
The SPGF_WacomGUI panel — portable exe, live mirror, one click away
Getting started

From clone to working pen

Everything you need before the first gesture fires.

Requirements

  • Samsung Galaxy Note 3 SM-N9005 for the tested configuration, or a compatible Wacom kernel device for experimental use
  • Root access via Magisk, SuperSU or an equivalent su
  • An AOSP/LineageOS-based ROM that exposes the input devices
  • Display over other apps permission for the wheel
  • Notification permission on Android 13+ for the foreground service
  • Windows 10/11 for the desktop panel (portable exe — nothing to install)

Build & install

shell
# From the repository root (Gradle 8.x or bundled .tools/gradle-8.13)
gradle :app:assembleDebug

# Install on a connected device
adb install -r app/build/outputs/apk/debug/app-debug.apk

Kotlin · AndroidX · Jetpack Compose · Material 3 — no NDK or JNI required.

First launch checklist

  1. Grant root access when requested.
  2. Grant Display over other apps for the wheel.
  3. Allow notifications on Android 13+.
  4. Start the S Pen service from the dashboard — it must stay running, because extraction is a Linux input event, not a system broadcast.
  5. Enable Open wheel on S Pen extraction for automatic Air Command.
  6. Configure side-button gestures, the wheel slots and the accent color.
  7. Run SPGF_WacomGUI.exe on the PC, press Detect, then Start streaming.
  8. In Wacom Mode, tap Detect device resolution after changing orientation or a monitor override.

The service notification reports whether the digitizer reader is active. If the kernel device is missing, the app stays usable as a configuration tool and reports the failure instead of blocking the UI.

Hardware compatibility

Tested where it matters

Tested end-to-end

Samsung Galaxy Note 3 SM-N9005

The only hardware validated on the connected rooted ROM used by this repository. Everything — presence switch, digitizer axes, Wacom Mode, the wheel — is tuned against this device.

Potential · unverified

  • Galaxy Note 4 / Edge / 5 / 7
  • Galaxy Note 8 / 9 / 10 / 20
  • Galaxy Tab models with a Wacom digitizer
  • Any rooted Android hardware exposing a Linux input node with ABS_X, ABS_Y, pressure, BTN_TOUCH and BTN_STYLUS

Each target needs its own device-name, axis-range, switch-polarity, kernel-permission and orientation validation. An S Pen slot alone implies nothing.

Diagnose your device

adb
# Inspect input devices without changing state
adb shell su -c "getevent -lp"

# Watch the app's own logs
adb logcat -s SPenGestureService EPenInputReader SPenDebug

Expected capabilities include BTN_TOUCH, BTN_STYLUS and BTN_DIGI. The service accepts switch codes 001a, SW_001A and common pen-switch aliases; if the switch never fires, the 5-second activity fallback takes over.

Honest engineering

Limitations & project map

No magic, no overpromises — here is exactly what this tool is and isn't.

Known limitations

  • Text-based getevent parsing has slightly more latency than a native binary reader.
  • No Samsung handwriting recognition — Screen Write and Smart Select are deliberately simple utilities.
  • Pen Window and root toggles depend on the ROM and aren't available on every build.
  • Android overlay policy and the kernel can limit touch passthrough or background execution.
  • The wheel is intentionally compact with no blurred backdrop: Android can't blur another app's private pixels, and a small window never blocks unrelated touches.
  • If a ROM mounts the panel in reverse, pick Landscape (inverted) or use --orientation landscape-inverted.

Project map

SPenGestureService.kt
Foreground orchestration and runtime state
EPenInputReader.kt
Isolated root input reader and event parser
EventDeviceFinder.kt
Stable device discovery and capability limits
PenGestureAnalyzer.kt
Non-blocking button and hover state machine
WheelOverlay.kt
Compact lower-right Canvas Air Command overlay
MainComposeScreen.kt et al.
Material 3 screens (notes, tablet UI)
TabletInputCapture.kt
Capability-aware normalized frames
TabletNetworkServer.kt
Latest-frame TCP transport
scripts/SPGF_Wacom.py
ADB-first PC emulator (classic console)
scripts/SPGF_WacomGUI.py
Portable Windows control panel
site/
This landing page, deployed on Vercel
docs/TRANSLATION.md
Documentation and localization workflow

Testing

JVM tests are hardware-free
gradle :app:testDebugUnitTest
python scripts\test_i18n.py
python scripts\test_spen_mouse_emulator.py

Covers input parsing, presence decoding, the five-second idle rule, coordinate normalization and pressure curves. A connected phone is recommended for final acceptance testing because switch codes and polarity are kernel-specific.

Download

Get SPGF

Grab the latest APK and the portable Windows panel straight from GitHub Releases — or build them yourself from source.

SPGF app icon Android

SPGF com.spengesturefix

Rooted Android · AOSP/LineageOS-based ROM · Wacom digitizer required. Root via Magisk/SuperSU, overlay permission and notifications on Android 13+.

— stars — downloads
Windows · v2.1

SPGF_WacomGUI.exe portable · ~20 MB

Windows 10/11 · no installer, no Python. Settings live next to the exe; copy the file anywhere. USB detection uses adb if present, otherwise set the phone IP manually.

Release history

License

MIT, with credit where it's due

SPGF is free and open source under the MIT license. You can use, study, modify and redistribute it — including in your own fork or rebranded build — with one condition:

Any copy, fork, modification or redistribution — including renamed or rebranded versions — must credit the original project: SPenGestureFix (SPGF) by Clutsy — github.com/Clutsy/SPenGestureFix — in the source tree, in the app's About screen, in the documentation and on any download page.

The full wording lives in the LICENSE file. Independent open-source project — not affiliated with or endorsed by Samsung. S Pen and Galaxy Note are trademarks of Samsung Electronics.

Open source · MIT

Ready to wake up your pen?

Clone it, build it, flash your gestures back. Star the repo if it saves your Note from a drawer.