Cross-platform HID and serial library


libhs is a C library to enumerate HID and serial devices and interact with them. It is:

  • single-file: one header is all you need to make it work.
  • public domain: use it, hack it, do whatever you want.
  • multiple platforms: Windows (≥ Vista), Mac OS X (≥ 10.9) and Linux.
  • multiple compilers: MSVC (≥ 2015), GCC and Clang.
  • driverless: uses native OS-provided interfaces and does not require custom drivers.


Just download libhs.h from the GitHub repository. This file provides both the interface and the implementation. To instantiate the implementation, #define HS_IMPLEMENTATION in ONE source file, before including libhs.h.

libhs depends on a few OS-provided libraries that you need to link:

OS Dependencies
Windows (MSVC) Nothing to do, libhs uses #pragma comment(lib)
Windows (MinGW-w64) Link user32, advapi32, setupapi and hid -luser32 -ladvapi32 -lsetupapi -lhid
OSX (Clang) Link CoreFoundation and IOKit
Linux (GCC) Link libudev -ludev

This library is developed as part of the TyTools project where you can find the original non-amalgamated libhs source code. The amalgamated header file is automatically produced by CMake scripts.

Look at Sean Barrett's excellent stb libraries for the reasoning behind this mode of distribution.

In order to use the library you can: