Welcome to HidApi.Net a modern cross platform C# binding for the C HIDAPI library. Supported platforms are Linux, OSX and Windows.
Supported HIDAPI version: Up to 0.14
To use the library please reference the nuget package in your project. Additionally it is required to either ensure that HIDAPI is available on the host system or is distributed as part of your application.
To get an overview of the API please refer to the API documentation.
You can use the Hid class to enumerate over devices or directly use the device class to connect to a known device:
foreach(var deviceInfo in Hid.Enumerate())
{
using var device = deviceInfo.ConnectToDevice();
Console.WriteLine(device.GetManufacturer());
}
Hid.Exit(); //Call at the end of your program
var device = new Device(0x00, 0x00); //Fill vendor id and product id
Console.WriteLine(device.GetManufacturer());
Hid.Exit(); //Call at the end of your program
In order to access HID devices as an unprivileged user an udev rule must be installed on the host system. Please refer to the sample udev file of the HIDAPI project.
If the application targets at least .NET 8 the nuget package allows applications to be published as Native AOT as itself is AOT compatible.
To build the solution locally execute the following commands:
$ git clone https://github.com/badcel/HidApi.Net.git
$ cd HidApi.Net/src
$ dotnet build
HidApi.Net is licensed under the terms of the MIT-License. Please see the license file for further information.