Commit Graph

353 Commits

Author SHA1 Message Date
Ozkan Sezer
aaba01aee4 hidapi: syncing with mainstream:
- macos, pthread_barrier_wait: properly check the wait condition
- windows: Assert that struct has the correct size
- windows: Fix printf/string-related issues
- other miscellaneous stuff irrelevant in SDL. (for symmetry...)
2023-11-23 11:35:02 +03:00
Ozkan Sezer
5730eb67f0 add HAVE_GCC_DIAGNOSTIC_PRAGMA to SDL_internal.h, use it 2023-11-23 11:33:20 +03:00
Ryan C. Gordon
c6d9fb1ad7 hidapi: Avoid memcpy'ing to NULL.
(This fix was originally from @themightyoarfish on GitHub. Thanks!)

Fixes #8428.
Reference PR #8431.
2023-11-06 13:48:07 -05:00
Ryan C. Gordon
c53843a961 docs: Remove Doxygen \brief tags.
Doxygen and the wiki bridge don't need them; they'll both just use the first
line/sentence instead.

Fixes #8446.
2023-11-06 10:26:06 -05:00
Sam Lantinga
0b460f34ba The HP HyperX controllers have a share button 2023-11-03 14:47:20 -07:00
Sam Lantinga
23ceae94c9 Fixed Xbox 360 Controller support using libusb on Linux 2023-10-25 14:50:07 -07:00
Sam Lantinga
f52b330ed8 Added support for the HP HyperX Clutch Gladiate controller 2023-10-25 09:00:26 -07:00
Sam Lantinga
34719cba96 Fixed crash in hid_init() if the HIDDeviceManager isn't available 2023-09-22 10:14:16 -07:00
Sam Lantinga
f622f21e6f Fixed build 2023-09-15 05:17:33 -07:00
Sam Lantinga
5774c9638c Prefer hidraw over libusb when libusb whitelisting is not enabled
Since opening devices via libusb will unbind them from other drivers, we will either whitelist specific devices that we want to support via libusb or we will prefer other drivers over libusb.
2023-09-15 05:14:26 -07:00
Sam Lantinga
9301f7ace2 hidapi/libusb: only enumerate each interface once
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-15 05:07:05 -07:00
Ozkan Sezer
923d612ca1 hidapi: sync macOS code with mainstream.
this merges mainstream commit 4009466d59c41f (mainstream PR/611)
2023-08-27 22:33:32 +03:00
Ozkan Sezer
3b1d1e4e31 hidapi: sync the hidraw changes with mainstream
Apply mainstream commit 8a4de63b (mainstream PR/601) to our hidapi.
The patch is a direct apply of the mentioned commit, with one sdl-
specific part guarded by HIDAPI_IGNORE_DEVICE adapted accordingly.
2023-08-26 08:09:10 -07:00
Sam Lantinga
845f3c7450 Fixed mismatch between stdlib calloc() and SDL free()
Fixes https://github.com/libsdl-org/SDL/issues/8145
2023-08-23 14:49:29 -07:00
Sam Lantinga
3e1ae0c867 Clearified the libusb whitelist default logic 2023-08-14 12:19:37 -07:00
Ozkan Sezer
f464eb2c54 SDL_hidapi.c: change 'use_libusb_whitelist_default' into a macro.
Avoids 'initializer element is not constant' error from older compilers.
2023-08-14 17:01:24 +03:00
Ethan Lee
f0f15e365d hidapi: Use a whitelist for libusb when other backends are available 2023-08-13 14:16:11 -07:00
Sam Lantinga
c94cb3a5d8 Simplified the Xcode project to a single Framework target
Static and shared libraries can be built using CMake support in SDL 3.0

