// HID report handling NTSTATUS TouchI2C_ProcessHidReport(WDFDEVICE device, PVOID reportBuffer, ULONG reportLength) { // Implement HID report processing }
// Create the device object status = WdfDeviceCreate(&DeviceInit, WDF_NO_OBJECT_ATTRIBUTES, &device); if (!NT_SUCCESS(status)) { return status; }
// Device detection NTSTATUS TouchI2C_CreateDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit) { WDFDEVICE device; NTSTATUS status; kmdf hid minidriver for touch i2c device download
return STATUS_SUCCESS; }
// Define the driver's name and GUID #define DRIVER_NAME "TouchI2C" DEFINE_GUID(GUID_DEVINTERFACE_TouchI2C, 0x5B3B33B0, 0x1234, 0x5678, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34); // Usage Page (Generic Desktop) 0x15
// Copy the HID descriptor to the buffer RtlCopyMemory(buffer, hidDescriptor, sizeof(hidDescriptor)); }
A hardware engineer, Alex, had designed a new touch I2C device that was compact, efficient, and highly responsive. However, when it came to integrating the device with Windows, Alex encountered a significant challenge. The device used the I2C protocol to communicate with the computer, but Windows didn't have a built-in driver to support this device. // Logical Minimum 0x26
// HID descriptor VOID TouchI2C_GetHidDescriptor(WDFDEVICE device, PVOID buffer, ULONG bufferLength) { // Define the HID descriptor UCHAR hidDescriptor[] = { // Report descriptor 0x06, 0x00, 0x00, // Usage Page (Generic Desktop) 0x15, 0x00, 0x00, // Logical Minimum 0x26, 0xFF, 0x00, // Logical Maximum 0x35, 0x00, 0x00, // Physical Minimum 0x45, 0x00, 0x00, // Physical Maximum 0x75, 0x08, // Report Size 0x95, 0x01, // Report Count 0x85, 0x01, // Report ID 0x05, 0x08, // Usage (Multi-touch) 0x19, 0x01, // Usage Minimum 0x29, 0x01, // Usage Maximum 0x25, 0x01, // Logical Minimum 0x35, 0x01, // Physical Minimum 0x45, 0x01, // Physical Maximum 0x75, 0x08, // Report Size 0x95, 0x01, // Report Count 0xB1, 0x02, // Feature };
Here's a snippet of the driver's code to illustrate the key components: