678 Commits

Author SHA1 Message Date
nastys
f42423643e Add Sixaxis init for Monterey 2025-05-23 03:08:36 +02:00
Ihor Dutchak
d6b2a97460 Fix hid_read_error documentation (#742) 2025-05-18 21:25:13 +03:00
Ihor Dutchak
3425db0fee CI: Install awk on Fedora for Autotools (#739) 2025-05-07 11:26:15 +03:00
Ihor Dutchak
4da6b893d9 Update link on Coverity status badge (#738) 2025-05-06 20:57:12 +03:00
Ihor Dutchak
8c9cbf6c02 Fix CI build on latest Archlinux (#733) 2025-04-04 18:44:06 +03:00
Ihor Dutchak
0ab6c14264 Add missing sanity checks (#727)
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>
2025-03-13 13:11:20 +02:00
Ihor Dutchak
95e6b98ce9 Add hid_read_error (#721)
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.
2025-03-11 19:26:36 +02:00
Ihor Dutchak
122ecb023a Simplify doxygen installation (#723) 2025-03-02 21:55:07 +02:00
Ihor Dutchak
424d63fb29 Update docs.yaml (#722)
Fix build with latest GithubActions.
2025-03-02 21:42:01 +02:00
Ihor Dutchak
2446b2a8ef macOS: add option to mimic 1.0.0 compatibility version (#709)
As it used to be with autotools.

Fixes: #622
2025-03-01 22:32:53 +02:00
toxie
c5ee4d331e Fix WinAPI backend compilation as C++ source (#718)
Fix compilation with older WINVER.
2025-02-25 22:58:47 +02:00
Ihor Dutchak
b26f057996 Ensure last_error_str released on macOS (#714)
Found by Coverity
2025-01-14 23:20:52 +02:00
JoergAtGithub
ff67c77dad Reconstruction logic for padding bytes at the end of Reports (only possible for devices without ReportID) (#707)
-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.
2024-10-30 17:30:14 +02:00
Megamouse
750bf201ae Add missing checks for malloc/calloc/CloseHandle (#702) 2024-10-03 22:24:19 +03:00
Ihor Dutchak
c15392af9b winapi: add hid_winapi_set_write_timeout (#700)
Add API function to control hid_write timeout on WinAPI backend.

Resolves: #686
2024-10-03 14:00:43 +03:00
Megamouse
5c4acf88a8 Windows: return bytes_written if WriteFile returns synchronously (#697)
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.
2024-09-29 12:09:13 +03:00
Ihor Dutchak
ba28d382cb Update upload-artifact action to v4 (#693)
- to match recently updated download-artifact (v3 is incompatible with v4);
- actions/upload-artifact@v3 is scheduled for deprecation on November 30, 2024;
2024-09-15 18:46:31 +03:00
dependabot[bot]
f2e8d41e06 build(deps): bump actions/download-artifact from 3 to 4 in /.github/workflows (#691)
As recommended by @dependabot.
2024-09-06 12:03:35 +03:00
Anonymous Maarten
c3c79a7d82 hidapi: fix "conversion from 'size_t' to 'int', possible loss of data' (#681)
This warning shows up when building with libusb support using MSVC.
Upstreaming of 1664ac4fcb
2024-08-21 12:32:38 +03:00
Ihor Dutchak
d101e5c7e4 macOS: fix hid_send_output_report implementation
- fix name of the function on macOS
- add compile-time check by the CI

Fixes: #683
2024-08-02 16:48:23 +03:00
Ihor Dutchak
9fc8b01c77 hid_send_output_report: bump version to 0.15.0 2024-08-02 16:40:57 +03:00
mbcinergy
4578ea2461 Add hid_send_output_report() (#677)
`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.
2024-06-12 19:40:09 +03:00
Ihor Dutchak
6c2de30431 Switch to macos-13 for Coverity
Apparently `macos-latest-large` is only available for payed accounts.
2024-04-28 13:45:39 +03:00
Ihor Dutchak
bda710178d Explicitly use non-ARM64 macOS runner
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.
2024-04-28 12:50:07 +03:00
Ihor Dutchak
c2ffb03ef6 Fix Github Builds status badge (#672)
As per new Github API.
2024-04-06 12:23:07 +03:00
Sam Lantinga
d0732cda90 hidapi/windows: do not wait in GetOverlappedResult() in hid_read_timeout() (#577)
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>
2024-03-05 14:56:29 +02:00
Ihor Dutchak
76462bd767 Avoid CMake backward compatibility warning (#663)
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
2024-03-05 13:26:01 +02:00
Vladimir Gladkov
4f2e91bae8 windows: change MAX_STRING_WCHARS to 126 (#627)
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).
2024-03-04 13:08:57 +02:00
Ihor Dutchak
7011fa98af pthread_barrier_wait: properly check the wait condition (#644)
- minor code-style fixes;
2023-11-22 12:26:16 +02:00
Moritz 'Morty' Strübe
4168d87521 Fix the windows build by fixing printf related issues (#641)
- Fix printf/string-related issues
- CI: Turn on -Wformat-signedness for GNU-cc
- Windows: Assert that struct has the correct size
2023-11-17 13:59:40 +02:00
Moritz 'Morty' Strübe
02c0f78d05 Doc: Fix target documentation (#640) 2023-11-17 13:45:47 +02:00
Moritz 'Morty' Strübe
9b507edd8a CMake: optionally install pkgconfig (#639)
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.
2023-11-16 15:19:02 +02:00
Ryan C. Gordon
eea8cac079 Don't try to memcpy() to a NULL destination. (#637)
This function is called with a literal NULL for that pointer later in
the file.
2023-11-12 18:26:05 +02:00
JoergAtGithub
86b056fe70 Fix two C++-Builder 11 issues (#634)
* 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
2023-10-27 02:19:38 +03:00
JoergAtGithub
3c04eacbca Added clang-cl build to CI (#631)
- Using -G"NMake Makefiles", because I couldn't get the other generators to work with clang-cl
- ASAN=off because it's not supported by clang-cl yet
2023-10-26 20:02:01 +03:00
Sam Lantinga
baa0dab611 Only enumerate each interface once (#625)
If a device has multiple altsettings, like an Xbox Series X controller, make sure we only enumerate each interface once, not once for each altsetting.
2023-09-25 00:54:40 +03:00
Ihor Dutchak
1ba21cee74 Fix Ubuntu Coverity check (#626) 2023-09-18 14:27:20 +03:00
Ihor Dutchak
116bda5d47 Update BUILD.autotools.md (#624)
* Update BUILD.autotools.md

Do not recommend using in-source Autotools build.

Closes: #621
2023-09-17 08:33:03 +03:00
braewoods
c19ae126d8 NetBSD: Initial UHID native backend implementation (#612) 2023-09-04 12:25:53 +03:00
Brendan Shanks
4009466d59 macOS: Check for macOS 10.10 using kCFCoreFoundationVersionNumber instead of AppKit (#611)
Effectivelty removes the dependency on AppKit for HIDAPI.

Fixes: #587
2023-08-27 17:28:01 +03:00
Ihor Dutchak
8a4de63b56 hidraw: report only Top-Level Usage_page/Usage pairs as 'unique' devices (#601)
- 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: #298
Fixes: #454
2023-08-26 11:02:42 +03:00
Ihor Dutchak
09ab35ffa9 CI: Fix Archlinux build (#610)
Apparently when installing/upgrading packages on Archlinux - need to explicitly make sure `glibc` is upgraded as well.

Fixes: #607
2023-08-14 13:10:17 +03:00
Ihor Dutchak
5fd7a79b37 Refine CTest args (#606)
- 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;
2023-08-05 16:19:00 +03:00
Sam Lantinga
98ab22a33d Suppress Visual C++ warning C4214: nonstandard extension used: bit field types other than int (#602) 2023-07-29 20:09:20 +03:00
Sam Lantinga
4c932622e8 hidapi/libusb: enable support for Xbox 360 and Xbox One controllers (#572)
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.
2023-07-23 12:57:49 +03:00
Ihor Dutchak
d0856c05ce Fix Windows CI (#598)
`refreshenv` stopped working in PowerShell context
2023-07-03 17:27:27 +03:00
luzpaz
849c8a9099 Fix various typo (#597)
Found via `codespell -q 3 -L childs,fo,xwindows`
Encountered in downstream https://github.com/libsdl-org/SDL
2023-07-03 17:18:54 +03:00
Sam Lantinga
80e8d62bc1 libusb: same logic to get the config descriptor for hid_open_path() and hid_enumerate() (#568) 2023-06-07 11:54:10 +03:00
Sam Lantinga
c6c4dd0243 macOS: fix crash when IOHIDDevice property is not a string (#573)
- fixed crash on macOS when AirPods are connected (reported to happen with some AirPods on some macOS version);
2023-06-07 11:53:05 +03:00
Sam Lantinga
fea2357cc5 libusb: use LIBUSB_CALL for the read_callback function (#569) 2023-06-07 01:05:42 +03:00