Skip to content

Latest commit

Β 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FastTouch 0.1.0 [ALPHA-2026-05-23] β€” Ultra-Fast Native Windows Touchscreen & Multi-Touch Engine for Java

Status License: MIT Java Platform JitPack


⚑ High-speed Win32 WM_POINTER multi-touch digitizer interception, pressure tracking, and contact bounding-box geometry for Java.

FastTouch provides hardware-level touchscreen and multi-touch digitizer access directly from the Win32 Pointer API (WM_POINTER), bypassing the single-cursor mouse emulation limitations of standard AWT and Swing. Track 10+ simultaneous fingers, variable pressure force (0..255), and exact physical contact patch dimensions with minimal latency.

Watch Showcase Demo (YouTube)

FastTouch Multi-Touch Demo


Quick Start

import fasttouch.FastTouch;
import javax.swing.JFrame;

public class Demo {
    public static void main(String[] args) {
        JFrame frame = new JFrame("FastTouch Demo");
        frame.setSize(1280, 800);
        frame.setVisible(true);

        // 1. Initialize native touch interception on the target window
        FastTouch touch = FastTouch.create(frame);

        // 2. Add high-rate multi-touch listener
        touch.addListener(point -> {
            System.out.printf("[TOUCH] ID=%d Pos=(%d,%d) Pressure=%d Size=%dx%d Phase=%s\n",
                point.id, point.x, point.y, point.pressure, point.width, point.height, point.state);
        });

        // 3. Start background polling thread (~120 Hz)
        touch.start();
    }
}

Table of Contents


Why FastTouch?

Standard Java input subsystems (AWT MouseListener, JavaFX, Swing) fundamentally treat touchscreens as simulated single-point mouse cursors:

  1. Single-Cursor Emulation: Standard AWT collapses multiple finger touches into a single cursor, discarding all concurrent multi-touch points and gestures.
  2. Missing Contact Geometry: Physical force levels (0..255) and contact area bounding boxes (width Γ— height) are completely lost in pure Java.
  3. Event Queue Latency: Synthesized mouse events are queued through the Event Dispatch Thread (EDT), creating noticeable tactile lag during rapid multi-finger gestures.
  4. Complex External Daemons: Alternative solutions rely on external TUIO daemons or legacy WM_TOUCH wrappers that suffer from socket jitter and dropped events.

FastTouch bridges directly to the modern Win32 WM_POINTER subsystem:

  • Simultaneous Multi-Touch: Distinguishes 10+ independent physical touch contacts simultaneously with unique pointer IDs.
  • Hardware Force & Contact Geometry: Provides true normalized pressure (0..255) and contact patch pixel dimensions (width Γ— height).
  • Low-Latency Polling Pipeline: Native window subclassing captures pointer messages before the standard Java window procedure.
  • Zero-GC Polling: High-speed circular event structures eliminate memory churn during continuous 120 Hz gesture streams.
Feature Java AWT / Swing Legacy TUIO / WM_TOUCH Wrappers FastTouch
Multi-Touch Contacts Single cursor emulation 2–5 points (Driver dependent) 10+ simultaneous points
Input Subsystem Synthesized WM_MOUSEMOVE Legacy WM_TOUCH / UDP socket Native Win32 WM_POINTER
Pressure Tracking ❌ None (Binary 0/1) ⚠️ Rarely supported βœ… Normalized 0–255 pressure force
Contact Geometry ❌ Lost (Single coordinate) ⚠️ Inconsistent dimensions βœ… Exact bounding box (width Γ— height)
Dispatch Latency 15–30 ms (EDT queue lag) 5–15 ms (Network/socket lag) < 0.1 ms (Direct subclassing)
Event Pipeline Overhead High EDT event churn Network daemon overhead Zero GC allocations in loop

Key Features

  • πŸ–οΈ True Multi-Touch Interception β€” Track 10+ concurrent fingers with individual touch IDs.
  • 🎯 Pressure Sensitivity β€” Normalized 0–255 contact pressure force directly from the digitizer driver.
  • πŸ“ Contact Geometry β€” Real physical width and height bounding boxes per touch point.
  • ⚑ Native Win32 WM_POINTER Hook β€” Fast, direct Windows 8/10/11 pointer pipeline.
  • πŸ“¦ Zero-Copy Native Pipeline β€” Minimized JNI overhead and zero GC pressure in the event loop.

