Commit Graph

9260 Commits

Author SHA1 Message Date
Ryan C. Gordon
ad090d2444 include: A ton of little documentation tweaks, fixes, and improvements.
This is just stuff I noticed while working on the wikiheaders updates. A
thorough pass over all the docs would not be terrible, and maybe a simple
script to check for consistency (does everything have a `\since` on it? etc)
might be nice, too.
2024-04-09 00:50:02 -04:00
Ryan C. Gordon
6906c50e8b assert: SDL_AssertData::always_ignore should be an SDL_bool, not an int. 2024-04-09 00:50:01 -04:00
Petar Popovic
c8a066019b Renaming SDL_eventaction to SDL_EventAction 2024-04-08 14:28:52 -04:00
Petar Popovic
1efadcc5d4 Revert renaming SDL_eventaction. adding it again in next commit with
scripts

This reverts commit f08c31060a.
2024-04-08 14:28:52 -04:00
Frank Praznik
224f2e921e video: Remove unused bootstrap declarations
Pandora and KMSDRM_Legacy are not used anywhere.
2024-04-08 11:07:05 -04:00
Petar Popovic
764fe72449 SDL_time.h: Renaming enums SDL_DATE_FORMAT and SDL_TIME_FORMAT to SDL_DateFormat and SDL_TimeFormat 2024-04-07 23:03:01 -04:00
Petar Popovic
f08c31060a Renaming SDL_eventaction to SDL_EventAction 2024-04-07 12:04:32 -04:00
Semphris
6ad390fc50 File dialog improvements
- Add a globally-accessible function to handle the parsing of filter extensions
- Remove the ability of putting the wildcard ('*') among other patterns; it's either a list of patterns or a single '*' now
- Add a hint to select between portals and Zenity on Unix
2024-04-04 22:07:14 -07:00
Sam Lantinga
5fa87e29e7 Removed SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE
These flags are unnecessary and have always been a source of confusion.
2024-04-04 13:30:49 -07:00
Ryan C. Gordon
ff651a7941 filesystem: Turn off case-insensitivity if glob pattern is NULL.
Just a small optimization; it'll avoid some allocations and case-folding we
don't actually need the results of later.
2024-04-04 10:44:19 -04:00
Sam Lantinga
0abdc1a343 Renamed GLOBDIR to GLOB 2024-04-04 07:40:48 -07:00
Ryan C. Gordon
764207d873 filesystem: Added SDL_GlobDirectory() and SDL_GlobStorageDirectory().
Fixes #9287.
2024-04-04 09:40:13 -04:00
Ryan C. Gordon
810656962c stdlib: Export some Unicode functions to other SDL internals. 2024-04-04 09:40:13 -04:00
Ryan C. Gordon
9192485746 filesystem: SDL_EnumerateDirectory should return -1 or 0.
The callback requesting a non-error stop should not return a special value.
2024-04-04 09:40:13 -04:00
Sam Lantinga
a8ed32c5f7 Re-enable cursor clipping when clicking into a window when relative mouse mode is enabled 2024-04-03 12:41:19 -07:00
Frank Praznik
2d9aff6433 wayland: Always use the whole buffer surface for the damage region
Using the current window size at the time of the call may not be correct if the window or buffer size was changed after the fact, so always set the damage region to cover the entire buffer.
2024-04-03 11:07:08 -04:00
Clownacy
65e7c8e265 Fix default Windows window icon not suiting the DPI.
For whatever reason, `ExtractIconEx` returns icons whose sizes are
inappropriate for the current DPI, resulting in terribly-blurry
window icons at higher DPIs.

To solve this, the window icon is now set to the first icon group
that is present in the executable. This behaviour should match what
Explorer does. By selecting an icon group instead of a specific icon,
Windows is free to select the icon within the group that best suits
the current DPI.

