Commit Graph

574 Commits

Author SHA1 Message Date
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
Mykola f45df3be33 Add configure~ to .gitignore (#459) 2022-09-15 13:01:29 +03:00
Dimitriy Ryazantcev 0f2cf886e5 RFC: Add HID bus type in hid_device_info (#308) 2022-09-10 19:18:09 +03:00
Ihor Dutchak ceb41e0abe CI: more CMake build checks (#450)
Check CMake build on:
- Alpine
- Archlinux
- Fedora/mingw64
- FreeBSD
2022-09-10 16:56:05 +03:00
Ihor Dutchak 8224a4cb56 CI: add OpenBSD compilation check (#449)
NOTES, as described in #31:
- it is still hard to use HIDAPI on OpenBSD since it is hard to use LIBUSB with HID devices;
- there is a name colision with `hid_init` from `usbhid` OpenBSD library;
2022-09-10 16:54:19 +03:00
Ihor Dutchak 8068574ee1 Add meson.build as a wrapper over CMake (#410)
- not an independent build system, but a wrapper over CMake;
- may be used as a standalone Meson build or as a subproject;
2022-09-10 16:52:46 +03:00
Ian Douglas Scott dbd1681831 linux: Open files with O_CLOEXEC to not leak fds to child processes (#446)
Motivation described here: https://github.com/libusb/hidapi/pull/446
2022-08-21 21:40:39 +03:00
Adrian Granados 15a7114cee Fixes "parameter not found" warning in documentation (#445) 2022-08-16 17:42:09 +03:00
Ihor Dutchak ea38f6538f libusb: fix HID Report descriptor request (#444)
- pass the actual HID Report descriptor size (from HID descriptor);
- interface_num has to be wIndex, and not as part of wValue for LIBUSB_DT_REPORT request;
2022-08-16 16:29:10 +03:00
Ihor Dutchak 779346241b libusb: fix enumerating device path w/o root access (#442) 2022-08-15 12:47:27 +03:00
Ihor Dutchak c3ae3d0b58 Run hidtest for no more than 10 seconds when no hid_read data (#440)
Avoid infinite reading from the device if the device doesn't send any interrupt reports.
Otherwise hidtest has to be stopped by Ctrl+C interruption, which doesn't give a chance to close the device properly,
as a result this has negative side-effects when using LIBUSB backed.
2022-08-14 12:33:15 +03:00
Ihor Dutchak 597160da3c Reattach kernel driver when failed to claim interface (#441)
Potential execution path may happen if kernel driver successfully detached,
but libusb failed to claim the requested interface.

Otherwise the device remains with detached kernel driver.
2022-08-14 12:31:59 +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 81dd62dd10 Ensure Iconv is found when provided via CFLAGS/LDFLAGS (#430)
- by default find_file/find_library doesn't respect CFLAGS/LDFLAGS, and FindIconv fails to find Iconv;
- by explicitly trying to link against `-liconv` - we're checking if library is available in such way;
- additionally: if Iconv is detected as BUILT_IN, no need to explicitly depend on `Iconv::Iconv`;
2022-06-22 01:30:45 +03:00
Ihor Dutchak 59e84ca74f podspec: include darwin-specific header (#412) 2022-05-31 14:58:01 +03:00
Ihor Dutchak ace1e9a2dc Fix Cygwin Appveyor build (#423)
- run Cygwin on a newer environment;
- keep MSVC running on VS 2015, just to cover automated testing of it;

Fixes: #419
2022-05-31 13:16:03 +03:00
Ihor Dutchak 7610829409 v0.12.0 Release hidapi-0.12.0 2022-05-25 15:52:59 +03:00
MeeSong 844e4682a9 Fix: memory write out of bounds. (#418) 2022-05-25 15:49:47 +03:00
Ihor Dutchak 93285f5246 windows: Add .rc (#415)
- Add resource file for DLL;
hidapi-0.12.0-rc2
2022-05-11 17:47:38 +03:00
Ihor Dutchak 52fa87300b Windows build artifacts with Github Actions (#414)
- a straight-forward build matrix for Appveyor;
- MSBuild builds with Github Actions;
- Visual Studio 2022 support for `.sln` (toolset v143);
- gather Windows build artifacts with Github actions;
2022-05-08 19:59:39 +03:00
Ihor Dutchak 51196845d4 Prepare RC2 2022-05-08 15:00:10 +03:00
Ihor Dutchak e0f44a5887 Make a note about VERSION 2022-05-08 14:59:17 +03:00
Ihor Dutchak c95795ab5c Fix hidtest build
- fix including platform-specific includes when HIDAPI is a CMake subdirectory;
- check libusb and winapi platform-specific headers with hidtest;
2022-05-05 14:53:17 +03:00
Ihor Dutchak 52c728acf4 Use propper type for mach_port_t default param
- enable compilation warnings as errors for CI to catch such issues in the future;
- fix Mingw strict compilation warnings;
2022-05-05 14:53:17 +03:00
Ihor Dutchak 2aeb0688fa Don't use deprecated kIOMasterPortDefault (#406)
`kIOMasterPortDefault` is deprecated since macOS 12.0.
One alternative is to use named constant `kIOMainPortDefault` which is not available before macOS 12.0.

Both named constants are just an alias for `NULL`, so it is simpler to use it directly instead.

Fixes: #377
hidapi-0.12.0-rc1
2022-05-02 14:48:12 +03:00
Ihor Dutchak cd95af8d70 libusb: cmake: Proper dependency on Iconv (#405)
- explicitly add Iconv as a dependent library;
- check if iconv requires pointer-to-const as input (introduce ICONV_CONST check);
- NetBSD CI (has external Iconv library implementation that uses all of the above);
2022-05-02 14:18:03 +03:00
Ihor Dutchak 874b29c8e7 Fix find_package(hidapi) warnings (#404)
- FindPkgConfig.cmake warns it is not called by find_package;
- CMake package `config` file and `exports` file names should not match,
otherwise it gets included recursively by GLOB expression;
2022-05-02 14:09:16 +03:00
Jacob Shaffer 08563a0249 add better windows error handling (#388) 2022-05-02 14:08:44 +03:00
Ihor Dutchak 68bcbfcafa README: explicit statement on single source build (#370) 2022-05-02 14:05:05 +03:00
SNEHAL 536bad201e libusb: Fix double free of buffer pointer in hid_close() (#395)
Make buffer pointer NULL, once it is freed.

In hid_close() buffer pointer is freed and next to that the libusb_free_transfer function is called which checks for if the LIBUSB_TRANSFER_FREE_BUFFER flag is set and the buffer pointer is not NULL. when this condition evaluates true, it
tries to free memory for a buffer which is already free and a crash occurs.

Even though the described behavior should not happen as per libusb documentation, it has been observed with some version(s) of libusb.
2022-04-23 15:54:26 +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 05f0588220 darwin: add option to open device in non-exclusive mode (#397)
Resolves: #27
Resolves: #344
2022-04-23 14:16:42 +03:00
Ihor Dutchak 75aafc3ac9 CI: check for new headers installation 2022-02-25 11:45:27 +02:00
Ihor Dutchak 97887cf2eb Upgrade build script for Windows Server 2022 2022-02-25 11:45:27 +02:00
Frederik Seiffert 1ce31c3594 macos: Add Mac-specific API to get device Location ID (#378) 2022-02-25 10:54:28 +02:00
Frederik Seiffert 2cfd63ac41 windows: Add Windows-specific API to get device container ID (#379) 2022-02-25 10:53:00 +02:00
Frederik Seiffert e08ddcee5f macOS: Fix build warnings (#374) 2022-02-05 17:24:20 +02:00
Dimitriy Ryazantcev c84e42ad91 Extract CM_Get_DevNode_PropertyW() and CM_Get_Device_Interface_PropertyW() calls to separate functions (#372) 2022-02-05 17:03:42 +02:00
Ihor Dutchak 2551a5d84b Reorganize Windows source structure
- separate HID declarations for non-DDK build into re-usable headers;
- refactor initialisation/deinitialisation of HIDAPI;
- make all the comments consistent (C-style only);
2022-01-29 18:33:15 +02:00
Ihor Dutchak 6f37897bef Remove stale Windows/macOS example/test 2022-01-29 18:33:15 +02:00
Ihor Dutchak 69dcdc1ff0 Update copyright strings 2022-01-29 18:33:15 +02:00
Megamouse 5f66a371ca Win32: Don't pass invalid pointers to HidD_FreePreparsedData in hid_open_path (#373)
Fixes a segfault that happens when hid_open_path is called on a previously disconnected device.
This is a regression caused by:
b600727 - Win32: Fix memory leak in `free_hid_device` (#361)

Co-authored-by: Megamouse <studienricky89@googlemail.de>
2022-01-29 18:32:25 +02:00
Ihor Dutchak 0feb5a4fdd Fix wording (#368) 2022-01-22 04:34:32 +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
Youw 31bde69a1f Fire v0.11.2 hidapi-0.11.2 2022-01-03 14:53:10 +02:00
Ihor Dutchak f0a4a1fa2e Fix potential crash when libusb_detach_kernel_driver fails (#363)
In case if libusb_detach_kernel_driver fails inside hidapi_initialize_device
HIDAPI had tried to `libusb_close(dev->device_handle)` two times:
- right after `libusb_detach_kernel_driver`;
- outside of `hidapi_initialize_device` function;

The fix: `libusb_close` the device only once.
And since `hidapi_initialize_device` is not responsible for opening the device -
it is not responsible for closing it either.
2022-01-03 14:16:37 +02:00
Dimitriy Ryazantcev af6c6012b6 Parse USB interface number from device Hardware IDs (#360)
Strickly speaking we cannot parse interface string at all and only allowed to parse Hardware ID string.
hidapi-0.11.1
2021-12-23 00:01:41 +02:00
Dimitriy Ryazantcev b600727200 Win32: Fix memory leak in free_hid_device (#361)
- Fix memory leak in `free_hid_device`;
- Simpllify `hid_open_path` code;
2021-12-22 23:59:56 +02:00