Write a simple Win32 app that:
The HID class driver sends IOCTL_HID_READ_REPORT (IRP_MJ_INTERNAL_DEVICE_CONTROL). The minidriver forwards the request to the lower driver (HIDI2C.sys), then modifies the output buffer.
if (NT_SUCCESS(Params->IoStatus.Status)) PHID_XFER_PACKET transfer = NULL; WdfRequestRetrieveOutputMemory(Request, &memory); transfer = (PHID_XFER_PACKET)WdfMemoryGetBuffer(memory, NULL); // Parse HID report (assume touch digitizer usage page) BYTE* reportData = (BYTE*)(transfer + 1); ULONG reportLen = transfer->OutputBufferLen;
The handler validates input, updates driver’s calibration structure, saves to registry, and optionally applies it to the hardware. kmdf hid minidriver for touch i2c device calibration
Now, go forth and calibrate – down to the last raw I2C byte.
Calibration is the most critical phase in deploying an I2C-connected touch device under Windows. Without precise calibration, Touch I2C devices suffer from coordinate drifting, missed gestures, and misaligned touch targets.
In EvtDriverDeviceAdd :
Comprehensive Guide to KMDF HID Minidriver for Touch I2C Device Calibration
X_cal = A * X_raw + B * Y_raw + C Y_cal = D * X_raw + E * Y_raw + F
: Your driver. It binds to the I2C transport, fetches raw coordinate data, applies calibration matrices, and structures the data into HID-compliant reports. Write a simple Win32 app that: The HID
// Translate: X' = a*X + b*Y + cx calibrated->X = (LONG)(cal->A * raw->X + cal->B * raw->Y + cal->Cx); calibrated->Y = (LONG)(cal->D * raw->X + cal->E * raw->Y + cal->Cy); // Clamp to touch resolution
| Problem | Symptom | KMDF Debugging Technique | |---------|---------|--------------------------| | I2C clock stretching | Timeout reading registers | Use WPP tracing; check STATUS_IO_TIMEOUT | | Interrupt storms | High CPU, missed touches | Verify edge vs. level trigger in ACPI | | Non-monotonic raw values | Jumps in X/Y | Check I2C buffering; add median filter in DPC | | Registry corruption | Coefficients lost after reboot | Validate WdfRegistryAssignMemory return |