Commit Graph

9103 Commits (19764ffcc811a498a508fe524a986455d25cf7e1)

Author SHA1 Message Date
Frank Praznik 19764ffcc8 wayland: Add the xdg-foreign-unstable-v2 protocol
Add the xdg-foreign-unstable-v2 protocol and use it to create export handles for toplevel windows, which will be used when an external component, such as the file chooser portal, requires it.
2024-03-15 18:30:05 -04:00
Ryan C. Gordon b7cda16613
iostream: Final fixes before merging.
- SDL_GetRWProperties -> SDL_GetIOProperties
- SDL_GetRWStatus -> SDL_GetIOStatus
- Some documentation corrections and improvements.
2024-03-15 15:37:03 -04:00
Ryan C. Gordon 5a21d87e69
rwops: Changed filenames that reference "rwops" to "iostream". 2024-03-14 23:30:59 -04:00
Ryan C. Gordon 6776b6108a
iostream: "free*" params should be "closeio". 2024-03-14 23:14:46 -04:00
Ryan C. Gordon 3a344cf877
rwops: Fixed some SDL2 symbols that got missed. 2024-03-14 21:57:21 -04:00
Ryan C. Gordon 5f64cc511e
rwops: Fixed build on Android. 2024-03-14 19:38:15 -04:00
Ryan C. Gordon fc7afa9cbf
rwops: Renamed SDL_RWops to SDL_IOStream, and other related symbols. 2024-03-14 19:38:12 -04:00
Ryan C. Gordon fe33b2a81b
rwops: Give implementations access to status value. 2024-03-14 19:37:07 -04:00
Ryan C. Gordon cc58da4c63
rwops: Add SDL_GetRWStatus, make the statuses into an enum. 2024-03-14 19:37:06 -04:00
Ryan C. Gordon e35c304022
rwops: Add properties for some of the internal implementation details. 2024-03-14 19:37:05 -04:00
Ryan C. Gordon 7d4d8ccde0
rwops: Rename everything from SDL_RWxxx to SDL_XxxRW. 2024-03-14 19:37:04 -04:00
Ryan C. Gordon 655ceb3b31
rwops: Renamed SDL_CreateRW and SDL_DestroyRW to SDL_OpenRW and SDL_CloseRW. 2024-03-14 19:37:01 -04:00
Ryan C. Gordon 525919b315
rwops: Reworked RWops for SDL3.
- SDL_RWops is now an opaque struct.
- SDL_AllocRW is gone. If an app is creating a custom RWops, they pass the
  function pointers to SDL_CreateRW(), which are stored internally.
- SDL_RWclose is gone, there is only SDL_DestroyRW(), which calls the
  implementation's `->close` method before freeing other things.
- There is only one path to create and use RWops now, so we don't have to
  worry about whether `->close` will call SDL_DestroyRW, or if this will
  risk any Properties not being released, etc.
- SDL_RWFrom* still works as expected, for getting a RWops without having
  to supply your own implementation. Objects from these functions are also
  destroyed with SDL_DestroyRW.
- Lots of other cleanup and SDL3ization of the library code.
2024-03-14 19:36:08 -04:00
Semphris 70c2e15615 Add file dialogs 2024-03-14 15:40:25 -07:00
Sam Lantinga 30e93b40c2 If a mapping specifies a crc, don't match for controllers that don't have that CRC
The CRC is used to distinguish between different controllers that have the same VID/PID, so if the CRC doesn't match, it's probably a different controller that we don't know about.

