Commit Graph

12552 Commits (2a271aeaf1aae91ef0235aac477e860a8d286ed8)

Author SHA1 Message Date
SDL Wiki Bot 2a271aeaf1 Sync SDL3 wiki -> header 2023-05-26 15:20:16 +00:00
Sam Lantinga 381cb41027 Don't export hidapi functions from SDL 2023-05-26 08:19:04 -07:00
Sam Lantinga 007c36e513 Added SDL_HINT_HIDAPI_IGNORE_DEVICES to specify devices that should be ignored in SDL_hid_enumerate() 2023-05-26 08:19:04 -07:00
Sam Lantinga e6834a1535 hidapi/linux: fixed crash if uevent info isn't available
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga b35d813ebb hidapi/linux: retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled)
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 7c65c9d411 hidapi/linux: fixed doubled and missing report ID for BLE devices
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 9c2ec04733 hidapi/windows: fixed PS4 controllers over Bluetooth on Windows 7
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 8f60d3ee86 hidapi/windows: 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.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga f5c731212e hidapi/windows: 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.

Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga c09848f7ab hidapi/windows: avoid enumerating devices that may hang when queried
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga b0ba509d87 hidapi/windows: allow building on Windows, using the SDL C runtime
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 57b33aec01 hidapi/libusb: allow building on Windows, using the SDL C runtime
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga feb7178e66 hidapi/mac: 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.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 2fa4b2e78f hidapi/mac: fixed crash on macOS when AirPods are connected
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga daccd7289b hidapi/libusb: added quirks for the Sony PS3 controller
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 3b06d64dc3 hidapi/libusb: enable support for Xbox 360 and Xbox One controllers
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga e2ec976735 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>
2023-05-26 08:19:04 -07:00
Sam Lantinga 04e686c52f hidapi/libusb: use LIBUSB_CALL for the read_callback function
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 5de35a1d77 hidapi/libusb: use the same logic to get the config descriptor in hid_open_path() as in hid_enumerate()
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 08:19:04 -07:00
Sam Lantinga 0487621ec4 Added iOS/tvOS hidapi 0.14.0 support 2023-05-26 08:19:04 -07:00
Sam Lantinga bb12c6e03e Added Android hidapi 0.14.0 support 2023-05-26 08:19:04 -07:00
Sam Lantinga 92b3969ea3 Fixed parameter documentation mismatch 2023-05-26 08:19:04 -07:00
Sam Lantinga 22f22472a0 Create wrapper headers for platform specific hidapi modules 2023-05-26 08:19:04 -07:00
Sam Lantinga 2a08bf6118 Use the bus in the HIDAPI joystick guid now that it's available 2023-05-26 08:19:04 -07:00
Sam Lantinga af45ae7296 Update the SDL HIDAPI API to match upstream hidapi 0.14.0 2023-05-26 08:19:04 -07:00
Sam Lantinga 003a9b9666 Added interface_class, interface_subclass, and interface_protocol to USB device info
Currently only filled in for libusb
2023-05-26 08:19:04 -07:00
Sam Lantinga 55ed69fc9a Fixed building SDL_hidapi.c with new hidapi 2023-05-26 08:19:04 -07:00
Sam Lantinga 651d9c4a6e Fixed compiling hidapi in SDL build environment 2023-05-26 08:19:04 -07:00
Sam Lantinga 2004304348 Directly include hidapi.h bundled with the hidapi source code 2023-05-26 08:19:04 -07:00
Sam Lantinga 3b7b8f3c09 Updated hidapi to 0.14.0 release
Upstream: https://github.com/libusb/hidapi/releases/tag/hidapi-0.14.0
2023-05-26 08:19:04 -07:00
Sam Lantinga 6b8b9af88a Disable HIDAPI libusb support on FreeBSD in CI
It looks like we're expecting a newer version of libusb than is installed on our VM image. Disabling pending further investigation.
2023-05-26 08:19:04 -07:00
Sam Lantinga b252ecec6d Fixed crash if trying to dump a packet larger than USB_PACKET_LENGTH 2023-05-26 08:19:04 -07:00
Sam Lantinga 2bf6a7c6af Fixed build warning on Xcode 14.3 2023-05-26 08:19:04 -07:00
Sam Lantinga b0d52f11f4 Added udev_device_get_syspath() to udev context 2023-05-26 08:19:04 -07:00
Sam Lantinga c9d8a04945 Added SDL_swprintf() and SDL_vswprintf() 2023-05-26 08:19:04 -07:00
Sam Lantinga 6c28546828 Added SDL_wcstol() 2023-05-26 08:19:04 -07:00
Sam Lantinga 7602a3181e Allow declarations after statements
The SDL coding standard is C89 plus C++ style comments and mixed code and declarations.
2023-05-26 08:19:04 -07:00
Ryan C. Gordon 35292d7dba pulseaudio: Redesigned to use pa_threaded_mainloop.
We weren't meant to have multiple contexts and mainloops, but we had one
for each opened device and the hotplug detection thread. Instead, use
pa_threaded_mainloop, which can be shared between threads and objects, and
a single context (which, according to the PulseAudio documentation, is
usually meant to be a singleton that represents a global server connection,
possibly with multiple streams hung on it).

