Commit Graph

7758 Commits (d4519aafd3d1f3f54cef62ba09c016e6f913a772)

Author SHA1 Message Date
Ozkan Sezer 4cfacd5cb7 SDL_dynapi.c: minor cosmetics. 2023-06-10 20:50:02 +03:00
Sam Lantinga 281018f169 Make it clear that you can't mix 2D rendering and the window surface API
Also added functions to query and destroy the window surface so you can switch between modes if you want.

See https://github.com/pygame-community/pygame-ce/issues/2190 for more details.
2023-06-10 08:39:20 -07:00
Sam Lantinga 5490873daa Fixed querying device info on the MOBAPAD M073
The query packet needs to contain valid rumble data in order to be accepted by the controller.

Fixes https://github.com/libsdl-org/SDL/issues/7788
2023-06-09 18:41:21 -07:00
Sam Lantinga 2042e9c4e3 Only update the serial number if it hasn't already been set
This fixes the serial number for Nintendo Switch Pro, which is queried from the hardware in device initialization, and was later clobbered by the USB string which isn't correct.
2023-06-09 17:34:12 -07:00
Sam Lantinga c8051b11e8 Fixed reading input from the Razer Atrox Arcade Stick using Windows Gaming Input 2023-06-09 14:35:43 -07:00
Sylvain aaccf3cd52 X11: common function to wait for the WM before sending SDL Window events 2023-06-09 19:48:59 +02:00
Sylvain 8096f7269b Android: add robustness. check that the native code is run for the first time. 2023-06-09 10:13:58 +02:00
Sylvain ae9d8acc3b Android: when an EventFilter is binded to SDL_EVENT_DID_ENTER_FOREGROUND event and triggered, GL context is expected to be already restored. 2023-06-09 10:00:01 +02:00
Sam Lantinga 4c0758a234 Fixed crash if display couldn't be found in SDL_UpdateFullscreenMode() 2023-06-08 12:39:32 -07:00
Sam Lantinga 32d015a6a0 Fixed PS3 controller initialization over Bluetooth
Now that we have hidapi that knows whether the controller is connected via Bluetooth or USB, this is much easier to fix.
2023-06-08 10:46:56 -07:00
Frank Praznik e15da1985a video: Apply cleared flag states when restoring hidden windows
Hiding a window and then clearing the minimized, maximized, fullscreen, or grabbed flags wouldn't result in the new state being applied to the window when shown, as the pending flags would always be zero, resulting in the flag application function never being entered. Calling SDL_RestoreWindow() didn't result in the minimized or maximized state being cleared on the hidden window either.

Save the current window flags to the pending flags when hiding a window, and universally apply the pending flags when the window is shown again to ensure that all state that was set or cleared when the window was hidden is applied. Any pending flags that match the existing window flags will be automatically deduplicated by the corresponding functions.
2023-06-08 12:34:56 -04:00
Ryan C. Gordon 49b5cfa6c5
x11: check if window size/position has changed during SDL_ShowWindow.
Fixes #4216.
2023-06-07 15:42:22 -04:00
Sam Lantinga dc06116c71 Steam sets the device version of the Steam Virtual Gamepad to 0, for the best compatibility with old games 2023-06-06 12:33:48 -07:00
Sam Lantinga d032492aab Fixed detecting Bluetooth Steam Controllers on Windows 2023-06-05 21:28:12 -07:00
Sam Lantinga 17c397f7ec Save the error code before doing any other operation
SDL_ClearError() resets the Win32 error code to 0
2023-06-05 21:18:49 -07:00
Sam Lantinga 6e7769cde1 Fixed detecting Bluetooth Steam Controllers 2023-06-05 19:52:00 -07:00
Sam Lantinga 6150b5b3cb Don't bother re-encoding Latin1 characters in the ASCII range 2023-06-04 05:37:06 -07:00
Sam Lantinga 491ae20d96 Only convert the result of XLookupString() if it's not already UTF-8
Fixes https://github.com/libsdl-org/SDL/issues/7766
2023-06-04 02:50:03 -07:00
Sam Lantinga c369b90019 Fixed SDL_iconv_string() truncation when handling SDL_ICONV_E2BIG 2023-06-04 01:01:06 -07:00
Sam Lantinga d40695115f Cleaned up Alt-Enter/Ctrl-Enter fullscreen toggle logic
Alt-Enter will go from the current state to fullscreen desktop, or if already there, will leave fullscreen mode.
Ctrl-Enter will go from the current state to exclusive fullscreen mode, or if already there, will leave fullscreen mode.
2023-06-03 23:24:21 -07:00
Rusty Moyher 052a9d3284 macOS: Removed the fullscreen blanking window
- Removed the blanking window used in SDL_WINDOW_FULLSCREEN. This allows CMD + Tab to work.
- Changed the fullscreen NSWindow level so this works properly.

