Virtual HID Concepts

I’m afraid this message is mostly targeted at Mr Holan, who has forgotten more about HID than the rest of us will ever know, but it’s a question I’ve seen on multiple forums without a particularly good answer.

As a virtual HID driver, you find yourself having to deal with GetInputReport, SetOutputReport, ReadReport and WriteReport. The question that comes up is, what’s the difference? Having just completed a VHID project, I think I can answer this, but I’d like confirmation.

As far as I can tell, SetOutputReport and WriteReport are identical, and can be handled by the same handler.

GetInputReport wants an immediate answer to the question “what is the CURRENT state of this report?”

ReadReport is the outlier. It says “please queue this IRP, and the next time there is a change in any report, send it to me.”

Do I have those about right? If three applications have queued up ReadReport calls, do I complete all three of them when there is a change?

You are asking me to remember 20 year old design decisions ;). Yes, what you wrote sounds about right. HIDclass was developed on win98 and then moved to NT, so the difference between GetInputReport and ReadReport is the evolution of a polling to async model. IIRC ReadReport was added to support kbdhid and mouhid (both NT only drivers as the win9x input stack was an entirely different design) pending a read to wait for the next chunk of data.

Each handle has its own copy and queue of the data reported. This is handled by HIDclass, you should see only one readreport for all three applications (hidclass does the deMUXing IIRC).