Commit Graph

528 Commits

Author SHA1 Message Date
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
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.
hidapi-0.11.0
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](https://github.com/systemd/systemd/blob/3a1220eedfb65355c387c29584380742a21917aa/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
https://github.com/flirc/hidapi/commit/8d251c3854c3b1877509ab07a623dafc8e803db5

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
Dimitriy Ryazantcev 5a88dcd7ab Fix possible garbage in device strings returned from hid_enumerate()
In some cases HidD_GetSerialNumberString/HidD_GetManufacturerString/HidD_GetProductString can fail.
For example if we have Bluetooth LE gamepad on Windows.
In this case we are currently returning not initialized strings in `hid_device_info`.
2021-07-08 14:39:54 +03:00
Ihor Dutchak 382138ee67 Doc: using old-sty;e badge for GitHub Actions 2021-07-04 00:15:49 +03:00
Ihor Dutchak dd2db8e2bb CI: more CI for CMake
- Linux CMake build;
- Windows MSVC build;
- Windows NMake build;
- Windows MinGW build;
2021-07-04 00:10:29 +03:00
Ihor Dutchak c84cf1dec3 VERSION - follow Semantic 2021-07-03 23:43:58 +03:00
bearsh 03998f4418 libusb backend: stabilize device path (#291)
Format the path like the linux kernel does:
<busnum>-<port[.port]>…:<config num>.<interface num>

Closes: #117
2021-07-03 22:06:31 +03:00
Ihor Dutchak ec0727c344 version bump 2021-07-03 22:04:45 +03:00
Ihor Dutchak 3ebfaa8521 More details for CMake documentation 2021-07-03 21:09:26 +03:00
Ihor Dutchak b7053119ed Documentation refactoring and update
- separate readme for HIDAPI build;
- separate readme for HIDAPI build with Autotools;
- add (separate) readme for HIDAPI build with CMake;
2021-07-03 20:38:58 +03:00
Ihor Dutchak f5ada42915 CI: macOS build for CMake 2021-07-03 20:38:58 +03:00
Ihor Dutchak f2bb972e7f add CMake build system 2021-07-03 20:38:58 +03:00
Ihor Dutchak 6fcb0bb228 win: hid_get_feature_report: Correct number of bytes_returned (#286)
This originally tested/confirmed by @mcuee.
Confirmed the expected behavior by Tim Roberts https://sourceforge.net/p/libusb/mailman/message/37303650/.
Relates to: #232.
2021-06-19 07:23:35 +03:00
JoergAtGithub e74189d867 win: hid_get_input_report: Correct number of bytes_returned (#232)
Fixes: #229

This originally tested/confirmed by @JoergAtGithub and @mcuee.
And confirmed the expected behavior by Tim Roberts https://sourceforge.net/p/libusb/mailman/message/37303650/.
2021-06-19 06:09:47 +03:00
Ihor Dutchak 42fa21fff1 drop support of macOS 10.5 and earlier (#121)
- IOHIDDeviceGetService is available since macOS 10.6
2021-06-14 13:30:35 +03:00
Erik OShaughnessy 7620bc7faa Guard against zero length buffers in hid_write (#279) 2021-06-14 04:09:13 +03:00
Be fc8fdd2bf4 improve documentation for udev rule files on Linux (#276)
- use TAG+="uaccess" instead of overly broad MODE="0666" by default example
        as advised by Debian:
        https://lists.debian.org/debian-devel-announce/2016/11/msg00008.html
        Adding the uaccess tag to udev rules
        ------------------------------------
Packages containing udev rules that use GROUP="plugdev" should also add
 TAG+="uaccess" so that all users that are physically present can access
 the relevant devices, instead of just users in the plugdev group
 (GROUP="plugdev"). Some packages use MODE="666" to allow all users
 (including remote users) to access devices. For almost all devices it is
 probably more appropriate to switch from MODE="666" to GROUP="plugdev",
 MODE="660", TAG+="uaccess" so that remote users cannot access local
 devices. Check the wiki page for USB gadgets[13] for more hints.
 There is a lintian warning in progress[14] for these issues.
  -- Paul Wise & Petter Reinholdtsen
 [] https://wiki.debian.org/USB/GadgetSetup
 [] https://bugs.debian.org/841670

- remove documentation for Linux <2.6.24
2021-05-21 01:04:08 +03:00
Be c13fb1a880 README: document how to choose between libusb & hidraw backends 2021-05-20 20:29:53 +03:00
Ihor Dutchak c7a2339b05 libusb: add support for potential Android JNI backend 2021-05-18 16:39:01 +03:00
Ihor Dutchak b72a367555 Switch builds.sr.ht from ~qbicz to ~z3ntu (#269) 2021-05-11 12:53:18 +03:00
MonkeybreadSoftware 6f0056e1ce Build workaround for kernels older than 2.6.39 (#260) 2021-05-05 11:51:16 +03:00
jeremyouellet b8837014ef Use Conditional PlatformToolset projects for VS (#261) 2021-05-05 11:48:34 +03:00
Ihor Dutchak 6a01f3b4a8 Switch to libusb/hidapi appveyor project for badge 2021-03-19 00:49:27 +02:00
Ihor Dutchak 0ea5e9502f windows: cache write buffer allocated for small user buffers 2021-03-07 13:58:57 +02:00