(cherry picked from commit 1fa6142903)
2024-04-02 12:04:52 -07:00
Anonymous Maarten
143b070074 cpuinfo: fix -Wmissing-prototypes warning 2024-04-02 18:57:36 +02:00
Ryan C. Gordon
58529c1827 stdlib: SDL_utf8strlen and SDL_utf8strnlen now use SDL_StepUTF8 internally.
Otherwise, they might find out strings with malformed UTF-8 sequences produce
a different amount of codepoints than the count returned here, overflowing
buffers that might be allocated based on the results.
2024-04-01 22:43:19 -04:00
Sam Lantinga
17d4f8d699 Updated to version 3.1.1 for the preview release 2024-04-01 17:03:46 -07:00
Brian Collins
560daa07f2 Workaround a macOS cursor-related bug.
This fixes an macOS bug that is only known to occur in fullscreen windows on the built-in displays of newer MacBooks with camera notches. When the mouse is moved near the top of such a window (within about 44 units) and then moved back down, the cursor rects aren't respected. This can cause the default cursor to be visible when it should not be.

(cherry picked from commit f1690e265e)
2024-04-01 16:21:24 -07:00
Sam Lantinga
a82ed82bc7 SDL_QueryTexture() fills in a pointer to SDL_PixelFormatEnum 2024-04-01 15:45:22 -07:00
Sam Lantinga
aea44cff6b Fixed warning C4702: unreachable code 2024-04-01 14:30:11 -07:00
Sam Lantinga
85b7f131b0 Fixed warning C4701: potentially uninitialized local variable 'percent' used 2024-04-01 14:27:19 -07:00
Sam Lantinga
8847b35244 Separate joystick power state into battery status and percentage
This allows you to see battery percentage while the controller is charging
2024-04-01 13:59:00 -07:00
Frank Praznik
a00ac61514 time: Fix UWP build 2024-04-01 10:53:35 -04:00
danginsburg
650ba8f3ec Vulkan Renderer - closes #9385. When the vertex buffer size is exceeded, make sure to wait for outstanding work before resizing it. This fixes validation errors/crash found with using Imgui SDL3 renderer on Vulkan. 2024-04-01 07:38:31 -07:00
Sean Ridenour
feebb9fcf8 Fix file selection dialog boxes not working on macOS 11.0+ 2024-04-01 07:38:05 -07:00
Frank Praznik
c0bfd8bafd time: Only call GetSystemTimePreciseAsFileTime if available
GetSystemTimePreciseAsFileTime is only available on Win8/Server 2012 or higher, so it must be dynamically loaded and only used if available.  Fixes compatability with Win7 and XP.
2024-04-01 10:23:02 -04:00
Sam Huang
a9cab01185 Don't change cwd with file dialogs 2024-03-31 12:50:29 -07:00
Sam Lantinga
fbbee04423 Revert "Only clear the raw input queue status if we don't call GetRawInputBuffer()"
This reverts commit 02c63667c7.

It turns out that QS_RAWINPUT isn't actually cleared by GetRawInputBuffer(). See https://github.com/libsdl-org/SDL/issues/9409 for more details.
2024-03-31 12:44:13 -07:00
Mathieu Eyraud
4d00706f57 Do not store pointer before potentialy freeing it
Store data to windows->driverdata after call to SetProp() in case it fails.
2024-03-30 11:07:42 -07:00
Mathieu Eyraud
36dec0bf4e Fix return value of WIN_GetMonitorPathInfo 2024-03-30 11:04:32 -07:00
Sam Lantinga
8201b6dc4d Added support for raw mousewheel events 2024-03-30 07:38:38 -07:00
Sam Lantinga
4a00d34a86 Always send raw mouse button state changes
Fixes https://github.com/libsdl-org/SDL/issues/9395
2024-03-30 07:30:43 -07:00
Semphris
335fa5d6e4 Disable SDL dialogs for tvOS and iOS 2024-03-29 23:13:15 -07:00
Ryan C. Gordon
a5c892d2c3 stdlib: Improve Unicode support and consistency in string comparison functions.
SDL_strcasecmp (even when calling into a C runtime) does not work with
Unicode chars, and depending on the user's locale, might not work with
even basic ASCII strings.

This implements the function from scratch, using "case-folding,"
which is a more robust method that deals with various languages. It
involves a hashtable of a few hundred codepoints that are "uppercase" and
how to map them to lowercase equivalents (possibly increasing the size of
the string in the process). The vast majority of human languages (and
Unicode) do not have letters with different cases, but still, this static
table takes about 10 kilobytes on a 64-bit machine.

