Commits on Sep 20, 2016
  1. all: Fix a few typos

    diegoherranz committed with Jan 28, 2016
  2. Documentation: path fixes

    hid-libusb.c was renamed hid.c long ago but documentation wasn't
    diegoherranz committed with Jan 28, 2016
  3. windows: Set maximum buffer for USB strings to 0xFFF wide characters

    Limit the size of the buffer passed to hid_get_manufacturer_string(),
    hid_get_product_string(), and hid_get_serial_number_string() because
    calling the underlying win32 functions with larger buffers causes them
    to fail.
    amullins83 committed with Jun 20, 2016
  4. Mac: Disable unused get_location_id()

    Disable get_location_id(). It's not used in active code since make_path()
    was removed.
    mrpippy committed with Nov 24, 2014
  5. Mac: Remove unused get_string_property_utf8()

    Remove get_string_property_utf8(), it's not used since make_path() was removed
    mrpippy committed with Nov 24, 2014
  6. Mac: Use IOKit IOService:/ paths for devices

    Change hid_enumerate() and hid_open_path() to use IOKit IOService:/
    paths to uniquely identify devices, instead of creating a path
    (done by the make_path() function).
    The path passed to hid_open_path() now must be a valid path to an
    IOHIDDevice in the IOService plane, like:
    mrpippy committed with Apr 13, 2013
Commits on Mar 3, 2016
  1. linux: Check value returned by fstat(2)

    Problem reported by the Coverity tool
    CID 1042532 (#1 of 1): Unchecked return value from library
    (CHECKED_RETURN)2. check_return: Calling function
    "fstat(dev->device_handle, &s)" without checking return value. This
    library function may fail and return an error code.
    Ludovic Rousseau committed with Alan Ott Sep 22, 2013
  2. windows: Always open with sharing enabled

    In the past, there was desire to make hid_open() open devices
    exclusively, preventing devices from being opened more than once.
    Unfortunately, recent versions of Windows have made this largely
    impossible for many devices, as it appears that Windows itself is
    holding certain HID devices open or preventing them from being
    opened in exclusive mode.
    This patch will always open devices in SHARED mode on Windows.
    committed Mar 3, 2016
Commits on Aug 18, 2014
  1. windows: Return the correct length from hid_get_feature_report()

    The Windows DeviceIoControl() doesn't account for the report ID byte.
    Reported-by: Petr Stehlík <>
    committed Aug 18, 2014
Commits on Jul 23, 2014
  1. libusb: Adapt to FreeBSD 10

    FreeBSD 10 has libusb_get_string_descriptor() in base libusb, so don't
    define it here.
    blabber committed with Dec 14, 2013
  2. libusb: Add Android support

    This code originally came from Pekka Nikander <>
    prusnak committed with Apr 6, 2014
Commits on Jul 22, 2014
  1. libusb: Fix null pointer dereference in hid_open()

    Make sure hid_device_info.serial_number is not null before passing it to
    When libusb can't open a device for any reason (e.g. file system
    permissions), hid_device_info.serial_number is NULL. Make sure
    hid_device_info.serial_number is not null before passing it to wcscmp(3).
    Signed-off-by: Michael Hanselmann <>
    hansmi committed with Dec 19, 2013
  2. windows: Limit hid_read() return value to buffer length

    hid_read() and hid_read_timeout() now return the number of bytes copied,
    instead of the number of bytes returned by GetOverlappekdResult() (which is
    the maximum report size for the device).  This limits the return value to
    the requested length (buffer size), matching the behavior on other
    marktsuchida committed with Dec 21, 2013
  3. configure: Check for Fox 1.7 as well as Fox 1.6 for the testgui

    The testgui will work with both, so check for them both at
    configure time.
    This came from Alex Barker <> and was posted on github.
    committed Jul 22, 2014
  4. windows: Set the OS report buffer size to 64 reports

    Resolves issues with dropped input reports when receiving a large amount
    of data.
    swt2c committed with Jan 29, 2014
  5. libusb: Include PTHREAD_CFLAGS when linking libhidapi-libusb

    m4/ax_pthread.m4 says that PTHREAD_CFLAGS needs to be provided to the
    linker line as well as the compile line.  This enables static library
    builds of hidapi.
    swt2c committed with Feb 4, 2014
  6. hidtest: Remove "All Rights Reserved" from hidtest.cpp

    The language may be confusing for this file, since the hidtest.cpp file
    may be used by anyone for any reason.
    bwildenhain committed with Apr 28, 2014
Commits on Dec 13, 2013
  1. linux: Better kernel version detection

    Refactor version detection into a function.
    Handle versions of form X.Y.Z as well as X.Y.
    Don't do workarounds for old kernels if version cannot be detected.
    Klee Dienes committed with Sep 26, 2013
Commits on Nov 1, 2013
  1. header: Clarify comment on hid_read() and hid_read_timeout()

    Clarify that a return value of zero means no packet was available.
    committed Nov 1, 2013
