Skip to content

hidapi adapter is a port of popular cross platform library "hidapi"

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
hidapi_licence_bsd.txt
BSD-3-Clause
hidapiadapter_licence_bsd.txt
Notifications You must be signed in to change notification settings

nvchernov/hidapiadapter

hidapi adapter

This project was created to port popular library, that helps to interact with HID devices - hidapi (C language) https://github.com/signal11/hidapi

The main goal of project is to make library that adapted to C#

Here is example showing how to print information about connected HID devices

    //trying to find devices with any vendor_id, product_id
    var devices = HidDeviceManager.GetManager().SearchDevices(0, 0);

    if(devices.Any())
    {
        foreach(var device in devices)
        {
            device.Connect();

            Console.WriteLine(
              $"device: {device.Path()}\n" +
              $"manufacturer: {device.Manufacturer()}\n" +
              $"product: {device.Product()}\n" +
              $"serial number: {device.SerialNumber()}\n");

            device.Disconnect();
        }

    }

How to use?

To get devices use SearchDevices static method of HidDeviceManager class.

    HidDeviceManager.GetManager().SearchDevices(0, 0);

SearchDevices will return a set of founded devices (HidDevice)

To interact with devices use methods Read\Write. Here example

...
    m_ReadResult = m_Device.Read(m_Buffer, m_Buffer.Length);
    if (m_ReadResult == -1)
        throw new HardwareConnectionException("Cannot read data from device");
...

Nuget

Install-Package HidApiAdapter

Troubleshooting

Properties of installed dlls

If you getting DllNotFoundException: ... DLL "hidapi32"

Change properties of installed dlls - hidapi32.dll hidapi64.dll like on screenshot

image

No C++ Redistributable package installed

You may getting exception "DllNotFoundException: Unable to load DLL 'hidapi32': The specified module could not be found" because you have no C++ Redistributable package installed on your windows. To fix this just install it

About

hidapi adapter is a port of popular cross platform library "hidapi"

Topics

Resources

License

BSD-3-Clause, BSD-3-Clause licenses found

Licenses found

BSD-3-Clause
hidapi_licence_bsd.txt
BSD-3-Clause
hidapiadapter_licence_bsd.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages