Scroll to Top

Kmdf Hid Minidriver For Touch I2c Device Calibration Best • Ad-Free

Kmdf Hid Minidriver For Touch I2c Device Calibration Best • Ad-Free

The Touch Controller reports raw ADC values. The KMDF driver applies the math before reporting up to HIDClass.sys.

Recommendation: For standard I2C touch devices, Approach A (Firmware Handled) is preferred. However, the driver must implement Approach B (Driver Handled) as a fallback if the firmware lacks processing capability.

Implement a second IOCTL to delete the registry key and send a "Reset to Factory" Feature Report (usually Report ID 0x01, byte 2 = 0x01). This is critical for field maintenance.

Windows touch devices (I2C HID digitizers) often require calibration to map raw sensor coordinates to screen coordinates. While user-mode calibration via TouchCalibration (tabcal) exists, kernel-mode calibration inside a KMDF HID minidriver is necessary when: kmdf hid minidriver for touch i2c device calibration best

This document outlines best practices for implementing calibration in a KMDF HID minidriver for an I2C touch device.

Your KMDF HID minidriver should expose a private IOCTL for calibration data injection. Example:

// In your EvtDeviceIoControl handler
case IOCTL_TOUCH_SET_CALIBRATION:
    // Parameters: XScale, YScale, XOffset, YOffset, Threshold
copy_from_user(&calib, inputBuffer, sizeof(CALIBRATION_DATA));
// Store in device context
devContext->XScale = calib.XScale;
devContext->XOffset = calib.XOffset;
// Apply clipping to avoid invalid coordinates
devContext->CalibrationValid = TRUE;
break;

Best Practice: Protect calibration parameters with a spinlock or mutex, as they are accessed both in IOCTL context and interrupt DPC.

Here is the step-by-step implementation of a calibration subroutine within a KMDF HID minidriver for an I2C touch device. The Touch Controller reports raw ADC values

Calibration must survive reboots. Options:

Recommended: Implement calibration persistence in a companion user-mode Windows service. The KMDF driver remains stateless regarding persistent storage, enhancing stability.


A HID Minidriver (also called a HID Transport Driver) sits below the class driver (HIDClass.sys). Its job is to communicate directly with the I²C controller, retrieve HID reports from the touch device, and forward them up the stack. Recommendation: For standard I2C touch devices, Approach A

Touch Device (I2C) → KMDF HID Minidriver → HIDClass.sys → Touch Input Stack → User Mode

On EvtDevicePrepareHardware, your driver must:

// Pseudo-logic: Request HID descriptor over I2C
WDFI2C_TARGET_REQUEST_PARAMETERS_INIT(&reqParams);
// Read 4 bytes: wHIDDescLength, bcdVersion, wReportDescLength
// Extract the Report ID for calibration from the Report Descriptor later.

Still have more questions?

Head back to the documentation overview or check out the FAQ!