Commit Graph

109 Commits

Author SHA1 Message Date
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
Sam Lantinga c8a64ad90c Fixed building when SDL_LIBUSB_DYNAMIC is defined 2021-01-07 10:23:55 -08:00
Sam Lantinga bf754b52bf Valve contributed code is under the Zlib license 2021-01-04 12:17:24 -08:00
Ozkan Sezer 01a2f27679 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle()
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Cameron Gutman 414ddc32c5 Do not wait in GetOverlappedResult() in hid_read_timeout()
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.
2021-01-01 17:34:07 -06:00
Sam Lantinga f0b6c78733 Fixed Windows XP compatibility with recent hidapi commit 2021-01-02 09:58:08 -08:00
Sam Lantinga ab55ec4850 Fix use-after-free SBH corruption due to overlapped ReadFile in hidapi not being canceled for all threads before device close
- hidapi already called CancelIo on hid_close but that only cancels pending IO for the current thread. Controller read/writes originate from multiple
  threads (serialized, but on a different thread nonetheless) but device destruction was always done on the main device thread which left any
  pending overlapped reads still running after hidapi's internal read buffer is deallocated leading to intermittent free list corruption.
2021-01-01 11:12:41 -08:00
Sam Lantinga ff913a22f4 Fixed compile warnings on platforms without hidapi support 2020-12-23 16:16:55 -08:00
Sam Lantinga 047b20e3b6 Fixed compile warnings on platforms without hidapi support 2020-12-23 16:11:16 -08:00
Ozkan Sezer 90456670b5 more "'for' loop initial declarations are only allowed in C99 mode" fixes 2020-12-17 14:11:00 +03:00
Sam Lantinga 14f977348d Fixed whitespace 2020-12-15 14:57:47 -08:00
Sam Lantinga 706f63759c Fixed build for platforms with only libusb hidapi implementations 2020-12-13 01:58:05 -08:00
Sam Lantinga 43aad96681 Fixed bug 5222 - Crash when running with -DHIDAPI=ON
Mathieu Eyraud

SDL dynamically loads libusb but does not check the return value of 'SDL_LoadFunction'.

Also libusb is loaded and initialized several time because 'SDL_hidapi_wasinit' is never set to true.

I made a patch if you want to test:
  - check that 'hid_init' is called once and only once,
  - check return value of 'hid_init',
  - check return value of 'SDL_LoadFunction',
  - check return value of 'SDL_malloc',
  - add some debug logging.
2020-12-08 19:03:50 -08:00
Sam Lantinga 59f28b7f4b Fixed whitespace 2020-12-03 18:17:01 -08:00
Sam Lantinga 9fc4a4c92c Revamped Xbox One HIDAPI init sequence
Added support for querying the controller serial number on newer firmware
2020-11-24 22:25:26 -08:00
Sam Lantinga 5b3616c325 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices
This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
2020-11-23 18:24:05 -08:00
Sam Lantinga a94fe009c6 Moved comment with the code it covers 2020-11-21 18:40:27 -08:00
Sam Lantinga 49f7be6d0d Fixed compile warning C4127: conditional expression is constant 2020-11-21 18:37:56 -08:00
Sam Lantinga 63b52e8e67 Remove SDL dependency in Windows code 2020-11-21 18:34:32 -08:00
Sam Lantinga d4954eb090 Removed debug code 2020-11-21 18:26:43 -08:00
Sam Lantinga b442e617e9 Fixed adding an extra zero byte for feature reports
At least with PS4 and PS5 controllers DeviceIoControl() returns the correct value
2020-11-21 18:15:55 -08:00
Sam Lantinga 6b56b98fc3 Fixed is_BLE() return value 2020-11-21 09:26:11 -08:00
Sam Lantinga 65c9f1d2cc Fixed upstream bug: FD 0 is a valid file descriptor
https://github.com/libusb/hidapi/issues/199
2020-11-21 09:06:48 -08:00
Sam Lantinga b0b76a61c7 Fixed rumble on PS5 controllers connected to Windows over Bluetooth 2020-11-19 07:12:53 -08:00
Sam Lantinga 30371f2d4d Fixed doubled report ID for Bluetooth Classic devices on Linux 2020-11-13 13:17:04 -08:00
Sam Lantinga e12457d8bf Added support for the Xbox Series X controller to the HIDAPI driver 2020-11-10 12:26:30 -08:00
Ryan C. Gordon b3a34c94e0 hid: Add Microsoft Precision Mouse to the joystick blacklist.
Same deal as the Razer keyboards, it hangs the enumeration.
2020-05-06 03:18:25 -04:00