Commit Graph

2053 Commits

Author SHA1 Message Date
Sam Lantinga
08b9c55393 Fixed error: cast from pointer to integer of different size 2026-07-17 22:08:39 -07:00
Sam Lantinga
f00052ffe2 testffmpeg: fixed memory leak using DRM frames with the Vulkan renderer 2026-07-17 19:24:46 -07:00
Sam Lantinga
762f4abbd0 Fixed an error with goto crossing variable initialization 2026-07-17 16:56:23 -07:00
Sam Lantinga
332e7a050e testffmpeg: added support for VA-API and DRM frames when using Vulkan rendering 2026-07-17 16:23:48 -07:00
Antonio Ospite
d330686798 test: Remove superfluous null byte from ps3_hid_report_descriptor
Remove a superfluous null byte at the end of ps3_hid_report_descriptor,
as it might confuse some more stricter parser.

The data in ps3_hid_report_descriptor probably comes for a libinput
recording, and sometimes those can have superfluous null byte at the
end.

This is mentioned for example in the hidreport project:
64d4067403/tools/libinput-recording-extract-hid-descriptor.py (L25-L27)

As a proof that the original HID report descriptor of the actual device
is 148 bytes long, the following lsusb capture can be compared:
http://ps3.jim.sh/sixaxis/usb/lsusb.txt

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
2026-07-16 08:53:14 -07:00
Ozkan Sezer
a6c294410e introduce new printf format macros SDL_PRISZu, SDL_PRISZx and SDL_PRISZX 2026-07-13 22:35:03 +03:00
Antonio Ospite
b9758218c8 Misc cleanup for src/joystick/hidapi/SDL_report_descriptor.c and new test program (#15959)
* testevdev: Always use decimal for HID report descriptors size

The size of the HID report descriptors in the SDL_COMPILE_TIME_ASSERT
checks is specified sometimes in decimal and sometimes in octal.

Always used decimal for consistency.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* SDL_report_descriptor: Add missing include guards in header file

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* SDL_report_descriptor: Fix some ignored return values

Fix some ignored return values resulting in incomplete error checking.

For instance:

  - ParseMainItem() was always returning true because the return value of
    AddInputFields() was not handled.

  - ParseLocalItem() was always returning true because the return value of
    AddUsage() was not handled.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* test: Add new test program for SDL_report_descriptor code

Add support for testing the SDL_report_descriptor code by adding a new
executable to make it easier to experiment with HID report descriptor
parsing.

The main() function which originally was in
src/joystick/hidapi/SDL_report_descriptor.c is moved to a separate file
named test/testdescriptor.c in order to simplify dealing with multiple
build systems.

For instance if the main() was in
src/joystick/hidapi/SDL_report_descriptor.c the code would have to
account for the cases when the file is built as part of the library or
when it's built as part of a standalone executable, in which case the
dynamic API mechanism needs to be disabled.

This would pose a problem especially with MSVC which uses pre-compiled
headers (PCH) which do not sit well with the preprocessor logic that
would be needed, like the hacks added in test/testevdev.c

Using a completely separate source file for the standalone executable
avoids the issue, especially considering that the new file is not built
with MSVC at all.

The new test program can be built with:

  cmake -DCMAKE_BUILD_TYPE=Debug -DSDL_TESTS=ON -S . -B build
  make -C testdescriptor

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* testdescriptor: Fix compiler warning

Fix compiler warning:

-----------------------------------------------------------------------
.../test/testdescriptor.c: In function ‘main’:
.../test/testdescriptor.c:56:17: warning: unused variable ‘file’ [-Wunused-variable]
   56 |     const char *file = argv[1];
      |                 ^~~~

-----------------------------------------------------------------------

Use the `file` variable when appropriate since it is already declared
and assigned.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* testdescriptor: Clean up descriptor context before exiting

For correctness clean up the descriptor parsing context before exiting,
even though this is not a problem in practice for a standalone
executable.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* testdescriptor: Exercise public API for parsing report descriptor

This gives some more coverage when running the SDL_report_descriptor
test program.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* SDL_report_descriptor: use size_t for variables that represent buffer sizes

Using size_t type for variables that represent buffer sizes in
src/joystick/hidapi/SDL_report_descriptor.[hc] addresses possible errors
when using the functions in combination with SDL_LoadFile, like in
test/testdescriptor.c

When building with CMake on Windows x64 the compilation was failing with
the following error:

-----------------------------------------------------------------------
D:\a\SDL\SDL\test\testdescriptor.c(69): error C2220: the following warning is treated as an error
D:\a\SDL\SDL\test\testdescriptor.c(69): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data
-----------------------------------------------------------------------

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

* SDL_hidapi_xboxone: protect against passing negative size to SDL_ReadReportData

Since SDL_ReadReportData() is now using size_t for the buffer size, also
change its user HIDAPI_DriverXboxOne_HandleDescriptorReport to pass
size_t, but protecting against possible cases of passing negative values
to SDL_ReadReportData().

To do that it is enough to check that the "size" argument is not zero,
so it will never be negative when decremented (size--) a few lines
below.

Note: this just addresses a theoretical issue with future callers of
HIDAPI_DriverXboxOne_HandleDescriptorReport, the current code would be
already safe as the current caller already checks that size > 0.

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>

---------

Signed-off-by: Antonio Ospite <antonio.ospite@collabora.com>
2026-07-13 08:26:03 -07:00
Sam Lantinga
9149eca207 testffmpeg_vulkan: enable the VK_KHR_video_maintenance1 extension
This is used by ffmpeg, so we'll enable it if it's available
2026-07-10 11:40:30 -07:00
Sam Lantinga
094213b3be testffmpeg_vulkan: fixed goto jump past variable initialization 2026-07-10 10:07:50 -07:00
Sam Lantinga
4a00b98c91 testffmpeg: added a --nodelay command line option 2026-07-10 10:06:48 -07:00
Sam Lantinga
573fc51938 testffmpeg_vulkan: use C++ compatible code structure 2026-07-10 10:06:48 -07:00
Sam Lantinga
6ce3d843fc testffmpeg_vulkan: fixed usage of timeline semaphores 2026-07-10 10:06:48 -07:00
Can H. Tartanoglu
bb6f24e542 testprocess: handle async exec failure for missing executables 2026-07-04 11:16:57 -07:00
Sam Lantinga
07ecc125cf Added SDL_PIXELFORMAT_P408 and SDL_PIXELFORMAT_P416 2026-06-22 17:01:54 -05:00
Semphriss
e52dbf4442 Add basic Ubuntu Touch functions #12543
This adds support for:
* System theme
* Sandbox detection
* Device form factor detection

Many things aren't properly supported yet, but changes and upgrades will happen on the Ubuntu Touch side, so SDL should automatically support more Ubuntu Touch features as time goes.
2026-06-21 11:51:15 -07:00
Ryan C. Gordon
72771ac0b4 credits: Update links to Will Provost's album "The Living Proof"
Amazon's store link was still "http://" instead of "https://", and since they
don't have the physical CD in stock anymore (and probably won't ever again), I
added a link to the album on Amazon Music, for those that want to access it.
2026-06-10 20:48:57 -04:00
Frank Praznik
8275f6e90d Add D-Bus notification driver
Use the core and portal notification implementations to dispatch system notifications.
2026-06-10 13:25:38 -04:00
Frank Praznik
068e405912 Add notification framework with test and dummy driver 2026-06-10 13:25:38 -04:00
Frank Praznik
96919c37c9 stdlib: Add SDL_wcstoul(), SDL_wcstoll(), and SDL_wcstoull()
Includes the appropriate stdlib checks and automated tests.
2026-06-08 11:58:47 -04:00
Sam Lantinga
e04bfb4c6e render: an empty clip rect should clip all drawing
Added a test to validate this and fixed the Metal renderer

