Commit Graph

13662 Commits (082ef41566362281d954c8f2d35f1cc171e83d58)

Author SHA1 Message Date
Anonymous Maarten 13a6a72b88 windows: SDL_GetTicks64 -> SDL_GetTicks 2023-05-27 02:02:46 +02:00
Anonymous Maarten b4291412a4 tests: build tests with C90 standard
C90 mode is disabled for:
- testautomation: use of isnan/isfinite
- testlock: use of kill
- testvulkan: use of c++ style strings in vulkan.h
2023-05-27 01:49:07 +02:00
Anonymous Maarten 5b5b67df20 wayland: don't use libdecor_frame_get_* functions when header doesn't have it
and we're statically linking to the library.
This fixes building SDL with -DSDL_WAYLAND_SHARED=OFF
2023-05-27 01:25:27 +02:00
Ryan C. Gordon c6cecb0fb0
wasapi: Deal with HDMI or DisplayPort-based audio devices.
They can vanish for UP TO EIGHT SECONDS...!

This is for devices that connect to HDMI/DisplayPort/etc, where it
presumably has to wait for a display to get up and running before it
can play audio through it, so one can see the audio device fail when
changing display modes, or the system returning from sleep. Since this
can be triggered by a game changing video resolutions at startup (either
before or after opening the audio device!), it's important to deal with.

In normal conditions, it shouldn't take this long to open or recover an
audio device, but this is better than unexpectedly losing the device
in this situation.

Fixes #7044.
Fixes #5571.

(cherry picked from commit 48e71ae87be425f117dece3735b148fbc5f2606e)
2023-05-26 19:15:56 -04:00
Nikita Krapivin 97a927b44e gdk: Fix the project 2023-05-26 14:53:17 -07:00
Sam Lantinga 128ca70160 Added support for printing wide strings using "%ls" syntax 2023-05-26 13:58:10 -07:00
Ozkan Sezer a8a72de6fb fix mingw build failures in CI with clang-tidy. 2023-05-26 23:55:04 +03:00
Sam Lantinga 31d0d1b93a Fixed HIDAPI driver build 2023-05-26 10:03:11 -07:00
Sam Lantinga 1ef18c7677 Fixed windows build 2023-05-26 09:50:30 -07:00
Sam Lantinga cb73bed6eb SDL API renaming: SDL TLS functions
Fixes https://github.com/libsdl-org/SDL/issues/7743
2023-05-26 08:33:15 -07:00
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