Fixes issue #7776
2023-06-03 23:05:09 -07:00
Sam Lantinga fa41ece65f Allow other applications to open controllers on macOS 2023-06-03 11:53:36 -07:00
Sam Lantinga 6815e75caf Steam uses a different VID/PID for the Steam Virtual Gamepad on Windows 2023-06-03 11:39:03 -07:00
Sam Lantinga 5f00147e61 Revert "Fixed detection of the Steam Virtual Gamepad on macOS"
This reverts commit 5fcd70578b.

Steam has been updated to send a version of 1 to avoid conflicts with controllers that report a version of 0.
2023-06-03 11:35:27 -07:00
Ozkan Sezer 0c862d9a55 added compiler support comment about #pragma push_macro/pop_macro. 2023-06-03 17:23:40 +03:00
Sam Lantinga 5fcd70578b Fixed detection of the Steam Virtual Gamepad on macOS 2023-06-02 18:37:45 -07:00
Sam Lantinga 9837653b9d Allow the application to send commands to Nintendo Switch controllers 2023-06-02 15:52:56 -07:00
Sam Lantinga 7c55845c80 Fixed build if SDL_JOYSTICK_RAWINPUT_MATCHING isn't enabled 2023-06-02 11:20:31 -07:00
Sam Lantinga 767507fcf6 Don't use raw input while Remote Desktop is active
Raw input will not send game controller events while Remote Desktop is active, so dynamically switch between XInput and raw input when Remote Desktop state changes.

Fixes https://github.com/libsdl-org/SDL/issues/7759
2023-06-02 11:16:07 -07:00
Sam Lantinga a5a1844681 Fixed build error 2023-06-02 10:20:29 -07:00
Sam Lantinga e8b5b4881c Fixed WGI immediately being correlated with raw input devices with no input
The at rest match state is 0x0000008800000000, not 0
2023-06-02 09:38:18 -07:00
Sam Lantinga 2e27812d39 Fixed event sequence when Remote Desktop connects and disconnects
1. Send display disconnected events for all displays no longer connected
2. Send display connected events for all displays that have been connected
3. Send window display events for any windows that have changed displays
2023-06-02 08:51:47 -07:00
Alibek Omarov 6aaf032320 wayland: reset orientation bitmask before reading values from hint on QtWayland
Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
(cherry picked from commit 68e3e99087544c64abb534613643080312aced96)
2023-06-02 08:06:30 -07:00
Ozkan Sezer 8c476ca1b0 hidapi/libusb: need libusb >= 1.0.16 because of libusb_get_port_numbers 2023-06-02 07:26:38 -07:00
Ozkan Sezer e27c10a5b1 hidapi/libusb: don't try to dlsym libusb_wrap_sys_device
not used in SDL.
2023-06-02 07:26:38 -07:00
Ozkan Sezer 3ecdbf27cc hidapi: silence redefinition warnings 2023-06-02 07:25:02 -07:00
Sam Lantinga f082c68b2f Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/582 2023-06-01 10:48:15 -07:00
Sam Lantinga b36679b90e Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/582 2023-06-01 08:27:56 -07:00
Sam Lantinga 20182eed7c Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/572 2023-06-01 07:47:28 -07:00
Sam Lantinga 0cff44dbd4 Updated with upstream suggestions in https://github.com/libusb/hidapi/pull/577 2023-06-01 07:28:44 -07:00
Sam Lantinga 4f58445f03 Ignore both the mouse and keyboard endpoints of Steam Controllers when enumerating game controllers 2023-05-31 14:28:50 -07:00
Nikita Krapivin c886e80675 gdk: Virtual keyboard and text input backend 2023-05-31 13:11:39 -07:00
Sam Lantinga b6a88b0339 Don't try to interpret Xbox controllers as raw HID devices on Windows
These generate fake reports which don't include separate trigger axes, and the HIDAPI joystick driver doesn't understand this report format.
2023-05-31 10:49:46 -07:00
Frank Praznik adad6514d4 wayland: Add aspect-correct output for scaled modes
Add aspect-correct output of scaled video modes and a hint to control this behavior (aspect, stretch, or none).

The Wayland spec states that fullscreen surfaces that do not cover the entire output shall be centered with the borders masked by the compositor, so no additional work is required aside from calculating the proper window dimensions.

The default is still 'stretch' mode, as some window managers as of this time (KDE and older versions of GNOME still found in LTS distros) don't behave according to the spec and present an unmasked window that is not centered, so it's not yet safe to change the default.
2023-05-31 13:41:49 -04:00
Sam Lantinga 4644ac99fa Remove unneeded property type check 2023-05-31 08:27:54 -07:00
Sam Lantinga 0b28cbe385 Allow building on really old Linux kernels (thanks @sezero!) 2023-05-30 16:36:40 -07:00
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
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
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 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
Sam Lantinga 128ca70160 Added support for printing wide strings using "%ls" syntax 2023-05-26 13:58:10 -07: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
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 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
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 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
Linus Probert da3fefc65c x11: Adds support for generic clipboard data in X11
Re-writes clipboard data handling in X11 to an on demand approach where
data can be produced on request instead of storing it in X11 properties
on the window.
Primary selection has been changed to mimic this behavior even though
it's only possible to use it for text as of now.
2023-05-23 08:51:56 -07:00
Sam Lantinga 61ef4efdfa Fixed duplicate Joy-Con controllers on macOS
If both Apple and HIDAPI drivers see the controller, HIDAPI will be preferred.