Even this will fail in one known case: the Turkish 'i' folds differently
if you're writing in Turkish vs other languages. Generally this is seen as
unfortunate collateral damage in cases where you can't specify the language
in use.

In addition to case-folding the codepoints, the new functions also know how
to decode the various formats to turn them into codepoints in the first
place, instead of blindly stepping by one byte (or one wchar_t) per
character.

Also included is casefolding.txt from the Unicode Consortium and a perl
script to generate the hashtable from that text file, so we can trivially
update this if new languages are added in the future.

A simple test using the new function:

```c
 #include <SDL3/SDL.h>

 int main(void)
 {
     const char *a = "α ε η";
     const char *b = "Α Ε Η";
     SDL_Log("    strcasecmp(\"%s\", \"%s\") == %d\n", a, b, strcasecmp(a, b));
     SDL_Log("SDL_strcasecmp(\"%s\", \"%s\") == %d\n", a, b, SDL_strcasecmp(a, b));
     return 0;
 }
```

Produces:

```
INFO:     strcasecmp("α ε η", "Α Ε Η") == 32
INFO: SDL_strcasecmp("α ε η", "Α Ε Η") == 0
```

glibc strcasecmp() fails to compare a Greek lowercase string to its uppercase
equivalent, even with a UTF-8 locale, but SDL_strcasecmp() works.

Other SDL_stdinc.h functions are changed to be more consistent, which is to
say they now ignore any C runtime and often dictate that only English-based
low-ASCII works with them.

Fixes Issue #9313.
2024-03-29 15:01:40 -04:00
Ryan C. Gordon
4659a84bd1 coreaudio: fix race condition when closing an input device. 2024-03-29 00:55:38 -04:00
Ryan C. Gordon
2fd9447670 coreaudio: Make sure device handles are unique.
AudioDeviceID is not unique (hardware that can do both capture and output
will expose both interfaces off the same AudioDeviceID!).
2024-03-28 21:45:00 -07:00
Sam Lantinga
87235e0f6d Fixed detecting CoreAudio devices that have both capture and output endpoints 2024-03-28 18:35:42 -07:00
Sam Lantinga
af5728b94d Fixed event handle accumulation when the SDL window doesn't have focus
This also fixes a crash on shutdown caused by the raw input thread failing to stop
2024-03-28 15:11:45 -07:00
Christoph Reichenbach
6d37f4798e SDL_pen.c: release pen mutex on error return 2024-03-28 20:37:54 +00:00
Susko3
d785a647a4 Fix 'SyntaxWarning: invalid escape sequence' when running gendynapi.py 2024-03-28 13:21:26 -07:00
Sam Lantinga
47378eddf6 Fixed error: ordered comparison of pointer with integer zero 2024-03-28 09:34:48 -07:00
Sam Lantinga
fc81d4e5fc Fixed 64-bit conversion warnings 2024-03-28 09:12:26 -07:00
Sam Lantinga
c8489a3710 Disable XInput2 keyboard events
It turns out they're only delivered to the window with mouse focus, not keyboard focus.

Fixes https://github.com/libsdl-org/SDL/issues/9374
2024-03-28 08:50:47 -07:00
danginsburg
fb5307c1b3 Vulkan Renderer - fix synchronization validation issues with testrendertarget and testcopyex. When a texture is destroyed, VULKAN_IssueBatch is called to make sure the texture isn't referenced in any outstanding command work. This path did not wait on the semaphore from vkAcquireNextImageKHR, which would create a hazard. 2024-03-28 07:37:49 -07:00
Ryan C. Gordon
d00ccc1546 audio: Fix audio stream incorrectly not unlocking during unbind.
(This patch was from @0x1F9F1, thanks!)

Fixes #9379.
2024-03-27 17:36:26 -04:00
Ryan C. Gordon
38e3c6a4aa main: Add an optional appstate param to main callback entry points.
This allows apps to maintain state data without using global variables.

Fixes #9377.
2024-03-27 17:22:08 -04:00
Sam Lantinga
02c63667c7 Only clear the raw input queue status if we don't call GetRawInputBuffer()
GetRawInputBuffer() will do that for us when we read all the queued events
2024-03-26 15:27:57 -07:00