src/joystick/hidapi/SDL_hidapijoystick.c


Log

Author Commit Date CI Message
Sam Lantinga cec5a129 2021-08-12T15:49:33 Fixed libudev hotplug notifications in the HIDAPI driver
Ryan C. Gordon dd683073 2021-08-06T15:13:14 hidapi: Patched to compile on QNX. Fixes #4591.
Sam Lantinga 2a53f831 2021-07-26T23:29:20 Fixed controllers showing up under both MFI and HIDAPI drivers The Game Controller Kit doesn't show the controllers at startup, so the HIDAPI driver sees them first and therefore gets preference when a controller is supported by both drivers. This fixes bug https://github.com/libsdl-org/SDL/issues/4209
Sam Lantinga d135c076 2021-07-08T13:22:41 Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers See testgamecontroller.c for an example of a custom PS5 trigger effect
Dimitriy Ryazantcev 17ed8d80 2021-07-07T16:05:35 Added HIDAPI backend for Amazon Luna Controller Model T28B69 connected via Bluetooth LE (VID:0171, PID:0419). To enter Bluetooth pairing mode hold B and Action (button with circle) buttons for 3 seconds. It works via usual HIDAPI if special filter driver is not installed: https://www.amazon.com/gp/help/customer/display.html?nodeId=GZCT4CTFHXLHEB9T With that driver installed it mimics Xbox One controller and works via XInput under Windows. Under DInput this controller is not usable at all.
Dimitriy Ryazantcev b81969d4 2021-05-17T14:50:33 Be more explicit about Xbox 360/One device ids. When Xbox One/Series Controllers are connected via USB on Windows they all are using `XBOXGIP` driver and produce a special ProductID `0x02FF` (GIP software PID) for any connected controller. On the other hand `Xbox 360 Wireless Controller Reciever` (PID 0x0719) is using `XUSB` driver and produces special ProductID `0x02A1` (XUSB software PID) for each connected Xbox 360 Wireless Controller. Also fixed Xbox One Series X Controller comment.
Steven Noonan 4535d654 2021-04-22T14:35:59 HIDAPI_UpdateDiscovery: only treat "add" and "remove" events as relevant I have a buggy system which reports a udev "change" event for an empty USB-C port every 0.14 seconds, which causes annoying frame hitches because SDL decides that means it needs to do a libusb hid_enumerate, which is slow (~25ms!) because of the get_usb_string() calls in there. We only need to re-enumerate if we've seen a device added or removed, so let's filter out the change event first. Signed-off-by: Steven Noonan <steven@valvesoftware.com> Signed-off-by: Sam Lantinga <slouken@libsdl.org>
Mathieu Eyraud 7a2b6f33 2021-02-22T13:32:42 Guard Inotify stuff with macro This fix implicit declaration of close and unused variable warning.
David Gow db58166e 2021-02-21T17:28:08 joystick: hidapi: Properly include <unistd.h> when inotify not available In the extremely unlikely event that inotify is not available (and, therefore, HAVE_INOTIFY is not #defined), SDL will no-longer build. This is because <unistd.h> is only included when HAVE_INOTIFY is defined, and PR #4098 adds a call to access(…, F_OK), which requires <unistd.h>. (Note that the F_OK symbol is the only one which actually prevented SDL from compiling, but both access() and close() fell back to implicit definitions, which is a bit concerning.) Fixes: 8d43f45a7b ("Don't use udev for joystick enumeration if running in a container")
Ludovico de Nittis 8d43f45a 2021-02-16T14:13:30 Don't use udev for joystick enumeration if running in a container If we are running in a container, like Flatpak[1] or pressure-vessel[2], it's likely that we are using user namespaces, therefore udev event notification via netlink won't work reliably. Use their filesystem API to detect them and automatically fallback to the inotify-based enumeration. [1] <https://flatpak.org/> [2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel> Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
Ludovico de Nittis 2c326915 2021-02-16T12:39:48 Use inotify for HIDAPI joystick enumeration if not using udev This improves SDL's ability to detect HIDAPI joystick hotplug in a container environment because we cannot reliably receive events from udev in a container. For a more detailed explanation of why this issue happens with containers, please check the previous commit "joystick: Use inotify to detect joystick unplug if not using udev" (b0eba1c5). Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
Ludovico de Nittis b17242bf 2021-02-16T11:50:20 Allow libudev for HIDAPI joystick to be disabled at runtime As already explained in the previous commit "joystick: Allow libudev to be disabled at runtime" (13e7d1a9), libudev can fail in a container. To make it easier to experiment with, we add a new environment variable "SDL_HIDAPI_JOYSTICK_DISABLE_UDEV" that disables udev and let it fallback to the device enumeration using polling. Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
Sam Lantinga 42607909 2021-02-20T22:51:57 Remove devices from the list after they've been disconnected due to read errors. This fixes problems with controllers not being re-detected when a computer goes to sleep and a controller is removed and plugged back in while it's asleep.
Sam Lantinga 7f710e93 2021-01-28T14:54:01 Make sure we don't create a game controller mapping for HID devices that aren't supported by HIDAPI
Sam Lantinga c857b5e0 2021-01-23T11:21:01 Minor cleanup
Sam Lantinga 1981d23f 2021-01-23T11:06:35 Fixed bug 5466 - Add haptic support for Stadia Controller Dimitriy Ryazantcev Consider adding support for Stadia Controller haptics. Here is example code how to deal with it: https://github.com/chromium/chromium/blob/99314be8152e688bafbbf9a615536bdbb289ea87/device/gamepad/hid_haptic_gamepad.cc#L45
Sam Lantinga e2f46ed8 2021-01-14T23:49:20 Always lock the HIDAPI device when closing, in case rumble is pending
Sam Lantinga 907b8eeb 2021-01-14T23:49:16 Make sure the HIDAPI device is locked when closing it, in case there is rumble pending that didn't complete
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga 80e5c689 2020-12-13T01:20:38 Fixed the PS5 controller not disconnecting when powered off
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga c9723c40 2020-12-07T09:38:21 Fixed potential hang in joystick close if the rumble thread is blocked for some reason It's still possible to hang when shutting down, if the rumble thread is still hung, but it won't block indefinitely at runtime.
Sam Lantinga 1031231b 2020-12-03T18:17:03 Fixed duplicating a device between XInput and HIDAPI
Sam Lantinga a0c5bfa3 2020-11-27T13:08:40 Moved raw input event processing from the main thread to the joystick thread This allows fast joystick event delivery regardless of what the main thread is doing.
Sam Lantinga ce77966d 2020-11-27T10:44:49 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers
Sam Lantinga 9fc4a4c9 2020-11-24T22:25:26 Revamped Xbox One HIDAPI init sequence Added support for querying the controller serial number on newer firmware
Sam Lantinga 5b3616c3 2020-11-23T18:24:05 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.
Sam Lantinga fcb21aa8 2020-11-17T10:30:20 Added API for sensors on game controllers Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers Also fixed an issue with the accelerometer on iOS having inverted axes
Sam Lantinga d140d887 2020-11-16T17:36:47 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial()
Sam Lantinga 71e32f5e 2020-11-16T15:00:15 Added SDL_crc32()
Sam Lantinga c6c116e8 2020-11-16T10:51:13 Implemented setting the LED color on the PS5 controller
Sam Lantinga 78422fa3 2020-11-13T13:17:07 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth
Sam Lantinga 1e2caac5 2020-11-11T18:57:37 Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers()
Sam Lantinga 3a3aaac2 2020-11-06T11:30:52 Added 4 auxiliary buttons to the game controller API Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver PS4 and PS5 controllers use AUX1 to represent the touchpad button Nintendo Switch Pro controllers use AUX1 to represent the capture button
Sam Lantinga a22beef4 2020-11-05T17:03:28 Moved the PS5 controller driver to a separate file, as the advanced feature protocol is very different from that of the PS4
Sam Lantinga e555d453 2020-11-05T11:07:54 Added SDL_JoystickHasLED Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga d000c1cd 2020-05-29T21:22:11 Fixed bug 5155 - HIDAPI_JoystickDisconnected incorrect array shift Anthony Pesch I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward. The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
Sam Lantinga 345b4d7e 2020-05-29T13:37:21 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification Jan Bujak I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL. Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this: https://www.kernel.org/doc/html/v4.15/input/gamepad.html Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments. Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.) With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
Ethan Lee 83cddd2e 2020-04-30T11:57:29 Add SDL_JoystickSetLED. Currently, this is only supported by the PS4 HIDAPI driver.
Sam Lantinga b6afbe63 2020-04-07T09:38:57 Added SDL_log.h to SDL_internal.h so logging is available everywhere
Sam Lantinga f55cbdfd 2020-03-20T21:05:07 Allow Valve devices in driver check, we know they're well behaved controllers
Sam Lantinga 4dea340c 2020-03-16T12:23:38 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows Jimb Esser Add new RawInput controller API, and improved correlation with XInput/WGI Reorder joystick init so drivers can ask the others if they handle a device reliably Do not poll disconnected XInput devices (major perf issue) Fix various cases where incorrect correlation could happen Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation Correlate by axis motion as well as button presses Fix failing to zero other trigger Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init() Add missing device to device names Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices Updated to SDL 2.0.13 code with the following notes: New HID driver: xbox360w - no idea what that is, hopefully urelated SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data. SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem. Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason. Something changed in how devices get names, so getting generic names. Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
Sam Lantinga d662a659 2020-03-13T19:00:22 Fixed crash if manufacturer or product string is NULL
Sam Lantinga c44473ba 2020-03-12T19:47:30 Unified code to standardize joystick names
Sam Lantinga 3b3ae4d1 2020-03-02T15:06:47 Possible fix for bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application Jake Breen When I run SDL_INIT with SDL_INIT_JOYSTICK it stalls for about 10 seconds (last report was 10,615ms), but only if I'm currently playing audio. (Like in Spotify for example.) querying something related to device access (last dll loaded) 'BabbysFirst64.exe' (Win32): Loaded 'C:\Windows\SysWOW64\deviceaccess.dll'. I use a USB DAC because my mobo's audio out is pretty not great. And I've noticed unplugging it seems to solve the issue. I haven't noticed any other issues that are caused by my DAC. My DAC is the Sound BlasterX G1 https://us.creative.com/p/gaming-headsets/sound-blasterx-g1 Vid = 041E PID = 3249 My system specs: - Windows 10 Pro - Ryzen 2700x - 16GB Ram - Nvidia 2070 RTX Additional USB devices plugged in: - Valve Index - Xbox One Elite Controller
Romain Roff? 53462163 2020-03-01T13:01:53 mac: Fix gamepad detection
Sam Lantinga 715f8d42 2020-02-14T16:15:46 Fixed bug 4986 - Memory leak in HIDAPI_JoystickConnected meyraud705 Memory allocated for device->joysticks on line 589 of SDL_hidapijoystick.c is never freed. Also, use memmove because memory is overlapping.
Sam Lantinga 1684606f 2020-02-04T15:26:56 Fixed long delay on main thread caused by blocking rumble writes in HIDAPI drivers There is now a thread that handles all HIDAPI rumble requests and a lock that guarantees that we're not reading and writing the device at the same time.
Sam Lantinga 6efebf17 2020-02-04T12:48:53 Moved rumble expiration to the main joystick handling level, and prevent sending the driver layer duplicate rumble requests.
Sam Lantinga 39a498c9 2020-01-31T13:09:20 Build the hidapi framework and weak link it on Mac OS X
Sam Lantinga 91121ee4 2020-01-31T10:45:04 Weak link the hidapi framework on iOS and tvOS
Sam Lantinga adb53d0b 2020-01-26T10:32:39 Fixed disabling the Xbox 360 wireless HIDAPI driver
Sam Lantinga 9c3d1602 2020-01-19T11:43:36 Refactored code so SDL_GetJoystickGameControllerType() is called less during controller detection
Sam Lantinga 43aa1fa9 2020-01-18T11:21:14 Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android
Sam Lantinga 4e682461 2020-01-17T10:43:14 Reattach the kernel driver after closing USB controllers
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 7775f7ce 2020-01-13T22:05:54 Fixed deadlock in HIDAPI joystick system
Sam Lantinga 47abe4e3 2020-01-09T14:53:30 Fixed crash when unplugging a HIDAPI controller
Sam Lantinga a9482a1d 2019-12-30T09:44:32 Added support for the Nintendo GameCube adapter, tested on Steam Link hardware
Zack Middleton f0cee3ed 2019-12-22T13:15:11 Fix shutting down HIDAPI device with multiple joysticks Using Wii U GameCube USB adapter with multiple controllers attached and restarting SDL input in a game results in extra joysticks with NULL name. HIDAPI_CleanupDeviceDriver() shut down joysticks by iterating through device->num_joysticks but each HIDAPI_JoystickDisconnected() decreases device->num_joysticks and shifts joysticks array down. Resulting in only half of controllers being shutdown. It worked with only 1 controller attached though. Disconnect HIDAPI device joystick 0 until there are none left.
Sam Lantinga 46e1377d 2019-12-20T20:12:03 Automatically assign player indexes to game controllers, and allow changing the player index for game controllers and joysticks. Added the functions SDL_JoystickFromPlayerIndex(), SDL_JoystickSetPlayerIndex(), SDL_GameControllerFromPlayerIndex(), and SDL_GameControllerSetPlayerIndex()
Sam Lantinga 2481ab93 2019-12-19T15:58:16 Fixed compiler warning
Sam Lantinga e22e77da 2019-12-19T15:01:35 Added an untested driver for the Nintendo GameCube adapter, based on code contributed by Ethan Lee
Sam Lantinga 15d30298 2019-12-19T15:01:32 Added support for wireless Xbox 360 controllers using the HIDAPI driver
Sam Lantinga e7f7e3f4 2019-12-19T15:01:30 Refactored HIDAPI controller code to support dongles and hubs that dynamically attach controllers
Sam Lantinga 0352814a 2019-12-13T16:07:25 Added general remapping of controller manufacturer
Sam Lantinga 0f529160 2019-12-11T17:47:01 Added custom names for some controllers
Sam Lantinga e029fdbb 2019-12-11T17:46:59 Shorten "Performance Designed Products" to "PDP"
Sam Lantinga 8b50dcb2 2019-12-11T17:46:54 Use the controller product string instead of hard-coding controller names
Sam Lantinga 3469481e 2019-12-10T10:00:49 Don't include the manufacturer if it's already included in the product string
Sam Lantinga 36265063 2019-12-09T13:54:03 Added some missing Xbox controller names
Sam Lantinga 43cb7b3c 2019-11-27T12:38:51 Added support for the Hori Fighting Commander
Sam Lantinga a76e5474 2019-11-27T12:38:48 Added support for the PowerA XB1 Fusion Fight Pad
Sam Lantinga a5e6b87c 2019-11-26T08:35:41 Added support for a variant of the PowerA FUSION Pro Controller
Sam Lantinga f3d95396 2019-11-25T15:02:54 Added some missing controller names
Sam Lantinga 8243a3e8 2019-11-25T15:02:50 Added support for the Hyperkin X91
Sam Lantinga 1e24a151 2019-11-18T11:51:39 Added names for some missing Xbox controllers
Sam Lantinga cf33f1f0 2019-11-13T21:53:01 Added a utility function to simplify the hint handling logic
Sam Lantinga 9da4bfc1 2019-10-22T10:57:07 Added support for the Power A Nintendo Switch Enhanced Wireless Controller
Sam Lantinga c10a8742 2019-07-31T10:20:37 Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePresent()
Andrew Eikum c172f36b 2019-07-31T11:14:48 joystick: Ensure HIDAPI is initialized before calling it
Sam Lantinga dc714389 2019-07-25T15:21:44 Don't call hid_enumerate() if the HIDAPI drivers are all disabled
Sam Lantinga be6cda9f 2019-06-19T15:54:21 Rolling back GameCube HIDAPI support It causes the HIDAPI devices to always be opened on enumeration, which causes crashes in the Windows drivers when multiple applications are reading and writing at the same time. We can revisit this after 2.0.10 release.
Zack Middleton 82af4276 2019-06-08T13:36:59 hidapi: Use GameCube adapter controller port for player index The Nintendo USB GameCube adapter has four controller ports. Return the port number as 0 to 3 from SDL_JoystickGetPlayerIndex() and SDL_JoystickGetDevicePlayerIndex().
Ethan Lee c5286156 2019-03-12T20:27:54 hidapi: Add support for Wii U/Switch USB GameCube controller adapter. Note that a single USB device is responsible for all 4 joysticks, so a large rewrite of the DeviceDriver functions was necessary to allow a single device to produce multiple joysticks.
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga 14c55ac8 2018-10-26T20:20:28 This change looks okay in the general case. If we run into problems where these events aren't dispatched (initialized on a different thread than the main thread?) we may need to create a separate thread to handle device notifications like we do with the windows joystick subsystem.
Ryan C. Gordon be8ef94f 2018-10-26T14:43:39 hidapi: Don't run a separate event loop for device notifications. Fixes Bugzilla #4286.
Sam Lantinga 14329256 2018-10-25T16:53:14 Generalized the XInput user index into a player index
Sam Lantinga 19445561 2018-10-02T20:51:33 Make sure we don't read and write to HIDAPI at the same time, it's not thread-safe on Windows
Ozkan Sezer 870c44bf 2018-09-25T09:20:56 safer this way, just in case..
Sam Lantinga cd90e2ca 2018-09-24T16:33:14 Fixed bug 4267 - linkage failure with --enable-hidapi because of missing libudev symbols Ozkan Sezer hidapi dynamic udev initial patch
Sam Lantinga 6a7b0c27 2018-09-14T12:41:29 Fixed crash launching under Steam on Mac OS X
Ozkan Sezer 33381d3d 2018-09-07T11:03:24 hidapi/SDL_hidapijoystick.c: fix build in C90 mode: src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_InitializeDiscovery': src/joystick/hidapi/SDL_hidapijoystick.c:281: error: 'true' undeclared (first use in this function) src/joystick/hidapi/SDL_hidapijoystick.c:281: error: (Each undeclared identifier is reported only once src/joystick/hidapi/SDL_hidapijoystick.c:281: error: for each function it appears in.) src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_UpdateDiscovery': src/joystick/hidapi/SDL_hidapijoystick.c:339: error: 'true' undeclared (first use in this function) src/joystick/hidapi/SDL_hidapijoystick.c:341: error: ISO C90 forbids mixed declarations and code
Sam Lantinga 34237b80 2018-08-31T18:10:21 Better fix to make sure we're only returning controllers from the HIDAPI joystick API
Sam Lantinga 16ccff3c 2018-08-29T20:23:36 Fixed whitespace
Sam Lantinga 3f5ff751 2018-08-15T23:14:43 Use a unified name list for Xbox 360 and Xbox One controllers for drivers that can handle both
Sam Lantinga 63107524 2018-08-15T19:53:34 Fixed input from the Steam Virtual Gamepad on Mac OS X
Sam Lantinga 0903e835 2018-08-15T19:53:31 Use SDL specific window class to avoid conflicting with Steam
Sam Lantinga c8866658 2018-08-15T19:53:30 Catch device removal as well as device arrival on Windows