72 Commits

Author SHA1 Message Date
nastys
f42423643e Add Sixaxis init for Monterey 2025-05-23 03:08:36 +02:00
Ihor Dutchak
d6b2a97460 Fix hid_read_error documentation (#742) 2025-05-18 21:25:13 +03:00
Ihor Dutchak
95e6b98ce9 Add hid_read_error (#721)
hid_read_error is a separate error function, that returns error status of hid_read/hid_read_timeout.
hid_read/hid_read_timeout is no longer changes internal buffer used by hid_error and it makes it safe to use hid_read/hid_read_timeout from a separa thread, concurently with other device functions.
2025-03-11 19:26:36 +02:00
Ihor Dutchak
9fc8b01c77 hid_send_output_report: bump version to 0.15.0 2024-08-02 16:40:57 +03:00
mbcinergy
4578ea2461 Add hid_send_output_report() (#677)
`hid_send_output_report` sends report over control pipe, unlike existing `hid_write` which would send the data on the first interrupt OUT endpoint, if one exists and only falls back to control pipe.
2024-06-12 19:40:09 +03:00
Brendan
e65402ff46 Automate doxygen builds (#521)
- updated the doxyfile using doxygen -u
- include hidtest/test.c as a doc'd example
- use a brief doxygen/main_page.md file as the generated site's main page
- strip absolute paths from doxygen output (which now displays as relative paths to repo root)
- add CI to build the docs and save as a CI artifact and rewrite the contents of the gh-pages branch for deployment (for master builds)
- add some missing docstrings and excluded undocumented "helper macros" to satisfy warnings output in doxygen's build log
2023-04-05 12:41:14 +03:00
Dimitriy Ryazantcev
bd6be4d83b windows: try to get USB device serial number if not provided by HidD_GetSerialNumberString (#464)
This is efficient for Xbox Common Controller class (XUSB) devices like Xbox 360 or Xbox One controllers that are missing serial number via usual HID API.
2023-03-14 00:50:57 +02:00
Ihor Dutchak
fc3eed3845 windows: Have a separate definition flag for export (#515)
On some compilers an empty definition (e.g. -DHID_API_EXPORT)
means the same as `=1` (i.e. -DHID_API_EXPORT=1), but the HID_API_EXPORT macro should be
empty in static library build case.

Having a separate compiler definition flag solves that issue.
2023-03-13 12:11:37 +02:00
Ihor Dutchak
19f71a5017 hid_get_report_descriptor: bump version to 0.14.0 (#516) 2023-03-12 16:48:48 +02:00
Ihor Dutchak
26b5bb0ccf RFC: add hid_get_report_descriptor API function (#451)
- native implementations for hidraw/libusb/macOS;
- HID Report Descriptor reconstruction from HIDP_PREPARSED_DATA on Windows;
- unit-tests for some known devices for `hid_winapi_descriptor_reconstruct_pp_data`;
- support for ASAN builds (mainly to check the `hid_winapi_descriptor_reconstruct_pp_data`/its unit-tests;
2023-03-12 14:45:30 +02:00
Ihor Dutchak
438d06568d windows: don't mark with dllexport in static build (#507)
Don't mark API functions with __declspec(dllexport) when building a static library on Windows.
Enforced by CMake builds.
For other builds a compile definition is available.

Related: #480
2023-02-22 02:05:47 +02:00
Ihor Dutchak
4ebce6b505 Bump version to 0.13.1 2023-01-09 13:31:33 +02:00
Ihor Dutchak
4e63d6dfc3 Introduce HID_API_MAX_REPORT_DESCRIPTOR_SIZE (#452)
- first step is to use HID_API_MAX_REPORT_DESCRIPTOR_SIZE internally;
- port a few improvements from get-descriptor branch early;

Resolves: #384
2022-09-15 13:05:56 +03:00
Dimitriy Ryazantcev
0f2cf886e5 RFC: Add HID bus type in hid_device_info (#308) 2022-09-10 19:18:09 +03:00
Adrian Granados
15a7114cee Fixes "parameter not found" warning in documentation (#445) 2022-08-16 17:42:09 +03:00
Ihor Dutchak
5e299f4736 v0.13.0 for new API function (#439) 2022-08-13 19:43:44 +03:00
Julian Waller
5c9f147a07 Add hid_get_device_info (#432)
- new API function: `struct hid_device_info * hid_get_device_info(hid_device *dev);` to get `hid_device_info` after the device already opened;
- reused existing implementation on Windows and macOS from enumeration routines to have the implementation;
- refactored libusb implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;
- refactored hidraw implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;

Resolves: #431
Closes: #164
Closes: #163
2022-08-13 19:01:57 +03:00
Ihor Dutchak
eaa5c7c6f1 hid_error improvements (#428)
- make the behaviour of methods which set hid_error more consistent;
- make the documentation and the implementation of hid_error consistent and safe;
- windows: add global error implementation;

Co-authored-by: Julian Waller <git@julusian.co.uk>
2022-06-22 01:34:39 +03:00
Ihor Dutchak
bca404520f Fire v0.12.0 (#398)
- add convenient macros to check HIDAPI version in runtime;
- mark in which version all recent HIAPI API functions where added;
2022-04-23 15:50:41 +03:00
Ihor Dutchak
69dcdc1ff0 Update copyright strings 2022-01-29 18:33:15 +02:00
Youw
31bde69a1f Fire v0.11.2 2022-01-03 14:53:10 +02:00
Ihor Dutchak
ec0727c344 version bump 2021-07-03 22:04:45 +03:00
Ihor Dutchak
d9471d4608 Version 0.10.1 2020-11-23 21:39:25 +02:00
Antonio Borneo
8caf8c8985 hidapi.h: fix API prototype for gcc flag -Wstrict-prototypes (#207) 2020-11-23 21:04:19 +02:00
Jacob Alexander
48cacfa98b Usage Page and Usage on Linux with hidraw (#139)
NOTE: This commit does not handle composite HID descriptors
I am interested in adding support for composite descriptors though I still need to find a
device with a composite descriptor to test it correctly.

The implementation idea is similar, as in #125 for macOS.
2020-11-23 21:02:16 +02:00
Ihor Dutchak
302d1f2401 Fire v0.10.0 2020-10-25 23:59:59 +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
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