Reputation: 826
I'm new to working with the Windows HID API, and I've inherited some code that uses ReadFile to block waiting for a new input report. I'd like to use some sort of "Peek" to find out if an input report is available prior to calling ReadFile. I've tried using PeekNamedPipe, but the call returns immediately with no error, and also without reading any data. What is the right way to determine if an input report is available from a USB HID device?
Upvotes: 1
Views: 853
Reputation: 2653
If your goal here is to remove the blocking aspect of ReadFile
in the original solution I'd recommend changing this to use overlapped I/O. Then you can just call ReadFile
and wait on an event for the report to arrive.
I haven't used PeekNamedPipe in this type of application, so I can't comment on how it operates but it sounds like if it returns with no error and no data that a report has not arrived.
Upvotes: 1