Commits on Oct 6, 2013
  1. HIDAPI 0.8.0-rc1

    committed Oct 6, 2013
  2. autotools: Add mac_support.h to

    Not sure how this got missed.
    committed Oct 6, 2013
  3. testgui: Remove pre-built testgui executable

    Executables should have never been in the repo to begin with.
    committed Oct 6, 2013
  4. libusb: Fix 'dev' memory leak on hid_init() failure.

    Signed-off-by: Mario Kleiner <>
    kleinerm committed with Oct 5, 2013
  5. all: Fix license name

    "GNU Public License" does not exist. It is called "GNU General Public
    License", "GNU GPL" or simply "GPL".
    ikarienator committed with Oct 3, 2013
Commits on Sep 9, 2013
  1. mac: Fix incorrect device list after device removal

    On Mac OS X 10.8.x (Mountain Lion), if a device is connected, opened, then
    closed, then unplugged, subsequent calls to hid_enumerate() will still
    list the device (even though it's been unplugged).  If the device is
    plugged in again, a second instance will show up in the list and often it
    will be impossible to open either.  Github user TamToucan figured out that
    in hid_enumerate() if a call is made to IOHIDManagerSetDeviceMatching()
    before the call to IOHIDManagerCopyDevices() that this will clear the
    Thanks to TamToucan for figuring this out.
    committed Sep 9, 2013
  2. README: Add build dependencies

    Some build system dependencies were missing from the documentation.
    committed Sep 9, 2013
  3. gitignore: add config.* to .gitignore

    This makes HIDAPI less noisy when used a git submodule.
    Signed-off-by: Spencer Oliver <>
    ntfreak committed with Aug 6, 2013
  4. libusb: Properly wait for transfer cancellation on read_thread() exit

    While triaging libusb bugs, I took an indepth look at:
    This has lead me to the conclusion that there are 2 issues with hidapi's
    libusb code wrt waiting for the transfer cancellation on read_thread()
    1) There is a race where hid_close() can successfully cancel the transfer
    after a read_callback() has submitted it but before read_thread() checks
    shutdown_thread.  If this race is hit, then the libusb_cancel_transfer()
    in read_thread() will fail, causing read_thread() to not call
    libusb_handle_events() to complete the cancelled transfer.  hid_close()
    will then free the transfer, and if later on libusb_handle_events() gets
    called on the same context, it will try to complete the now freed
    transfer.  This is what I believe leads to the segfault described in
    2) hidapi uses one read_thread() per hid_device, so if there are multiple
    hid_devices then there are multiple threads calling
    libusb_handle_events(), in this case there is no guarantee that a single
    libusb_handle_events() call will successfully lead to the cancelled
    transfer being completed.  If the transfer completion is already handled
    by another read_thread() and there are no other events, then the
    libusb_handle_events() call will hang, and thus the pthread_join() and
    thus hidapi_close() will hang.
    As number 2 is a generic problem found in more libusb apps, libusb has
    gotten a new API called libusb_handle_events_completed(), which takes an
    extra pointer to an int, whose contents must be set to nonzero on
    completion by the callback, which allows waiting for the completion of a
    specific transfer in a race-free manner.
    This patch switches the waiting for the transfer's final completion to
    using libusb_handle_events_completed(), thereby fixing both issues.  Note
    the while is necessary since libusb_handle_events_completed(), like
    libusb_handle_events(), will return as soon as it has handled *any* event.
    The difference with libusb_handle_events_completed() is that once it has
    all the necessary internal libusb locks, it checks the contents of the
    completed parameter, and will bail if that has become nonzero without
    waiting for further events.
    Signed-off-by: Hans de Goede <>
    jwrdegoede committed with Jul 8, 2013
Commits on Apr 23, 2013
  1. windows: Fix leak of event handle on open_device() failure

    Create a new free_hid_device() function which takes care of all the
    resources in hid_device which may need to be freed/released.
    Reported-by: Johan Lindh <>
    committed Apr 23, 2013
Commits on Mar 5, 2013
  1. mac: Unregister the proper removal callback in hid_close()

    Unregister from IOHIDManager instead of IOHIDDevice.
    Thanks to github user tomsor for noticing this.
    committed Mar 5, 2013
Commits on Jan 21, 2013
  1. linux: Use poll() even in non-blocking mode

    It appears that calls to read() when in non-blocking mode will not set errno
    to other than EAGAIN when the a device has been disconnected.  Note that
    this is the same errno code set when there is simply no data to return.
    Make it so that poll() is used, in non-blocking mode, to check the
    status of the device. In blocking mode though, poll() is not needed.
    committed Jan 21, 2013
  2. linux/libusb: do not check bDeviceClass on enumeration

    Some composite devices do not have bDeviceClass set to
    LIBUSB_CLASS_PER_INTERFACE and were ignored when enumerating HID devices.
    Ignore checking the bDeviceClass as we will be checking interface
    bInterfaceClass later anyway.
    Signed-off-by: Spencer Oliver <>
    ntfreak committed with Dec 19, 2012
  3. libusb: check for failure of hid_init()

    Return NULL from hid_enumerate() and hid_open_path() if hid_init() fails.
    ngs committed with Jan 21, 2013