Is there an API in .NET (C#) for using USB HID (human interface) devices?
-
Duplate question: http://stackoverflow.com/questions/68749/working-with-usb-devices-in-net – Morten Frederiksen Mar 20 '12 at 18:07
-
1Not totally a duplicate -- this question deals with HID (which I'm assuming means "driverless" HID), so the answers to the other question don't all apply to this one. – HanClinto Oct 03 '12 at 17:58
-
No - HID actually means all existing or yet not invented devices that humans may interact with or not interact soo much. Let it be a temp sensor or a button or a colorimeter. Some data in, some out (low amounts) – Robetto Apr 20 '16 at 13:05
-
Yep. https://github.com/MelbourneDeveloper/Hid.Net . It supports .Net Core, Framework, Android, and UWP. – Christian Findlay Aug 15 '18 at 06:54
8 Answers
HidLibrary wraps up all the P/Invoke calls for you. But no, it doesn't look there are any nice framework APIs for dealing with USB devices.

- 30,738
- 21
- 105
- 131

- 668
- 8
- 15
-
4+1 for HidLibrary; I was starting to go down the road of rolling my own C# wrapper lib for the kernal32 and hid.dlls. HidLibrary has already done the hard work (mostly) and provides a clean, simple API at that. Got me up and running amazingly fast (like, minutes). And you can install it with nuget, which is nice. There are other c# hid.dll wrapper libs out there, but nothing quite so clean that I've seen. – ptrandem Nov 17 '12 at 00:16
-
1
-
HidLibrary is Windows only. Device.Net supports Hid and USB on Android, Windows, and UWP. https://github.com/MelbourneDeveloper/Device.Net – Christian Findlay Jan 18 '19 at 08:47
Here's mine little library for dealing with HID devices.
It might be useful, especially when you are trying to communicate using raw HID reports. I've also included a simple demonstration of how to use it.

- 30,738
- 21
- 105
- 131

- 41
- 1
There's nothing direct or high-level. There are some things you can do through the managed WMI API, but I've personally found a lot of WMI interaction with hardware to be cryptic at best and requiring a lot of trial-and-error to get it to do what you want.
Someone on The Code Project has developed a .NET component for USB HID you can try out that's probably going to fit the bill better than WMI.

- 30,738
- 21
- 105
- 131

- 1,062
- 12
- 20
I would suggest you follow this example instead. It was invaluable in getting me up and running with HiD dev in C#.

- 12,966
- 7
- 55
- 87

- 6,986
- 16
- 73
- 121
I suggest you start here: http://wiimotelib.codeplex.com/

- 1,404
- 8
- 15
-
-
3Because the Wiimote is a HID device under windows, and that codeplex project has all the p/Invoke work needed to communicate with a HID device from the CLR done for you in the HDImports class – squig May 28 '10 at 14:18
-
Try looking at this: Simple HID Library. The main page has a list of other open source libraries.

- 5,114
- 1
- 40
- 72
I was also searching for it. I'm using the code I found here: http://janaxelson.com/hidpage.htm

- 21
- 3