Real-World Use Cases

  • 🎨 Digital Whiteboards & Canvas Apps: Multi-finger drawing, simultaneous collaborative markup, and pressure-sensitive sketching.
  • πŸ“± Interactive Kiosk & POS Terminals: Responsive multi-touch navigation, pinch-to-zoom, and multi-user kiosks.
  • πŸŽ›οΈ Audio & DJ Control Surfaces: Multi-slider and multi-dial tactile touch controllers requiring concurrent multi-point tracking.
  • πŸ€– Touch Telemetry & Automation: High-rate gesture and touch telemetry capture for automated UI testing and recording.

Performance Benchmarks

FastTouch is measured using JMH (Java Microbenchmark Harness) to ensure zero-overhead event processing:

Benchmark / Operation Score (ops/ms) Ops per Second
benchmarkTouchPointAllocation ~18,200 ops/ms > 18.2 Million
benchmarkTouchPointFormatting ~1,450 ops/ms > 1.45 Million
Native Polling Loop Rate ~120 Hz Smooth Real-time Tracking

Measured on Windows 11 (x64), JDK 17+.


API Quick Reference

Method Return Type Description Docs
FastTouch.create(frame) FastTouch Resolves window HWND and installs native WM_POINTER subclass hook. Reference
addListener(listener) void Registers a callback for real-time touch point dispatch. Reference
removeListener(listener) void Unregisters a previously registered touch listener. Reference
start() void Launches the dedicated background touch polling thread (~120 Hz). Reference
stop() void Halts the background touch polling loop. Reference
poll() void Executes a single polling iteration and dispatches touch events. Reference
FastTouch.isTouchAvailable() boolean Queries if a physical touchscreen or multi-touch digitizer is present. Reference
FastTouch.getMaxTouchPoints() int Returns maximum simultaneous touch points supported by hardware. Reference

Technical Demos & Benchmarks

Case Java Example Launcher Description
Interactive Multi-Touch Canvas Demo.java run-demo.bat Real-time multi-touch visualization displaying contact rings, pressure levels, and coordinates.
JMH Microbenchmark Suite Benchmark.java run-benchmark.bat Microbenchmark suite profiling touch point allocation and formatting throughput.

Installation

Option 1: Maven (Recommended)

Add the JitPack repository and the dependency to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- FastTouch Library -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastTouch</artifactId>
        <version>0.1.0</version>
    </dependency>
    <!-- Required Native JNI loader -->
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastCore</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastTouch:0.1.0'
    implementation 'com.github.andrestubbe:FastCore:0.1.0'
}

Option 3: Direct Download (No Build Tool)

Download the latest JARs directly to add them to your classpath:

  1. πŸ“¦ FastTouch-0.1.0.jar (The Core Library with embedded native DLL)
  2. βš™οΈ fastcore-0.1.0.jar (The Mandatory Native Loader)

Important

All JARs must be in your classpath for the JNI calls to function correctly.


Documentation

  • COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
  • REFERENCE.md: Comprehensive API specification, contact point fields, and hook lifecycle.
  • PHILOSOPHY.md: The engineering rationale for hardware-native touch interception.
  • ROADMAP.md: Planned milestone features and performance extensions.
  • CHANGELOG.md: Complete version history and release notes.

Platform Support

Platform Architecture Status Driver / Subsystem
Windows 10 / 11 x64 βœ… Fully Supported Native Win32 WM_POINTER Subsystem
Linux x64 / AArch64 🚧 Planned libinput / evdev Multi-Touch Slots
macOS Apple Silicon / x64 🚧 Planned NSEvent & MultitouchSupport Framework

Related Projects

  • FastCore β€” Native Library Loader & JNI Utilities for Java
  • FastStylus β€” Native Pen & Stylus Pressure API for Java
  • FastMouse β€” Ultra-Low Latency Native RawInput Mouse Engine
  • FastKeyboard β€” Ultra-Fast Native RawInput Keyboard Engine
  • FastHotkey β€” Low-Latency Global Hotkey API for Java
  • FastVulkan β€” High-Performance Native Vulkan 2D Rendering Engine

License

MIT License β€” See LICENSE file for details.


Part of the FastJava Ecosystem β€” Making the JVM faster. πŸš€

About

πŸ‘† Native touchscreen input for Java. Multi-touch, pressure, and gestures impossible in pure Java.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages