rub-me is a small Go + cgo project that listens to macOS private MultitouchSupport events and detects a two-finger rubbing gesture on Apple Silicon trackpads.
- macOS on Apple Silicon (
darwin/arm64) - Go 1.26.1+
CGO_ENABLED=1(enabled by default on macOS)
MultitouchSupport is a private framework, so behavior can change across macOS versions.
go run ./cmd/rub-meOptions:
-cooldown(default900ms): minimum delay between detections-min-relative-speed(default0.08): required relative finger speed-min-flips(default3): required back-and-forth direction changes-debug(defaultfalse): print periodic raw frame diagnostics-audio(defaultaudio.mp3): play this file on detection (set empty to disable)
Example:
go run ./cmd/rub-me -debug -min-relative-speed 0.06 -min-flips 2 -audio ./audio.mp3internal/multitouch/shim.msubscribes to contact frame callbacks usingMTRegisterContactFrameCallback.internal/multitouch/multitouch_darwin_arm64.gobridges each native frame into Go structs.internal/rubbing/detector.gorecognizes rubbing when two fingers:- maintain a reasonable spacing,
- move mostly opposite each other,
- keep low center-of-mass drift,
- flip relative motion direction multiple times in a short window.
go test ./...