Fixes https://github.com/libsdl-org/SDL/issues/7479
2023-05-22 13:54:15 -07:00
Sam Lantinga cf0abf9911 Fixed handling the Saitek P3600, which doesn't use the Xbox 360 controller protocol 2023-05-22 12:41:03 -07:00
Frank Praznik 1cadf4bab9 wayland: Validate surfaces and window data before sending touch events
Ensure that incoming touch events originate from valid surfaces owned by SDL and have proper window data before forwarding them to the touch subsystem, or the window focus pointer that is sent with the event may not be a pointer to an SDL window.

Additionally, ensure that allocated touch events are always cleaned up on exit.
2023-05-22 14:40:09 -04:00
Sam Lantinga 4dd9f61bfd Don't map the top keyboard row to numbers when using the one-handed DVORAK layouts (thanks @tormol!)
Fixes https://github.com/libsdl-org/SDL/pull/5127

(cherry picked from commit a2f4783e753e499c7f6660bf34e337618239a72f)
2023-05-22 11:33:47 -07:00
Caleb Cornett 376a3cd100 Fix Xbox link error from IsRectEmpty 2023-05-21 19:09:28 -07:00
Sam Lantinga d7a56b93d5 Revert "Popups don't accept first focus clicks"
This reverts commit 9d40d619709ce830372835ca29f516b73a685317.
2023-05-21 08:18:46 -07:00
Sam Lantinga e1a28bc16f Popups don't accept first focus clicks
I'm not sure if this is is what we want, but it matches Windows behavior
2023-05-21 08:17:42 -07:00
M. P. Halpin bbf38bbbc3 Stop beep when running iOS apps on ARM-based Macs 2023-05-20 11:20:38 -07:00
Sam Lantinga a6a222095e Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
Fixes https://github.com/libsdl-org/SDL/issues/7160
2023-05-20 11:14:34 -07:00
Sam Lantinga f005106d1b Make sure the sentinel is at the end of the current event pump cycle
If we're waiting, it's possible to not get any events, then add the sentinel, then pump again and then add another sentinel. We want to make sure we only have one sentinel and that it's at the end of the currently pumped events.

Testing:
* Verified test case in https://github.com/libsdl-org/SDL/issues/6539
* Verified test case in https://github.com/libsdl-org/SDL/issues/5350

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

(cherry picked from commit 00b87f1ded0a4fdb6a0bab611171f37eeb0b2ebb)
2023-05-20 10:37:40 -07:00
Sam Lantinga 1a3b713524 Added support for the PowerA MOGA XP-Ultra Controller 2023-05-19 14:39:30 -07:00
Sam Lantinga 517a2afcbd Added support for the PowerA MOGA XP-Ultra Controller 2023-05-19 14:38:50 -07:00
Sam Lantinga f60622c510 Undo name change for the controller list 2023-05-19 14:26:37 -07:00
Sam Lantinga 24007b00b2 Moved the controller list out so it can be included elsewhere 2023-05-19 14:22:35 -07:00
Sam Lantinga 4e9cfad558 Cache window manipulation calls while an SDL_Window is hidden and replay them when the window is set visible
- SDL_MaximizeWindow, MinimizeWindow, SetFullScreenWindow, etc are not meant to show the window if it isn't currently visible, but on some platforms
  (e.g. Windows) it isn't possible to set this state without also showing the window so cache the flags in a pending_flags field until SDL_ShowWindow is
  called. Then replay the pending flags through ApplyPendingFlags (hoisted out from SDL_FinishWindowCreation).
2023-05-19 10:23:16 -07:00
Ozkan Sezer 5c019bc97e style fixes for SDL_PROC macros. 2023-05-19 14:10:02 +03:00
Frank Praznik d5f07730be x11: Dynamically update the scale factor
If the text-scaling-factor setting is available via D-Bus, add a listener and update the content scale values for the displays if the value is changed during runtime.

Factors out the D-Bus message pump from the system theme detection code to the general D-Bus code, as it's now used for more purposes than just the system theme.
2023-05-18 16:16:00 -07:00
Sam Lantinga 068d3da366 Fixed window and backbuffer size on Android 2023-05-18 16:11:57 -07:00
Sam Lantinga a66cad79c1 SDL_GetClosestFullscreenDisplayMode() now takes a boolean whether to include high density modes
Also changed the match to prioritize resolution over refresh rate
2023-05-18 12:15:23 -07:00
Frank Praznik 32ab1183c7 x11: Expose the text/global scaling factor as the display content scale
Expose the text scaling factor (aka the global scale factor on KDE) as the display content scale value so applications can scale themselves as necessary.

If D-Bus is unavailable or retrieving the setting fails, fall back to trying the legacy GDK_SCALE envvar before reverting to the default 1.0 value.
2023-05-18 14:34:25 -04:00
Sam Lantinga 87186a893c Integrate 8067023 and 8067041 to SDL3:
Change 8067023 by mikela:
	Add SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED to SDL_RaiseWindow

	- When set to false, this allows SDL_RaiseWindow to bring a chosen window to the top of the stack but not force input focus to it

