Commit Graph

14327 Commits (c88c12148d8d795c33f469764033a44a5a115fb6)

Author SHA1 Message Date
Sam Lantinga 4d5949dcf6 Added a controller name for the Steam virtual gamepad 2023-12-17 10:07:46 -08:00
Sam Lantinga 695846f2ed Pass through the name of the controller for the XInput mapping 2023-12-17 09:33:53 -08:00
Frank Praznik 1745289b1b x11: Don't move the window when restoring and ensure that resize and position events are sent when entering or leaving fullscreen
Account for the border sizes when restoring the window and only turn off resize events when entering or leaving fullscreen until the frame extents are changed, and only if they are, or previously were, non-zero.

This necessitated further refinement to the sync algorithm as well, but as a result, the sync function no longer occasionally times out if creating a window and immediately recreating it when initializing a renderer, and some rare, spurious size and position failures in the centered window and state automated tests seem to be fixed.
2023-12-17 11:39:49 -05:00
Dimitriy Ryazantcev 08a7ca4d53 XInput: Use XInputGetCapabilitiesEx instead of fragile GuessXInputDevice
XInputGetCapabilitiesEx (ordinal 108) is available in XInput 1.4 that is shipped with Windows 8 and newer.
2023-12-17 08:32:10 -08:00
Sam Lantinga 7f75178908 Verify that the %p format specifier works for 64-bit pointers 2023-12-17 08:14:20 -08:00
Sam Lantinga 72b7acfe8a Don't create a TLS error buffer if we're just clearing the error
Fixes https://github.com/libsdl-org/SDL/issues/7600
2023-12-16 21:28:43 -08:00
Matt Guerrette 240e7747c8 Fix #8702: Add SDL_hidapi_steamdeck.c to Xcode target
This commit fixes a linker issue when building SDL 3.0 using Xcode
2023-12-16 20:25:33 -08:00
Frank Praznik b937c54b66 win32: Set all size and position variables for external windows 2023-12-15 16:41:20 -05:00
Sam Lantinga 8c285828e5 Fixed return value for SDL_UDEV_AddCallback()
Fixes https://github.com/libsdl-org/SDL/issues/8694
2023-12-15 10:06:01 -08:00
Sam Lantinga cbf9012c74 Fixed build 2023-12-15 10:03:11 -08:00
Sam Lantinga 5547007915 Added test for inverted cursor 2023-12-15 09:59:50 -08:00
Dimitriy Ryazantcev 0ab13f2498 joystick: fixup for Wireless Xbox 360 Controller VID/PID detection in WGI backend.
It turns out that returned PID is zero in this case and it breaks SDL_IsXInputDevice/HIDAPI_IsDevicePresent checks
2023-12-15 08:57:09 -08:00
Dimitriy Ryazantcev 627d134b9e Add support for monochrome cursors with inverted pixels under Windows.
Fixes #8157
2023-12-15 08:56:17 -08:00
Frank Praznik 21879faf48 wayland: Handle mouse focus when receiving touch events
Compositors may switch from mouse to touch mode when a touch event is received, causing a pointer leave event and subsequent loss of mouse focus.

