Silicon-level and mechanical tolerances mean no two touch sensors are identical. Calibration bridges the gap between raw hardware readings and accurate screen coordinates.
VOID ApplyTouchCalibration( _In_ PDEVICE_CONTEXT Context, _In_ LONG RawX, _In_ LONG RawY, _Out_ PLONG CalibratedX, _Out_ PLONG CalibratedY ) if (!Context->IsCalibrated) *CalibratedX = RawX; *CalibratedY = RawY; return; // Kernel-safe fixed-point matrix multiplication *CalibratedX = ((Context->AlphaA * RawX) + (Context->AlphaB * RawY) + Context->AlphaC) / Context->Divisor; *CalibratedY = ((Context->AlphaD * RawX) + (Context->AlphaE * RawY) + Context->AlphaF) / Context->Divisor; Use code with caution. 6. Communicating with User-Mode Calibration Apps
The touch point doesn't align perfectly with the finger.
// FEATURE: Restore Calibration on Power Up if (pDevCtx->CalibrationLoaded && pDevCtx->CalibrationCache) NTSTATUS status = ApplyCalibrationToHardware(pDevCtx->I2CTarget, pDevCtx->CalibrationCache);
Alternatively, the driver can pass the raw data and let the Windows Input Stack ( mshidkmdf.sys ) apply the calibration matrices defined in the registry. kmdf hid minidriver for touch i2c device calibration
Touch controllers assert an interrupt line whenever a new touch coordinate is available. The minidriver handles this interrupt to trigger an I2C read transaction.
Set up a fixed-point multiplication matrix helper function within the data parsing loop.
Translating raw ADC (Analog-to-Digital Converter) matrices into exact pixel coordinates (
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL EvtIoDeviceControl; Silicon-level and mechanical tolerances mean no two touch
are the matrix constants calculated during the user-space calibration wizard. 4. Persisting Calibration Data
For every raw coordinate point collected P'(x', y') , the system expects an ideal, corrected point P(x, y) . The relationship can be represented by these equations:
A core feature for a KMDF HID minidriver on I2C touch devices is . This feature corrects physical misalignment (e.g., inverted axes or "small box" scaling) by applying a transformation matrix to raw I2C touch coordinates before they are wrapped into a HID report. Coordinate Remapping Feature This feature intercepts raw
Calibration data: formats, storage, and versioning Touch controllers assert an interrupt line whenever a
Packages the data into HID reports for the operating system. 📐 The Geometry of Precision
VOID TouchEvtIoDeviceControl( _In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode ) NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST; PDEVICE_CONTEXT devContext = GetDeviceContext(WdfQueueGetDevice(Queue)); PVOID inputBuffer; UNREFERENCED_PARAMETER(OutputBufferLength); switch (IoControlCode) case IOCTL_SET_TOUCH_CALIBRATION: if (InputBufferLength < sizeof(CALIBRATION_DATA_STRUCT)) status = STATUS_BUFFER_TOO_SMALL; break; status = WdfRequestRetrieveInputBuffer(Request, sizeof(CALIBRATION_DATA_STRUCT), &inputBuffer, NULL); if (NT_SUCCESS(status)) PCALIBRATION_DATA_STRUCT pData = (PCALIBRATION_DATA_STRUCT)inputBuffer; // Atomically update calibration matrix parameters devContext->AlphaA = pData->A; devContext->AlphaB = pData->B; devContext->AlphaC = pData->C; devContext->AlphaD = pData->D; devContext->AlphaE = pData->E; devContext->AlphaF = pData->F; devContext->Divisor = pData->Divisor; devContext->IsCalibrated = TRUE; status = STATUS_SUCCESS; break; WdfRequestComplete(Request, status); Use code with caution. 7. Performance Optimization and Verification
A function that utilizes SpbTargetSendData to write to the I2Ccap I squared cap C address of the touch sensor.
NTSTATUS TouchEvtDeviceAdd( _In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit ) NTSTATUS status; WDFDEVICE device; PDEVICE_CONTEXT devContext; HID_MINIDRIVER_REGISTRATION hidRegistration; UNREFERENCED_PARAMETER(Driver); // Invoke HID Class function to configure DeviceInit status = HidRegisterMinidriver(&hidRegistration); // Note: Actual binding requires assigning the WDFDEVICE to the HID stack status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &device); if (!NT_SUCCESS(status)) return status; devContext = GetDeviceContext(device); devContext->WdfDevice = device; // Allocate resources, assign I2C targets, initialize spinlocks for calibration data return status; Use code with caution. 4. The Touch Calibration Pipeline
The touch controller provides raw coordinate data. Your driver must map these to the HID_REPORT structure expected by Windows.
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.