Change 8067041 by mikela:
	Rename SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN
2023-05-18 09:21:29 -07:00
Sam Lantinga 887a1b5969 Print some newly added window flags 2023-05-18 07:33:49 -07:00
Sam Lantinga cc94f600fd Officially added the concept of window pixel density
The SDL_WINDOW_ALLOW_HIGHDPI flag has been renamed SDL_WINDOW_HIGH_PIXEL_DENSITY, and added the function SDL_GetWindowPixelDensity()
2023-05-17 17:54:03 -07:00
Sam Lantinga e708674416 Always expose the high density video modes in the mode list
The SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint is going away, so this matches the macOS logic
2023-05-17 17:40:16 -07:00
Ryan C. Gordon 2e646c7141
audio: Load .WAV files with format->blockalign==0.
In theory this is illegal, but legit wavefiles in the field do it, and
it's easy to bump it to 1 for general purposes.

Formats with more specific alignment requirements already check for them
separately.

Fixes #7714.
2023-05-17 20:06:58 -04:00
Ryan C. Gordon d05639a626
dynapi: Accept a comma-separated list of libraries to attempt to load.
First one to load and have the necessary symbol is the one we accept,
if any. Once we accept one, we won't try loading others.

Fixes #7613.

(cherry picked from commit 32999798e0232cdeda777a32ce2fe6b78ec2bb4e)
2023-05-17 20:03:36 -04:00
Frank Praznik 68edc72ae8 wayland: Fixups for new DPI code
Add support for the pixel density hint and fix integer scaling to assume that exclusive fullscreen pixel density values are always 1.
2023-05-17 19:01:14 -04:00
Sam Lantinga a3ce0d03e3 Fixed building with older macOS SDK 2023-05-17 13:32:21 -07:00
Sam Lantinga 26e780bc9e Fixed warning "A function declaration without a prototype is deprecated in all versions of C" 2023-05-17 12:58:00 -07:00
Sam Lantinga c699f3d1d8 Updated SDL high DPI support
We have gotten feedback that abstracting the coordinate system based on the display scale is unexpected and it is difficult to adapt existing applications to the proposed API.

The new approach is to provide the coordinate systems that people expect, but provide additional information that will help applications properly handle high DPI situations.

The concepts needed for high DPI support are documented in README-highdpi.md. An example of automatically adapting the content to display scale changes can be found in SDL_test_common.c, where auto_scale_content is checked.

Also, the SDL_WINDOW_ALLOW_HIGHDPI window flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint.

Fixes https://github.com/libsdl-org/SDL/issues/7709
2023-05-17 12:58:00 -07:00
valid-ptr 0fbb9c779c SDL emscripten port: preventDefault should not be called on mousedown. Otherwise mouseup will not be fired outside iframe in Chrome-based browsers
(cherry picked from commit 424bc4bcf75cebc86b693b4b920ee686ce6550ea)
2023-05-17 12:35:02 -07:00
Ryan C. Gordon b5cd0749b2
blit: Add a case for 8-bit blits that sdl12-compat exposed.
sdl12-compat can get into a state where a color-keyed surface is
marked for blending, but wants to blend with full alpha (which
is the same as _not_ blending), so rather than fail to find a
blitter in that case, it just selects the colorkey blitter.

Reference https://github.com/libsdl-org/sdl12-compat/issues/233

(cherry picked from commit 0eea92c8fcc4b5c572a0dd9848ca8886978ee0a2)
2023-05-16 14:42:16 -04:00
Vid Tadel f94aa6208a Implement generic clipboard data on MacOS 2023-05-16 11:02:18 -07:00
Sam Lantinga 642504bc59 Check to make sure the Windows joystick device has buttons and axes
This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10
2023-05-15 21:43:55 -07:00
Sam Lantinga 4de7433a9e Use the term "points" instead of "screen coordinates"
It turns out that screen coordinates were confusing people, thinking that meant pixels, when instead they are virtual coordinates; device independent units defined as pixels scaled by the display scale. We'll use the term "points" for this going forward, to reduce confusion.
2023-05-15 11:20:38 -07:00
Ryan C. Gordon 9facc86b6a
audio: more AudioStream allocation work.
This was only including the resampling buffer needs if it was larger
the other allocation needs, but it needs to be included unconditionally.

For safety's sake, we also make sure the pre-resample buffer doesn't risk
overflow, too, but this might not be necessary in practice.
2023-05-12 21:35:23 -04:00
Sam Lantinga e596dd8dad Fixed crash creating a window with the Vivante video driver 2023-05-12 16:24:13 -07:00
Linus Probert 19adfa3ad9 wayland: Add support for images in clipboard.
Re-writes the clipboard data handling in wayland to an on demand
solution where callbacks are provided to generate/provide the clipboard
data when requested by the OS.
2023-05-12 07:54:56 -07:00
Sylvain dfd80f3d76 Android: control activity re-creation 2023-05-12 07:48:33 -07:00
Sam Lantinga 2e6c48dcb4 Added support for the GameSir-G7 Controller for Xbox 2023-05-11 17:44:56 -07:00
Ryan C. Gordon 80a8691098
audio: Fixed buffer overflow in SDL_AudioStream resampling. 2023-05-11 16:25:20 -04:00
Ryan C. Gordon 9bf0934877
audio: SDL_memcpy() params were backwards. :O 2023-05-11 15:13:11 -04:00
Sam Lantinga d98bd67733 Fixed lockup while waiting for events 2023-05-10 17:35:13 -07:00
Sylvain 6d9ccbb3c7 Android: use the headers to have the audio pause/resume definitions
and make SDL_PriveAudioData more private
2023-05-10 09:34:53 +02:00
Sam Lantinga 28f891ad0a Allow the application to send rumble packets to Nintendo Switch controllers 2023-05-09 17:08:47 -07:00
Frank Praznik 785b7c6636 wayland: Implement global mouse coordinate emulation
Wayland doesn't support getting the true global cursor position, but it can be faked well enough for what most applications use it for: querying the global cursor coordinates and transforming them to the window-relative coordinates manually.

The global position is derived by taking the cursor position relative to the toplevel window, and offsetting it by the origin of the output the window is currently considered to be on. The cursor position and button state when the cursor is outside an application window are unknown, but this gives 'correct' coordinates when the window has focus, which is good enough for most applications.
2023-05-09 14:17:18 -07:00
Ryan C. Gordon 7b6dabd81f
audio: AudioStreams shouldn't overflow output buffers.
Before, as ConvertAudio might have expanded data in-place temporarily during
its work, this could blow up. Now if there's a chance of that, it'll
work out of an internal buffer and copy the final results to the output
buffer.

If the output format can handle the temporary expansion, we write directly
to the output buffer without the extra copy.

Fixes #7668.
2023-05-09 14:19:16 -04:00
Sylvain 04e17d4e46 Remove _THIS in src/audio/ 2023-05-09 11:29:33 -04:00
Sylvain 81ff49f4b5 Remove _THIS in src/video and in src/events (also VideoDevice) 2023-05-09 11:29:33 -04:00
Sylvain df314ba93e Remove _THIS in src/core: EVDEV UDEV 2023-05-09 11:29:33 -04:00
Ryan C. Gordon 0e1669e296
audio: Fixed audiostreams converting incorrect channel counts. 2023-05-09 10:58:32 -04:00
Ryan C. Gordon 7f219aa369
audio: Make sure AudioStream's internal buffers are large enough.
It needs to deal with ConvertAudio growing buffers in-place, as it might
convert smaller types to float as an intermediate step.
2023-05-09 10:57:23 -04:00
Ryan C. Gordon c7629704b4
audio: SDL_ConvertAudioSamples shouldn't calculate its output buffer size.
Just use what the AudioStream calculates instead.
2023-05-09 10:56:34 -04:00
Ryan C. Gordon a88aeb2a8a coreaudio: Flush/stop the AudioQueue before disposing of it.
Otherwise, a CoreAudio thread lingers forever, and coreaudiod eats CPU
until the SDL process terminates.

Fixes #7689.

(cherry picked from commit 86786ed5447fe32ea2e48f12f0598816a76721c2)
2023-05-08 14:26:34 -04:00
Semphris 7f2ef4d02f Implement SDL_GetPath stub for all OSes 2023-05-08 09:36:39 -07:00
Ozkan Sezer ef2ad2b0c6 windows/SDL_sysfilesystem.c: fix SHGetKnownFolderPath calling convention 2023-05-08 11:55:32 +03:00
Frank Praznik b92eaddbbd wayland: Fix the corner case when positioning popups
If the popup is positioned such that it requires correction on both the x and y axes, it will be aligned with parent only at the window corners, which is neither overlapping nor adjacent. In this case, nudge the window plus or minus one screen unit on the x axis so it is properly adjacent to the parent and within spec guidelines.
2023-05-06 12:35:47 -04:00
Sam Lantinga b6df25c334 Removed redundant __powerpc__ check 2023-05-06 08:44:19 -07:00
Jeremy Rand 9142292f4a SDL_blit_N.c: Move ppc64le swizzle outside of loop
An in-place swizzle mutation was erroneously inside of a loop, which
caused each consecutive 4-pixel vector to alternate between correct and
incorrect endianness.

The bug was introduced in 715e070d29.

Thanks to RobbieAB for reporting the bug.