Don't relinquish mouse focus on surfaces with active touch events. If there are active touch events when pointer focus is lost, the keyboard focus is used as a fallback for relinquishing mouse focus: if, in this case, the keyboard focus is then lost and there are no active touches, mouse focus is lost, and if all touches are raised and there is no keyboard or pointer focus, then the window loses mouse focus.
2023-12-14 14:17:33 -05:00
Sam Lantinga 58a5f5cbe8 Allow sendCommand() to be overridden by derived classes
In this case it's used to prevent switching to windowed mode when destroying and recreating the main window
2023-12-13 10:13:17 -08:00
Sam Lantinga e6d8ef1a5b Revert "Back out Steam virtual gamepad changes"
This reverts commit 34eb24ebc4.
2023-12-13 09:45:39 -08:00
Sam Lantinga b0e7b7db6f Don't unload graphics libraries until after the window has been destroyed.
This fixes creating a window after the first window has been destroyed on Android. The graphics library had been unloaded, so eglDestroySurface() wasn't called, leaving a surface attached to the window, which would prevent attaching new EGL surfaces to the window (eglCreateWindowSurface() would fail with BAD_ALLOC)
2023-12-12 23:17:41 -08:00
Max Maisel 69288038ed Refactor away some additional integer types. 2023-12-12 12:51:37 -08:00
Max Maisel f3048e3cd2 Add new file to vcxproj files. 2023-12-12 12:51:37 -08:00
Max Maisel 5a21febecb Add new steam deck HIDAPI controller to controller database. 2023-12-12 12:51:37 -08:00
Max Maisel 67d44c1017 Disable lizard mode while steam deck HID device is opened. 2023-12-12 12:51:37 -08:00
Max Maisel 6dd6827343 Translate steam deck HID reports to SDL events. 2023-12-12 12:51:37 -08:00
Max Maisel 94f621e030 Implement steam deck HIDAPI initialization. 2023-12-12 12:51:37 -08:00
Max Maisel c1a7d0f96e Add steam deck detection and HIDAPI driver scaffold. 2023-12-12 12:51:37 -08:00
Sam Lantinga 0baee3e676 Reversed test to be easier to read, more efficient, and match other code 2023-12-12 12:25:51 -08:00
Frank Praznik bddbd1e317 cocoa: Check the resizable flag along with zoomed status when resizing
isZoomed always returns true if the window is not resizable, so the resizable flag needs to be checked as well.
2023-12-12 14:35:49 -05:00
Frank Praznik 835c733f4d video: Only sync when programmatically entering/exiting fullscreen
Otherwise, the sync function can be recursively entered when the fullscreen state is updated by a window manager event.
2023-12-12 12:58:05 -05:00
Dimitriy Ryazantcev c790572674 Use existing XUSB driver software PID 0x02a1 instead of PID 0x02fe
0x02fe is actually PID of Xbox Wireless Adapter for Windows 10 (Model 1790) and creates confusion.

Here is USB descriptor dump: https://github.com/DJm00n/ControllersInfo/blob/master/xboxone/DescriptorDump_Adapter%20(Xbox%20Wireless%20Adapter%20for%20Windows).txt
2023-12-11 11:45:05 -08:00
Sam Lantinga 581d1cab25 You should call present when using a software renderer as well.
Fixes https://github.com/libsdl-org/SDL/issues/8676
2023-12-11 08:43:31 -08:00
Sam Lantinga 5173b0c2cc Make built-in joystick device lists extendable by using hints
Fixes https://github.com/libsdl-org/SDL/issues/8595
2023-12-10 12:53:03 -08:00
Sam Lantinga 34eb24ebc4 Back out Steam virtual gamepad changes
We are planning a different approach to handle these
2023-12-10 08:35:35 -08:00
Sam Lantinga 7529d25b2b Use the Steam virtual gamepad slot as the gamepad player index 2023-12-09 21:00:32 -08:00
Sam Lantinga 445f08a0fb Print the gamepad player index when opening a gamepad 2023-12-09 21:00:11 -08:00
Sam Lantinga 17723381da Sort Steam virtual gamepads by Steam controller slot
This makes sure that games launched by Steam see the first controller first, and the controllers in the game match up with the controllers in the Steam UI.

Fixes https://github.com/libsdl-org/SDL/issues/8672
2023-12-09 20:33:05 -08:00
Ryan C. Gordon f3d8a2def5
audio: Fixed resource leak in unlikely failure case during device add. 2023-12-09 15:41:45 -05:00
Frank Praznik 63ae84e140 x11: Improve sync algorithm
Track and check move and resize requests separately, and consider them done if either the window is already at the expected location, or at least one configure event which moved or resized the window was processed. The avoids a timeout condition if resizing the window caused it to be implicitly moved in order to keep it within desktop bounds.

