Kmdf - Hid Minidriver For Touch I2c Device Calibration ((hot))
NTSTATUS TouchCalibGetI2cTarget(WDFDEVICE Device, WDFIOTARGET *IoTarget)
For engineers developing touch solutions over the I2C (Inter-Integrated Circuit) bus, the challenge is twofold. First, the device must conform to Windows' HID (Human Interface Device) standards. Second, it must account for physical variances in the touch sensor, display lamination, and environmental drift. The most robust solution to these challenges is a specifically architected for I2C touch device calibration.
Calibration data is obtained via a user‑mode calibration app that:
This write‑up assumes you have:
Pseudo-code:
[HID_Inst] Include = machine.inf Needs = HID_Inst.NT
Windows uses to send calibration data from user-mode software (like the Control Panel) to the kernel-mode driver. kmdf hid minidriver for touch i2c device calibration
#define IOCTL_SET_CALIBRATION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
User Mode ---------------------------- HID Class Driver │ Kernel Mode │ HID minidriver callbacks ▼ KMDF HID Minidriver │ I²C KMDF Lower Filter │ (or replaces HIDI2C.sys) ▼ I²C Controller Driver │ Hardware ▼ Touch Device (I²C)
Calibration ensures that a touch at physical location (x,y) on the glass corresponds accurately to pixel on the screen. A. Types of Calibration The most robust solution to these challenges is
return status;
Touch I2C controllers typically require calibration data (offsets, sensitivity thresholds, baseline values) to function correctly. This data is often generated at the factory. If the data is lost when the device reboots or if the controller lacks internal non-volatile memory (NVM), the touch experience degrades (drift, ghost touches).
NTSTATUS EvtDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit) WDF_OBJECT_ATTRIBUTES attributes; WDFDEVICE device; NTSTATUS status; // Configure the device as a filter or a standard HID miniport Status = HidP_SysPowerCaps(...); status = WdfDeviceCreate(&DeviceInit, &attributes, &device); if (!NT_SUCCESS(status)) return status; // Register with hidclass.sys HID_MINIDRIVER_REGISTRATION registration; RtlZeroMemory(®istration, sizeof(registration)); registration.Revision = HID_REVISION; registration.DriverObject = WdfDriverWdmGetDriverObject(Driver); registration.RegistryPath = ...; // From DriverEntry registration.DeviceExtensionSize = sizeof(DEVICE_EXTENSION); status = HidRegisterMinidriver(®istration); return status; Use code with caution. Opening the I2C Target the touch experience degrades (drift