views:

2745

answers:

4

The library should;

-Be easy to use and few lines of client code should accomplish much
-Be as platform independent as possible. (In case of future ports to other platforms)
-Have C++ bindings.
-Be mature and stable

I would also like to be notified of most HID events through callbacks.

I have considered the following alternatives:

*libhid - (Unfortunately?) this is GPL and cannot be used in my application.
*WDK - Seems to be a bit low-level for my use. I don`t need that kind of control
*atusbhid - This has an appropriate level of abstraction but is firmly tied to the windows messaging loop

Do any of you have any other alternatives to offer?

+3  A: 

If libhid works for you, then perhaps the thing to do would be to write an app (which you would GPL), which uses libhid to talk to devices, then provides whatever you need via a TCP connection. Your real app would connect via TCP to do what it needs. This would obviously be a massive performance it.

This app would effectively be a 'shim' between libhid and your app. In this case, the shim would exist for legal, not technical reasons.

I'm not saying it's a good idea, just that it's an idea.

Michael Kohne
+2  A: 

HIDmaker software suite from Trace systems is an option.

Pros: - Easy to use (Excelent for learning how to program for USB HID) - Generates working applications source code in a various project formats (Visual Studio, Borland) - Generates stable example code for both host and device (stable in my experience) - High performance (if HID can even be said to have high performance in the first place)

Cons: - Only works on Microsoft Windows - Uses it's own USB library I think (ActiveX)

So in effect, it just provides you with a C++ binding to their ActiveX control. Also, it's meant to produce the code on the hardware side for a variety of microcontrollers. That seems a bit overkill to me.
Dave Van den Eynde
+2  A: 

Consider rolling your own. You'll have total control over the interface, the level of platform independence, and such. Even though a project is GPL, you can use it as a recipe for your own, and as a testbed to find issues with your own.

Dave Van den Eynde
+3  A: 

Look at this code:

http://khason.net/blog/read-and-use-fm-radio-or-any-other-usb-hid-device-from-c

It gives you some simple classes to talk to a HID device. What it boils down to is, get the alias for the device (something like \?\HID#Vid_nnnn&Pid_nnn#.......) and use CreateFile to open it. You can get the device's alias under HKML\SYSTEM\CCS\Control\DeviceClasses{4d1e55...}\

The Vid and Pid are the vendor ID and product ID of the device (check Device Manager).

Coderer