Fixes https://github.com/libsdl-org/SDL/issues/9265
2024-03-14 13:26:56 -07:00
Frank Praznik 717f297849 Add 'wl_list_for_each_safe' to the clang-format macro list
...and fix the formatting when it is used.
2024-03-14 10:22:23 -04:00
Frank Praznik 4686a737a9 wayland: Minor cursor code cleanup
Clean up variable declarations and fix some formatting issues.
2024-03-13 12:39:00 -04:00
Dimitriy Ryazantcev 1973edb9b7 WIN_UpdateKeymap: cleanup code a bit 2024-03-13 09:09:59 -07:00
Anthony 0a86f8eb6e
Move some code blocks inside `SDL_VIDEO_RENDER_SW`, where it belongs (#9259)
There was some software renderer specific code that can be excluded with SDL_LEAN_AND_MEAN. This contributes towards #9206
2024-03-12 21:15:46 -07:00
Frank Praznik c2e9693de5 wayland: Add cursor-shape-v1 protocol support 2024-03-12 20:54:55 -04:00
Frank Praznik 9bdb992925 wayland: Allocate the cursor shared memory buffer entirely in memory, if possible.
Use memfd_create() to allocate the temporary SHM backing file in memory, and set the size with posix_fallocate(), which will return an error on insufficient space vs ftruncate(), which will silently succeed and allow a SIGBUS error to occur if the unbacked memory is accessed.

Additionally, make the legacy path more robust by unlinking the temp file, so it won't persist after close, and unmapping the shared memory buffer.
2024-03-12 20:54:55 -04:00
Sam Lantinga d79f865251 Removed incorrect mapping for a HORI controller
This broke support for the Hori Fighting Stick EX2, which gets a good mapping if the automatic mapping is allowed to create one.

If the original controller needs a mapping, it should be added with a crc, since that VID/PID combination is used by several HORI controllers.
2024-03-11 17:11:20 -07:00
Anonymous Maarten bee8a95571 Fix SDL_LEAN_AND_MEAN build 2024-03-11 13:46:16 -07:00
Sam Lantinga d4794cc714 Fix crash in SDL_UpdateFullscreenMode calling SetWindowFullscreen with a null display
- This mirrors the check above for fullscreen=true in the unlikely case where there is no primary display detected
2024-03-11 11:17:45 -07:00
Sam Lantinga ab5351f5d6 Fixed leaving the cursor clip set when changing window focus
While the focus change happens, Windows appears to reset the cursor clip rectangle, and then restore it if the application that has focus has the clip rectangle set.

This fixes resetting the clip rectangle while changing focus between windows in the same application, e.g. the Source 2 editor.
2024-03-11 10:58:40 -07:00
Sam Lantinga efbbafb3f1 Re-added balls to the SDL joystick API
It turns out these were being used on Linux and at least one virtual driver was making use of them (thanks @mrfixit2001!)
2024-03-10 21:30:14 -07:00
Sam Lantinga 53e86be22f Minor cleanup with the new PS3 driver for windows 2024-03-10 20:12:11 -07:00
Riccardo Marcangelo 6534029691
Add DualShock 3 HIDAPI support on Windows (#9144)
This adds HIDAPI support for DualShock 3 controllers on Windows, addressing the current absence of this feature in SDL. To utilize this functionality, the official Sony driver 'sixaxis.sys' must be installed. HID offers several advantages over DirectInput, including rumble support and the ability to control the LED lights that display the controller number.
2024-03-10 20:08:36 -07:00
r4nx feadbffb67 Destroy properties after applying them to avoid memory leakage 2024-03-10 18:16:40 -07:00
Sam Lantinga e3cf2e4794 Turn HIDAPI joystick support off by default on mobile platforms
On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers.

Fixes https://github.com/libsdl-org/SDL/issues/9241
2024-03-10 15:00:49 -07:00
Sam Lantinga ed463b41e1 Unified the software renderer creation path
Previously there were two different paths for renderer creation, and the HDR metadata initialization was missing when creating a software renderer for a surface. Now all the cases are handled in a single path, so regardless of whether you create a software renderer by name, a software renderer for a surface, or fall back to a software renderer, you'll get the correct initialization in all cases.

Fixes https://github.com/libsdl-org/SDL/issues/9221
2024-03-10 11:05:26 -07:00
Anonymous Maarten 3bc27d3856 hidapi_libusb: use SDL_wcscmp and SDL_wcslcpy from SDL 2024-03-10 09:07:33 -07:00
Green Sky 4de30a26a2 x11: workaround issues with primary selection and clipboard temporal ignorance 2024-03-10 08:59:44 -07:00
Simon McVittie 76defc5c82 joystick: Remove redundant CHECK_JOYSTICK_MAGIC in SDL_GetJoystickName
Since commit 0dfdf1f3 "Fixed crash if joystick functions are passed a
NULL joystick", we've already done this check by the time we get to
this point.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-03-09 08:40:04 -08:00
Sam Lantinga 16e0806ced Note that the cursor clip has been cleared even if we didn't do it
This releases the mouse cursor when bringing up the console on Counter Strike in dev mode.
2024-03-08 15:56:49 -08:00
Mingjie Shen 19b3ddac2f Fix TOCTOU race condition
Separately checking the state of a file before operating on it may allow
an attacker to modify the file between the two operations. (CWE-367)
Fix by using fstat() instead of stat().
2024-03-08 15:52:04 -08:00
Sam Lantinga cde793b0f5 Added support for the 6-button SEGA Mega Drive Control Pad for Nintendo Online
Closes https://github.com/libsdl-org/SDL/pull/9225
2024-03-08 12:33:54 -08:00
Sam Lantinga 790cd395f5 Make sure the type in the SDL_Event aligns properly across the union 2024-03-07 06:58:43 -08:00
Sam Lantinga e9ab2d46de Revert "Change `SDL_Keycode` type to an enum"
SDL_Keycode can actually be any printable character on the keyboard, so isn't limited to the enumerated values of SDL_KeyCode.
2024-03-07 06:58:43 -08:00
Sam Lantinga 33eaddc565 Cleaned up various type conversion issues
This makes sure SDL_PixelFormatEnum flows through the internal code correctly, as well as fixing a number of other minor issues.
2024-03-07 06:58:43 -08:00
Sam Lantinga 57a160c9ab Fixed mapping for the Sanwa Supply JY-P76USV controller 2024-03-06 20:53:48 -08:00
Sam Lantinga c70710cde8 SDL_GetPixelFormatEnumForMasks() returns SDL_PixelFormatEnum 2024-03-06 16:19:08 -08:00
Susko3 01248a99c8 Add `default: break;` to switches on SDL_Event::type
This is just a nice-to-have, as `SDL_Event::type` in an `Uint32`, so there are no
compiler errors about not handling all `SDL_EventType` enum values.
2024-03-06 15:40:05 -08:00
Susko3 722f4104bf Use enums as types in SDL_*Event structures
The main `SDL_Event` union is not using the enum as
valid user events types are not in the enum.
2024-03-06 15:40:05 -08:00
Susko3 641b911d38 Update some internal files to use `SDL_WindowFlags` 2024-03-06 15:08:12 -08:00
Susko3 ce44eff3d2 Use `SDL_WindowFlags` in public headers 2024-03-06 15:08:12 -08:00
Susko3 424616e032 Use SDL_PixelFormatEnum as type 2024-03-06 15:02:13 -08:00
Sam Lantinga 38c54b8e0e More null checks for SDL window operations 2024-03-06 13:33:30 -08:00
Sam Lantinga 6664a089d8 Add missing null check for displaydata during window creation
Found in the wild from minidump reports. Unclear displaydata is null, but according
to the API it is possible for this call to return null so it seems like a valid check.
2024-03-06 13:33:27 -08:00
Sam Lantinga 610e798406 Fix clicking on the titlebar causing mouse input to freeze until esc is pressed
When the titlebar drage region is clicked two actions are triggered:
  * The WM transfers focus to the application
  * The application starts a drag operation because the drag region was clicked

When the drag operation starts before input has been transferred to the application the
window manager gets in a bad state where mouse clicks don't work and the system isn't
actually dragging.

In this CL we delay drag operations until after the application has acquired active focus.
This fixes the problems outlined above.
2024-03-06 13:33:23 -08:00