Author Topic: USB HID keyboard  (Read 10536 times)

HDowns

  • Member
  • ***
  • Posts: 14
USB HID keyboard
« 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?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB HID keyboard
« Reply #1 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

HDowns

  • Member
  • ***
  • Posts: 14
Re: USB HID keyboard
« Reply #2 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.
« Last Edit: September 25, 2012, 07:54:29 am by HDowns »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB HID keyboard
« Reply #3 on: September 25, 2012, 11:12:30 am »