← Back to docs

Input · input

Portal Input — Touch, Keyboard & Fusion Engine

Complete input pipeline for the Spaceboard: touch event normalization, multi-touch fusion engine (tracking → intent classification → action generation), QWERTY keyboard layout, and virtual keyboard/pointer via /dev/uinput. Includes portal-keyboardd, a standalone DRM/KMS binary that owns the eDP-1 display.

portal-inputv0.2.0input
34.5K
Lines of Code
922
Tests
207
Files

Architecture

Two components: (1) portal-input library — touch types/normalization, keyboard layout/models/state, fusion engine (tracker → classifier → actions), virtual devices (keyboard/pointer via uinput), zones/edge detection, gesture recognition, haptic feedback, telemetry. (2) portal-keyboardd binary (feature-gated) — DRM/KMS direct scanout, Cairo/Pango keyboard rendering, evdev touch parsing, action dispatch, app orchestrator with main loop. The fusion engine classifies each touch as Typing (y<50%, short duration), Pointing (y≥50%, deliberate movement), Gesture (high movement), or RestingPalm (3+ clustered touches).

Overview

portal-input is the input subsystem for the Spaceboard tactile surface. It implements the complete pipeline from raw touch events to virtual device output: touch events from the ELAN hid-over-i2c touchscreen are parsed via evdev Protocol B, normalized to [0,1] coordinates, fed into a fusion engine that tracks finger positions/velocities, classifies intent (Typing, Pointing, Gesture, or RestingPalm), and generates InputActions (KeyPress, PointerMove, Scroll, etc.). These actions are dispatched to virtual keyboard and pointer devices via /dev/uinput, which Wayfire sees as real input devices. The crate also includes portal-keyboardd, a standalone binary that directly owns the eDP-1 display via DRM/KMS dumb-buffer scanout, renders the QWERTY keyboard using Cairo/Pango, and handles the complete input loop without compositor involvement for the keyboard screen.

Key Types

ZoneIdInput zone identifier — Cardinality, Dimension, EdgeZone for edge gestures.
KeyCodeVirtual key codes matching the QWERTY keyboard layout.
InputActionEnum of input actions: KeyPress, PointerMove, PointerButton, Scroll, etc. Generated from classified intents.
FusionEngineOrchestrates the pipeline: TouchTracker (position/velocity/distance) → IntentClassifier (Typing/Pointing/Gesture/Palm) → ActionGenerator (InputActions from intent + context).
VirtualKeyboardVirtual keyboard device via /dev/uinput — key events injected into Wayfire's input stream.
VirtualPointerVirtual pointer device via /dev/uinput — mouse movement, button clicks, scroll events.
ModifierSetBitflag set of active keyboard modifiers (Shift, Ctrl, Alt, etc.).

Modules

touch

Touch event types and coordinate normalization — TouchEvent, TouchEventType, normalizer maps to [0,1].

keyboard

QWERTY keyboard layout with pixel-accurate key regions, key state management, VirtualKey enum.

fusion

Fusion engine — TouchTracker (position/velocity/distance), IntentClassifier (Typing/Pointing/Gesture/Palm rules), ActionGenerator.

gesture

Gesture recognition — multi-touch gesture detection (swipes, pinches, edge gestures).

haptic

Haptic feedback — vibration motor control for touch confirmation.

layout_engine

Layout engine — positions keyboard keys, calculates key regions for hit-testing.

output

Output handling — display surface management for keyboard rendering.

zones

Zone definitions — screen regions with different input behaviors (keyboard zone, trackpad zone, edges).

special_keys

Special key definitions — Backspace, Enter, Shift, Space, modifier combinations.

channels

Channel-based communication between input threads.

telemetry

Input telemetry — latency tracking, classification accuracy metrics.

thread_lifecycle

Thread lifecycle management — graceful shutdown of input processing threads.

Data Flow

ELAN touchscreen /dev/input/event2 → evdev Protocol B parsing → normalize to [0,1] → FusionEngine (tracker → classifier → actions) → VirtualKeyboard/Pointer → /dev/uinput → Wayfire (GLASSES-1). Keyboard rendering: Cairo/Pango → DRM dumb-buffer blit → eDP-1 scanout

Dependencies

External (17)

anyhow workspacethiserror workspacetracing workspacelibc 0.2fontdue 0.9serde 1serde_json 1evdev 0.13wayland-client 0.31wayland-backend 0.3smithay-client-toolkit 0.20glow 0.16cairo-rs 0.19pango 0.19pangocairo 0.19libloading 0.8ctrlc 3.4

External: evdev/rustix (raw input), drm/gbm (direct display), cairo/pango (keyboard rendering), glow (GLES shaders, Orange Pi only). portal-keyboardd requires --features keyboardd.