Commit Graph

1801 Commits

Author SHA1 Message Date
Sam Lantinga f18e023317 Added testclipboard 2024-12-31 19:27:11 -08:00
Sam Lantinga 1c04ebe423 Renamed SDL_ASYNCIO_CANCELLED to SDL_ASYNCIO_CANCELED 2024-12-30 19:13:02 -08:00
Anonymous Maarten 543f244965 tests: include SDL_build_config.h when HAVE_BUILD_CONFIG is defined 2024-12-29 20:08:06 +01:00
Ozkan Sezer c2121dd9a2 testcamera: fix MSVC build failure due to C4244 warning. 2024-12-29 21:28:02 +03:00
Sam Lantinga 5c84d38822 testcamera: don't pick a frame size larger than the maximum texture size
Ran into this on a Huawei Y6 phone, where the back facing camera can generate 4160x2000 frames, but the maximum texture size was 4096x4096
2024-12-29 09:41:00 -08:00
Anonymous Maarten f1232de3d2 cmake: add_dependencies must have at least 2 arguments 2024-12-28 02:43:12 +01:00
Anonymous Maarten 2664d36faf cmake: avoid parallel generation of headers through intermediate target
See
https://cmake.org/cmake/help/latest/command/add_custom_command.html#example-generating-files-for-multiple-targets
2024-12-28 02:39:12 +01:00
Sam Lantinga 75a24116b5 testcontroller: show gamepad connection state 2024-12-27 13:58:49 -08:00
Semphris 0461180e25 SDL_EVENT_QUIT when no window nor tray
SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE will not fire if there are active tray icons. This impacts only applications that create tray icons, and that at least one icon outlives the last visible top-level window. SDL_EVENT_QUIT will fire when the last active tray is destroyed if there are no active windows.
2024-12-27 09:22:27 -08:00
Sam Lantinga 948b16533c testcamera: use the first available cameras 2024-12-26 19:23:43 -08:00
Semphriss 01b9b0edb7
Add system tray support (#10873) 2024-12-24 10:36:39 -08:00
capehill 80c1b1e1a0 Fix testautomation pixels_saveLoadBMP big endian issue
It seems created surfaces are ARGB8888 format on both BE and LE,
therefore BGRA32 failed.
2024-12-22 12:08:54 -08:00
Sam Lantinga cadeec9cc9 SDL_SoftStretch() doesn't handle large pixel formats
Fixes https://github.com/libsdl-org/SDL/issues/11534
2024-12-21 09:19:03 -08:00
Sam Lantinga f37eef948c Removed raw mouse events
It's too close the 3.2.0 release for an API change like this.

If/when we re-add these, some things for consideration:
* What use cases does this enable that aren't currently possible?
* What cross-platform API guarantees do we make about the availability of these events? e.g. do we try to simulate them where raw input isn't actually available?
* How is this different from the existing relative mode, and how do we clearly explain when you want these events vs wanting relative mode?

Notes from @expikr:
First observation: the reason I originally passed denominators instead of multipliers was because some rational values cannot be exactly represented by floats (e.g 1/120) so instead let the end-developer decide how to do the dividing themselves. It was the reason why it was using split values with an integer numerator to begin with, instead of having both as floats or even just normalize it in advance.

On the other hand, passing them as multipliers might have hypothetical uses for dynamically passing end-user controlled scaling in a transparent manner without coupling? (Though in that case why not just do that as additional fields appended to `motion` structs in an API-compatible layout?)

So it’s somewhat of a philosophical judgement of what this API of optional availability do we intend for it to present itself as:
- should it be a bit-perfect escape hatch with the absolute minimally-denominal abstraction over platform details just enough to be able to serve the full information (á la HIDPIAPI),
- or a renewed ergonomic API for splitting relative motion from cursor motion (in light of The Great Warping Purge) so that it is unburdened by legacy RelativeMode state machines, in which case it would be more appropriate to just call it `RELATIVE` instead of `RAW` and should be added alongside another new event purely for cursor events?

This alternate API stream was conceived in the context of preserving compatibility of the existing RelativeMode state machine by adding an escape hatch. So given the same context, my taste leans towards the former designation.

However, as The Great Warping Purge has made it potentially viable to do so, if I were allowed to break ABI by nuking the RelativeMode state machine entirely, I would prefer the latter designation unified as one of three separate components split from the old state machine, each independently controlled by platform-dependent availability without any state switching of a leaky melting pot:
- cursor visibility controls (if platform has cursor)
- cursor motion events (if platform has cursor)
- relative motion events (if the platform reports hardware motion)
2024-12-21 05:18:42 -08:00
Sam Lantinga c44fa5bb07 Updated raw input events to match SDL style
Also added raw keyboard events, and implemented raw input events on iOS, OpenBSD console, Linux console, and X11
2024-12-21 05:18:42 -08:00
Frank Praznik 5ec5f23fff
tests: Print accurate enabled/disabled relative mode status in testrelative 2024-12-20 10:57:12 -05:00
cosmonaut 0f9e86fe1c tests: Fix GPU tests crashing when window is minimized 2024-12-19 16:21:50 -08:00
cosmonaut e46d8756e5 tests: Update GPU tests to use new swapchain best practice 2024-12-19 15:55:04 -08:00
Frank Praznik 4bfc8f84f7
tests: Add a raw event mode to testrelative
Add a code path to test raw motion events (activated by '--raw').
2024-12-19 14:14:36 -05:00
Sam Lantinga e08f34c3be Removed SDL_HINT_MOUSE_RELATIVE_MODE_WARP
This complicated mouse handling and is a rarely tested path. Real relative mode is much better performance and higher precision.
2024-12-19 10:33:02 -08:00
Frank Praznik eda0261c4e video: Drop size and position requests for windows in a fixed size/position state
It is not uncommon for clients to redundantly set the window size and position, either as a holdover from an SDL 1 port, when this was required, due to any window state change triggering a universal update function that sets all window state, even if unnecessary (e.g. always calling SDL_SetWindowSize(), even if the window is fullscreen), or due to the use of compatability layers. Historically, these clients expect that their behavior won't override the base window state, which is an assumption that the windowing changes in SDL 3 broke by caching size and position changes that can't be applied immediately.

This change drops size and position requests when the window is in the maximized and fullscreen states (fullscreen-desktop windows will be repositioned, but the non-fullscreen floating position will not be overwritten), which is behavior more in line with existing client assumptions, and should ease the porting process, as well as prevent annoying bugs when older software is run via sdl2-compat.

In the process of making these changes, pending window state has been moved to separate variables in the SDL_Window struct, as this fixes bugs regarding fullscreen display selection and centering windows immediately after resize on asynchronous platforms, which had issues due to pending state possibly being overwritten.
2024-12-17 10:45:40 -05:00
Ryan C. Gordon 1fbb8e1824
examples/audio/04-multiple-streams: Remove drag-and-drop support.
I'm going to reuse that code for an actual drag/drop example later, but for
simplicity and accessibility of the examples, this is just going to load two
wavs and loop them, so you get the music with a sword-clinking sound mixed
over it.
2024-12-10 23:10:43 -05:00
Sam Lantinga 900627f7fc Enable the SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS hints on macOS
Fixes https://github.com/libsdl-org/SDL/issues/4000
2024-12-06 17:07:16 -08:00
Sam Lantinga 23828b62d4 Added SDL_IsMainThread() and SDL_RunOnMainThread() 2024-12-05 13:53:51 -08:00
Ryan C. Gordon 3ca629ceb5 asyncio: Allow file closes to request a flush/fsyncdata. 2024-12-03 17:32:20 -05:00
Ryan C. Gordon e79ce2a200 asyncio: Added async i/o APIs. 2024-12-03 17:32:20 -05:00
Ryan C. Gordon f852038384 filesystem: Added SDL_GetCurrentDirectory().
Fixes #11531.
2024-11-27 23:42:11 -05:00
Sam Lantinga e027b85cc4 Validate that pixel formats have the correct attributes
Also added a test to save and load as BMP format to make sure pixel transformations are working correctly.

Fixes https://github.com/libsdl-org/SDL/issues/11483
2024-11-17 11:58:57 -08:00
Ryan C. Gordon e4778d53d3
testautomation_video: Another Emscripten test to be skipped. 2024-11-14 19:34:25 -05:00
Ryan C. Gordon d48d4c8c48
testautomation_video: Don't test window position on Emscripten.
This _might_ fix GitHub Actions. We'll know once I push this!  :)
2024-11-14 19:00:10 -05:00
cosmonaut a85f0b49f4 GPU: Remove D3D11 shaders from testgpu_spinning_cube 2024-11-12 17:32:25 -08:00
L zard 1ed1bc1d5d testautomation keyboard: use `space` instead of `a` 2024-11-08 07:01:50 -08:00
capehill 588e32ea5a test: Change LoadContext() return value type from int to bool
It should be then consistent with SDL_SetError().
2024-11-05 14:22:57 -08:00
Sam Lantinga ecfd143a26 testcontroller: update the controller name when it's opened as a gamepad 2024-11-05 11:43:28 -08:00
Sam Lantinga 0ef7a1d901 Show the guid of gamepads that are opened 2024-11-05 11:43:28 -08:00
Wouter Wijsman 780578cd36 PSP: Allow building tests in parallel 2024-11-01 08:57:09 -04:00
Sam Lantinga 77a0411dde Minor cleanup 2024-10-31 15:44:41 -07:00
Sam Lantinga 850158f83f testcontroller: fixed incorrect usage of memcpy() 2024-10-24 18:12:01 -07:00
Sam Lantinga 370c0426ce testspriteminimal: only quit when escape is pressed 2024-10-23 10:51:14 -07:00
Sam Lantinga 45584ad73e Simplify get_channel_name() so it's easier for people to read and understand 2024-10-22 18:19:30 -07:00
Sam Lantinga 315842cf71 Fixed crashes handling D3D11/12 device lost in testsprite
You can test this using "dxcap -forcetdr"
2024-10-21 00:29:18 -07:00
Petar Popovic 6897385623 Add `void` to `run_colorspace_test()` function prototype 2024-10-16 11:16:42 -07:00
Sam Lantinga afee27a530 Make sure stdio handles are in blocking mode
Standard I/O doesn't work well with non-blocking handles, so make sure any pipes are in blocking mode before launching child processes.

Fixes https://github.com/libsdl-org/SDL/issues/10998
2024-10-14 22:10:49 -07:00
Sam Lantinga bb764e3106 Added support for full range BT.709 YUV conversion
Also added simple colorspace testing to testyuv.
2024-10-14 20:36:46 -07:00
Zack Middleton f212cb5f92 Don't overwrite the SDL_IOFromConstMem() error in testshape 2024-10-14 20:07:03 -07:00
Ryan C. Gordon 44bc19b592
test: remove testaudio-art.txt (this info is in test/LICENSE.txt now). 2024-10-14 01:52:18 -04:00
Sam Lantinga d7be7fc168 Fixed Cohen-Sutherland out code computation for float line intersection
Fixes https://github.com/libsdl-org/SDL/issues/10866
2024-10-13 13:04:59 -07:00
Cameron Cawley 2bef8852fb testdrawchessboard: Allow using the standard render API 2024-10-12 16:07:16 -07:00
Cameron Cawley 94c8c170eb 3DS: Only bundle resources with tests that need them 2024-10-12 13:59:00 -07:00
Sam Lantinga c5904d8710 Improved implementation of SDL_DelayPrecise() (thanks @nightmareci!)
Fixes https://github.com/libsdl-org/SDL/issues/10592
2024-10-11 21:18:31 -07:00
Ozkan Sezer 41dfe2c246 test/testautomation_stdlib.c: fix gcc warning on 32 bit
test/testautomation_stdlib.c:361: warning: integer constant is too large for 'long' type
2024-10-10 21:10:24 +03:00
Frank Praznik 40ff6a2785 test: Fix mouse focus test on X11
X11 seems to need a slight delay before warping the pointer to ensure that the window is actually fully visible on the desktop, or the pointer enter event may not be sent.

This also disables the warp focus test on XWayland, as warping the mouse cursor when outside the window on any Wayland desktop usually just doesn't work.
2024-10-10 11:37:45 -04:00
Sam Lantinga 8262072d91 Fixed possible memset(NULL) call in testautomation's SDL_aligned_alloc() check
Fixes https://github.com/libsdl-org/SDL/issues/11144
2024-10-10 08:06:18 -07:00
Sam Lantinga c8f5f6d47a Added SDL_DelayPrecise()
SDL_DelayNS() now passes through to the high precision OS delay function, and SDL_DelayPrecise() tries to busy wait to get as close as possible to the desired wait time.

Fixes https://github.com/libsdl-org/SDL/issues/11141
2024-10-10 08:06:18 -07:00
Daniel Ludwig 5b6342a00d Default SDL_HINT_JOYSTICK_GAMEINPUT to "1" on GDK platforms 2024-10-09 07:30:13 -07:00
Daniel Ludwig ed87e7e434 test: enable GameInput driver on GDK platforms
By default, it's the only driver available on Xbox, but disabled.
2024-10-09 07:30:13 -07:00
Ryan C. Gordon 9f170286ba
test: Replace README with LICENSE.txt
Fixes #11097.
2024-10-06 19:05:18 -04:00
Sam Lantinga c358bf3f9b Removed test program list, it's better to just look at the code.
Fixes https://github.com/libsdl-org/SDL/issues/9399
2024-10-06 11:28:29 -07:00
Sam Lantinga f8dd73fdb9 Fixed build 2024-10-06 08:42:00 -07:00
Sam Lantinga 0f47d3a77b Fixed use after free (thanks @meyraud705!)
Fixes https://github.com/libsdl-org/SDL/issues/11090
2024-10-06 08:34:35 -07:00
capehill e159bcf5de test: Make blit_testExampleApplicationRender work on big endian
Changed image data pixel format to BGRA32.
2024-10-06 08:27:58 -07:00
Sam Lantinga 596ef1ba2e Moved the SDL_ttf IME demo to showfont in the SDL_ttf project 2024-10-06 00:24:01 -07:00
Sam Lantinga 8db3b47482 Just use normal stdio for the child process
Make sure we flush all output so it's seen by the parent as it happens.
2024-10-04 14:13:52 -07:00
Sam Lantinga 6c64c62114 Rename SDL_BUTTON() to SDL_BUTTON_MASK()
Fixes https://github.com/libsdl-org/SDL/issues/11056
2024-10-04 09:13:59 -07:00
Sam Lantinga fe2880fcda Rename SDL_SetThreadPriority() to SDL_SetCurrentThreadPriority()
Fixes https://github.com/libsdl-org/SDL/issues/11055
2024-10-04 08:57:03 -07:00
Petar Popovic 020fb6889c Removed unnecessary const-qualifiers in src and test files 2024-10-03 17:39:08 -04:00
Frank Praznik 522321b7c9
test: Fix testcustomcursor on high-DPI displays
Use the backbuffer dimensions and scale the chessboard pattern to draw it filling the window on scaled displays.
2024-10-01 12:40:17 -04:00
Sam Lantinga 3b3c4a79b6 Don't close file descriptors already handled by AddFileDescriptorCloseActions()
Fixes https://github.com/libsdl-org/SDL/issues/10997
2024-10-01 09:32:14 -07:00
Ryan C. Gordon 0b5e01a305 loadso: library handles are now `SDL_SharedObject*` instead of `void*`.
Improved the SDL_loadso.h documentation a little, too.

Fixes #11009.
2024-10-01 12:16:10 -04:00
Sam Lantinga 1f3a0d12e6 Made texture size and format public in the API
Also added refcount to textures so they can be retained by application code.
2024-10-01 08:10:04 -07:00
Evan Hemsley afdf325fb4
GPU: Add swapchain dimension out params (#11003) 2024-09-30 10:23:19 -07:00
Ryan C. Gordon 1787d6ca5c main: SDL_AppQuit() now reports the result value.
Fixes #10994.
2024-09-29 23:24:04 -04:00
Anonymous Maarten 7241dd9ec3 Add more SDL_Process tests 2024-09-30 03:03:33 +02:00
Ryan C. Gordon 7d21a49c9c filesystem: SDL_EnumerateDirectoryCallback uses an enum now, not an int.
Fixes #10955.
2024-09-28 01:33:40 -04:00
Ryan C. Gordon e944f0fb9d testfilesystem: Added test of creating parent dirs. 2024-09-27 18:54:18 -04:00
Petar Popovic 48c3ee2120 testcolorspace.c: Fix unreachable code warning 2024-09-27 15:22:24 -07:00
Evan Hemsley be401dd1e3
GPU: More robust error reporting (#10958)
---------

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
2024-09-27 00:30:18 -07:00
Sam Lantinga 345d9bfe19 A zero source rect is valid for blitting
A zero sized source rect draws pixels sourced from a 0x0 region on the source surface.

Fixes https://github.com/libsdl-org/SDL/issues/8580
2024-09-25 22:36:55 -07:00
Simon McVittie 80da805688 build: Fix testprocess invocation during "as-installed" tests
During build-time testing, we can use `$<TARGET_FILE:childprocess>` to
pass the just-built childprocess executable to it as an argument, but
during "as-installed" testing we need to use the installed path of
the childprocess executable instead.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-25 14:48:26 -07:00
Ryan C. Gordon 54459def69 render: Remove the logical presentation render target.
Now we render directly to the window, scaling as appropriate. This fixes some
concerns the render target introduced, like the quality of the final scaled
output, how to step outside of the logical size temporarily to draw some
things sharply at the native resolution, and loss of sub-pixel precision.

Fixes #8736.
2024-09-25 16:26:36 -04:00
Petar Popovic e5d3a1b6f5 Remove casts from typed pointer to void * for printf %p in test projects 2024-09-24 14:40:32 +03:00
Ryan C. Gordon 1828bde49f
examples/renderer/01-clear: Use the color-cycle code from testvulkan.c
(and testgpu_simple_clear.c, of course!)
2024-09-22 16:10:57 -04:00
Ozkan Sezer 254b36361e Add SDL_PRILL? format specifiers specifically for long long type. 2024-09-21 23:03:50 +03:00
Ozkan Sezer 88a01fbc96 testautomation_stdlib.c: fix -Wformat warnings from mingw with %lld/%llu
i.e.:  unknown conversion type character 'l' in format
See https://github.com/libsdl-org/SDL/pull/10789#issuecomment-2354011906
2024-09-19 20:37:11 +03:00
Frank Praznik fd0ce75e2e tests: Fix tests when run with the --high-pixel-density flag
Scales pointer coordinates where needed to fix the following tests when run with the --high-pixel-density flag:

- testaudio
- testaudiostreamdynamicresample
- testhittesting
- testintersections
- testmanymouse
- testoverlay
- testwm
2024-09-19 12:54:13 -04:00
Sam Lantinga 6771a6020d testcamera: don't enable verbose logging
Fixes https://github.com/libsdl-org/SDL/issues/10541
2024-09-18 22:26:38 -07:00
Sam Lantinga 1834c83d5a testplatform: make sure bool is 1 byte 2024-09-18 10:01:15 -07:00
Sam Lantinga a90ad3b0e2 Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
2024-09-18 08:32:30 -07:00
Sam Lantinga bd04459cde Fix typos (thanks @qndel!)
Fix typos in comments and in one case in a returned error ("insuffient -> insufficient" fb273eb)
codespell src/ *.cpp *.h *.hpp --ignore-words-list unknwn,thid,algebric,statics,pixelX,pEvents,caf,ptd,parms,pEvent,parm,TextureRS,TE,HDA,LOD,datas,UE,xwindows,IIF
cd src; git checkout \
    events/imKStoUCS.* \
    hidapi \
    joystick/controller_type.c \
    joystick/controller_type.h \
    joystick/hidapi/steam/controller_constants.h \
    joystick/hidapi/steam/controller_structs.h \
    libm \
    stdlib/SDL_malloc.c \
    stdlib/SDL_qsort.c \
    stdlib/SDL_strtokr.c \
    video/khronos \
    video/x11/edid.h \
    video/x11/edid-parse.c \
    video/x11/xsettings-client.* \
    video/yuv2rgb
2024-09-18 08:18:26 -07:00
Frank Praznik e4f987f299
tests: Fix testdropfile on high-DPI displays
Convert the window pointer coordinates to buffer coordinates for rendering, so that the cross-hairs align with the cursor on scaled desktops.
2024-09-18 11:00:19 -04:00
Ozkan Sezer 8caf25f7b3 testautomation_stdlib.c (stdlib_strtox): fix warning from gcc-4.9:
test/testautomation_stdlib.c: In function 'stdlib_strtox':
test/testautomation_stdlib.c:1339:9: warning: this decimal constant is unsigned only in ISO C90
         STRTOX_TEST_CASE(SDL_strtoul, unsigned long, "%lu", "4294967295", 10, 4294967295, 10);
         ^
test/testautomation_stdlib.c:1340:9: warning: this decimal constant is unsigned only in ISO C90
         STRTOX_TEST_CASE(SDL_strtoul, unsigned long, "%lu", "4294967296", 10, 4294967295, 10);
         ^
2024-09-18 01:03:10 +03:00
Sam Lantinga 8d223b3037 Renamed atomic functions to match SDL 3.0 naming convention
This will also allow us to cleanly add atomic operations for other types in the future.
2024-09-17 08:53:27 -07:00
Sam Lantinga f3e419596b Removed SDL_INIT_TIMER
This is no longer necessary before calling SDL_AddTimer()
2024-09-17 08:53:27 -07:00
Sam Lantinga 231ea07617 Added SDL_LogTrace() 2024-09-17 02:04:54 -07:00
Sam Lantinga dc639956ba Improve logging performance and make log priorities thread-safe
Fixes https://github.com/libsdl-org/SDL/issues/9679
2024-09-16 13:09:17 -07:00
Caleb Cornett 9416917353
GPU: Rework MSAA (#10859) 2024-09-16 12:19:09 -05:00
Sam Lantinga 0548050fc5 Verify that the subsystems were successfully initialized 2024-09-15 12:04:10 -07:00
Carl Åstholm 1f3fd65c4c cpuinfo: Rename SDL_GetCPUCount to SDL_GetNumLogicalCPUCores
This was the only API that broke the "GetNumThings" convention
used elsewhere, so renaming it helps with consistency.
Adding "logical cores" to the name also makes it a bit
more immediately obvious what the count actually represents.
2024-09-14 19:33:30 -07:00
Ryan C. Gordon 93bf534268
testgpu_simple_clear: Fixed AppInit return values. 2024-09-14 19:19:27 -04:00
Sam Lantinga e97f636590 SDL_PROP_PROCESS_CREATE_ENVIRONMENT_POINTER is an SDL_Environment pointer 2024-09-14 12:27:22 -07:00