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.
- 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
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
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
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.
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`.
- 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