libusb/hidapi logo

libusb/hidapi

Free

A Simple cross-platform library for communicating with HID devices

FreeFree tier
Type
Open Source

About libusb/hidapi

HIDAPI is a multi-platform library that allows applications to interface with USB and Bluetooth Human Interface Device (HID)-class devices on Windows, Linux, FreeBSD, and macOS. Originally developed by Alan Ott, it was moved to the libusb organization in 2019 for continued maintenance and bug fixes. The library offers four back-ends: Windows using hid.dll, Linux/hidraw using the kernel's hidraw driver, libusb via libusb-1.0, and macOS using IOHidManager. HIDAPI can be built as a shared library (.so, .dll, .dylib) or embedded directly into an application by adding a single source file and header per platform. It supports both USB and Bluetooth HID devices on the Linux/hidraw back-end, while the libusb back-end supports USB only. The library is widely used for building cross-platform tools and applications that interact with HID peripherals such as game controllers, sensors, and custom USB devices.

Key Features

Multi-platform support: Windows, Linux, FreeBSD, macOS
Supports USB and Bluetooth HID devices
Four back-ends: hid.dll, hidraw, libusb, IOHidManager
Can be built as a shared library or embedded directly as source
Single header and source file per platform for embedding
Actively maintained under the libusb organization
Includes test GUI and console test applications

Pros & Cons

Pros
  • Truly cross-platform with consistent API across Windows, Linux, FreeBSD, and macOS
  • Supports both USB and Bluetooth HID devices (depending on backend)
  • Can be used as a shared library or compiled directly into an application
  • Open source (BSD/GPL3 licensed) and free to use
  • Active development with regular updates and bug fixes
  • Well-documented API with test applications included
Cons
  • Bluetooth HID support is limited to specific back-ends (e.g., not available with libusb backend)
  • Some devices like keyboards and mice are blacklisted from hidraw nodes on Linux
  • Requires udev rules on Linux for unprivileged users to access HID devices
  • Linux/hidraw backend requires kernel 2.6.39 or later
  • No native support for Android or iOS (though community ports exist)

Best For

Building cross-platform applications that need to interact with HID devicesDeveloping software for game controllers, sensors, or other USB/Bluetooth HID peripheralsEmbedding HID device support into existing applicationsCreating diagnostic or debugging tools for HID devicesImplementing custom device interfaces for industrial or medical equipment

FAQ

What platforms does HIDAPI support?
HIDAPI supports Windows, Linux, FreeBSD, and macOS.
Does HIDAPI support Bluetooth HID devices?
Yes, but only with specific back-ends. The Linux/hidraw backend supports both USB and Bluetooth HID devices. The libusb backend supports USB only.
Can HIDAPI be embedded directly into an application?
Yes. HIDAPI can be built as a shared library or embedded directly by adding a single source file (per platform) and a single header to your application.
How do I choose between the hidraw and libusb back-ends on Linux?
Link to libhidapi-hidraw for devices with hidraw nodes (supports both USB and Bluetooth) or libhidapi-libusb for USB-only devices without kernel hidraw support.
What license does HIDAPI use?
HIDAPI is available under multiple licenses: BSD-style license (LICENSE-bsd.txt), GPLv3 (LICENSE-gpl3.txt), and the original license (LICENSE-orig.txt). The default is BSD.