Commit Graph

550 Commits

Author SHA1 Message Date
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
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 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.
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
Be
d67b5c9fec implement hid_get_input_report for Linux hidraw backend
Fixes https://github.com/libusb/hidapi/issues/259
2021-12-10 14:48:56 +02:00
Ihor Dutchak
b66d7c2c88
Explicit remark about BUILD_SHARED_LIBS (#349)
- a remark about using BUILD_SHARED_LIBS as a CACHE variable and CMP0077.
2021-11-12 01:17:06 +02:00
Ihor Dutchak
20a16a19b8
Update README.md (#350)
- remove "recommended" from deprecated GUI App;
- add reference to hidapitester in readme;
2021-11-12 01:14:29 +02:00
selsta
eb26015189
windows: add missing include for mingw32 (#348) 2021-11-11 01:00:25 +02:00
Ihor Dutchak
4ab60e005e
README: add links to backend description 2021-10-07 02:56:37 +03:00
Ihor Dutchak
0ec60c03cb Add <root>/libusb to includes for in-tree build
Otherwise it is impossible to `#include <hidapi_libusb.h>`,
when HIDAPI is added directly as a subdirectory of a CMake project.
2021-09-27 13:08:20 +03:00
Ihor Dutchak
b923aeda68 Windows: hid_get_feature/input_report return size fix (#334)
- It appears when the numbered reports aren't used,
WinAPI returns size of the report excluding the data[0] which contains 0,
as an indication that numbered reports aren't used;
Explicity count that byte in the result.

Fixes: #328
2021-09-27 13:07:02 +03:00
Ihor Dutchak
4d787499d9 Ignore Qt Creator user files 2021-09-27 13:07:02 +03:00
Bram Stolk
db1d0cb220
Update 69-hid.rules (#337)
`SUBSYSTEMS` should be used instead of `SUBSYSTEM` for "usb" match.

Fixes: #335
2021-09-25 02:52:04 +03:00
Ihor Dutchak
d4888c5f65
Remove DDK support files. (#333)
Deleted DDK build scripts, support files and documentation for it,
as it wasn't working of-the-box with recent tool-sets from MS anyway.

Still keeping `HIDAPI_USE_DDK` macro in the code,
as it still _can_ be used if the build configuration is setup properly.

Resolves: #49
2021-09-22 13:30:23 +03:00
Ihor Dutchak
77128aac88 Add deprecation message for Autotools 2021-09-20 16:06:27 +03:00
Ihor Dutchak
695b01f9da
v0.11.0 2021-09-18 19:02:28 +03:00
Ihor Dutchak
aaf5f3d172 add libusb-specific hid_libusb_wrap_sys_device
Rationale: on Android one must use UsbManager, to access any
USB device. As a result, libraries like libusb can only use file descriptors
that are provided by UsbManager.
libusb has an API to use such file descriptors: hid_libusb_wrap_sys_device.
Having hid_libusb_wrap_sys_device currently is the only way to make hidapi
work on Android without root access and without custom Android builds.

Relevant info: https://github.com/libusb/libusb/pull/830/files
2021-09-18 18:56:56 +03:00
Ihor Dutchak
301139e3cc update authors link 2021-09-18 18:56:56 +03:00
Ihor Dutchak
e050afb197
Fix sygwin compilation warnings (#331)
Fixes: #330
2021-09-18 18:31:26 +03:00
Ihor Dutchak
e9f8c3e75e
udev.rules documentation improvement (#326)
As recently discovered (thanks @tresf), the `TAG+="uaccess"` has to be used
before `73-seat-late.rules` and not before `70-uaccess.rules`.

Technically it doesn't harm to have a more restrictive recommenration,
but it was not technically correct.

Refference on `uaccess` TAG consumption:
[1](3a1220eedf/src/login/73-seat-late.rules.in), [2](https://www.apt-browse.org/browse/debian/wheezy/main/amd64/systemd/44-11+deb7u4/file/lib/udev/rules.d/73-seat-late.rules).
2021-09-13 17:00:58 +03:00
Dimitriy Ryazantcev
11cc0e8a86
Fetch Bluetooth LE HID device info from Windows devnode properties (#309)
As per MS, HidD_GetProductString/HidD_GetManufacturerString/HidD_GetSerialNumberString [doesn't work](https://docs.microsoft.com/en-us/answers/questions/401236/hidd-getproductstring-with-ble-hid-device.html) with Bluetooth LE (BLE) devices.

Add special handling for BLE devices and fill `manufacturer_string`/`product_string`/`serial_number` using BLE-specific API.

Fixes: #282
2021-09-06 19:16:15 +03:00
Ihor Dutchak
4d63a5085a
macOS: use IORegistryEntryGetRegistryEntryID to resolve paths (#322)
With some device connection configurations,
the device paths become over 512 bytes (io_string_t max length)
which makes them unusable with current implementation.

Rather than using ServiceRegistry string path, use its ID,
which is uint64_t and easily serializable/deserializable into a string.

Implementation idea by felix.schwarz@iospirit.com
8d251c3854

Fixes: #127, #236.
2021-08-23 20:58:13 +03:00
Ihor Dutchak
7c0dc53507
Update README.md (#324)
Clean/correct includes in the README example.
2021-08-23 20:55:51 +03:00
Ihor Dutchak
f75adc3c91
Correct example including hidapi.h 2021-08-17 17:17:29 +03:00
mcuee
8741697359
Update hid.c to fix MSYS2 MinGW-w64 compiler warning (#311)
This fixed a compiler warning when using MSYS2 MinGW-w64 compiler as mentioned in issue #289.

Since we changed strncpy to memcpy, it is not necessary to disable warning 4996 for MSVC.
2021-07-27 13:02:57 +03:00
Ihor Dutchak
ac8c9e5f94 Ubuntu CI: apt update before apt install 2021-07-26 13:31:09 +03:00
Dimitriy Ryazantcev
2a24bf9fcb
windows: cleanup code a bit (#305) 2021-07-16 19:11:58 +03:00
Dimitriy Ryazantcev
9404a954af
Whitespace cleanup in windows implementation (#302) 2021-07-09 17:32:43 +03:00