Built tests for macOS, iOS, and tvOS
2023-07-31 18:38:18 -07:00
Sam Lantinga
4749df0a63 Just disable the 4214 warning instead of trying to change the structure definition 2023-07-25 14:01:46 -07:00
Ozkan Sezer
4ca0e937e1 hidapi: remove unwanted files (e.g.: .git*, etc...) 2023-07-19 00:55:04 +03:00
Ozkan Sezer
40ac818bf8 hidapi: sync with mainstream (typo fixes) 2023-07-19 00:40:10 +03:00
Sam Lantinga
2bf05f38ad Increased the timeout when opening /dev/hidraw nodes
We're still seeing it taking longer than 10ms for permissions to become available on Steam Deck.
2023-07-18 14:28:55 -07:00
Sam Lantinga
be79f62cb7 Fixed warning C4214: nonstandard extension used: bit field types other than int 2023-07-06 18:14:22 -07:00
Sam Lantinga
c6ee9780df Fixed DualSense controllers not being picked up by the HIDAPI driver
The hidraw device may take additional time to get the correct permissions for us to open it. In my tests on Steam Deck hardware, this ranges between 5-8ms.
2023-06-18 12:19:54 -07:00
Sam Lantinga
dec0dbff13 Fixed enumerating Steam Controllers on iOS 2023-06-12 16:57:41 -07:00
Sam Lantinga
d032492aab Fixed detecting Bluetooth Steam Controllers on Windows 2023-06-05 21:28:12 -07:00
Sam Lantinga
17c397f7ec Save the error code before doing any other operation
SDL_ClearError() resets the Win32 error code to 0
2023-06-05 21:18:49 -07:00
Sam Lantinga
6e7769cde1 Fixed detecting Bluetooth Steam Controllers 2023-06-05 19:52:00 -07:00
Sam Lantinga
fa41ece65f Allow other applications to open controllers on macOS 2023-06-03 11:53:36 -07:00
Ozkan Sezer
0c862d9a55 added compiler support comment about #pragma push_macro/pop_macro. 2023-06-03 17:23:40 +03:00
Ozkan Sezer
8c476ca1b0 hidapi/libusb: need libusb >= 1.0.16 because of libusb_get_port_numbers 2023-06-02 07:26:38 -07:00
Ozkan Sezer
e27c10a5b1 hidapi/libusb: don't try to dlsym libusb_wrap_sys_device
not used in SDL.
2023-06-02 07:26:38 -07:00
Ozkan Sezer
3ecdbf27cc hidapi: silence redefinition warnings 2023-06-02 07:25:02 -07:00
Sam Lantinga
f082c68b2f Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/582 2023-06-01 10:48:15 -07:00
Sam Lantinga
b36679b90e Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/582 2023-06-01 08:27:56 -07:00
Sam Lantinga
20182eed7c Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/572 2023-06-01 07:47:28 -07:00
Sam Lantinga
0cff44dbd4 Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/577 2023-06-01 07:28:44 -07:00
Sam Lantinga
4f58445f03 Ignore both the mouse and keyboard endpoints of Steam Controllers when enumerating game controllers 2023-05-31 14:28:50 -07:00
Sam Lantinga
b6a88b0339 Don't try to interpret Xbox controllers as raw HID devices on Windows
These generate fake reports which don't include separate trigger axes, and the HIDAPI joystick driver doesn't understand this report format.
2023-05-31 10:49:46 -07:00
Sam Lantinga
4644ac99fa Remove unneeded property type check 2023-05-31 08:27:54 -07:00
Sam Lantinga
0b28cbe385 Allow building on really old Linux kernels (thanks @sezero!) 2023-05-30 16:36:40 -07:00
Ozkan Sezer
20dfb7df2c hidapi/linux/hid.c: define BUS_SPI if not already defined. 2023-05-31 01:55:40 +03:00
Sam Lantinga
0ffeca8a1c Added SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS to control whether SDL_hid_enumerate() enumerates all HID devices or only controllers.
By default SDL will only enumerate controllers, to reduce risk of hanging or crashing on devices with bad drivers and avoiding macOS keyboard capture permission prompts.
2023-05-27 10:51:52 -07:00
Ozkan Sezer
77e59d4fa9 fixed build error due to -Wunused-function 2023-05-27 18:56:10 +03:00
Ozkan Sezer
8ea76ba116 move diagnostic pragma out of the function for old gcc versions. 2023-05-27 18:40:56 +03:00
Sam Lantinga
211054d9db hidapi: improved error handling 2023-05-27 08:33:48 -07:00
Sam Lantinga
2666e15cf1 hidapi: fixed upstream build 2023-05-27 08:21:59 -07:00
Sam Lantinga
bc28790817 Make sure hidapi error handling is thread-safe
The hidapi method of storing the error on the device is not thread-safe, and not only could it result in a double free if multiple threads were setting the error at the same time, but SDL could be trying to use the error message and have it be freed out from under it by another thread.

Use SDL's error functions since they already use thread-local storage.
2023-05-26 23:50:50 -07:00
Sam Lantinga
d51f84a2e1 Revert "Fixed double-free during multi-threaded hidapi access"
This reverts commit 2b386b6c80.

This isn't the right approach. Even if the string itself isn't double-freed, it can be returned to the application and then freed while the application is trying to use it. This really needs to be in thread-local storage to be completely safe.

In SDL we already have a global thread-local error string, so I'm going to make an SDL-specific change to handle the error strings safely.
2023-05-26 23:50:50 -07:00
Sam Lantinga
1c9aae9a29 hidapi build fixes for the upstream build environment 2023-05-26 22:50:39 -07:00