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.
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.
- 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;
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
- 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: #431Closes: #164Closes: #163
- 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>
- 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;
- separate HID declarations for non-DDK build into re-usable headers;
- refactor initialisation/deinitialisation of HIDAPI;
- make all the comments consistent (C-style only);
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>
- 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
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`.
- cast hidapi supplied size_t parameters to DWORD when calling Windows
API functions
- cast size_t return variables in `hid_read_timeout` and
`hid_send_feature_report` to int in order to match hidapi signature.