AirDesk is a native macOS prototype for webcam-based hand tracking and gesture-driven cursor control. The current runtime is implemented in Swift with AVFoundation for camera capture, Vision for hand-pose tracking, AppKit/CoreGraphics for overlay and mouse integration, and SwiftPM for building and testing.
The original Python/OpenCV/MediaPipe prototype has been retired from this repository. Historical Python packaging, tests, and PyInstaller configuration were removed so the Swift package is the only supported runtime.
- Captures live video from Desk View Camera when available, with fallback to the default webcam.
- Detects one hand using Apple Vision hand-pose observations.
- Mirrors normalized hand landmarks so motion feels natural on screen.
- Smooths the index fingertip cursor with a One Euro filter.
- Detects thumb-index pinch with hand-scale normalization, hysteresis, and debounce.
- Shows a transparent click-through overlay with a visible trackpad region, camera preview, and cursor bloom.
- Uses relative desk-trackpad motion by default, with live axis flips for camera orientation tuning.
- Keeps real macOS mouse events disabled by default behind an explicit command-line safety gate.
- macOS 14 or newer.
- Xcode or Command Line Tools with Swift 6.2 or newer.
- Camera permission for the process that launches AirDesk.
- Accessibility permission only when real system mouse control is enabled.
From the repository root:
cd AirDeskNative
swift build
swift run AirDeskChecksPreview-only mode is the default and does not post system mouse events:
cd AirDeskNative
swift run AirDeskNativeTo allow real macOS mouse control, opt in explicitly:
swift run AirDeskNative --enable-system-actionsTo start with system control already armed:
swift run AirDeskNative --enable-system-actions --start-armedWhen system actions are enabled, press S while AirDesk is focused to arm or disarm mouse-event posting. If the app is disarmed, hand tracking and the overlay continue to run, but no real mouse events are posted.
Runtime tuning keys:
S arm/disarm real mouse control
M switch relative/absolute control mode
X flip horizontal motion
Y flip vertical motion
Relative mode is the default and is intended for desk-surface control. The first frame inside the trackpad zone anchors the hand; movement after that moves the cursor by delta, like a physical trackpad.
flowchart LR
A["AVCaptureSession frame"] --> B["VisionTracker"]
B --> C["GestureEngine"]
C --> D["MouseController"]
C --> E["OverlayWindowManager"]
D --> F["macOS mouse events"]
E --> G["Transparent overlay"]
Each frame follows this flow:
CameraManagercaptures a BGRA video sample buffer.VisionTrackerrunsVNDetectHumanHandPoseRequest.GestureEnginesmooths the index fingertip and computes pinch state.MouseControllermaps desk-surface finger deltas into display movement and optionally posts mouse events.OverlayWindowManagerupdates the trackpad visualization, camera preview, and cursor bloom.
AirDeskNative/
Package.swift
Sources/AirDeskNative/
AirDeskNative.swift
Sources/AirDeskChecks/
main.swift
Sources/AirDeskCore/
CameraManager.swift
CommandLineOptions.swift
GestureEngine.swift
MouseController.swift
OneEuroFilter.swift
OverlayWindow.swift
VisionTracker.swift
Real mouse control is intentionally disabled unless --enable-system-actions is passed. --start-armed is rejected unless system actions are also enabled. Losing hand tracking, leaving the trackpad region, or disarming during a drag forces a mouse-up release to avoid leaving the system in a stuck drag state.
- Package the Swift runtime as a signed
.appbundle with camera usage metadata. - Add an in-app status/menu control for arming instead of relying only on the
Skey. - Add tuning controls for trackpad bounds, pinch thresholds, and smoothing.
- Consider a small UI test harness with recorded hand-landmark fixtures.