Commit Graph

12888 Commits (eb0955ef89a1917b93da86d9b4b6fdf67cd61a8c)

Author SHA1 Message Date
Ozkan Sezer 9b147eb80b SDL_x11window.c: apply missing SDL2-to-SDL3 portage to fix build. 2023-05-31 01:55:50 +03:00
Ozkan Sezer c521e1286b SDL_dbus.h: define DBUS_TIMEOUT_USE_DEFAULT if not already defined. 2023-05-31 01:55:40 +03:00
Ozkan Sezer 20dfb7df2c hidapi/linux/hid.c: define BUS_SPI if not already defined. 2023-05-31 01:55:40 +03:00
Ryan C. Gordon 19c10b41fd
x11: Attempt to wait for SDL_MaximizeWindow to complete before returning.
Fixes #7070.

(cherry picked from commit 379a6f4dabc448d37a5823724d507967e2e069eb)
2023-05-30 17:10:04 -04:00
Sam Lantinga 1fdcb610ff Fixed build 2023-05-30 05:52:07 -07:00
Sam Lantinga 4c36726a31 macOS child window fixes
- Fix places working with window coordinates that need to call SDL_RelativeToGlobalForWindow or SDL_GlobalToRelativeForWindow

- Remove NSScreen param from ConvertNSRect(). Reflecting the Y coordinate is done relative to the main screen height (which ConvertNSRect
  was already doing) so the explicit screen isn't needed.

- Refactor NSScreen lookups for point/rect and fix getting the screen for Cocoa_SetWindowPosition() to get the screen for the new position and
  not the window's current screen (which may not exist if the window is off-screen).

- Fix re-associating the popup and parent window when the child window is shown. Hiding a child window removes it from the window hierarchy
  and so must be added when the window is shown again.

- Allow popup windows that are not tooltips to gain key focus.
2023-05-29 16:44:17 -07:00
Ryan C. Gordon ecccf6f9ca
windows: Don't allow non-resizable windows to be maximized.
Fixes #6346.

(cherry picked from commit d275851dfbd586910ddf1fbed8ef54714afbe6c4)
2023-05-29 14:49:57 -04:00
David Gow 52b73d4115 pipewire: Set 'application.id' if SDL_HINT_APP_ID set
If SDL_HINT_APP_ID is set, pass it as the application.id to pipewire.
This gives any pipewire-based tools a hint to find an associated
.desktop file for icons, etc.
2023-05-29 11:03:34 -04:00
Sam Lantinga f74549ef2e Fixed build warning
(cherry picked from commit 5007b963639bff2fa3359abbfe20d53ea9111fd9)
2023-05-28 19:24:17 -07:00
Sam Lantinga 1da5b2e488 Disable SDL_JOYSTICK_RAWINPUT_XINPUT
Apparently when using the Xbox One Wireless Adapter, using XInput at the same time as raw input will cause the controller to turn off immediately after connecting. This appears to be a bug in the Windows 11 driver stack, but since WGI provides all the extended functionality we need, this can be turned off for now.

Fixes https://github.com/libsdl-org/SDL/issues/3468

(cherry picked from commit b2e88ecfeb5e4d7db021e43c1b9bc4c9d14f615c)
2023-05-28 18:44:02 -07:00
Ryan C. Gordon 95f244598b
power: On Linux, compare status strings as case-insensitive.
In case something reports "Device" when we expected "device", etc.

Reference Issue #6835.

(cherry picked from commit df9d0fb332ea65c3fc47f72574851c91da2c912b)
2023-05-28 21:36:56 -04:00
Frank Praznik 2f75596d5a Consolidate the X11 WM_CLASS and Wayland app ID envvars
Consolidate the X11_WMCLASS and WAYLAND_WMCLASS envvars into one SDL_HINT_APP_ID hint. This hint serves the same purpose on both windowing systems to allow desktop compositors to identify and group windows together, as well as associate applications with their desktop settings and icons.

The common code for retrieving the value is now consolidated under core/unix/SDL_appid.c as it's common to *nix platforms, and the value is now retrieved at window creation time instead of being cached by the video driver at startup so that changes to the hint after video initialization and before window creation will be seen, as well as to accommodate cases where applications want to use different values for different windows.
2023-05-28 19:15:36 -04:00
Sam Lantinga 85f33fe866 Fixed crash if the X11 display doesn't have a resource manager property 2023-05-27 20:42:22 -07:00
Anonymous Maarten 76a919d458 cmake: don't force enable/disable SDL_HIDAPI_LIBUSB
Use CMakeDependentOption instead to configure SDL_HIDAPI_LIBUSB to a okay-ish variable.
2023-05-28 03:27:20 +02:00
Jeffrey Knockel e4eab186ec Return xrandr-scaled display modes
XRandR supports applying transformations to an output's picture
including changes to scale. Such scaling is used by some desktop
environments under feature names such as "fractional scaling" to
accomodate HiDPI devices. Alternatively, such scaling can be enabled by
a command such as the following:

xrandr --output DP1 --scale 0.5x0.5 --filter nearest

XRandR scaling has no "HiDPI awareness" or other way for an application
to signal that it wants to work with physical display pixels, and so all
we do is scale SDL's returned display modes so that applications receive
the number of usable pixels that they expect.
2023-05-27 17:20:05 -07:00
SDL Wiki Bot 4d6ed7173e Sync SDL3 wiki -> header 2023-05-27 17:52:16 +00:00
Sam Lantinga 0ffeca8a1c Added SDL_HINT_HIDAPI_ENUMERATE_ONLY_CONTROLLERS to control whether SDL_hid_enumerate() enumerates all HID devices or only controllers.
By default SDL will only enumerate controllers, to reduce risk of hanging or crashing on devices with bad drivers and avoiding macOS keyboard capture permission prompts.
2023-05-27 10:51:52 -07:00
Ozkan Sezer 77e59d4fa9 fixed build error due to -Wunused-function 2023-05-27 18:56:10 +03:00
Ozkan Sezer 8ea76ba116 move diagnostic pragma out of the function for old gcc versions. 2023-05-27 18:40:56 +03:00
Sam Lantinga 211054d9db hidapi: improved error handling 2023-05-27 08:33:48 -07:00
Sam Lantinga 2666e15cf1 hidapi: fixed upstream build 2023-05-27 08:21:59 -07:00
Sam Lantinga bc28790817 Make sure hidapi error handling is thread-safe
The hidapi method of storing the error on the device is not thread-safe, and not only could it result in a double free if multiple threads were setting the error at the same time, but SDL could be trying to use the error message and have it be freed out from under it by another thread.

Use SDL's error functions since they already use thread-local storage.
2023-05-26 23:50:50 -07:00
Sam Lantinga d51f84a2e1 Revert "Fixed double-free during multi-threaded hidapi access"
This reverts commit 2b386b6c80.

This isn't the right approach. Even if the string itself isn't double-freed, it can be returned to the application and then freed while the application is trying to use it. This really needs to be in thread-local storage to be completely safe.

In SDL we already have a global thread-local error string, so I'm going to make an SDL-specific change to handle the error strings safely.
2023-05-26 23:50:50 -07:00
Sam Lantinga 1c9aae9a29 hidapi build fixes for the upstream build environment 2023-05-26 22:50:39 -07:00
Sam Lantinga 2b386b6c80 Fixed double-free during multi-threaded hidapi access
The error string is not protected by a mutex, and can be set from multiple threads at the same time. Without this change, it can be double-freed. It can still be double-allocated, leading to a memory leak, but at least it won't crash now.

Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2023-05-26 21:08:39 -07:00
Anonymous Maarten 860e52c99e windows: SDL_Delay expects a 32-bit integer 2023-05-27 02:12:59 +02:00
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