Kmdf Hid Minidriver For Touch I2c Device Calibration -
Calibration for KMDF HID minidrivers (commonly used for Silead and other I2C touchscreens) typically happens through firmware parameters in the Windows Registry or the .inf installation file rather than a graphical tool.
If your touch input is inverted, offset, or restricted to a small area, follow the steps below to correct the calibration. 1. Locate the Driver in Device Manager
Before making changes, verify you have the correct driver installed. Press Win + X and select Device Manager. Expand Human Interface Devices. Look for KMDF HID Minidriver for Touch I2C Device.
Right-click it, select Properties, and go to the Details tab.
Select Hardware Ids from the dropdown. Note the ID (e.g., ACPI\VEN_MSSL&DEV_1680). 2. Identify and Modify Registry Parameters
Most I2C touch minidrivers read calibration data from a specific registry key when the driver starts. Open Registry Editor (regedit.exe).
Navigate to:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\ACPI\
Look for the following keys (they may vary by manufacturer):
Touch0 to TouchX: These often contain hex values for X/Y limits. SwapXY: Set to 1 to swap axes; 0 to keep them.
InvertX / InvertY: Set to 1 to flip the direction of movement. kmdf hid minidriver for touch i2c device calibration
💡 Tip: If these keys are missing, check your driver's .inf file in the original driver folder. It usually lists the exact names of the parameters it uses. 3. Apply a Calibration Firmware File
Many Silead-based touchscreens require a specific firmware file (e.g., SileadTouch.fw) placed in the Windows Drivers folder to map the digitizer correctly.
Ensure the firmware file is in C:\Windows\System32\drivers\.
If the touch is still inaccurate, you may need a firmware file specific to your tablet model rather than just a generic driver.
Community-sourced firmware repositories like the gsl-firmware GitHub often provide the correct .fw files for various budget tablets. 4. Use the Built-in Windows Tool
If the hardware-level calibration (Registry/Firmware) is close but not perfect, use the Windows software-level calibration.
Search for "Calibrate the screen for pen or touch input" in the Start menu.
Click Calibrate... and follow the on-screen crosshair prompts.
Warning: This only fixes slight offsets. If your touch is inverted or mirrored, you must fix the Registry or Firmware first. Troubleshooting Common Issues Primary Fix Touch is inverted Change InvertX or InvertY in Registry. X and Y are swapped Change SwapXY in Registry. Touch only works in a small box Calibration for KMDF HID minidrivers (commonly used for
Update the SileadTouch.fw file or correct the MaxX / MaxY values in Registry. No touch response
Check for a yellow exclamation mark in Device Manager and reinstall the driver. If you'd like to proceed, could you tell me:
What is the exact Hardware ID of the device? (found in Device Manager) What is the brand and model of the tablet/laptop? Is the touch inverted, offset, or completely unresponsive? Touchscreen Not Working Properly Windows Only - Hi10 Pro
4.6 Dynamic Calibration – IOCTL Interface
To support calibration changes at runtime (e.g., from a user-mode calibration app), you implement a custom IOCTL handler:
NTSTATUS TouchCalibEvtIoDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, ...)
switch (ControlCode)
case IOCTL_SET_TOUCH_CALIBRATION:
// Read calibration matrix from user buffer
WdfRequestRetrieveInputBuffer(Request, sizeof(CALIB_PARAMS), ¶ms, &length);
// Store in device context safely
WdfDeviceGetDeviceContext(Device)->CalibParams = updatedParams;
break;
The user-mode calibration tool can then call DeviceIoControl to update coefficients without a driver reload.
6. INF & Installation
The INF must mark the driver as a HID minidriver and declare HID class as upper filter:
[Version] Signature = "$WINDOWS NT$" Class = HIDClass ClassGuid = 745a17a0-74d3-11d0-b6fe-00a0c90f57da[Standard.NT$ARCH$] %DeviceDesc% = HID_Inst, ACPI\XYZ1234
[HID_Inst] Include = machine.inf Needs = HID_Inst.NT
[HID_Inst.NT] Include = machine.inf Needs = HID_Inst.NT AddReg = HID_AddReg The user-mode calibration tool can then call DeviceIoControl
[HID_Inst.NT.Services] Include = machine.inf Needs = HID_Inst.NT.Services AddService = MyTouchHid, 0x00000002, MyDriverService
[MyDriverService] ServiceType = 1 StartType = 3 ErrorControl = 1 ServiceBinary = %12%\MyTouchHid.sys
Part 3: Core Architecture – KMDF HID Minidriver for Calibration
Let’s outline the major components of our driver, which we'll name TouchCalibMini.sys.
9.1 WPP Tracing
Add WPP traces for calibration flow:
WPP_INIT_TRACING(DriverObject, RegistryPath);
TraceEvents(TRACE_LEVEL_INFO, DBG_INIT,
"Calibration version %d loaded, size %d", version, size);
Part 1: Understanding the Problem – Why Calibrate I2C Touch Devices?
Unlike USB or Bluetooth HID devices, I2C touch controllers often lack sophisticated onboard processing. Many commodity touch controllers (e.g., from Goodix, FocalTech, or Cypress) provide raw ADC values from a resistive or capacitive matrix. These raw values require transformation into screen coordinates via a calibration formula:
X_screen = (X_raw - X_min) * (X_resolution / (X_max - X_min))
Y_screen = (Y_raw - Y_min) * (Y_resolution / (Y_max - Y_min))
However, factors such as:
- Mechanical misalignment (touch sensor bonded slightly offset from display)
- Temperature drift (capacitance changes)
- Panel variance (each unit has different min/max raw values)
necessitate a parameterized calibration. A static calibration written into firmware is insufficient for dynamic environments. Therefore, the system needs a driver that can:
- Read raw touch data via I2C.
- Apply calibration coefficients (offset, scale, rotation, or polynomial corrections).
- Report corrected HID touch reports to the OS.
- Allow runtime calibration updates without rebooting.
Implementation outline (practical)
- Device initialization
- Create WDFDEVICE, configure I/O queues, create SPB/I2C target, register WDFINTERRUPT.
- Read controller properties and firmware capabilities (supports firmware calibration? native calibrated output?).
- Load calibration
- Try reading calibration from device flash (via I2C feature command).
- Validate; if invalid, try registry / OS-stored calibration; if both invalid, use identity.
- Input pipeline
- On interrupt: queue worker to read report(s) at passive level if necessary.
- Parse contacts and timestamps; map raw coords through current calibration function; build HID input report and complete.
- Calibration routines
- Provide IOCTLs or HID feature reports to:
- Start calibration session
- Submit calibration control points
- Commit or abort calibration
- Read current calibration
- Implement worker to compute transform (least squares, grid generation) and verify residual errors.
- Atomically write calibration to device flash and mirror to registry.
- Provide IOCTLs or HID feature reports to:
- Persistence and rollback
- Use temporary staging area in device flash; verify checksum; then activate.
- Provide fallback on activation failure.
10. Sample Calibration Flow
- Boot: Driver loads, reads
HKLM\...\CalibrationMatrix. - Device start: Sends I²C command to enable raw mode.
- Report interception: Every touch report is transformed.
- User-mode calibration tool sends IOCTL to driver to update matrix:
#define IOCTL_SET_CALIBRATION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)