Commit Graph

136 Commits

Author SHA1 Message Date
Sam Lantinga
67c4b99639 Fixed enabling udev hotplug detection on Linux 2021-12-15 10:39:42 -08:00
Ozkan Sezer
09465a9083 hidapi, windows: replace a strncpy() with plain memcpy()
mainstream has a similar change, already.
2021-11-30 21:10:10 +03:00
Ozkan Sezer
8f17af5e21 hidapi: mark libusb function pointers with LIBUSB_CALL. 2021-11-27 11:02:04 -08:00
Sam Lantinga
30f04d63e6 HIDAPI is only reliable on Android 4.3 and newer
Fixes https://github.com/libsdl-org/SDL/issues/4955
2021-11-26 07:15:46 -08:00
Sylvain
d5813776db Release UDEV ressources 2021-11-25 07:24:18 -05:00
Sylvain
d31251b014 use SDL's functions version inplace of libc version 2021-11-22 08:38:46 -08:00
Cameron Gutman
343fa61215 hid: fix inconsistent indentation 2021-11-20 13:17:59 -06:00
Cameron Gutman
db60b27188 hid: Only enumerate IOHIDDevices that are likely to be joysticks
Touching HID devices with keyboard usages will trigger a keyboard capture
permission prompt on macOS 11+. See #4887

Like the IOKit joystick backend, we accept HID devices that have joystick,
gamepad, or multi-axis controller usages. We also allow the Valve VID for
the Steam Controller, just like the Windows HIDAPI implementation does.
2021-11-20 13:13:17 -06:00
Ozkan Sezer
b67965979a SDL_hidapi.c: fix SDL_udev.h include path
fixes https://github.com/libsdl-org/SDL/issues/4981
2021-11-19 11:55:50 +03:00
Ozkan Sezer
d2cf191936 hidapi, linux: merged a minor warning + code style fix from mainstream. 2021-11-17 10:00:10 +03:00
Sam Lantinga
66058bbbd5 Fixed exception accessing Bluetooth devices on Android 12
Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()

Fixes https://github.com/libsdl-org/SDL/issues/4952
2021-11-15 16:52:56 -08:00
Mathieu Eyraud
5fc7a90a8b Fix refcounting in SDL_hid_exit 2021-11-12 01:25:15 -08:00
Sam Lantinga
162772aa63 Fixed build warnings on Android 2021-11-11 20:50:54 -08:00
Sam Lantinga
9c3bcf8e8a Added SDL_hid_ble_scan() for pairing Steam Controllers on iOS and tvOS 2021-11-11 17:31:14 -08:00
Sam Lantinga
911d91c55c Retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled) 2021-11-11 14:36:05 -08:00
Sam Lantinga
b9b0df40bf Fixed Linux build 2021-11-11 12:52:40 -08:00
Sam Lantinga
c9ada1c142 Made HIDAPI device change notifications available via SDL_hid_device_change_count() 2021-11-11 12:46:10 -08:00
Sam Lantinga
6c4b4ee7a6 Don't assert on API parameters
This causes lots of spam in test automation and it's not clear it's useful to developers. If we need this level of validation, we should add a log category for it.
2021-11-10 09:41:43 -08:00
Sam Lantinga
0f2bf62935 Fixed building hidapi when libusb is available 2021-11-09 06:20:46 -08:00
Sam Lantinga
b8327a4a48 Added SDL_HIDAPI_DISABLED so it can be disabled like other SDL subsystems 2021-11-08 07:19:45 -08:00
Sam Lantinga
f61b10dcf1 Do more robust validation of devices passed to the SDL HIDAPI functions 2021-11-08 06:34:32 -08:00
Ozkan Sezer
dd8c354843 SDL_hidapi.c: avoid possible NULL pointer dereferences. 2021-11-08 17:00:56 +03:00
Sam Lantinga
5b646cd19e Build hidapi code into SDL as a new public API
This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
2021-11-07 23:00:59 -08:00
Sam Lantinga
db18764e41 Use correct relative include path 2021-10-01 16:27:59 -07:00
Sam Lantinga
bf97c5a22f Make sure SDL file descriptors don't leak into child processes 2021-09-08 14:47:40 -07:00
Sam Lantinga
7d66fa209a Fixed double-copy of the report in BlueZ >= 5.56 2021-09-07 17:38:26 -07:00
Sam Lantinga
8b1f8b6ec5 Use the high speed alternate setting on new Microsoft Xbox controllers 2021-08-27 11:14:09 -07:00
Sam Lantinga
a91ab883e9 Fixed building on Windows with cmake, ninja, and clang 2021-08-06 12:28:24 -07:00
Sam Lantinga
f93e9047eb Implemented the timeout in hid_read_timeout() on Android
This fixes detecting PS5 controllers connected over USB
2021-07-08 18:44:50 -07:00
Sam Lantinga
814285d6e3 Workaround for crash on Apple Mac M1 hardware 2021-06-23 09:19:02 -07:00
Sam Lantinga
0e62926ec5 Fixed crash if vendor or product strings are empty 2021-06-10 16:28:32 -07:00
Sam Lantinga
cb5e86353b Fixed crash after reinitializing libusb HID support 2021-06-08 13:15:24 -07:00
Sam Lantinga
6de33c0945 Clarify why we're skipping Game Controller framework supported devices in hid.c 2021-06-03 09:05:33 -07:00
Patrick Hogan
28da6c5ddb Have HIDAPI skip MFI supported HID devices on macOS to avoid duplicate devices. 2021-06-03 09:03:11 -07:00
Steven Noonan
17d8479d98 hidapi/libusb: maintain in-memory cache of vendor/product strings
The get_usb_string call is rather expensive on some USB devices, so we
cache the vendor/product strings for future lookups (e.g. when
hid_enumerate is invoked again later).

