Commit Graph

99 Commits

Author SHA1 Message Date
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
Ryan C. Gordon
85d97410d4 hid: Cleanup Windows joystick blacklist code, to make additions easier. 2020-05-06 03:13:44 -04:00
Ryan C. Gordon
3625b83c63 hid: Add Razer Arctosa keyboard to hid enumeration blacklist.
Hangs SDL, same as the Razer Lycosa.

Fixes Bugzilla #5101.
2020-04-21 01:32:48 -04:00
Ryan C. Gordon
eaaa809e40 hidapi: Blacklist the Razer Lycosa keyboard from enumeration.
It's not a joystick and it hangs device enumeration.
2020-04-15 13:33:09 -04:00
Sam Lantinga
6e646b6156 Removed blacklist entries for devices that aren't game controllers, allow Steam Controllers 2020-03-20 20:53:26 -07:00
Cameron Gutman
5ed71f3bc0 Only enumerate HID devices on Windows that have gamepad HID usages
There are a number of poorly behaved HID devices that time out on attempts to
read various strings. Rather than end up on an endless treadmill of blacklisting
broken devices, reduce our risk by only querying devices that are gamepads.
SDL_hidapijoystick.c already checks these same usages, so we shouldn't
exclude any working HID devices (caveat below).

This also makes HidP_GetPreparsedData() and HidP_GetCaps() failure skip
the device entirely, but that seems desired. If a device can't even return basic
top-level collection data properly, we want nothing to do with that broken device.
If we do find devices that work with HIDAPI joystick and fail these calls, we can
add an exception via VID+PID matching.
2020-03-20 13:44:50 -07:00
Sam Lantinga
19c3484469 Fixed slow enumeration when Apple Cinema HD display 30" is plugged in 2020-03-13 19:19:29 -07:00
Ethan Lee
133b475586 Use LIBUSB_CALL for hidapi's read_callback function 2020-03-11 14:17:19 -04:00
Sam Lantinga
cb986aff9f Fixed exception at shutdown if the controllers are closed after the HIDDeviceManager is shutdown 2020-03-13 13:05:32 -07:00
Sam Lantinga
69a8c8468c Fixed using more than one Xbox Bluetooth controller
Don't prevent duplicate devices using hidraw, instead libusb takes precedence and all hidraw devices that aren't handled by libusb are available
2020-03-04 09:42:08 -08:00
Sam Lantinga
96836ec643 Add 500ms max wait time for hid_write to complete on Windows
It appears that with some (presumably) flaky drivers or hardware that the WriteFile in hid_write never completes leading to GetOverlappedResult to block forever waiting for it.
2020-03-03 09:22:43 -08:00