Fixes https://github.com/libsdl-org/SDL/issues/15434
2026-05-29 13:58:34 -07:00
Sam Lantinga
a95f5f9874 testcontroller: make sure touchpad touches are visible even at very light pressure 2026-05-28 09:58:33 -07:00
Ryan C. Gordon
d7ba3efe6b filesystem: Implement SDL_GetExeName() for all platforms. 2026-05-27 15:41:51 -04:00
Sam Lantinga
1db2b71ef0 testgpurender_msdf: allow changing the text being rendered 2026-05-25 20:21:32 -07:00
Anonymous Maarten
32c19b9dc8 Fix buffer-overflow access in process_testStdinToStdout
Backing memory of SDL_IOFromDynamicMem is not null-terminated.
2026-05-25 17:29:58 +02:00
Frank Praznik
f31ca02723 video: Windows keep any position set when in fullscreen after leaving fullscreen
Adds an automated test for the behavior as well.
2026-05-18 09:09:49 -07:00
ceski
d8b2434047 testcontroller: correct fix for touchpad free/allocate 2026-05-17 18:19:29 -07:00
Cameron Gutman
6d3404e4bb gamepad: Add SDL_GAMEPAD_TYPE_STEAM for Steam Controllers 2026-05-17 11:19:16 -07:00
ceski
5b98c1cc2f Add capacitive sense gamepad events (#15627) 2026-05-17 08:26:29 -07:00
ceski
984fcdaa8a testcontroller: free/allocate touchpads only when needed 2026-05-17 07:45:59 -07:00
Ozkan Sezer
a34b35a382 cygwin, test/cmake: hard-code opengl as native opengl32.
FindOpenGL from cmake >= 3.19, or cygwin-provided cmake versions don't
test for native windows opengl32, but we want native windows opengl32.
2026-05-17 09:55:31 +03:00
Anonymous Maarten
d1d54b8c56 test: build testsprite as c++ application 2026-05-15 18:08:09 +02:00
stahta01
6586bebfec Fix Cygwin building and add CI (#15566)
Co-authored-by: TrueCat17 <truecat17@gmail.com>
Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
2026-05-15 08:48:24 -07:00
ceski
006959ca87 Add dual touchpad support to testcontroller (#15540) 2026-05-13 23:49:01 -07:00
Gabriel Wang
0f175891a6 Add SVE2 SIMD Alpha-Blending Blitter (#15504)
SVE/SVE2 is a new SIMD extension for AArch64. Compared to NEON, SVE/SVE2 brings the following benefits that are good for SDL projects:

- Lane prediction: we don't have to treat the tail part of a stride separately when the width is n times the hardware vector size
- Although the performance is almost no difference from NEON when the hardware vector size is 128bits, when the hardware provides a longer vector size, e.g. 256, 512, ... 2048, we can enjoy the large performance gain without modifying the source code or recompiling a library.

The functional correctness is validated in a dedicated [qemu project](https://github.com/GorgonMeducer/aarch64_qemu_mac_template/tree/SDL-SVE2-Acceleration-Validation).

The performance is tested on [Radxa Orion 6 N](https://radxa.com/products/orion/o6n/), which provides 4x A720 and 4x A520 processors. Since the vector size is 128 bits, which is the same as NEON, the performance is almost the same (or no worse than) the NEON acceleration.
2026-05-13 23:37:46 -07:00
Cameron Cawley
e50faf4e6a Support the full set of standard CSS cursors 2026-05-13 20:24:44 -07:00
Susko3
2949a0d6d5 Enable text editing events in checkkeys 2026-05-07 09:57:08 -07:00
Anonymous Maarten
81cde11d1e tests: fix test/emscripten/server.py when running without --map 2026-04-29 20:30:14 +02:00
Ryan C. Gordon
7212ab1c2a checkkeys: Sleeping for 100ms every frame makes the program too unresponsive.
Makes it feel like there's a bug in SDL's text input handling. 10ms is fine.
2026-04-28 08:08:15 -04:00
Sam Lantinga
6f952a8e63 testime: use the correct properties when enabling text input 2026-04-27 10:54:03 -07:00
Anders Jenbo
a8ecd677ed Add DOS platform support (DJGPP) (#15377)
* dos: Some initial work.

* dos: Turn off buffer on stdio SDL_IOStreams.

Seeking breaks otherwise. We might be able to just fflush() before or seeking
instead?

* dos: Audio implementation using the Sound Blaster 16.

* dos: remove audio Pump interface.

Turns out DosBox-X was having trouble with the Sound Blaster or something;
standard DosBox works correctly directly from the interrupt handler, and
without doubling the buffer size.

* dos: just dump and restore the stdio buffer when seeking.

This is MUCH faster than just leaving buffering disabled, and also works
around getting bogus reads after an fseek. SDL_LoadWAV on test/sample.wav
no longer takes several seconds to finish, and comes up with the correct
data.

I wonder if we're triggering this in LoadWAV because we're malloc'ing data
between seeks/reads, and it's causing the djgpp transfer buffer to change. Or
maybe the Fat DS trick is confusing it? I don't know, I haven't had time to
debug it, it might just be a legit libc bug in djgpp too, for all I know.

* dos: Protect audio device "thread" iterations when streams are locked.

This uses an old trick we used in SDL 1.2 for MacOS Classic, which did its
audio callback in a hardware interrupt. If the audio is locked when the
interrupt fires, make a note of it and return immediately. When the lock is
released, if the interrupt has been fired, run the audio device iteration
right then.

Since there isn't a big device lock in SDL3 (available to the app, at least),
this keeps a counter of when any SDL_AudioStream is locked, which is probably
good enough.

* dos: Implemented initial video subsystem.

This uses VESA interfaces to manage the display and works with the software
renderer.

Events aren't hooked up yet, so prepare to close DosBox on each run.  :)

* dos: Whoops, forgot to add these to revision control. Core and Main support.

* dos: Wired up basic filesystem support.

This gets most of the rendering examples, which use SDL_GetBasePath() to
find textures to load, working.

* dos: Fixed compiler warning.

* dos: Initial mouse support!

* dos: Move interrupt hooking code into core/dos.

* dos: Initial keyboard support!

* dos: Use a simple ring buffer for keyboard events.

Of course Quake 1 solved this better, haha. It's smart: less memory, dirt
simple, and you don't even have to worry about synchronizing with the
interrupt handler, because it's safe for both sides no matter when an
interrupt fires.

* ci: add djgpp job

[sdl-ci-filter djgpp]
[sdl-ci-artifacts]

* dos: Fix build issues after rebase onto current main

- SDL_runapp.c: Add SDL_PLATFORM_DOS to the exclusion list so the
  generic
  SDL_RunApp() is disabled when the DOS-specific one is compiled.
- SDL.c: Exclude SDL_Gtk_Quit() on DOS. DJGPP defines __unix__ which
  sets
  SDL_PLATFORM_UNIX, but DOS has no GTK/display server. The GTK source
  is not compiled (CMake UNIX is false for DOS) so this was a link
  error.
- sdlplatform.cmake: Add DOS case to SDL_DetectCMakePlatform so the
  platform is properly detected from CMAKE_SYSTEM_NAME=DOS.
- i586-pc-msdosdjgpp.cmake: Add i386-pc-msdosdjgpp-gcc as a fallback
  compiler name, since some DJGPP toolchain builds use the i386 prefix.

* Add 8-bit palette support to DOS VESA driver

* Add VBE page-flipping, state restore, and robust keyboard handling

- Implement double-buffered page-flipping for VBE modes with >1 image
  page
- Save and restore full VBE state on video init/quit for clean mode
  switching
- Improve DOS keyboard handling: support extended scancodes and Pause
  key
- Lock ISR code/data to prevent page faults during interrupts
- Always vsync when blitting in single-buffered modes to reduce tearing

* Refactor Sound Blaster audio mixing to main loop

Move audio mixing out of IRQ handler to main loop for improved
stability and to avoid reentrancy issues. Add SDL_DOS_PumpAudio
function, update DMA buffer handling, and adjust sample rate to 22050
Hz.
Silence stale DMA buffer halves to prevent stutter during load.

* Add DOS timer support and update build config

* Add support for pre-SB16 8-bit mono Sound Blaster audio

Detect SB version and select 8-bit mono or 16-bit stereo mode.
Handle DMA and DSP setup for both SB16 and pre-SB16 hardware.
Add FORCE_SB_8BIT option for testing in DOSBox.

* Add SB Pro stereo support and simplify IRQ handler

* Add DOS joystick driver support

* Improve DOS hardware handling and clarify memory allocation

- Poll Sound Blaster DSP status instead of fixed delay after speaker-on
- Clarify DPMI conventional memory is always locked; update comments
- Document and justify DMA memory allocation strategy
- Free IRET wrapper after restoring interrupt vector to avoid leaks
- Throttle joystick axis polling to ~60 Hz to reduce BIOS timing loop
  cost
- Always poll joystick buttons directly for responsiveness

* Query and use mouse sensitivity from INT 33h function 0x1B

* Add support for VESA banked framebuffer modes

Implement banked framebuffer access for VBE 1.2+ modes without LFB.
Detect and initialize banked modes, copy framebuffer data using bank
switching, and blank the framebuffer on mode set. Page-flipping is
disabled in banked mode.

* Add optional vsync to page flipping in DOS VESA driver

* Add cooperative threading support for DOS platform

* Move SoundBlaster audio mixing to SDL audio thread

* Fix DOS platform comments and workarounds for DJGPP support

* Fix SoundBlaster IRQ handling and DMA setup for DOS

- Pass IRQ number to DOS_EndOfInterrupt and handle slave PIC EOI
- Validate DMA channel from BLASTER variable
- Correct DMA page register selection for SB16
- Improve BLASTER variable parsing and error messages
- Unmask/mask IRQs on correct PIC in DOS_HookInterrupt
- Rename SDL_dosjoystick.c to SDL_sysjoystick.c
- Include SDL_main_callbacks.h in SDL_sysmain_runapp.c
- Add include guard to SDL_systhread_c.h

* Add DOS platform options and preseed cache for DJGPP

Disable unsupported SDL features when building for DOS. Add
PreseedDOSCache.cmake to pre-populate CMake cache variables for DJGPP.

* cmake: use a 8.3 naming scheme for tests on DOS

* Apply code style

* Update include/SDL3/SDL_platform_defines.h

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Code review clean up

- Split DOS VESA mode-setting into its own file
- Replace magic numbers with named constants
- Update copyright dates to 2026
- Substract time taken by other threads form delays

* Fix DOS bugs and improve compatibility

- Disable fseeko64 for DJGPP due to broken implementation
- Refactor DOS timer delay to always yield and avoid busy-waiting
- Fix animated cursor rendering in DOS VESA backend
- Always set display mode when creating DOS VESA window
- Work around DJGPP allowing invalid file access in testfile.c
- Bump max threads to 16
- Apply workarounds for threading tests

* Add DOS platform documentation and fix a few issues

- Fix fullscreen default resolution
- Improve best mode matching
- Fix builds on GCC older than 7.0
- Fix text input events

* Fix keyboard mapping of "*"

* Fix running, and existing, under PCem

* Apply suggestions from code review

Co-authored-by: Cameron Cawley <ccawley2011@gmail.com>

* Pre-mix audio in ring buffer and copy to DMA via IRQ thread

* Video fixes and optimizations

* DOS: Fix Intel 740 and VGA compatability

* DOS: Update readme

* DOS: Fix thread ID, get GPU name

* DOS: Cap mouse range

* DOS: Map test resources to 8.3 names

* DOS: Skip unsupported WM color modes

* Fix "windowed" resolution selection

* DOS: Hide INDEX8 modes behind SDL_DOS_ALLOW_INDEX8_MODES

* Remove SDL_HINT_DOS_ALLOW_INDEX8_MODES and order modes logically

* Don't convert cursor if dest is not INDEX8

---------

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Cameron Cawley <ccawley2011@gmail.com>
Co-authored-by: Gleb Mazovetskiy <glex.spb@gmail.com>
Co-authored-by: Jay Petacat <jay@jayschwa.net>
Tested-by: Cameron Cawley <ccawley2011@gmail.com>
2026-04-23 19:54:49 -04:00
Anonymous Maarten
c00e9c991e test: use SDL_test for event handling 2026-04-14 02:46:42 +02:00
Anonymous Maarten
745f9905c1 test: render name of current active cursor 2026-04-14 02:46:42 +02:00
Frank Praznik
f40955cd00 test: Render a blank window in testtray
Some platforms require drawing something to the window for it to be mapped, so create a renderer and redraw on exposure events.

Additionally, add the license to the testtray.c file and clang-format the source.
2026-04-11 10:11:43 -04:00
Anonymous Maarten
396eeff350 cmake: add SDLTEST_GDB option to run tests under gdb debugger printing stacktraces 2026-04-11 04:12:15 +02:00
Sam Lantinga
51aeebd889 testcolorspace: fixed color check when output is linear colorspace with 8-bit precision 2026-04-07 14:05:51 -07:00
Sam Lantinga
cf71571c96 testcolorspace: use the SDL main callbacks 2026-04-07 14:05:51 -07:00
Frank Praznik
682da4ee98 misc: Use the OpenURI D-Bus portal for opening URLs
This works inside of containers, and supports passing an activation token with the request, which is needed on Wayland to transfer focus to the browser.
2026-04-05 16:31:50 -04:00
Anonymous Maarten
03f74f3ad3 testyuv: make test params static const 2026-04-02 21:25:41 +02:00
Anonymous Maarten
b77fdcc638 Disable UB sanitizer in signed shift test 2026-04-02 21:25:41 +02:00
Anonymous Maarten
f7661ff016 Avoid unaligned memory access while testing SSE4.2 CRC intrinsics 2026-04-02 21:25:41 +02:00