Based on #696
- Add missing checks for zero/null arguments;
- Better management of error strings in case of failures;
---------
Co-authored-by: Megamouse <studienricky89@googlemail.com>
hid_read_error is a separate error function, that returns error status of hid_read/hid_read_timeout.
hid_read/hid_read_timeout is no longer changes internal buffer used by hid_error and it makes it safe to use hid_read/hid_read_timeout from a separa thread, concurently with other device functions.
-Add reconstruction logic of const padding bytes at the end of a report for devices which don't use ReportIDs
-Enhanced padding logic to distinguish between byte and bit padding.
-Add a new test case for Razer Cobra mouse `1532_00A3_0002_0001` which has a completly con feature report of 90 bytes.
-Modified expected report descriptor reference file `045E_02FF_0005_0001_expected.rpt_desc` to include additional padding bytes.
According to documentation, the system reserves the right to run
WriteFile synchronously, even if FILE_FLAG_OVERLAPPED is set,
so `bytes_written` needs to be taken from `WriteFile` directly in that case.
- to match recently updated download-artifact (v3 is incompatible with v4);
- actions/upload-artifact@v3 is scheduled for deprecation on November 30, 2024;
`hid_send_output_report` sends report over control pipe, unlike existing `hid_write` which would send the data on the first interrupt OUT endpoint, if one exists and only falls back to control pipe.
As of recently, `macos-latest` runner switched to macOS-14-arm64 host, and Coverity (at least currently available image) only works on Intel/x86_64-based systems.
`macos-latest-large` macOS runner is Intel-based, as per documentation.
This is unsafe because the event is auto-reset, therefore the call to
WaitForSingleObject() resets the event which GetOverlappedResult() will
try to wait on.
Even though the overlapped operation is guaranteed to be completed at
the point we call GetOverlappedResult(), it will still wait on the event
handle for a short time to trigger the reset for auto-reset events. This
amounts to roughly a 100 ms sleep each time GetOverlappedResult() is called
for a completed I/O with a non-signalled event.
In the context of HIDAPI, this extra sleep means that callers that loop
on hid_read_timeout() with timeout=0 will loop forever, since the 100 ms
sleep each iteration ensures ReadFile() will always have new data.
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
Avoid a message:
```
Compatibility with CMake < 3.5 will be removed from a future version of CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
```
Fixes: #642
Win32 HID API doc says: For USB devices, the maximum string length is 126 wide characters (not including the terminating NULL character).
For certain USB devices, using a buffer larger or equal to 127 wchars results in successful completion of HID API functions, but a broken string is stored in the output buffer. This behaviour persists even if HID API is bypassed and HID IOCTLs are passed to the HID driver directly (IOCTL_HID_GET_MANUFACTURER_STRING, IOCTL_HID_GET_PRODUCT_STRING, etc).
So, the buffer MUST NOT exceed 126 wchars.
windows: refactor ULONGLONG hid_internal_get_info(...) -> hid_internal_detect_bus_type_result hid_internal_detect_bus_type(...)
hid_internal_detect_bus_type is now only responsible for detection of the bus type; rename it accordingly. Also, mixing an internal flag and DEV_INST into an ULONGLONG retval feels kinda hackish; use a cleaner approach instead (add an internal flag to help distinguishing between BLUETOOTH and BLE devices, then clear it once we are done).
If HIDAPI_INSTALL_TARGETS is set to off, pkgconfig is still installed.
This a problem when statically linking against hidapi and then using
CMake's install-feature.
* Invert preprocessor condition, as the Microsoft compiler seems to be the special case - not the other way around
* Removed redefinition of typedef 'PHIDP_PREPARSED_DATA' in hidapi_hidsdi.h to match the original hidsdi.h
As reported in #630
- unique Top-Level Usage_page/Usage: to be consistent with Windows/macOS (OS-level implementations).
- support for single Usage Page item for several UsageIDs;
- support for 32bit Usage items;
Fixes: #298Fixes: #454
- don't use `--rerun-failed` - it only makes sense on subsequent runs of the test, when checking of failed tests got fixed;
- add `--no-compress-output` - to avoid stripping test's output of failure;
Xbox controllers are not technically HID devices, but you can talk to them directly using libusb, and [SDL](https://github.com/libsdl-org/SDL) uses this to talk to controllers which may not have OS-level support.