HIDSharp

HIDSharp is a multiplatform C# library for USB HID devices.

Version 2.0 allows you to read and parse reports from any USB HID input device. You can read USB gamepads, scales, anything you need. It does this by providing full report descriptor and report parsing capability. HIDSharp is, to my knowledge, the first driverless cross-platform library which can do this! Of course, raw reading and writing is still fully supported.

Version 1.5 and below are COM enabled to allow use by VB6 and MS Access programs (the .NET Framework will of course need to be installed). If there is demand I may add COM support to HIDSharp 2.0.

HIDSharp has received eight years of continual use with a Dymo Scale in MS Access, and seven years in commercial software with a wide variety of USB HID devices I've developed, so I know it to be reliable.

HIDSharp supports Windows, MacOS, and Linux (hidraw).

HIDSharp uses the Apache open-source license.

Downloads

Version 2.1.0 (May 4, 2019) (includes C# sample)
Version 2.0.8 (January 21, 2019) (includes C# sample)
Version 1.5 (May 18, 2013) (includes C# sample)
Version 1.4.0.1 (April 21, 2013) (includes C# sample)
Version 1.3 (February 23, 2013) (includes C# sample)
Version 1.1 (July 28, 2012) (includes C# and VB6 samples)
Version 1.0 (August 28, 2010) (includes C# and VB6 samples)
NuGet Package "HidSharp"
Online Documentation

Version History

2.1.0 (May 4, 2019):
Added experimental Bluetooth Low Energy support on Windows. This part of the library may change in the future. Let me know how it works for you.
Fixed a race condition in the exclusivity layer.
Fixed a threading bug that cropped up on .NET Core on Linux.
Serial devices that use Windows's buggy usbser.sys driver are now compatible with HIDSharp, including the detection of connection and disconnection.

2.0.8 (January 21, 2019):
Added support in SerialStream for seven data bits and even/odd parity.
Fixed a bug on MacOS which caused HID devices without serial numbers to not show up.

2.0.6 (December 27, 2018):
Added support in SerialStream for two stop bits.

2.0.5 (October 15, 2018):
HIDSharp is now compatible with .NET Core on Linux.
Fixed a garbage collector-related crash on MacOS.

2.0.2 (May 5, 2018):
Fixed a bug on Linux which caused output reports to be sent incorrectly on devices which do not use a Report ID.
DeviceList GetSerialDeviceOrNull() will now match the filesystem name (COM1, /dev/ttyUSB, etc.) as well as DevicePath.

2.0.1 (April 11, 2018):
Fixed a bug on Windows where, in some cases, being unable to reconstruct a device's report descriptor could prevent that device from being opened at all.
HIDSharp now includes assemblies for both .NET Framework 3.5+ and .NET Standard 2.0+.

2.0 (April 9, 2018):
Vastly improved the report descriptor parsing functionality.
You can now decode (nearly) any HID device's reports, on all platforms!

Added GetReportDescriptor support on MacOS version 10.8 and higher.
Added GetReportDescriptor support on Windows. This descriptor is a reconstruction as Windows does not provide a way to directly access this information.
Added an AreDriversBeingInstalled property on DeviceList. (Windows will sometimes close streams of composite HID devices opened while their drivers are being installed.)
Added a Changed event on DeviceList, for detecting device connect and disconnect.
Added a NativeImplementation property to Device.
Added an exclusivity layer, with the ability to request interruption. This is useful for interprocess cooperation, but must be enabled manually.
Added support for serial ports. This is still somewhat buggy on Linux, but on MacOS it works better than the Mono native implementation.
Added support for Linux libudev.so.1.
Exposed GetFileSystemName(). This can be used on Linux to check hidraw permissions.
Fixed max report lengths on MacOS for devices which do not use a Report ID.
Fixed Linux and MacOS not throwing IOException on HID Read() when the device is disconnected.
Fixed Linux support on recent Mono versions.
Fixed 32-bit Linux support (Raspberry Pi).
GetFeature() and SetFeature() now work on Linux.
HIDSharp now uses the Apache open-source license.

Feedback on the new features is appreciated. Some code modifications will be needed to use this new version.

1.5 (May 18, 2013):
Added the DevicePath property to HidDevice.
This is useful for differentiating devices with the same VID, PID, etc.

1.4.0.1 (April 21, 2013):
Added missing XML documentation file to the archive.

1.4 (April 20, 2013):
Documented the most important classes.
Fixed a problem with output reports on 64-bit Windows.
Fixed a timeout bug on Windows.
Parallelized device enumeration.
Reordered platform detection to prevent binary planting on Windows.

1.3 (February 23, 2013):
Fixed Linux libudev reference to not require developer package symlinks.

1.2 (October 16, 2012):
Fixed MacOS support.

1.1 (July 28, 2012):
Added experimental MacOS and Linux support.
Added experimental report descriptor parsing.

1.0 (August 28, 2010):
Initial release.