Author Topic: Detect HID Devices  (Read 3612 times)

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Detect HID Devices
« on: January 26, 2010, 12:01:08 pm »
Hi Roman,

some time ago I posted a Thread here how to detect devices with WM_DEVICECHANGE. Well I got it working fine with ports. But I have problems with HID devices.

Attached you will find my code for port devices.

If I attach a HID device to the computer I only get DBT_DEVNODES_CHANGED for Msg.WParam. This is a known "problem" in windows because HID devices don´t send DBT_DEVICEREMOVECOMPLETE or DBT_DEVICEARRIVAL. This is a problem for me because I can´t get details about the attached device.

Do you see any change to get a similar mechanism to detect HID devices after they are attached to the computer?

What I wan´t to achieve is to display a message to the User: "Deivce <DEVICENAME> was attached to USB port XY".

If I use DBT_DEVNODES_CHANGED I have two problems:
1) I can´t get any device details.
2) DBT_DEVNODES_CHANGED is send several times if you attach a device to the computer.

Any idea?

Greetz Dominik

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Detect HID Devices
« Reply #1 on: January 28, 2010, 07:59:34 pm »
Hi !

No idea on this topic ?

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Detect HID Devices
« Reply #2 on: February 02, 2010, 07:22:39 am »
Hi !

I can´t beleave that there is no answer for my question  :o

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detect HID Devices
« Reply #3 on: February 04, 2010, 06:39:33 pm »
Hello

I'm sorry but I don't understand.
Do you try to run UsbDeviceDemo? Does it refresh USB device list correctly?
Do you try to run HidDemo? Does it refresh HID device list correctly?

If all is ok in these demos just take a look their source code.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Detect HID Devices
« Reply #4 on: February 05, 2010, 07:16:38 am »
Hi Roman,

you missunderstood me.
Your demos all run fine - that´s not the problem. And for sure I took a look into the source codes.

I think it would be more clear if you run my attached demo application.

Let me explain what I wanna do:
If a user plug in a new serial port (USB / Serial converter) or a new HID device I need a popup which shows details about that device. One thing I wanna show is the friendly name of the device.

To achieve this I want to use the WM_DEVICECHANGE windows message. But HID devices only send  DBT_DEVNODES_CHANGED (what I need is DBT_DeviceArrival, DBT_DeviceRemoveComplete to get device details). So how can I read the device details after plugin the device?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Detect HID Devices
« Reply #5 on: February 05, 2010, 07:38:49 am »
Hello

I understood you correctly.
And I have seen your code. You try to analyze WM_DEVICECHANGE message.

Please note that WM_DEVICECHANGE is only notification message. It has very small details about real event.
It has no device description. Detailed device information is available only in SetupDiXXXX API.

Our demo projects call WMDeviceChange() methods for reload (refresh) internal device list of necessary type.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.