Author Topic: Problem with generic_hid_cs project  (Read 8634 times)

m.alizadeh91

  • Member
  • ***
  • Posts: 17
Problem with generic_hid_cs project
« on: July 20, 2011, 09:52:40 am »
hello sir
I was using your project to find out how can i work with hid devices.. after while i get Pid and Vid of a mouse and used it in your program.
your project detected it as a mouse but it errors that "handle is invalid and cant communicate with it" . i'm really mixed up. why it can't read data from a mouse???? (or keyboard) .
I'm working on industrial project which needs to communicate with usb. so it's really vital to me to understand about HID's.
really thanks sir.
i'm waiting for your reply
thanks again.  :)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Problem with generic_hid_cs project
« Reply #1 on: July 20, 2011, 10:19:13 am »
Windows 2000 and later have exclusive read/write access to Input reports from HIDs that are configured as a system keyboards or mice.

To read keyboard or mouse input, search on DirectInput or raw input.

My example code is for HIDs with vendor-defined functions.

Jan

m.alizadeh91

  • Member
  • ***
  • Posts: 17
Re: Problem with generic_hid_cs project
« Reply #2 on: July 20, 2011, 10:31:11 am »
Thanks Jan.
Actually i'm using W7. can you guide me briefly about vendor-defined devices? Aren't mice and keyboards included? I've read your book (only chapter 8 -13)
 Anyway, I'm working on a device that uses a PLC(programmable logic controller) and sends data to computer via a USB cable. i want to know: is it a HID device?? can i receive data by hid.dll and kernel32.dll?
i'm really sorry for bothering you and for bad English :(
really thanks ... :)


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Problem with generic_hid_cs project
« Reply #3 on: July 20, 2011, 10:37:01 am »
How an application communicates with a USB device depends on the device driver that Windows has assigned to the device. The choice of driver in turn depends on finding a match between the information in the descriptors that Windows retrieves on device attachment or bootup and the information stored in the PC's INF files.

If it's an existing device, look in Windows Device Manager to find out what driver Windows is using.

A HID's report descriptor tells whether the device has a vendor-defined function.

Jan

 

m.alizadeh91

  • Member
  • ***
  • Posts: 17
Re: Problem with generic_hid_cs project
« Reply #4 on: July 20, 2011, 11:08:47 am »
thank Mr.Jan
I used a game controller and then i saw data transferring :) One last question!! did you mean that mice are not vendor-defined devices??? and my game controller is vendor-defined so your project can receive data from it?
thanks again and so shameful for taking your time :(

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Problem with generic_hid_cs project
« Reply #5 on: July 20, 2011, 01:37:14 pm »
Windows takes control of system mice and keyboard HIDs only.

Jan