Gestures & Glide Typing
Relevant source files
The following files were used as context for generating this wiki page:
- app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingManager.kt
- app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt
- app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingClassifier.kt
- app/src/main/kotlin/dev/patrickgold/florisboard/lib/devtools/Devtools.kt
- app/src/main/res/values/strings.xml
The Gestures and Glide Typing system in Ownkey Keyboard provides a modern input method where users can input words by sliding their finger across the keys (glide typing) or perform specific keyboard actions through directional swipes. The system leverages a statistical classifier to translate raw pointer movements into word candidates and a management layer to synchronize these inputs with the keyboard's Natural Language Processing (NLP) engine and UI components.
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingManager.kt, app/src/main/res/values/strings.xml:618-622
System Architecture
The glide typing feature is built on a decoupled architecture consisting of a manager, a classifier interface, and a concrete statistical implementation.
Key Components
| Component | Description |
|---|---|
GlideTypingManager | Orchestrates the flow between the gesture detector and the classifier. Handles asynchronous suggestion updates. |
GlideTypingClassifier | An interface defining the contract for processing gesture points and returning suggestions. |
StatisticalGlideTypingClassifier | The primary implementation that compares user gestures against "ideal gestures" generated from dictionary words. |
Pruner | Internal utility within the classifier used to filter out unlikely word candidates based on length and extremities to save cycles. |
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingManager.kt:29-35, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingClassifier.kt:22-26, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:40-45
Data Flow Overview
The following diagram illustrates how a touch gesture is processed from the initial point addition to the final word commitment in the text field.
The system ensures that compute-heavy tasks like suggestion generation occur on a background thread (Dispatchers.Default) to prevent UI micro-pauses.
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingManager.kt:85-115, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:180-220
Statistical Classifier Logic
The StatisticalGlideTypingClassifier determines the intended word by calculating the probability that a user's gesture matches the "ideal" path for words in the dictionary.
Ideal Gesture Generation
For every candidate word, the system generates an "ideal gesture" by connecting the centers of the keys corresponding to the word's characters. It accounts for double letters (e.g., "pool") by adding small loops at the key's location to differentiate them from single-letter paths.
Comparison Metrics
The classifier uses two primary standard deviations to evaluate similarity:
- Shape Similarity (
SHAPE_STD): Expressed for normalized gestures, independent of keyboard size. - Location Similarity (
LOCATION_STD): Dependent on key radius and actual keyboard dimensions.
The final confidence score is calculated using Gaussian probability:
Confidence = 1.0 / (ShapeProbability * LocationProbability * WordFrequency)
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:66-83, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:195-205
Optimization through Pruning
To maintain performance, a Pruner filters the dictionary before intensive calculations:
- Extremity Pruning: Matches the start and end points of the user gesture to words that start and end near those keys.
- Length Pruning: Discards words whose ideal gesture length differs from the user's gesture length by more than a specific threshold (
PRUNING_LENGTH_THRESHOLD).
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:255-275, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/StatisticalGlideTypingClassifier.kt:294-315
Configuration & User Interaction
Users can customize gesture behavior through the keyboard settings. These preferences are mapped to the logic in GlideTypingManager.
User Preferences
| Preference Key | Description |
|---|---|
pref__glide__enabled | Toggles the entire glide typing system. |
pref__glide__show_trail | Enables the visual "glide trail" following the finger. |
pref__glide_trail_fade_duration | Configures how long the trail remains visible after the finger moves. |
pref__glide_preview_refresh_delay | Frequency of suggestion updates while a glide is in progress. |
pref__glide__immediate_backspace_deletes_word | If enabled, pressing backspace immediately after a glide deletes the entire word instead of one character. |
Sources: app/src/main/res/values/strings.xml:619-631, app/src/main/kotlin/dev/patrickgold/florisboard/ime/text/gestures/GlideTypingManager.kt:69-75
Swiping Actions
Beyond glide typing for text input, the system supports directional swipes on specific keys (like the Space Bar or Delete key) to trigger functional actions.
Developer Tools & Debugging
The system provides several hooks for debugging gesture logic via the Devtools utility and specific overlay settings.
- Feature Config Log: Developers can verify if Glide is enabled in the active preference model.
- Key Touch Boundaries: Visualizes the touch targets used by the classifier to determine key hits during a glide.
- Gesture Trail Rendering: Controlled via Snygg CSS rules (e.g.,
snygg__rule_element__glide_trail).
Sources: app/src/main/kotlin/dev/patrickgold/florisboard/lib/devtools/Devtools.kt:118-124, app/src/main/res/values/strings.xml:433, app/src/main/res/values/strings.xml:830
Conclusion
Gestures and Glide Typing in Ownkey Keyboard provide a high-performance, dictionary-backed input method. By combining a robust statistical classifier with efficient pruning algorithms and asynchronous data processing, the system delivers real-time word suggestions and functional shortcuts without impacting the responsiveness of the main keyboard interface.