Now instead of polling in a loop, threads will block until the
threaded_mainloop runs a callback, and the callback will fire a signal to
unblock the thread.

Prior to this, the code upset ThreadSanitizer, as Pulse has some unprotected
global resource that each mainloop/context would touch.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon 81fe505c31 audio: remove is_in_audio_device_thread()
SDL mutexes are always recursive in modern times, so no need to check this,
plus the test triggers a false-positive on ThreadSanitizer.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon d4bc393efe
video: Only specify some GL context attributes if not the explicit default.
Just in case it upsets some OpenGL drivers unnecessarily.

Fixes #7730.
2023-05-25 10:04:44 -04:00
David Edmundson a6bb00f399 x11: Use XResources font DPI as a fallback for X11 content scale
There are many toolkit specific ways to set a font DPI in X11 desktop
environments. The primary approach of reading a Gnome specific setting
from the portal is ok, it will work on Gnome and on Plasma most the
time.

The current fallback GDK_SCALE is less great; it's an internal GTK
setting relating to the mapping of logical pixels to device pixels
within the toolkit, it's a developer setting for GTK devs. We were
instructed within Plasma to not set this as it caused issues.

Xft.dpi in xresources is a good universal fallback, it's very dated to
the point that it works in clients like xterm, Qt on X11 uses it in our
font DPI path.
2023-05-24 13:58:42 -07:00
Sam Lantinga 65180804c4 Disable unused local typedefs warning
This triggers on gcc 4.8.4 for compile time asserts inside of functions

Fixes https://github.com/libsdl-org/SDL/issues/7732
2023-05-23 17:23:30 -07:00
Sam Lantinga a9c988b2a9 Fixed building on 32-bit Linux 2023-05-23 14:36:25 -07:00
Sam Lantinga 06d5989157 Fixed crash if video isn't initialized in SDL_CreatePopupWindow() 2023-05-23 13:41:34 -07:00
Sam Lantinga e92e4d8b50 Save waitable timers in thread local storage instead of continuously allocating and freeing them
Fixes https://github.com/libsdl-org/SDL/issues/6597
2023-05-23 11:32:40 -07:00
Sam Lantinga ddbdd73258 Updated source to match SDL function prototype style 2023-05-23 11:29:41 -07:00
Sam Lantinga 737aa881fa Updated source to match SDL function prototype style 2023-05-23 09:37:07 -07:00
Simon McVittie a828f5897e testevdev: Add some driving sim controllers from Proton issue reports
Ideally we'd detect these as "joysticks" (or more generally, gaming
controllers), but in most cases their evdev flags are indistinguishable
from an accelerometer or gyro, so the only way to achieve this would be
a table of known devices that doesn't currently exist.

One exception is the one that reports a THROTTLE axis and TRIGGER, THUMB
buttons, which would be reasonable to detect via the joystick heuristic.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:53:19 -07:00
Simon McVittie c88b1d1ca0 testevdev: Add the ability to mark a device entry as unimplemented
There are some devices for which SDL's device classification heuristic
is known not to give the ideal result. Add a way to incorporate these
into our test data, so that when the heuristic is improved we can
detect them as their intended device type, without making the test fail
before that has been implemented.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:53:19 -07:00
Simon McVittie 22e6319fed testevdev: Add data for some game controllers submitted to steam-devices
This will ensure that detection of these devices doesn't regress.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:52:53 -07:00