.NET API for HID (USB)?

58,121

Solution 1

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.

Solution 2

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.

Solution 3

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.

Solution 4

I would suggest you follow this example instead. It was invaluable in getting me up and running with HiD dev in C#.

Solution 5

Take a look at this library on Google Code:

C# USB HID driver

Share:
58,121

Related videos on Youtube

jco
Author by

jco

Updated on July 09, 2022

Comments

  • jco
    jco almost 2 years

    Is there an API in .NET (C#) for using USB HID (human interface) devices?

    • Morten Frederiksen
      Morten Frederiksen about 12 years
    • Prasanga
      Prasanga over 11 years
      Not 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.
    • Robetto
      Robetto about 8 years
      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)
    • Christian Findlay
      Christian Findlay over 5 years
      Yep. github.com/MelbourneDeveloper/Hid.Net . It supports .Net Core, Framework, Android, and UWP.
  • jco
    jco almost 14 years
    Why? A Nintendo Wiimote library!?
  • squig
    squig almost 14 years
    Because 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
  • Dark Star1
    Dark Star1 almost 14 years
    This doesn't answer the question.
  • ptrandem
    ptrandem over 11 years
    +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.
  • Saw
    Saw almost 11 years
    It is very unstable, especially on Win7
  • tarabyte
    tarabyte almost 10 years
    That library is no longer supported.
  • Christian Findlay
    Christian Findlay over 5 years
    HidLibrary is Windows only. Device.Net supports Hid and USB on Android, Windows, and UWP. github.com/MelbourneDeveloper/Device.Net