The automated positioning test now runs on GNOME/X11 without any sync requests timing out.
2023-12-08 13:14:55 -05:00
Frank Praznik 7e5511d3cd x11: Move unrelated variables out of XFixes #ifdef 2023-12-08 05:16:49 -05:00
Sam Lantinga 3c5e9e6112 We can wait up to 500ms in onNativeSurfaceDestroyed(), so wait at least that long in onDestroy() 2023-12-07 14:30:44 -08:00
Sam Lantinga 53cda988f4 Clear any errors from a previous run
The error is thread-local, and the java thread may run onCreate initialization multiple times depending on the Android life cycle
2023-12-07 14:30:40 -08:00
Anonymous Maarten a197efe3a7 pen: fix leak caused by pen subsystem 2023-12-07 20:38:00 +01:00
Anonymous Maarten fbb0914b78 wayland+x11: free system cursors when quiting video 2023-12-07 20:38:00 +01:00
Anonymous Maarten 7484d02a2e testshape: use SDL_test to create multiple windows 2023-12-07 20:38:00 +01:00
SDL Wiki Bot 20250aecc5 Sync SDL3 wiki -> header 2023-12-07 18:27:25 +00:00
Frank Praznik 4fd778119b video: Implement asynchronous windowing
SDL window size, state, and position functions have been considered immediate, with their effects assuming to have taken effect upon successful return of the function. However, several windowing systems handle these requests asynchronously, resulting in the functions blocking until the changes have taken effect, potentially for long periods of time. Additionally, some windowing systems treat these as requests, and can potentially deny or fulfill the request in a manner differently than the application expects, such as not allowing a window to be positioned or sized beyond desktop borders, prohibiting fullscreen, and so on.

With these changes, applications can make requests of the window manager that do not block, with the understanding that an associated event will be sent if the request is fulfilled. Currently, size, position, maximize, minimize, and fullscreen calls are handled as asynchronous requests, with events being returned if the request is honored. If the application requires that the change take effect immediately, it can call the new SDL_SyncWindow function, which will attempt to block until the request is fulfilled, or some arbitrary timeout period elapses, the duration of which depends not only on the windowing system, but on the operation requested as well (e.g. a 100ms timeout is fine for most X11 events, but maximizing a window can take considerably longer for some reason). There is also a new hint 'SDL_VIDEO_SYNC_ALL_WINDOW_OPS' that will mimic the old behavior by synchronizing after every window operation with, again, the understanding that using this may result in the associated calls blocking for a relatively long period.

The deferred model also results in the window size and position getters not reporting false coordinates anymore, as they only forward what the window manager reports vs allowing applications to set arbitrary values, and fullscreen enter/leave events that were initiated via the window manager update the window state appropriately, where they didn't before.

Care was taken to ensure that order of operations is maintained, and that requests are not ignored or dropped. This does require some implicit internal synchronization in the various backends if many requests are made in a short period, as some state and behavior depends on other bits of state that need to be known at that particular point in time, but this isn't something that typical applications will hit, unless they are sending a lot of window state in a short time as the tests do.

The automated tests developed to test the previous behavior also resulted in previously undefined behavior being defined and normalized across platforms, particularly when it comes to the sizing and positioning of windows when they are in a fixed-size state, such as maximized or fullscreen. Size and position requests made when the window is not in a movable or resizable state will be deferred until it can be applied, so no requests are lost. These changes fix another long-standing issue with renderers recreating maximized windows, where the original non-maximized size was lost, resulting in the window being restored to the wrong size. All automated video tests pass across all platforms.

Overall, the "make a request/get an event" model better reflects how most windowing systems work, and some backends avoid spending significant time blocking while waiting for operations to complete.
2023-12-07 10:26:19 -08:00
Sam Lantinga ace385a134 Revert "Fixed warning C33010: Unchecked lower bound for enum scancode used as index."
This reverts commit c484140f56.

Fixes clang warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
2023-12-06 09:17:47 -08:00
Ozkan Sezer e482f00a17 SDL_string.c (SDL_vsscanf): fix gcc build 2023-12-06 01:32:00 +03:00
Sam Lantinga f00ecf5f19 Fixed building with older Windows SDK 2023-12-05 11:00:18 -08:00
Sam Lantinga 7ca43995a1 Fixed warning C4028: formal parameter 1 different from declaration 2023-12-05 10:55:29 -08:00
Sam Lantinga aab7432f5f Fixed analyze warnings for SDL_dynapi_procs.h 2023-12-05 09:31:13 -08:00
Sam Lantinga c484140f56 Fixed warning C33010: Unchecked lower bound for enum scancode used as index. 2023-12-05 09:31:13 -08:00