20 Commits

Author SHA1 Message Date
Brendan Shanks
4009466d59 macOS: Check for macOS 10.10 using kCFCoreFoundationVersionNumber instead of AppKit (#611)
Effectivelty removes the dependency on AppKit for HIDAPI.

Fixes: #587
2023-08-27 17:28:01 +03:00
Jef Driesen
663f1a707d Link gcc helpers statically on MinGW (#488)
When compiling a 32bit dll with the mingw-w64 compiler, some 64bit
integer arithmetic operations are implemented using functions from
libgcc (e.g. __udivdi3 and __umoddi3 from libgcc_s_dw2-1.dll). This
unexpected dependency is inconvenient for applications.

The run-time dependency can be avoid by linking statically.
2022-12-12 20:27:20 +02:00
Dimitriy Ryazantcev
fe9a2a2e28 Ported code from SetupApi to CfgMgr32 (#362)
- https://docs.microsoft.com/windows-hardware/drivers/install/porting-from-setupapi-to-cfgmgr32
-  Use Unicode Windows API internally where possible.
2022-01-21 18:43:08 +02:00
Ihor Dutchak
77128aac88 Add deprecation message for Autotools 2021-09-20 16:06:27 +03:00
Ihor Dutchak
f2bb972e7f add CMake build system 2021-07-03 20:38:58 +03:00
Florin Popescu
de08a4f3b8 Added support for MSYS2 2021-03-07 13:57:19 +02:00
Jan Palus
d15d594a41 configure.ac: remove duplicate AC_CONFIG_MACRO_DIR (#226)
fixes build with autoconf 2.70
2021-01-15 15:32:14 +02:00
Ihor Dutchak
8f72236099 add hid_version/hid_version_str API (#192)
- API functions to get runtime version of the library;
- macros to get static/compile-time version of the library;
- VERSION file;
2020-10-14 18:41:08 +03:00
Ihor Dutchak
cdc473dfe4 Don't leak device handle in macOS 10.10 or newer (#186)
In one of the early versions of macOS, when you try to close the device
with IOHIDDeviceClose() that is being physically disconnected.
Starting with some version of macOS, this crash bug was fixed,
and starting with macSO 10.15 the opposite effect took place:
in some environments crash happens if IOHIDDeviceClose() is _not_ called.

This patch is to keep a workaround for old versions of macOS,
and don't have a leak in new/tested environments.

Fixes: #144.
2020-09-29 14:01:30 +03:00
CodeforEvolution
f2611e0237 Changes to Build System for Haiku
Co-authored-by: @CodeforEvolution
Co-authored-by: Luca Weiss <luca@z3ntu.xyz>
Co-authored-by: Begasus <begasus@gmail.com>
Co-authored-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
2020-02-12 17:00:07 +02:00
Luca Weiss
fc677b8195 configure.ac: Use pkg-config to find libusb on *freebsd 2019-08-30 10:23:23 +02:00
Filip Kubicz
7da5cc91fc configure.ac: release 0.9.0
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-06-19 12:34:38 +02:00
Filip Kubicz
d621d5fcaa configure.ac: Release 0.9.0-rc1
Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-06-19 09:12:36 +02:00
Luca Weiss
baaec212a0 configure.ac: don't use +=
The += operator is bashism and won't work with non-bash shells, such as
ash on Alpine Linux.
2019-06-07 08:32:53 +02:00
Alan Ott
99d0219a87 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 <alex@1stleg.com> and was posted on github.
2014-07-22 17:27:42 -04:00
Scott Talbert
54db8ca208 libusb: Add support for compiling on Debian/kFreeBSD 2014-07-22 16:29:52 -04:00
Alan Ott
40cf516139 HIDAPI 0.8.0-rc1 2013-10-06 18:43:37 -04:00
Hans de Goede
02a882c890 libusb: Properly wait for transfer cancellation on read_thread() exit
While triaging libusb bugs, I took an indepth look at:
https://github.com/libusbx/libusbx/issues/25

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()
exit:

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
https://github.com/libusbx/libusbx/issues/25

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 <hdegoede@redhat.com>
2013-09-08 21:50:36 -04:00
Peter Stuge
399e4fad12 configure.ac: Reduce required autoconf version to 2.63 which also works 2012-08-14 22:34:29 -04:00
Alan Ott
6d50f8fa0f Add Autotools build system (automake, autconf)
This adds the familiar autotools build system and associated documentation
for Linux, FreeBSD, Mac, MinGW, and Cygwin.  The old Makefiles have been
kept, and where appropriate have been renamed Makefile-manual.

Thanks to Peter Stuge, Ludovic Rousseau, Xiaofan Chen, Alex Dupre, and
Segher Boessenkool for providing testing, review, and suggestions, and to
Ludovic Rousseau for providing patches which contributed to this commit.
2012-07-16 00:43:04 -04:00