Commit Graph

45 Commits

Author SHA1 Message Date
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
Andrew Eikum
93dca80762 Update more repository URLs 2019-07-25 07:57:59 +02:00
Niklas Hambüchen
7df3973404 hidapi.h: Update documentation hid_error() 2019-07-15 13:15:46 +03:00
miketsmith
35c5b2e404 Fix doc string for hid_enumerate
Wrong struct called out
2019-06-18 07:28:12 +02:00
Luca Weiss
2f7a7c9948 Rename hid_device* parameters to dev
Previously, the header file used hid_device *device and the
implementations used hid_device *dev. Make this consistent.
2019-06-17 11:32:48 +02:00
Dylan McKay
00e6e4568f mac: Set a valid interface number on hid_device_info for USB HID devices
Previously the interface would never be set on Mac.

This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.

This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.

It is unclear if the macOS IOKit library returns valid interface numbers
for non-HID USB devices. Because of this, I have opted to simply skip
that case - leave it initialised to `-1`.

In the future, we can easily relax this restriction if it turns out
IOKit correctly returns interface number with non-HID USB devices. For
now, this commit brings 90% of the value at 5% of the risk.
2019-06-06 17:31:48 +02:00
Alan Ott
d17db57b9d header: Update documentation for hid_get_feature_report() 2014-08-18 11:20:40 -04:00
Alan Ott
1a42177fa5 header: Clarify comment on hid_read() and hid_read_timeout()
Clarify that a return value of zero means no packet was available.
2013-11-01 09:38:31 -04: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
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
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
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
27a0ad59e9 Added some info to the comments. 2011-09-10 17:40:31 -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
Ryan Pavlik
36c309f521 Parse the interface number out of the path on Windows where possible.
Although the Windows API doesn't provide direct access to interface number,
on child devices representing the interfaces of a composite device, it is
parsable from the device path. An excerpt of a path for interface 1 of a
Razer Hydra device is as follows:
\?\hid#vid_1532&pid_0300&mi_01

See table 4 and related text here:
  http://msdn.microsoft.com/en-us/windows/hardware/gg487473

This patch, if a path is available, and further, if &mi_ is found, parses
what it can for a hex value into the interface_number field. If there is
any problem, the invalid value (-1) is used instead.

Patch from Ryan Pavlik <abiryan@ryand.net> with modifications by Alan Ott.
2011-08-30 16:55:59 -04:00
Alan Ott
e62dba691d hid_read_timeout() (Linux and Windows).
hid_read_timeout() will execute a blocking read up until a timeout has been
reached or data has been received.

This patch implements it on all platforms and comes from Urs Fleisch.
Commit log message by Alan Ott.

Signed-off-by: Urs Fleisch <urs.fleisch@gmail.com>
Tested-by: Alan Ott <alan@signal11.us>
2011-08-08 21:01:37 -04:00
Alan Ott
98639e1f77 Change interface to interface_number in hid_device_info struct.
Forgot to add to previous commit.
2011-01-18 23:03:45 -05:00
Alan Ott
a93cdfbeac Add the interface number to hid_device_info on Linux/libusb implementation.
The interface number is added to the hid_device_info struct. Since the
Linux/libusb implementation can't put the Usage and Usage Page in the
hid_device_info struct because it requires detaching the kernel driver, the
interface number is added instead so that users with composite HID devices
can differentiate between the interfaces on the device.
2011-01-18 22:52:06 -05:00
Bastaan Veelo
ba51d59a4e hid_device_info with bcdDevice release number. 2011-01-18 18:38:35 -05:00
Alan Ott
3a4192eb45 Support for Usage Page and Usage for each device in the hid_device_info struct. 2011-01-11 23:59:12 -05:00
Ludovic Rousseau
8f3ccc3ec2 Avoid double inclusion of hidapi.h
Use HIDAPI_H__ instead of __HIDAPI_H__
2010-11-29 12:23:02 -05:00
Ludovic Rousseau
b09db7eb66 Avoid double inclusion of hidapi.h
Use the classic
 #ifndef __HIDAPI_H__
 #define __HIDAPI_H__
 ...
 #endif
2010-11-29 12:22:52 -05:00
Ludovic Rousseau
cad91b1808 Doxygen documentation
Convert the comments to make them use the Doxygen format and add a
Doxygen configuration file

Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-09 12:40:38 -04:00
Alan Ott
7650ac65b2 Merge branch 'master' of github.com:signal11/hidapi 2010-09-13 11:16:35 -04:00
Alan Ott
09cb41aada Additional licenses. HIDAPI is now GPLv3, BSD, or the original license,
at the discretion of the user. This should provide maximum flexibility and
freedom.
2010-09-13 11:15:24 -04:00
Alan Ott
5fa9bf37c4 Changes made for Cygwin. The _stdcall had to come out. I'm not sure about taking this out, but it's the only way I've found so far to make Cygwin work. 2010-09-07 14:13:41 -04:00
Alan Ott
17c4c9251c Changed hid_error() to return const. 2010-08-21 13:22:03 -04:00
Alan Ott
f53f5fb0f8 Changed hid_get_feature_report() to return the number of bytes actually read on Windows. This involved changing the implementation to use DeviceIoControl() rather than HidD_GetFeature().
Changed it on Mac as well to return the same. The Linux implementation already did this.
2010-08-14 14:12:43 -04:00
Alan Ott
65331407a7 Made the hid_error() return wchar_t* so we can get translated error messages. 2010-08-10 14:58:59 -04:00
Alan Ott
da1ab35011 Fixed up the header comments. 2010-07-28 20:32:41 -04:00
Alan Ott
2097e314fc Modified the windows build to not require the DDK to build the DLL.
Also moved the windows hid.cpp file to windows/ from hidapi/. hidapi/ now
only contains the library header file.
2010-07-27 22:28:42 -04:00
Alan Ott
5ff108a94b Changed name from hidapi/ to windows/ 2010-07-27 21:40:17 -04:00
Alan Ott
f3380552ee Checking in latest built files for Windows. 2010-07-25 23:16:23 -04:00
Alan Ott
d522d26d5c Added support for building the Windows version without the DDL by loading the hid.dll functions dynamically. 2010-07-25 23:07:17 -04:00
Alan Ott
49e5aedc06 Converted the Windows implementation over to use the new interface. 2010-07-25 22:11:50 -04:00
Alan Ott
aa3d51925a Changed the interface to use a pointer instead of an int as the device handle.
This is only implemented on Linux so far.
2010-07-24 11:05:36 -04:00
Alan Ott
23c43b0e84 Added some checking. 2010-07-10 22:01:43 -04:00
Alan Ott
32f9cb6c3c Added support for Set/Get Feature reports for Windows. 2010-07-05 16:35:42 -04:00
Alan Ott
96aca32ec8 Implemented the Manufacturer and Product strings in the hid_device struct on Windows. 2010-07-01 17:56:46 -04:00
Alan Ott
ebc18502b7 Added the hidapi_enumerate() interface on Linux.
Added manufacturer and product strings to the hid_device struct.
2010-07-01 17:39:24 -04:00
Alan Ott
0cc06e1f02 Added the hidapi_enumerate() interface to the Windows implementation. 2010-07-01 16:56:15 -04:00
Alan Ott
c506c71bb8 Enumeration interface and hidapi_open_path(). 2010-06-30 22:08:21 -04:00
Alan Ott
353308641d Whitespace update 2010-05-30 15:52:40 -04:00
Alan Ott
e90278d036 Added support for Nonblocking I/O.
Documented the hidapi.h header.
Fixed hid_get_error() wchar_t bug.
Fixed invalid handle error in hid_open()
Updated example to show non-blocking operation.
2010-05-30 15:10:55 -04:00
Alan Ott
5773da50d9 Initial import of source files. 2010-04-11 16:29:01 -04:00