Skip to content
All work

Case study · 02

osu!tab

Plays osu! with a Galaxy Tab and its S Pen as a pen tablet, over USB.

1.0.0Windows 11 · Galaxy Tab S8 Ultra

The osu!tab window on the PC, ready to play, next to the tablet showing a 120 × 75 mm pen area.

The numbers

median added latency
0.5 ms
median added latency
for 99% of pen reports
< 1 ms
for 99% of pen reports
from launch until the pen is ready
0.15 s
from launch until the pen is ready
the same through adb.exe
5.4 s
the same through adb.exe
ms, 99th percentile on a busy PC, direct USB
0.66–0.81
ms, 99th percentile on a busy PC, direct USB
ms, the same before tuning, through adb.exe
20.9–37.5
ms, the same before tuning, through adb.exe
simulated reports, 20 s, three runs each
480 Hz
simulated reports, 20 s, three runs each
saved by running on the faster cores
0.13 ms
saved by running on the faster cores

The problem

The problem

A Galaxy Tab with its S Pen is already a very good pen tablet, with a screen attached. osu!tab lets it work as one for osu! on Windows: over USB, without rooting the tablet, and with nothing to install on it by hand.

The goal was to put the cursor exactly where the pen is, as quickly as possible, with no smoothing or acceleration unless you turn it on.

How it works

From the pen to the cursor.

Galaxy Tab

  1. S Pen

    Kernel input device, /dev/input

  2. Helper (Rust)0.000 ms

    Reads the pen before Android does

USB

Direct to the debugging service

0.523 ms

Windows PC

  1. osu!tab (Rust)

    Maps the pen to the screen

  2. SendInput0.000 ms

    Moves the cursor

Median time per stage from the app's Latency page in one session at 481 Hz. The USB stage relies on clock alignment, so it's accurate to a fraction of a millisecond.
  1. 01

    Read the pen before Android does

    A small helper runs through Android's USB debugging connection and reads the S Pen from /dev/input, without root. Finger and palm input is on a separate device the helper never opens.

  2. 02

    Undo the kernel's smoothing

    Linux ignored pen movements under 0.02 mm and averaged those up to 0.08 mm, a few screen pixels on a small pen area. osu!tab turns that filter off while it holds the pen and puts it back when it lets go.

  3. 03

    Land on the right pixel

    The cursor can only sit on whole pixels, so osu!tab aims at the middle of the right one. Rounding in Windows can't push it onto the next.

  4. 04

    Tune for a busy PC

    It raises adb.exe to high priority, runs the tablet helper on the faster cores (about 0.13 ms off the median) and stops Windows treating osu!tab as background work.

Trade-offs

What each choice bought, and what it cost.

  • Reading /dev/input directly, not Android's input system

    GetsReports arrive earlier, and a resting palm can't move the cursor.

    CostsAndroid can't see the pen while osu!tab runs, so its palm rejection is off. The tablet app takes every touch instead.

  • USB debugging instead of root

    GetsIt works on a stock tablet, with nothing to install by hand.

    CostsUSB debugging gives the connected PC deep access to the tablet, so only allow PCs you trust.

  • Talking to the debugging service directly, not through adb.exe

    GetsThe pen is ready about 0.15 s after launch instead of 5.4 s, and there's no adb.exe to install.

  • A one-to-one cursor, with filters off by default

    GetsThe cursor is exactly where the pen is.

    CostsPen jitter reaches the cursor. The optional filters steady it at the price of a little lag.

  • Leaving out four tunings that didn't reliably help

    GetsThe multimedia scheduler, core pinning, WinUSB's RAW_IO and spinning on reads all kept medians at 0.52–0.56 ms, so they stayed out.

Not yet

What it doesn't do yet.

  • A worst case of about 12 ms shows up on every path, and its cause hasn't been found.
  • Real pen sessions sometimes stall for about 20 ms as the pen starts moving. That doesn't happen with simulated reports.
  • It has only been tested on a Galaxy Tab S8 Ultra, playing osu!lazer on Windows 11.
  • Sizes in millimetres assume the S8 Ultra's screen.

Built with

Built with

  • Rust
  • egui
  • Kotlin
  • C# (OpenTabletDriver plugin)
  • GitHub Actions
  • CodeQL

Every fact and number on this page comes from osu!tab's README and its guide.

Command palette

19 results