PORTS Forum

Ports and Interfaces => USB => Topic started by: Thanawat on July 08, 2013, 03:29:29 am

Title: How to get notified of Input Reports without Delay
Post by: Thanawat on July 08, 2013, 03:29:29 am
Hi,

I'm writing the Host application that will talk to a custom HID Keyboard. Though, this keyboard identifies itself to Windows as an HID, not Keyboard (so I think we can use HID API). Keystrokes are sent as Input Reports.
This may be a trivial question, but I'm not sure what is the best way to being kept notified of keystrokes without delay or performance impact (it's normal to have multiple keys in the order of milliseconds). Microsoft suggests that user mode applications should use ReadFile. So should I just have a separate thread that has an infinite loop calling ReadFile (overlapped read) and WaitForSingleObject then notify the main thread?

Best Regards,
Title: Re: How to get notified of Input Reports without Delay
Post by: Jan Axelson on July 08, 2013, 09:58:31 am
Yes, you can use ReadFile or the .NET Filestream class with notifications. I have example code:

www.Lvr.com/hidpage.htm

Other options are DirectX's DirectInput and the Raw Input API (for system keyboards).