Commit Graph

125 Commits

Author SHA1 Message Date
Luca Weiss
51bdec7844 Fix manual Makefiles and add CI for them (#131) 2020-01-12 04:09:48 +02:00
Daniel Van Noord
083223e779 Added support for Get Input Report (#59)
- Get Input Report supported on linux/libusb, mac and windows;
- linux/hidraw doesn't support it on kernel level;
2019-11-15 13:55:51 +02:00
Ludovic Rousseau
8184eb2087 Linux: fix Makefile-manual to build hidtest 2019-11-05 14:00:44 +01:00
Andrew Eikum
5d9b4cd93c Zero-initialize new hid_device_info structs
This fixes an uninitialized usage_page value leaking from the Linux
backend. It may fix other uninitialized values, too.
2019-07-25 08:08:12 +02:00
Andrew Eikum
93dca80762 Update more repository URLs 2019-07-25 07:57:59 +02:00
Ihor Dutchak
e4ad5ec64f Update README: hidraw: minimum supported kernel 2019-07-23 23:50:56 +03:00
Niklas Hambüchen
3bfe1001b6 hidraw: Implement hid_error() 2019-07-15 13:15:46 +03:00
Luca Weiss
6f79625abb linux: Drop workaround for kernel < 2.6.34
Also drop HIDIOC* definitions as they are present since kernel 2.6.39.
2019-07-15 13:14:08 +03:00
luz.paz
f01c4ede50 Misc. typo fixes
Found via `codespell -q 3`
2019-07-14 13:54:55 +02:00
Iakov Kirilenko
73b9ccb996 Explicit cast from void* to corresponding type
Fix compilation without -fpermissive
2019-06-24 22:55:27 +02:00
Diego Herranz
a6a622ffb6 all: Fix a few typos 2016-09-19 23:40:12 -04:00
Diego Herranz
1f615efdbe Documentation: path fixes
hid-libusb.c was renamed hid.c long ago but documentation wasn't
updated.
2016-09-19 23:40:11 -04:00
Ludovic Rousseau
98629a104b 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.
2016-03-03 11:01:36 -05:00
Klee Dienes
3a66d4e513 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.
2013-12-12 22:31:55 -05:00
Bei Zhang
2e27f98b3e all: Fix license name
"GNU Public License" does not exist. It is called "GNU General Public
License", "GNU GPL" or simply "GPL".
2013-10-06 17:33:44 -04:00
Alan Ott
119135b8ce 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.
2013-01-21 13:19:23 -05:00
Ludovic Rousseau
ec24f93100 all: make hid_enumerate() able to match any vendor or any product
Passing product_id=0 will match any product of a given vendor.  This patch
makes it also possible to use vendor_id=0 to match any vendor for a given
product id.

Windows code added to Ludovic's patch by Alan Ott.
2012-11-27 22:12:35 -05:00
Justin R. Cutler
69a91a8f6c All: Convert C99 comments (//) into C89 comments (/* */) 2012-11-26 18:49:51 -05:00
Stan Hu
d5710b4f96 linux: Fix memory leaks on serial number and product name
In get_device_string() serial_number_utf8 and product_name_utf8 could end
up not getting freed if certain errors occurred.
2012-11-26 15:07:51 -05:00
Stan Hu
1774c81f04 linux: check for EINPROGRESS from read()
Non-blocking I/O can cause read() to return EINPROGRESS in addition to
EAGAIN.  Handle this case.
2012-11-26 15:03:10 -05:00
Ludovic Rousseau
1826eabaef linux/hidraw: Fix compiler warning
hid.c: In function 'uses_numbered_reports':
hid.c:126:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:143:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
2012-11-26 11:21:42 -05:00
Ludovic Rousseau
85d608e80e Linux: Fix warning: function declaration isn't a prototype
linux/hid.c:83:13: warning: function declaration isn't a prototype [-Wstrict-prototypes]
linux/hid.c: In function 'new_hid_device':
linux/hid.c:83:13: warning: old-style function definition [-Wold-style-definition]
2012-09-21 10:51:34 -04:00
Ludovic Rousseau
8def28f09d Mac, Linux: Remove extra spaces at end of lines 2012-09-21 10:51:26 -04:00
Ludovic Rousseau
c279c1d25b Linux: Fix warning: comparison between signed and unsigned
mbstowcs() returns a size_t not an int.

hid.c: In function 'get_device_string':
hid.c:285:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:289:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
hid.c:318:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
2012-09-21 10:49:22 -04:00
Ludovic Rousseau
bfb2b5924d Linux: Remove unused function register_error()
Fix compiler warning
hid.c:93:13: warning: 'register_error' defined but not used [-Wunused-function]
2012-09-21 10:49:09 -04:00
Ludovic Rousseau
61757847c4 Linux: Fix warning: enumeration value not handled in switch
hid.c:282:5: warning: enumeration value 'DEVICE_STRING_COUNT' not handled in switch [-Wswitch-enum]
2012-09-21 10:49:03 -04:00
Ludovic Rousseau
6761e3f5ba Linux: Fix warning: no previous prototype
hid.c:190:1: warning: no previous prototype for 'parse_uevent_info' [-Wmissing-prototypes]
2012-09-21 10:48:54 -04:00
Ludovic Rousseau
367fc3f3aa linux: Fix bug on mbstowcs() usage
In case of error mbstowcs() returns (size_t) -1
It is not a negative value since mbstowcs() returns a size_t (unsigned)

Fix compiler warning:
hid.c: In function 'utf8_to_wchar_t':
hid.c:105:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
2012-09-21 10:48:36 -04:00
Thomas Perl
807afbc35c Linux: Fix return value handling of mbstowcs() 2012-07-17 22:31:05 -04:00
Alan Ott
48352615f0 Linux: Small refactoring of Thomas's previous patch 2012-07-17 22:31:05 -04:00
Thomas Perl
36f7dec134 linux/hid.c: Fix enumeration for Bluetooth devices 2012-07-16 01:09:13 -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
Alan Ott
38a7bf75f0 Renamed manual makefiles so they're out of the way of autotools
Files named Makefile which will conflict with autotools have been renamed to
Makefile-manual.
2012-07-16 00:43:04 -04:00
Alan Ott
0a199c36ed Linux: Fix error in Makefile
When the libusb implementation was moved into libusb/, this Makefile didn't
get updated properly.
2012-06-05 16:18:49 -04:00
Alan Ott
74440e2dbb FreeBSD: Add FreeBSD implementation.
This adds a FreeBSD implementation to HIDAPI using the libusb back-end. The
libusb/ folder now contains the libusb implementation and associated
Makefiles for Linux and FreeBSD. All libusb code has been removed from the
linux/ folder, so that the code in libusb/ can be shared by both (and
future) platforms.

This commit renames linux/hid-libusb.c to libusb/hid.c. Make sure to
use git log --follow to see full history of that file.

This code was written by:
 Alex Dupre <ale@FreeBSD.org>
 Alan Ott <alan@signal11.us>
2012-05-02 18:55:28 -04:00
Alan Ott
c30dfd8c97 Linux: add -lrt to link with librt.
This is required for some distributions but not others.
2012-05-02 14:42:26 -04:00
Alan Ott
1bde032170 Linux/libusb: Shutdown thread if it's not possible to submit transfer
This happens if a device gets opened a second time. The call to
libusb_submit_transfer() will fail, indicating that the read thread should
be shut down.
2012-04-23 17:54:58 -04:00
Frode Austvik
992fef24d5 Fixed a typo that made the shared libraries be empty. Added the hidtest-* binaries to the list of files ignored by git. 2012-03-29 18:53:08 -04:00
philip
1186ca26c7 All: Make serial_number parameter to hid_open() const.
This prevents a warning when passing in a literal.
2012-03-28 18:05:49 -04:00
Alan Ott
59b9428199 Linux: Clean up Makefile
Create separate targets for libusb and hidraw implementations.
Build shared libraries in a more standard way.
Add Comments.
2012-03-28 17:58:30 -04:00
Frode Austvik
d0b493183e Linux: Added make targets for building shared libraries. 2012-03-28 17:06:48 -04:00
Vadim Zaliva
8717b87398 Linux/hidraw: Fix return value string functions
get_serial_number()
	get_manufacturer_string()
	get_product_string()

This matches the documentation in header file to return 0 on success and -1
on error.
2012-02-28 11:26:22 -05:00
Alan Ott
7f6b496374 Linux: Took out one more setlocale() 2012-02-27 21:13:25 -05:00
Alan Ott
b57e8f6dac Linux: Don't set locale if it's already been set
Adapted from a patch received from Axel Rohde <axel.rohde@gmail.com>
2012-02-27 12:10:29 -05:00
Mario Kleiner
e8c3e8db61 Use private libusb_context for linux/libusb implementation.
Use a private libusb_context to avoid conflicts between
multiple libusb instances inside a single application
process. Many 3rd party libraries use libusb as backend,
so there is a good chance of collisions if the default NULL
context is used.

Modified by Alan Ott to also remove the initialized
variable since it's no longer needed (since we can use
the context instead), to make the style consistent, and
to remove unnecessary checks for initialized before calling
hid_init().

Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Alan Ott <alan@signal11.us>
2012-01-12 17:24:04 -05:00
Alan Ott
0c7d531a4a Linux/libusb: include wchar.h and define _GNU_SOURCE.
This needed for older systems (pre Glibc 2.10).

This patch is from Brendan Shanks (github user mrpippy).
2011-10-20 17:28:27 -04:00
Alan Ott
2a599c2387 Fixed simple logic error.
Emailed to me by Frode Austvik <edorfaus@xepher.net>
2011-09-15 14:12:22 -04:00
Frode Austvik
686acc0507 Implemented the USB interface number for Linux/hidraw implementation.
Initial code by Frode Austvik <edorfaus@xepher.net>
Some modification and documentation by Alan Ott <alan@signal11.us>
2011-09-15 09:15:46 -04:00
Alan Ott
c41e806042 Add empty hid_init() and hid_exit to linux/hid.c 2011-09-10 17:47:08 -04:00
Ludovic Rousseau
529fc51487 Add hid_init() and hid_exit()
The really missing function was hid_exit() to free ressources allocated
by the HIDAPI and libusb libraries.
2011-09-10 17:33:35 -04:00