This way, we only need to ask libusb for strings for devices we haven't
seen since before we started.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:40:23 -07:00
Sam Lantinga
3377861ab1 Added support for the Amazon Game Controller to the HIDAPI driver 2021-03-26 11:57:19 -07:00
Sam Lantinga
1133ea0349 Fixed crash on macOS when AirPods are connected 2021-03-22 19:18:57 -07:00
Sam Lantinga
1f7ec3fa4e Added support for the PowerA Xbox One Series X Wired Controller 2021-02-11 17:27:22 -08:00
Ozkan Sezer
bb9e049d1d minor updates to libc function checks 2021-02-10 10:22:19 -05:00
Sam Lantinga
1dc9180fb6 Fixed compiler warnings 2021-02-10 10:22:17 -05:00
Sam Lantinga
d59a926837 Fixed build warning 2021-02-10 10:22:17 -05:00
Sam Lantinga
eb83da0234 Fixed PS4 controllers over Bluetooth on Windows 7 2021-02-10 10:22:17 -05:00
Sam Lantinga
a4db44fa71 The Sharkoon Skiller SGH2 headset hangs in DirectInput enumeration, so avoid it here just in case.
See bug 5485 for details.
2021-02-10 10:22:17 -05:00
Ozkan Sezer
e91f83c1e0 hidapi.h: adjust so that it gives a smaller diff against mainstream 2021-01-24 00:51:25 -05:00
Sam Lantinga
d4794028bb Fixed build 2021-01-24 00:51:25 -05:00
Sam Lantinga
9e45372a2f Fixed build on Android and iOS 2021-01-24 00:51:25 -05:00
Sam Lantinga
bf53651d73 Make sure we only do GameCube adapter initialization if we were able to load libusb 2021-01-24 00:51:24 -05:00
Sam Lantinga
3527b49459 Fixed initializing the Nyko and EVORETRO GameCube adaptors
This requires root on most Linux distributions, as we have to directly send USB messages to the devices to enable input reports.
2021-01-24 00:51:24 -05:00
Ozkan Sezer
07f83cd5a6 hidapi/libusb/hid.c: fix race condition on device close (bug #5484)
From hidapi mainstream git: https://github.com/libusb/hidapi/issues/142
d2c3a9862e

Read callback may fire itself on its own even after its been requested
to stop and exactly before the calling code waits for its completion in
indefinite loop.  Explicitly preventing re-fireing the submission loop
fixes the issue.
2021-01-24 00:51:24 -05:00
Ozkan Sezer
327ea97436 hidapi/libusb/hid.c: whitespace tidy-up. 2021-01-24 00:51:24 -05:00