PORTS Forum

Ports and Interfaces => USB => Topic started by: HDowns on September 24, 2012, 10:07:15 am

Title: USB HID keyboard
Post by: HDowns on September 24, 2012, 10:07:15 am
I'm trying to read report using ReadFile from my keyboard, but encountered with one problem. I can't get usages from a report buffer

1. ReadFile - success (3 bytes, with Report ID).
2. GetButtonCaps - success (1 button capability).
3. the button capability match the report ID and I'm using report page from HIDP_BUTTON_CAPS to get usages.
4. GetUsagesEx - fail with error code HIDP_STATUS_INCOMPATIBLE_REPORT_ID.

I've read about this error code in MSDN (http://msdn.microsoft.com/en-us/library/ms923757.aspx), but I don't know how to interpret it in my situation
The device has only one button capability with one page ID and I use this page ID.

Could someone say, what is wrong?
Title: Re: USB HID keyboard
Post by: Jan Axelson on September 24, 2012, 10:47:32 am
Windows 2000 and later have exclusive read/write access to Input reports for HIDs that are configured as a system keyboards or mice. Use raw input or DirectInput instead.

http://msdn.microsoft.com/en-us/library/ms645536%28VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ee416842%28v=vs.85%29.aspx
Title: Re: USB HID keyboard
Post by: HDowns on September 25, 2012, 12:50:16 am
I can read a report, but I can't get button usages from this report.

Added: same problem appears with USB joystick.
Title: Re: USB HID keyboard
Post by: Jan Axelson on September 25, 2012, 11:12:30 am
The Usages are in the HIDP_CAPS structure:

http://msdn.microsoft.com/en-us/library/windows/hardware/ff539697%28v=vs.85%29.aspx