Commit Graph

22312 Commits

Author SHA1 Message Date
Ryan C. Gordon
daf519ae05 assert: make disabled asserts work with bitfield conditions.
We don't care _what_ the `sizeof` results are, we just want it to vaporize
the condition's code out of the build. So we check it with a `? 1 : 0`, so it
always boils down to a `sizeof (int)`, no matter what data type the condition
actually is.

This works with bitfields, pointers, anything that can be "truthy." If it
isn't truthy, it would fail when assertions are enabled anyhow.

Fixes #15990.
2026-07-13 18:17:33 -04:00
Ozkan Sezer
a6c294410e introduce new printf format macros SDL_PRISZu, SDL_PRISZx and SDL_PRISZX 2026-07-13 22:35:03 +03:00
Sam Lantinga
1f188100bc Added an msys build to the priority build list 2026-07-13 09:24:04 -07:00
Sam Lantinga
80be09a804 Fixed error: unknown conversion type character 'z' in format
That apparently isn't supported by the mingw compiler
2026-07-13 09:22:14 -07:00
Tim Stahlhut
c97d9feb13 Rewrite five SDL_DIRECTX header checks
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

[sdl-ci-filter msvc-*]
[sdl-ci-filter msys2-*]
[sdl-ci-filter cygwin]
[sdl-ci-filter ngage]
2026-07-13 09:07:26 -07: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
Ryan C. Gordon
d629eb3bf0 vita: Treat the d-pad as a hat switch at the SDL_Joystick level.
Reference Issue #14830.