Fixes https://github.com/libsdl-org/SDL/issues/3428
2023-05-06 11:05:48 -04:00
Ozkan Sezer 26903f237f windows/SDL_sysfilesystem.c: replace KNOWNFOLDERID type usage with GUID 2023-05-06 01:10:02 +03:00
Frank Praznik 1bf5a78b53 wayland: Don't print an error when moving a hidden popup window
Repositioning a hidden popup window is valid behavior, so don't print an error message in this case.
2023-05-05 14:05:34 -04:00
Frank Praznik 27085df50d wayland: Remove redundant window geometry configuration
The window geometry will be updated when in underlying shell surface config handler, before the config is ack-ed, so no need to do it in the popup config handler.
2023-05-05 13:54:10 -04:00
Frank Praznik eb6837e353 wayland: Validate and trigger the repositioning of popups in more cases
Validate and reposition popups in any case where the position or size may have changed. In particular, this fixes cases where the position parameters were adjusted while the window was hidden, as the new values weren't being applied in all cases.
2023-05-05 13:54:10 -04:00
Frank Praznik 17fba24e21 wayland: Adjust overlap required for popups to be considered adjacent
Popups beyond the right and bottom borders of the window must be width/height minus one in order to be considered adjacent and not be instantly closed or cause a protocol error.
2023-05-05 13:54:10 -04:00
Anonymous Maarten c810e5f63d video: set error code when SetWindowPosition fails 2023-05-05 17:50:32 +02:00
Ozkan Sezer 52c19bd21b attempt to fix more build failures against older Win32 SDKs. 2023-05-05 03:33:10 +03:00
Ozkan Sezer d7f1719777 fixed -Wundef warning due to HAVE_MMDEVICEAPI_H 2023-05-05 03:32:56 +03:00
Sam Lantinga 450c947949 Actually define the folder GUIDs 2023-05-04 16:39:16 -07:00
Sam Lantinga e0e95b1ea9 Fixed coding style and building on older Windows SDKs 2023-05-04 16:28:16 -07:00
Sam Lantinga 9b87de258f Fixed crash in new audio channel conversion code
Each loop needs to be run num_frames times, and the source and destination pointers are incremented by the number of channels during the conversion.
2023-05-04 15:50:38 -07:00
Semphriss c1dab7745a
Add SDL_GetPath() for default OS folders (#7665) 2023-05-04 11:38:11 -07:00
Ryan C. Gordon e191bc8491 audio: Simplified GetFirstAudioFormat/GetNextAudioFormat.
Now it just returns an iterable array and needs no global state.
2023-05-03 22:37:23 -04:00
Sam Lantinga b6ca360228 Added support for the Saitek Cyborg V.3 Rumble Pad in PS3 mode 2023-05-03 09:47:16 -07:00
Sam Lantinga 3f0c2a6694 Don't set the display scale if DPI scaling isn't enabled
In this case we want the display mode pixel to screen coordinates to be 1:1 ... but we lose information about the UI scaling of the display - is that okay?
2023-05-03 09:47:13 -07:00
Brick 86b5f40b53 Fixed CalculateAudioStreamWorkBufSize 2023-05-02 11:16:20 -04:00
Brick 079ae065f1 Added SDL prefix AUDIO_* constants 2023-05-02 08:09:06 -07:00
Brick 1ee2832326 Fixed SDL_ConvertMonoToStereo_SSE reading out of bounds 2023-04-30 13:14:20 -04:00
Sam Lantinga 255c3b7c82 By default, OpenBSD uses Linux controller mappings
Fixes https://github.com/libsdl-org/SDL/issues/7609
2023-04-29 17:09:17 -07:00
Sam Lantinga 0d559b7cb3 Fixed parsing SDL_mutex.h 2023-04-29 10:14:03 -07:00
Frank Praznik bee6099372 events: Emit an event when a window is destroyed
As child windows can be recursively destroyed when their parents are destroyed, emit an event to notify the application when a window is being or has been implicitly destroyed so that it can appropriately clean up any associated resources.

If the application has registered an event watch, the destroy message will be received when the window handle is still valid, so the application can retrieve and release any userdata associated with the window. If the message is processed at any time after that, the window handle is already invalid and the ID is only useful for application-side bookkeeping purposes.
2023-04-28 15:09:47 -04:00
Sam Lantinga 87ad71f9b2 Rename SDL mutex, semaphore and condition variable types to match SDL 3.0 naming convention 2023-04-28 12:08:33 -07:00
Sam Lantinga 61c0c009ab Rename SDL semaphore and condition variable functions to match SDL 3.0 naming convention
Fixes https://github.com/libsdl-org/SDL/issues/7642
2023-04-28 12:08:33 -07:00
Ryan C. Gordon e474047ff8 rwlock: Added SDL_rwlock API for shared locks. 2023-04-27 21:54:02 -04:00
Ryan C. Gordon 776820526b windows: Use InitializeSRWLock explicitly.
The docs say you should, if not statically initializing an SRWLOCK--which
we aren't--but in practice this is probably just being pedantic.

Still, better (thread) safe than sorry!
2023-04-27 21:54:02 -04:00
Ryan C. Gordon 70a501d8ec winrt: Don't reference generic Condition Variables at all.
It always has the SRWLOCK implementation available to it, so let the
linker throw away the generic version if possible.
2023-04-27 21:54:02 -04:00
Sam Lantinga a4b4dff4a2 Added support for the Astro C40 in Xbox 360 mode 2023-04-27 17:10:44 -07:00
Ryan C. Gordon e5a6c24c82 audio: Redesigned audio conversion code for SDL3.
- SDL_AudioCVT is gone, even internally.
- libsamplerate is gone (I suspect our resampler is finally Good Enough).
- Cleanups and improvements to audio conversion interfaces.
- SDL_AudioStream can change its input/output format/rate/channels on the fly!
2023-04-27 18:35:15 -04:00
Sam Lantinga 44bec9c01c Fixed build 2023-04-27 13:06:21 -07:00
Sam Lantinga c10849b40b Added support for new Xbox Elite 2 firmware 2023-04-27 12:33:33 -07:00
Sam Lantinga eaf17050b4 Allow popup windows to be raised through SDL_RaiseWindow
- This allows specific child popup windows to be activated explicitly.
2023-04-26 16:31:18 -07:00
Linus Probert 43f65a6ef0 wayland: Fixes a memory leak wheere primary selection isn't freed 2023-04-24 11:59:39 -07:00
Ozkan Sezer ae9119c36b hidapi/mac: replace sprintf uses with snprintf.
Reference issues:
-  https://github.com/libusb/hidapi/pull/509
-  https://github.com/libusb/hidapi/pull/511
2023-04-24 10:46:05 -07:00
Ozkan Sezer 62d1a2c836 hidapi/mac: import mainstream commit c1b9d2ad
c1b9d2ad98
Properly handle the close of run loop on macOS
(https://github.com/libusb/hidapi/pull/522)
- as per documentation `kCFRunLoopRunStopped` should be handled once the runloop is closed via `CFRunLoopStop`;
- if it is not handled - a race condition/crash may happen on the latest macOS when a device gets disconnected while being open;
2023-04-24 10:46:05 -07:00
Mingjie Shen ac607c1088 SDL_ConvertSurface(): add null pointer check
Check return values of SDL_CreateSurface()
and SDL_ConvertSurface().
2023-04-23 17:43:10 -07:00
Mingjie Shen bf8c9d2d70 Check return value of VIRTUAL_HWDataForIndex() 2023-04-23 17:40:15 -07:00
Mingjie Shen a4604cb0d6 Check return value of SDL_malloc() 2023-04-23 08:57:12 -04:00
Frank Praznik f431037f62 wayland: Insert new displays at the end of the output list
Insert new displays at the end of the list instead of the front so that the initial ordering, as exposed by the compositor, is preserved. This is particularly important when the compositor exposes the xdg-output instance after the wl_output instance, as xdg-output must be attached to the outputs in the same order that wl_output exposed them, or they can be added to the SDL output list in reverse order.
2023-04-21 12:59:36 -04:00
Sam Lantinga 0467301baf Report PS3 accelerometer values in m/s2 instead of Gs 2023-04-19 13:10:39 -07:00
Sylvain 9d18b4b5ed Android: fix crash when AAUDIO isn't used (bug #7620) 2023-04-18 21:34:18 +02:00
Frank Praznik bad4f4e5ac wayland: Destroy proxy wrappers before and callbacks before event queues
Destroy any proxy wrappers and callbacks before the associated event queues to silence libwayland warnings about destroying the queues while proxies are still attached.
2023-04-18 14:37:16 -04:00
Sylvain 7afe735b5f SDL_test: add more color when success/fail/skip 2023-04-14 12:12:45 +02:00
Sylvain 117169d610 Android AAUDIO: handle multiple devices 2023-04-14 11:31:47 +02:00
Ozkan Sezer c41a76657e SDL_timer.c: silence a minor warning. 2023-04-12 12:55:40 +03:00
Sylvain ec053ec4f8 Android: need to save/restore the swap interval / vsync
otherwise, there is a difference of framerate, either with gles2 or SDL_renderer (testspriteminimal, testgles2).
2023-04-12 11:09:59 +02:00
Frank Praznik 8162d6659a wayland: Use the integer buffer scale event when applicable
wl_compositor v6 introduces the preferred buffer scale event, which serves a similar function to the fractional scale protocol, but deals in integer scale factors. Listen to this event when the wl_compositor version is >= 6 and the fractional scale protocol is not present to set the scale factor for surfaces.
2023-04-10 10:16:33 -04:00
Sam Lantinga 05b701f12e Fix win32 windows with WS_EX_COMPOSITED style continuing to receive WM_PAINT messages after ValidateRect
- Composited windows seem to need to actually paint (or appear to paint) through calls to Begin/EndPaint to properly validate
  their update region. If not done they will continue to receive WM_PAINT messages for the same region.
2023-04-07 06:20:28 -07:00
Sam Lantinga 17bdea7a91 Fix pop-up windows changing position for each HideWindow()/ShowWindow() cycle
When X11_UpdateWindowPosition() was called and the position didn't update
we would fire an SDL_EVENT_WINDOW_MOVED event with the global x,y for
the pop-up instead of the relative position for the pop-up.

This change ensures we always have a relative position for pop-ups before sending
the SDL_EVENT_WINDOW_MOVED event.
2023-04-06 15:12:09 -07:00
Sam Lantinga 92821f7a82 Fixed Visual Studio warning 4389: '==': signed/unsigned mismatch 2023-04-06 15:11:56 -07:00
Sam Lantinga acadb6f873 More defensive coding against dangling device pointers 2023-04-06 11:33:27 -07:00
Sam Lantinga 558bbbb07a The latest Armor-X Pro firmware update fixes the sign on the Z axis of the sensors 2023-04-06 09:55:01 -07:00
Sylvain 3c703f2061 Android: message to indicate that main() is called for the 1 or n'th time 2023-04-06 10:08:07 +02:00
Cyril Dubet 60dcaff7eb Fix key code names for ISO keyboard layouts 2023-04-05 17:03:05 -07:00
Sam Lantinga e13b74ccf0 Fixed crash if joystick->hwdata != NULL && device->driver == NULL
This should never happen, but we're seeing it in the wild, so make sure that we can never call into a NULL device driver.
2023-04-05 11:24:27 -07:00
Frank Praznik a21ee02095 wayland: Use the output description from wl_output as of v4
xdg-output names and descriptions are deprecated in favor of those provided by the core wl_output protocol as of v4. Bump wl_output support to v4 and ignore the xdg-output description in favor of the wl_output description when appropriate.
2023-04-05 10:24:23 -04:00
Frank Praznik 5c27bc81d8 wayland: Use release for display and seat objects, if available
wl_seat and wl_output gained release methods, which should be preferred over destroy methods if they are available.

Bumps wl_output to version 3.
2023-04-05 10:24:23 -04:00
Frank Praznik 9084b6c666 wayland: Remove some unused variables 2023-04-05 10:24:23 -04:00
Ethan Lee 3ac48053bc wayland: Minor whitespace cleanup
Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
2023-04-05 08:58:12 -04:00
David Edmundson 0c551e7069 wayland: Support axis relative direction
This allows clients to be aware of "natural scrolling" settings in the
compostior and adjust accordingly to optionally keep the same wheel and
trackpad behaviour accross platforms.

Testing using the "testmouse" example, behaviour in the demo is now the
same regardless of the compositor setting for scrolling.
2023-04-05 08:58:12 -04:00
Anonymous Maarten ac72cdcf79 Fix -Wmissing-prototypes warning
./src/video/SDL_video.c:1734:13: warning: no previous prototype for function 'SDL_CreateWindowInternal' [-Wmissing-prototypes]
SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int w, int h, SDL_Window *parent, Uint32 flags)
            ^
./src/video/SDL_video.c:1734:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int w, int h, SDL_Window *parent, Uint32 flags)
^
static
2023-04-05 05:39:48 +02:00
Sam Lantinga cf2c6fa58d Fixed crash if dbus can't be initialized 2023-04-04 12:34:00 -07:00
Sylvain 407b85c506 Android: audio change audio assert when try to open concurrent device to a real error 2023-04-04 09:43:01 +02:00
Frank Praznik a874f6c993 wayland: Send system timestamps for relative pointer events 2023-04-02 10:51:37 -04:00
Frank Praznik 1869e1247d wayland: Track the serial numbers for implicit grab events and use them when raising windows
Track the serial numbers of key events, mouse button presses, touch down events, tablet tool down events, and tablet button presses, and pass the serial, along with the seat, to the xdg-activation protocol when raising windows to increase the chances of it succeeding.
2023-04-02 10:51:37 -04:00
Frank Praznik 6119ac8bb4 wayland: Don't round trip when setting the initial minimized and maximized states during window creation
Don't perform a round trip when setting the minimized and maximized window states during initial window creation, as it will be done later in the window creation process.
2023-04-02 10:51:37 -04:00
Frank Praznik ab948123c2 wayland: Avoid recursive calls into fullscreen setting functions
When changing the fullscreen state and performing a roundtrip, more than one configure event can be sent before getting the event that changes the fullscreen state. Don't change the higher-level window state and avoid recursive calls back into the video system during these events.
2023-04-02 10:51:37 -04:00
Frank Praznik 1f177cf93e wayland: Refactor constraint handling
According to the xdg-shell spec, xdg-toplevel min/max values are just hints, which compositors are free to ignore, and they often do so in several cases (usually when tiling, maximizing, or entering fullscreen). Even with the hints set, manually constraining the surface dimensions for non-maximized, non-fullscreen surfaces is required for consistent behavior.

In the case of maximized windows, the dimensions as specified in the configure event are non-negotiable and must be respected by the client, as not doing so is a protocol violation.

This also eliminates some redundant calls to set the libdecor resizable state, which can cause unnecessary commits internally.
2023-04-02 10:51:37 -04:00
Sam Lantinga 2aa2fa5449 Added SDL_CreateWindowWithPosition()
It turns out there's a race condition on X11 where the window could be placed by the window manager while being placed by the application, so we need to have the initial position available at window creation.
2023-03-31 17:21:44 -07:00
Anonymous Maarten b6ae281e97 Use #ifdef/#ifndef instead of #if defined/#if \!defined 2023-03-30 21:35:01 +00:00
Sam Lantinga 308bcbbe76 Fixed Visual Studio warning 4244 2023-03-30 14:04:32 -07:00