A Windows service that captures raw HID (Human Interface Device) touch input from touch screens and forwards the data to a serial device (e.g., ESP32) for further processing.
- Overview
- Features
- System Requirements
- Quick Start
- Command-Line Arguments
- Configuration
- Touch Data Format
- Dynamic Coordinate Scaling
- Logging
- Process Bypass Feature
- Troubleshooting
- Contributing
- License
This service intercepts touch events at the HID level, decodes comprehensive touch data including coordinates, pressure, contact information, and forwards it via serial communication. It features dynamic coordinate scaling, process filtering, and multiple logging formats for debugging and analysis.
Touch Screen (HID) → Raw Input API → Touch Decoder → Serial Queue → Serial Port (ESP32) ↓ Log Files (Raw/Decoded/Detailed)
./
├── Program.cs # Main application and HID processing
├── Helpers/
│ └── WindowProcess.cs # Window and process detection utilities
└── bin/
└── Release/
└── net10.0/ # Build output
└── win-x64/
└── publish/
└── TouchDataCaptureService.exe # Published executable
- Raw HID Touch Capture - Intercepts touch events directly from HID devices using Windows Raw Input API
- Comprehensive Touch Decoding - Extracts all available touch parameters:
- Position (X/Y coordinates)
- Contact ID and count
- Tip switch state
- Pressure sensitivity
- Contact dimensions (width/height)
- Orientation (azimuth, altitude, twist)
- Confidence and in-range detection
- High-Speed Serial Output - Default 3Mbps baud rate (configurable)
- Asynchronous Queue System - Non-blocking send/receive with dedicated threads
- Configurable Data Format - Send raw HID bytes or decoded touch data
- Optional Serial Logging - Debug serial communication when needed
- Dynamic Coordinate Scaling - Automatically normalizes touch coordinates to HID standard range (0-32767)
- Process Detection & Filtering - Optional bypass for specific applications
- Multi-touch Support - Handles up to 10 simultaneous contacts
- Real-time Calibration - Press 'R' key to reset coordinate scaling
- Multiple Log Formats - Raw bytes, decoded summary, and detailed human-readable logs
- Operating System: Windows 11
- Touch Screen: HID-compliant touch device
- Serial Port: Physical COM port, USB-to-Serial adapter, or virtual COM port
- Disk Space: Minimum 100 MB (for application and logs)
- .NET Runtime: .NET 10 Runtime or SDK
- Serial Drivers: Appropriate drivers for your serial device
- CH340/CH341 for common USB-Serial adapters
- FTDI drivers for FTDI chips
- CP210x drivers for Silicon Labs chips
- Administrator Rights - Required for HID device access during runtime
-
Install .NET 10 Runtime
- Download from: https://dotnet.microsoft.com/download/dotnet/10.0
- Or use winget
winget install Microsoft.DotNet.Runtime.10
-
Download or Build the Application
- Clone repository
git clone https://github.com/<your-organization>/ifpd-touchback-floatingmenu.git cd ifpd-touchback-floatingmenu- Build Release version
dotnet build -c Release
-
Install Serial Drivers (if using USB-to-Serial adapter)
-
Download the appropriate driver for your serial device:
- CH340/CH341: Download from manufacturer
- FTDI: Download from FTDI
- CP210x: Download from Silicon Labs
-
Install the downloaded driver:
- Run the driver installer as Administrator
- Follow the installation wizard
- Restart your computer if prompted
-
Verify driver installation in Device Manager:
devmgmt.msc
- Expand Ports (COM & LPT)
- Look for your device (e.g., "USB-SERIAL CH340 (COM3)")
- Note the COM port number (e.g., COM3, COM10)
- If you see a yellow warning icon, right-click and select Update driver
-
Alternative: List COM ports using PowerShell
Get-WmiObject Win32_SerialPort | Select-Object Name,DeviceID
-
-
Run the Application
- Navigate to build output
cd bin\Release\net10.0 - Run with default settings (COM10, 3Mbps)
.\TouchDataCaptureService.exe - Or with custom settings (replace COM3 with your actual COM port)
.\TouchDataCaptureService.exe --port COM3 --baudrate 115200
- Navigate to build output
- Connect your serial device (ESP32, Arduino, etc.)
- Identify the COM port (Device Manager → Ports)
- Run the application as Administrator
- Calibrate coordinates by touching all four corners of the screen
- Verify data in log files or serial monitor
TouchDataCaptureService.exe [options]
| Argument | Description | Default | Example |
|---|---|---|---|
-port <COMx> |
Set serial port | COM10 | -port COM3 |
--port <COMx> |
Set serial port (long form) | COM10 | --port COM3 |
-baudrate <value> |
Set baud rate | 3000000 | -baudrate 115200 |
--baudrate <value> |
Set baud rate (long form) | 3000000 | --baudrate 115200 |
-useraw |
Send raw HID bytes instead of decoded data | Disabled | -useraw |
--useraw |
Send raw HID bytes (long form) | Disabled | --useraw |
-seriallog |
Enable serial communication logging | Disabled | -seriallog |
--seriallog |
Enable serial logging (long form) | Disabled | --seriallog |
-h or --help |
Show help message | N/A | --help |
- Basic usage with default settings
TouchDataCaptureService.exe - Custom COM port
TouchDataCaptureService.exe --port COM5 - Multiple arguments
TouchDataCaptureService.exe --port COM3 --baudrate 115200 --seriallog - Raw data mode
TouchDataCaptureService.exe --port COM4 --useraw - View help
TouchDataCaptureService.exe --help
- Serial Port:
COM10 - Baud Rate:
3000000 (3Mbps) - Data Bits:
8 - Parity:
None - Stop Bits:
One - Handshake:
None - Log Mode:
RawAndDecoded - Process Bypass:
Always Enabled - Serial Logging:
Disabled
The application supports three logging modes (configured in code):
- RawOnly - Only raw HID bytes
- DecodedOnly - Only decoded touch data
- RawAndDecoded - Both formats (default)
To change the log mode, modify CurrentLogMode in Program.cs:
private static readonly LogMode CurrentLogMode = LogMode.RawAndDecoded;
⚠️ Important: Baud Rate Limitations
- Maximum baud rate: 3000000 (3 Mbps)
- Synchronization requirement: The baud rate configured in this service must match exactly with the baud rate configured in the MCU project (e.g., ESP32).
- Exceeding 3 Mbps may cause data corruption or communication failures.
- Common stable rates: 9600, 115200, 921600, 3000000
📌 Note: Raw vs Decoded Data Mode
- Default mode: Decoded data (CSV format)
- Current MCU project configuration: Configured to receive and parse decoded data
- To use raw data mode (
--userawflag): The MCU project firmware must be updated to parse raw HID byte format instead of CSV format- Ensure both the service and MCU firmware are synchronized on the data format being used
The service sends touch data in CSV format over serial:
TOUCH,<X>,<Y>,<ContactID>,<TipSwitch>,<Pressure>,<InRange>,<Confidence>,<Width>,<Height>,<Azimuth>,<Altitude>,<Twist>,<ContactCount>
| Field | Type | Range | Description |
|---|---|---|---|
| X | int | 0-32767 | Horizontal coordinate (scaled) |
| Y | int | 0-32767 | Vertical coordinate (scaled) |
| ContactID | int | 0-9 | Unique identifier for this touch point |
| TipSwitch | bool | 0/1 | Touch contact state (0=no touch, 1=touching) |
| Pressure | int | Device-dependent | Touch pressure (if supported) |
| InRange | bool | 0/1 | Proximity detection (hovering) |
| Confidence | bool | 0/1 | Touch confidence level |
| Width | int | Device-dependent | Contact width (if supported) |
| Height | int | Device-dependent | Contact height (if supported) |
| Azimuth | int | 0-360 | Rotation around Z-axis (degrees) |
| Altitude | int | 0-90 | Angle from screen surface (degrees) |
| Twist | int | Device-dependent | Stylus twist (if supported) |
| ContactCount | int | 1-10 | Total number of simultaneous contacts |
TOUCH,16384,8192,0,1,0,1,1,0,0,0,0,0,1
TOUCH,24576,16384,1,1,0,1,1,0,0,0,0,0,2
Interpretation:
- First touch at center-right (16384, 8192), single contact
- Second touch at lower-right (24576, 16384), two total contacts
The service automatically normalizes touch coordinates from device-specific ranges to the standard HID range (0-32767).
- Initial Sampling - Collects first 10 touch samples
- Range Detection - Determines min/max X/Y values from HID logical ranges
- Normalization - Scales all coordinates to 0-32767 range
- Continuous Updates - Adjusts scaling as needed
For best results, calibrate by touching all four corners:
- Top-Left Corner - Establishes minimum X and Y
- Top-Right Corner - Establishes maximum X
- Bottom-Left Corner - Establishes maximum Y
- Bottom-Right Corner - Confirms full range
Press the 'R' key while the application is running to reset scaling and recalibrate.
scaledX = ((rawX - minX) * 32767) / (maxX - minX) scaledY = ((rawY - minY) * 32767) / (maxY - minY)
The service logs scaling information every 50 samples when run in Debug mode:
[SCALING] Range: X(0-65535=65535) Y(0-65535=65535) | Raw(32768,16384) -> Scaled(16384,8192)
All log files are created in the application directory:
| File | Content | Format |
|---|---|---|
hid_raw.log |
Raw HID report bytes | Hex dump |
hid_decoded.log |
Decoded touch data | Compact summary |
hid_detailed.log |
Detailed touch parameters | Human-readable |
serial_data.log |
Serial TX/RX data | Timestamped (optional) |
09:15:23.456 [RAW] Device:HID_12345678 Size:32 Data:05-01-40-7F-20-3F-00-01...
09:15:23.456 [HID] Dev:HID_12345678 RID:5 CNT:1 X:16384 Y:8192 CID:0 TIP:1 RNG:1 CONF:1 PRESS:0 W:0 H:0 AZ:0 ALT:0 TWIST:0
09:15:23.456 [DETAILED] Timestamp: 09:15:23.456 | Device: 12345678 | ReportID: 5 | ContactCount: 1 | Position: (16384, 8192) | ContactID: 0 | TipSwitch: True | InRange: True | Confidence: True | ProcessName: chrome | ProcessID: 5432
09:15:23.456 TX: TOUCH,16384,8192,0,1,0,1,1,0,0,0,0,0,1 09:15:23.457
RX: OK
Log files include descriptive headers explaining the format:
HID Touch Data Decoded Log
Generated: 2026-03-20 09:15:00
Log Mode: RawAndDecoded
Serial Port: COM10 @ 3000000 baud
Column Format:
Timestamp [Type] Device ReportID ContactCount X Y ContactID TipSwitch [...]
The service automatically skips touch events originating from specific applications, preventing interference with UI overlays. This feature is always enabled by default.
- FloatingMenu - Floating menu application
- ScreenPaint - Annotation tool
- Touch Detected - Service captures HID coordinates
- Coordinate Conversion - Converts HID coordinates to screen coordinates
- Process Detection - Identifies which process owns the window at that location
- Filtering - Skips logging and serial transmission if process is in bypass list
Problem: Failed to open serial port COM10
Solutions:
- Check available COM ports in Device Manager under Ports (COM & LPT).
- List COM ports with PowerShell
Get-WmiObject Win32_SerialPort | Select-Object Name,DeviceID
- Verify port is not in use
Get-Process | Where-Object {$_.MainWindowTitle -like "COM10"}
- Run as Administrator
Start-Process TouchDataCaptureService.exe -Verb RunAs
Problem: Application runs but no touch events are captured
Solutions:
- Verify touch screen is working
- Check HID devices
Get-PnpDevice -Class HIDClass | Where-Object {$_.FriendlyName -like "touch"} - Run as Administrator - Required for HID access
- Check log files for error messages
Problem: Coordinates are out of range or inaccurate
Solutions:
- Reset scaling - Press 'R' key
- Calibrate - Touch all four corners systematically
- Wait for samples - Allow 10+ touches before expecting accurate scaling
- Check console output - Review scaling information in the console when running in Debug mode
Problem: Data not being transmitted or received
Solutions:
- Enable serial logging for debugging
TouchDataCaptureService.exe --port COM3 --seriallog
- Check serial log
- Verify baud rate matches receiver device
⚠️ Important: The baud rate must be identical in both this service and the MCU project. Maximum supported rate is 3000000 bps.
Try common baud rates
TouchDataCaptureService.exe --port COM3 --baudrate 115200 TouchDataCaptureService.exe --port COM3 --baudrate 9600
4. Check cable and port configuration
- Test with serial monitor (Arduino IDE, PuTTY, etc.)
Problem: Application consuming excessive CPU
Solutions:
- Disable serial logging (if enabled) Remove --seriallog flag
TouchDataCaptureService.exe --port COM10
- Check queue backlog in logs
Select-String -Path hid_decoded.log -Pattern "queue full"
Problem: Access denied or insufficient privileges
Solutions:
- Run as Administrator
Start-Process TouchDataCaptureService.exe -Verb RunAs - Or create shortcut with "Run as administrator" enabled
This is an internal Intel project. For contributions or issues:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/improvement) - Create a Pull Request
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0. See Apache-2.0.txt file for details.
- Deployment Guide: See DEPLOYMENT.md for publishing and deployment instructions
- Repository: https://github.com//ifpd-touchback-floatingmenu
- Issue Tracker: Report bugs and request features via GitHub Issues
- .NET Documentation: https://docs.microsoft.com/dotnet
- HID Specification: USB.org HID Documentation
- Version: 1.0.0
- Last Updated: March 2026
- Target Framework: .NET 10
- C# Version: 14.0
- Platform: Windows 11 (x64)