[sdl-ci-filter *]
2026-07-11 20:33:10 -07:00
Ryan C. Gordon
52ae8796a8 psp: Treat the d-pad as a hat switch at the SDL_Joystick level.
Reference Issue #14830.
2026-07-11 20:33:10 -07:00
Ryan C. Gordon
8c7508decd ps2: Treat the d-pad as a hat switch at the SDL_Joystick level.
Reference Issue #14830.
2026-07-11 20:33:10 -07:00
Ryan C. Gordon
fb3afd33e4 n3ds: Treat the d-pad as a hat switch at the SDL_Joystick level.
Reference Issue #14830.
2026-07-11 20:33:10 -07:00
Ryan C. Gordon
82141a2439 api: Added SDL_GetNumProperties().
Fixes #14761.
2026-07-11 15:11:30 -04:00
Nintorch
d11e3e087a Emscripten: Convert joystick axis 9 to a hat 2026-07-11 08:01:10 -07:00
Anonymous Maarten
891808e128 cmake: add missing cmake_pop_check_state to gameinput checks 2026-07-11 16:45:17 +02: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
Sam Lantinga
c1d4376d3c Fixed Vulkan validation errors when using ffmpeg video decode 2026-07-10 08:09:15 -07:00
Ozkan Sezer
f653c5e91c update khronos headers from mainstream. 2026-07-10 03:55:50 +03:00
Ryan C. Gordon
e7be7d844a vulkan: Make SDL_Vulkan_GetInstanceExtensions more robust.
Now it handles NULL `count` params at the higher level, and doesn't explode if
a backend doesn't implement it.
2026-07-09 17:28:07 -04:00
Tim Stahlhut
bb74b618ac Cygwin: Reduce warning
[sdl-ci-filter cygwin]
[sdl-ci-filter msys2-*]
[sdl-ci-filter msvc-*]
2026-07-09 09:03:46 -07:00
SDL Wiki Bot
50852f7f1b Sync SDL3 wiki -> header
[ci skip]
2026-07-08 23:11:32 +00:00
Sam Lantinga
782d6bc116 Note that Windows doesn't see mouse button releases when RIDEV_NOLEGACY is active. 2026-07-08 16:08:38 -07:00
palxex
fed7f6fe06 perf: fast-path pure palette animation for dos 2026-07-08 11:09:21 -07:00
Epifanov Ivan
425c6a2695 VITA: invalidate texture in render state on update (#15957) 2026-07-08 07:10:57 -07:00
meta-legend
e90bdfb5ea Avoid unnescessarily updating fullscreen display modes 2026-07-07 21:36:28 -07:00
ExtremelyLazyCat
5403934fd3 Add Mayflash N64 Controller Adapter mapping 2026-07-07 14:04:56 -07:00
Frank Praznik
a3a8141557 wayland: Simplify key repeat handling
Remove redundant state variables, remove trivial helper functions, and guard against the unlikely case where a compositor may set the repeat rate to zero while a repeat is active, which would result in a divide-by-zero error.

Key repeat is increasingly handled server-side with seat v10 and above, so consider that the most common path for the future.
2026-07-07 15:02:16 -04:00
Sam Lantinga
cf6a235a41 Only skip the Flydigi driver when checking to see if a device is handled by HIDAPI 2026-07-07 09:30:20 -07:00
Isabella Basso
1f3f714393 cocoa: restore discrete mouse wheel ticks 2026-07-07 10:44:51 -04:00
Gabriel Wang
7afd6c3497 Add sve2 acceleration for blit2to2 key (#15953) 2026-07-07 07:36:07 -07:00
Sam Lantinga
c0efc5862c Use the correct protocol for the PDP Afterglow Wave controller
Third party wireless controllers use the full Switch Pro protocol over Bluetooth and third party wired controllers use the input-only protocol.

The PDP Afterglow Wave Controller for Switch uses the same VID/PID for both wired and wireless variants, so we need to look at the connection type to determine what protocol to use.
2026-07-06 18:47:46 -07:00
Sam Lantinga
03f81ab4aa Fixed the 8BitDo Pro 3 controller showing up twice on macOS
Fixes https://github.com/libsdl-org/SDL/issues/15890
2026-07-06 17:03:23 -07:00
Sam Lantinga
ce417a40cf Start text input before showing the on-screen keyboard (thanks @sharkwouter!)
Fixes the on screen keyboard not sending an event the first time on PSP

Closes https://github.com/libsdl-org/SDL/pull/15950
2026-07-06 16:44:59 -07:00
Sam Lantinga
bd55a6d67d Fixed pressing back paddles and D-pad simultaneously on the GameSir-G7 Pro 8K controller 2026-07-06 16:35:24 -07:00
SDL Wiki Bot
eb88a154fa Sync SDL3 wiki -> header
[ci skip]
2026-07-06 20:30:33 +00:00
Sam Lantinga
d8d5b7c6c5 Added a slider to manually adjust HDR headroom on visionOS
Ideally the OS would provide a way to query the current headroom, but for now users can manually adjust it.
2026-07-06 13:25:12 -07:00
palxex
ac6e7c795e dos: Drain BIOS keyboard buffer in event pump to prevent overflow beeps 2026-07-06 13:32:30 -04:00
brentfpage
46dcc0c554 for 'pinch end' events on mobile devices, send dummy value -1 for (focus|span)_(x|y) 2026-07-06 05:52:47 -07:00
8BitDo
efa0e2d5ed support 8bitdo ultimate 3 (#15927) 2026-07-06 05:50:38 -07:00
Jacul
e1b3c8afd5 metal: check MTLBuffer allocations for nil before using their contents. 2026-07-05 23:53:21 -04:00
Ozkan Sezer
435539e66c ci: bump freebsd 2026-07-05 23:33:00 +03:00
Dimitriy Ryazantcev
362165ed9b Win32: Swap maskColor assignment based on alpha value
Looks like mask pixels was inverted.
2026-07-05 12:37:25 -07:00
Wouter Wijsman
8e3b6243fd PSP: Remove log statement 2026-07-05 11:34:49 -07:00
Wouter Wijsman
244af6edbb PSP: Remove double iconv close in PSP_ShowScreenKeyboard 2026-07-05 11:34:49 -07:00
Wouter Wijsman
4cc9a4bdfe PSP: Clean up PSP_ShowScreenKeyboard 2026-07-05 11:34:49 -07:00
Wouter Wijsman
db39db3e47 PSP: Run clang-format on PSP_ShowScreenKeyboard function 2026-07-05 11:34:49 -07:00
Wouter Wijsman
2f153f801a PSP: Fix compiler warnings in PSP_ShowScreenKeyboard 2026-07-05 11:34:49 -07:00
Wouter Wijsman
2f066afcb0 PSP: Improve safety in PSP_ShowScreenKeyboard 2026-07-05 11:34:49 -07:00