Compare commits

...

457 Commits

Author SHA1 Message Date
Sam Lantinga
ffa78e6bea Updated to version 2.28.0 for release 2023-06-20 11:00:20 -07:00
Simon McVittie
4ce5c3a694 ibus: Handle error when getting the D-Bus machine ID
It is possible for retrieving the machine ID to fail, either because
dbus was installed incorrectly (machine ID absent or corrupt), or in
32-bit builds, because stat() on the machine ID fails with EOVERFLOW
if it has an out-of-range timestamp or inode number.

dbus has historically treated this as a faulty installation, raising
a warning which by default causes the process to crash. Unfortunately,
dbus_get_local_machine_id() never had a way to report errors, so it has
no alternative for that (bad) error handling.

In dbus >= 1.12.0, we can use dbus_try_get_local_machine_id() to get
the same information, but with the ability to cope gracefully with
errors. ibus won't work in this situation, but that's better than
crashing.

(cherry picked from commit 91198baed4)

Mitigates: https://github.com/ValveSoftware/steam-for-linux/issues/9605
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-06-20 09:45:25 -07:00
Sam Lantinga
a3d4fd71c3 Added support for blitting SDL_PIXELFORMAT_INDEX1LSB
Fixes https://github.com/libsdl-org/SDL/issues/7844
2023-06-19 08:36:30 -07:00
Sam Lantinga
d97423ebab Fixed DualSense controllers not being picked up by the HIDAPI driver
The hidraw device may take additional time to get the correct permissions for us to open it. In my tests on Steam Deck hardware, this ranges between 5-8ms.

(cherry picked from commit c6ee9780df)
2023-06-18 12:22:06 -07:00
Sam Lantinga
333a03f1ec We don't know in advance whether a device is connected over Bluetooth in SDL2 2023-06-17 13:15:07 -07:00
Sam Lantinga
5b8fc907df Added support for the GameSir G4 Pro
We can't read device info or IMU calibration from this controller, and it has no gyro or accelerometer, but is otherwise perfectly functional.

(cherry picked from commit f168f9c813)
2023-06-17 13:07:03 -07:00
Eric Wasylishen
76392f4fe1 Handle DPI scaling in SDL_GetWindowSurface
Fixes DPI awareness of testdrawchessboard (previously, the surface was
being created in points instead of pixels, resulting in the demo app
only drawing in a corner of the screen on High-DPI displays)

*_CreateWindowFramebuffer()/*_UpdateWindowFramebuffer(): are updated
to use SDL_GetWindowSizeInPixels instead of SDL_GetWindowSize() or
window->w/window->h.

Most of the _CreateWindowFramebuffer backends are untested except
for Windows.

Fixes #7047

(cherry picked from commit 67c91353e0)
2023-06-14 17:23:54 -07:00
Sam Lantinga
3a5abee512 Removed unused function
(cherry picked from commit 73927b0948)
2023-06-14 15:16:44 -07:00
Sam Lantinga
e7ee375f22 Fixed third-party Nintendo Switch Pro controllers shutting down when we try to set the home LED.
This fixes the PDP Afterglow Wireless Deluxe Controller.

(cherry picked from commit 0c16f4faf0)
2023-06-14 15:15:27 -07:00
Sam Lantinga
4aec54988c Allow switching licensed Nintendo Switch Pro controllers into gyro input mode
(cherry picked from commit 8c95bd814b)
2023-06-14 15:13:11 -07:00
Sam Lantinga
271e03f0d7 Added support for the PowerA Fusion Pro Wireless Controller in Bluetooth mode
This controller shows up with a VID/PID of 0, but has full functionality over Bluetooth

(cherry picked from commit cdfc0c5a33)
2023-06-14 15:12:56 -07:00
Sam Lantinga
d4f9be4416 Updated to version 2.27.1 for release candidate 2023-06-13 19:44:26 -07:00
Sam Lantinga
1f5b21ead5 Removed more Linux Xbox mappings in favor of the automatic mapping
This fixes the Xbox Series X share button on Linux 5.x kernels.

(cherry picked from commit 0f4b15e16b)
2023-06-13 17:06:24 -07:00
Sam Lantinga
35c7884929 Use the automatic mapping instead of a hardcoded one for Xbox controllers on Linux
This is much more robust and able to dynamically create a mapping for Xbox One S, Xbox Series X, and Xbox Elite 2 controllers.

(cherry picked from commit 9567989eb3)
2023-06-13 17:06:21 -07:00
Sam Lantinga
3f6c4ec6d0 Cleanup for previous change, fixing typos, etc.
(cherry picked from commit 883b0f4071)
2023-06-13 17:04:54 -07:00
Sam Lantinga
fc72f12e7f Added automatic mapping support for Xbox controllers on the 6.x Linux kernels
This automatically adds support for the share button and paddles when present.

(cherry picked from commit db1d4d3d76)
2023-06-13 17:04:17 -07:00
Ozkan Sezer
681f67d353 fixed build after commit d2372c8538. 2023-06-14 00:25:50 +03:00
Sam Lantinga
d2372c8538 Added automatic mapping for Xbox Elite paddles using the xpadneo driver
We can't actually tell yet whether a controller has paddles, so this code isn't effective, but I'll file an upstream issue and see if we can get that resolved.

(cherry picked from commit b0677f476f)
2023-06-13 10:12:07 -07:00
Sam Lantinga
7db23f4ef1 Fixed joystick vendor detection in Linux automatic gamepad mapping
(cherry picked from commit 071d1e29dd)
2023-06-13 10:11:55 -07:00
Simon McVittie
36ff6327b0 linux: Improve gamepad mapping heuristic to accept Android conventions
This heuristic for gamepads without a more specific mapping already
tried two incompatible conventions for handling triggers: the Linux
Gamepad Specification uses hat switch 2 for the triggers (for whatever
reason), but the de facto standard set by the drivers for older Xbox
and Playstation controllers represents each trigger as the Z-axis of
the nearest analog stick.

Android documentation encourages Bluetooth gamepad manufacturers to use
a third incompatible convention where the left and right triggers are
represented as the brake and gas pedals of a driving simulator
controller. The Android convention also changes the representation of
the right stick: instead of using X and Y rotation as a second pair
of axes, Android uses Z position as a second horizontal axis, and
Z rotation as a second vertical axis.

Try to cope gracefully with all of these. This will hopefully resolve
the issue described in #5406 (when using unpatched kernels).

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cf1dc66e2c)
2023-06-13 05:46:01 -07:00
Simon McVittie
26a38a0b20 linux: Reduce magic numbers when mapping gamepad axes
The bitfield `mapped` has two different sets of meanings, depending
whether we're setting up the triggers or the d-pad. Represent them
as symbolic constants rather than opaque integers.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c4d49fadd4)
2023-06-13 05:45:43 -07:00
Sam Lantinga
b3e1fd97b8 Fixed enumerating Steam Controllers on iOS
(cherry picked from commit dec0dbff13)
2023-06-13 05:44:34 -07:00
Sam Lantinga
c77aaa5d99 Fixed n3ds build
(cherry picked from commit d95dbe78bb)
2023-06-12 15:41:09 -07:00
Sam Lantinga
e4e0a12901 Reduce the chance of destroying the joystick mutex while it's in use
Fixes https://github.com/libsdl-org/SDL/issues/7811

(cherry picked from commit 6390165fd4c193631d6780758a4aeec0d02b90eb)
2023-06-12 15:31:16 -07:00
Ryan C. Gordon
2afb49ba9a cocoa: Warp mouse to center of window before enabling relative mouse.
This prevents the case where the mouse might be at the edge of the
window when enabling relative mode, which confuses macOS, at it
might believe the user is attempting to resize the window.

Fixes #6994.
2023-06-11 12:47:26 -04:00
Ozkan Sezer
154ad6faa9 SDL_dynapi.c: minor cosmetics. 2023-06-10 20:50:10 +03:00
Sam Lantinga
2aa8525ecb Fixed build 2023-06-10 09:29:09 -07:00
Sam Lantinga
36033e3832 Make it clear that you can't mix 2D rendering and the window surface API
Also added functions to query and destroy the window surface so you can switch between modes if you want.

See https://github.com/pygame-community/pygame-ce/issues/2190 for more details.
2023-06-10 08:54:36 -07:00
Sam Lantinga
320f3fffbe Fixed querying device info on the MOBAPAD M073
The query packet needs to contain valid rumble data in order to be accepted by the controller.

Fixes https://github.com/libsdl-org/SDL/issues/7788

(cherry picked from commit 5490873daa)
2023-06-09 18:43:14 -07:00
Sam Lantinga
30b4d90f1c Only update the serial number if it hasn't already been set
This fixes the serial number for Nintendo Switch Pro, which is queried from the hardware in device initialization, and was later clobbered by the USB string which isn't correct.

(cherry picked from commit 2042e9c4e3)
2023-06-09 17:36:06 -07:00
Sam Lantinga
1cdd6dc829 Fixed reading input from the Razer Atrox Arcade Stick using Windows Gaming Input
(cherry picked from commit 172cfca51332a845abf9c141ae56aa121fe4ada5)
2023-06-09 14:36:12 -07:00
Ozkan Sezer
f5b3247aae further mouse relative motion fix for os/2 (thanks Andrey Vasilkin) 2023-06-08 03:40:32 +03:00
Ryan C. Gordon
aa536217b3 x11: check if window size/position has changed during SDL_ShowWindow.
Fixes #4216.

(cherry picked from commit 49b5cfa6c5)
2023-06-07 15:46:59 -04:00
Anonymous Maarten
14f4fd3f11 git commit -m "cmake: set maximum policy to 3.5
This fixes the following warning when configuring with CMake 3.27+:
```
CMake Deprecation Warning at CMakeLists.txt:3190 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
```
2023-06-07 20:35:32 +02:00
Ozkan Sezer
b1324fbc9f fixed os/2 mouse relative motion not working (thanks Andrey Vasilkin,)
for issue reported at https://github.com/bitwiseworks/SDL2-os2/issues/5
2023-06-05 11:50:50 +03:00
Sam Lantinga
4700fbcbdf Don't bother re-encoding Latin1 characters in the ASCII range
(cherry picked from commit 6150b5b3cb)
2023-06-04 05:40:07 -07:00
Eddy Jansson
2660da6f5c Always allocate zt in output of SDL_iconv_string()
Before this, the function could not be used on buffers,
as it would not account for the zero-termination unless
it was included in the input.

(cherry picked from commit 5f5abb6805)
2023-06-04 05:17:15 -07:00
Sam Lantinga
7c86d96e86 Fixed SDL_iconv_string() truncation when handling SDL_ICONV_E2BIG
(cherry picked from commit c369b90019)
2023-06-04 05:14:44 -07:00
Ozkan Sezer
a1dea11d32 fix MSVC build error. 2023-06-04 14:29:10 +03:00
Sam Lantinga
bfef7c302c Only convert the result of XLookupString() if it's not already UTF-8
Fixes https://github.com/libsdl-org/SDL/issues/7766

(cherry picked from commit 491ae20d96)
2023-06-04 02:54:21 -07:00
Sam Lantinga
b9d1c483b9 Fixed building with the 16.1.4479499 Android toolchain 2023-06-03 23:55:56 -07:00
Sam Lantinga
dc94cca8dd Fixed typo in cherry-pick (thanks @HadesD!) 2023-06-03 11:57:08 -07:00
Sam Lantinga
97fe777ab4 Steam uses a different VID/PID for the Steam Virtual Gamepad on Windows
(cherry picked from commit 6815e75caf)
2023-06-03 11:40:58 -07:00
Sam Lantinga
f1bad83a21 Revert "Fixed detection of the Steam Virtual Gamepad on macOS"
This reverts commit 7aa28ce279.

Steam has been updated to send a version of 1 to avoid conflicts with controllers that report a version of 0.
2023-06-03 11:36:38 -07:00
Sam Lantinga
7aa28ce279 Fixed detection of the Steam Virtual Gamepad on macOS
(cherry picked from commit 5fcd70578b)
2023-06-02 18:39:22 -07:00
Sam Lantinga
c89a460672 Fixed build if SDL_JOYSTICK_RAWINPUT_MATCHING isn't enabled
(cherry picked from commit 7c55845c80)
2023-06-02 11:20:55 -07:00
Sam Lantinga
e3bfacde3e Don't use raw input while Remote Desktop is active
Raw input will not send game controller events while Remote Desktop is active, so dynamically switch between XInput and raw input when Remote Desktop state changes.

Fixes https://github.com/libsdl-org/SDL/issues/7759

(cherry picked from commit 767507fcf6)
2023-06-02 11:19:44 -07:00
Sam Lantinga
9c05098ed9 Fixed WGI immediately being correlated with raw input devices with no input
The at rest match state is 0x0000008800000000, not 0

(cherry picked from commit e8b5b4881c)
2023-06-02 09:39:57 -07:00
Alibek Omarov
c395240425 hints: clarify support for comma-separated values for QtWayland orientation that's available since 2.0.22
Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
2023-06-02 07:41:08 -07:00
Alibek Omarov
68e3e99087 wayland: reset orientation bitmask before reading values from hint on QtWayland
Signed-off-by: Alibek Omarov <a1ba.omarov@gmail.com>
2023-06-02 07:41:08 -07:00
Ozkan Sezer
7f7ea909bc testautomation_guid.c: fix integer warning in 32 bit builds. 2023-05-31 04:50:02 +03:00
Ryan C. Gordon
379a6f4dab x11: Attempt to wait for SDL_MaximizeWindow to complete before returning.
Fixes #7070.
2023-05-30 17:04:31 -04:00
Ryan C. Gordon
d275851dfb windows: Don't allow non-resizable windows to be maximized.
Fixes #6346.
2023-05-29 14:47:53 -04:00
Ryan C. Gordon
a9ded76dff VisualC: turn on multi-processor compilation.
This makes SDL2 build in 12 seconds, instead of 50, on my Windows
workstation, with Visual Studio.
2023-05-29 14:47:52 -04:00
Sam Lantinga
5007b96363 Fixed build warning 2023-05-28 19:23:56 -07:00
Sam Lantinga
b2e88ecfeb Disable SDL_JOYSTICK_RAWINPUT_XINPUT
Apparently when using the Xbox One Wireless Adapter, using XInput at the same time as raw input will cause the controller to turn off immediately after connecting. This appears to be a bug in the Windows 11 driver stack, but since WGI provides all the extended functionality we need, this can be turned off for now.

Fixes https://github.com/libsdl-org/SDL/issues/3468
2023-05-28 18:41:21 -07:00
Anonymous Maarten
d6cd450624 windows: SDL_Delay expects a 32-bit integer 2023-05-27 02:34:41 +02:00
Anonymous Maarten
e875775940 windows: SDL_immdevice needs SDL_timer.h include 2023-05-27 02:10:18 +02:00
Anonymous Maarten
72606d97e6 cmake: allow #include "SDL2/SDL.h.h" when using SDL2 as subproject 2023-05-27 01:48:30 +02:00
Ryan C. Gordon
48e71ae87b wasapi: Deal with HDMI or DisplayPort-based audio devices.
They can vanish for UP TO EIGHT SECONDS...!

This is for devices that connect to HDMI/DisplayPort/etc, where it
presumably has to wait for a display to get up and running before it
can play audio through it, so one can see the audio device fail when
changing display modes, or the system returning from sleep. Since this
can be triggered by a game changing video resolutions at startup (either
before or after opening the audio device!), it's important to deal with.

In normal conditions, it shouldn't take this long to open or recover an
audio device, but this is better than unexpectedly losing the device
in this situation.

Fixes #7044.
Fixes #5571.
2023-05-26 19:15:28 -04:00
Sam Lantinga
7308325559 Added support for printing wide strings using "%ls" syntax
(cherry picked from commit 128ca70160)
2023-05-26 14:59:30 -07:00
Ozkan Sezer
9dea06f5b5 fix mingw build failures in CI with clang-tidy.
(cherry-picked from commit a8a72de6fb)
2023-05-26 23:55:04 +03:00
Anonymous Maarten
c68976360d Fix -Wunused-function warning when configuring with -DSDL_X11_XINPUT2=OFF 2023-05-26 15:28:58 -04:00
Ryan C. Gordon
a535cc62a0 video: Only specify some GL context attributes if not the explicit default.
Just in case it upsets some OpenGL drivers unnecessarily.

Fixes #7730.

(cherry picked from commit d4bc393efe)
2023-05-25 10:10:03 -04:00
Sam Lantinga
63b8af3558 Disable unused local typedefs warning
This triggers on gcc 4.8.4 for compile time asserts inside of functions

Fixes https://github.com/libsdl-org/SDL/issues/7732

Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
2023-05-24 04:45:40 +03:00
Sam Lantinga
3f1fd5abff Updated source to match SDL function prototype style 2023-05-23 10:59:03 -07:00
Sam Lantinga
92f72682e7 Document the Android SDK versions checked in Java code
(cherry picked from commit b48b1ce500)
2023-05-23 08:45:43 -07:00
Frank Praznik
891c89eeb8 Fix unused variable warnings 2023-05-23 11:15:48 -04:00
Frank Praznik
e2b8d96529 wayland: Validate surfaces and window data before sending touch events
Ensure that incoming touch events originate from valid surfaces owned by SDL and have proper window data before forwarding them to the touch subsystem, or the window focus pointer that is sent with the event may not be a pointer to an SDL window.
2023-05-23 10:31:28 -04:00
Sam Lantinga
78a92b4f9d Fixed duplicate Joy-Con controllers on macOS
If both Apple and HIDAPI drivers see the controller, HIDAPI will be preferred.

Fixes https://github.com/libsdl-org/SDL/issues/7479

(cherry picked from commit 61ef4efdfa)
2023-05-22 14:52:05 -07:00
Sam Lantinga
7b2b99a996 Fixed handling the Saitek P3600, which doesn't use the Xbox 360 controller protocol
(cherry picked from commit cf0abf9911)
2023-05-22 12:42:05 -07:00
Sam Lantinga
b6d051e226 Fixed reporting backspace key if there is no text in the edit buffer (thanks @312937!)
This workaround isn't necessary at API 30 and above.

Fixes https://github.com/libsdl-org/SDL/issues/7039

(cherry picked from commit c971795954)
2023-05-22 12:01:52 -07:00
Sam Lantinga
0ad0347acb Use numeric codes for Android versions, to avoid SDK dependencies
(cherry picked from commit 3f6b2d1a61)
2023-05-22 12:01:52 -07:00
Sam Lantinga
a2f4783e75 Don't map the top keyboard row to numbers when using the one-handed DVORAK layouts (thanks @tormol!)
Fixes https://github.com/libsdl-org/SDL/pull/5127
2023-05-22 11:30:42 -07:00
Caleb Cornett
2001a891c4 Fix Xbox link error from IsRectEmpty
(cherry picked from commit 376a3cd100)
2023-05-21 19:11:25 -07:00
M. P. Halpin
1ee9a437f9 Stop beep when running iOS apps on ARM-based Macs
(cherry picked from commit bbf38bbbc3)
2023-05-20 11:21:13 -07:00
Sam Lantinga
69644346ac Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
Fixes https://github.com/libsdl-org/SDL/issues/7160
2023-05-20 11:09:36 -07:00
Sam Lantinga
00b87f1ded Make sure the sentinel is at the end of the current event pump cycle
If we're waiting, it's possible to not get any events, then add the sentinel, then pump again and then add another sentinel. We want to make sure we only have one sentinel and that it's at the end of the currently pumped events.

Testing:
* Verified test case in https://github.com/libsdl-org/SDL/issues/6539
* Verified test case in https://github.com/libsdl-org/SDL/issues/5350

Fixes https://github.com/libsdl-org/SDL/issues/6539
2023-05-20 10:27:48 -07:00
Sam Lantinga
beca41480d Undo name change for the controller list
(cherry picked from commit f60622c510)
2023-05-19 14:27:06 -07:00
Sam Lantinga
43b12fd9bc Moved the controller list out so it can be included elsewhere
(cherry picked from commit 24007b00b2)
2023-05-19 14:23:57 -07:00
Sam Lantinga
e8ec8ba1d4 Added support for the Astro C40 in Xbox 360 mode
(cherry picked from commit a4b4dff4a2)
2023-05-19 14:23:57 -07:00
Ozkan Sezer
feeec90873 test/testgles2_sdf.c: type fixes from commit e26e893daf, style clean-up. 2023-05-19 17:00:24 +03:00
Anonymous Maarten
d361acdd4e testgles2_sdf: build with CMake + fix build errors/warnings 2023-05-19 15:24:52 +02:00
Ozkan Sezer
92a487f2e4 style fixes for SDL_PROC macros. 2023-05-19 14:10:02 +03:00
Ryan C. Gordon
df9d0fb332 power: On Linux, compare status strings as case-insensitive.
In case something reports "Device" when we expected "device", etc.

Reference Issue #6835.
2023-05-18 13:26:55 -04:00
Ryan C. Gordon
4a0b9522b6 audio: Load .WAV files with format->blockalign==0.
In theory this is illegal, but legit wavefiles in the field do it, and
it's easy to bump it to 1 for general purposes.

Formats with more specific alignment requirements already check for them
separately.

Fixes #7714.

(cherry picked from commit 2e646c7141)
2023-05-17 20:09:28 -04:00
Ryan C. Gordon
32999798e0 dynapi: Accept a comma-separated list of libraries to attempt to load.
First one to load and have the necessary symbol is the one we accept,
if any. Once we accept one, we won't try loading others.

Fixes #7613.
2023-05-17 20:03:17 -04:00
valid-ptr
424bc4bcf7 SDL emscripten port: preventDefault should not be called on mousedown. Otherwise mouseup will not be fired outside iframe in Chrome-based browsers 2023-05-17 12:30:32 -07:00
Ryan C. Gordon
0eea92c8fc blit: Add a case for 8-bit blits that sdl12-compat exposed.
sdl12-compat can get into a state where a color-keyed surface is
marked for blending, but wants to blend with full alpha (which
is the same as _not_ blending), so rather than fail to find a
blitter in that case, it just selects the colorkey blitter.

Reference https://github.com/libsdl-org/sdl12-compat/issues/233
2023-05-16 14:38:44 -04:00
Sam Lantinga
d42c303b24 Check to make sure the Windows joystick device has buttons and axes
This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10

(cherry picked from commit 642504bc59)
2023-05-15 21:44:20 -07:00
Sam Lantinga
237348c772 Changed all variadic macros into fixed (thanks @Wohlstand!) 2023-05-10 06:29:35 -07:00
Ryan C. Gordon
86786ed544 coreaudio: Flush/stop the AudioQueue before disposing of it.
Otherwise, a CoreAudio thread lingers forever, and coreaudiod eats CPU
until the SDL process terminates.

Fixes #7689.
2023-05-08 14:25:01 -04:00
Sam Lantinga
de93728674 Removed redundant __powerpc__ check
(cherry picked from commit b6df25c334)
2023-05-06 08:44:48 -07:00
Jeremy Rand
5e74365e55 SDL_blit_N.c: Move ppc64le swizzle outside of loop
An in-place swizzle mutation was erroneously inside of a loop, which
caused each consecutive 4-pixel vector to alternate between correct and
incorrect endianness.

The bug was introduced in 715e070d29.

Thanks to RobbieAB for reporting the bug.

Fixes https://github.com/libsdl-org/SDL/issues/3428

(cherry picked from commit 9142292f4a)
2023-05-06 08:39:59 -07:00
Loc(Elliot)
3e64fec9f4 Fix bug memory acess
Bitmap is not initialized before use, that cause segmentation fault on function use it. Fix by allocate memory before use.
2023-05-04 07:01:25 -07:00
Sam Lantinga
707e9397ca Removed memset_pattern4() from SDL headers
This requires including string.h, which isn't always done, so this commit simplifies dependencies on macOS

Fixes https://github.com/libsdl-org/SDL/issues/3657
2023-04-30 21:38:29 -07:00
Sam Lantinga
f72213c4ac By default, OpenBSD uses Linux controller mappings
Fixes https://github.com/libsdl-org/SDL/issues/7609

(cherry picked from commit 255c3b7c82)
2023-04-29 17:10:46 -07:00
Frank Praznik
132b88749c wayland: Destroy proxy wrappers and callbacks before event queues
Destroy any proxy wrappers and callbacks before the associated event queues to silence libwayland warnings about destroying the queues while proxies are still attached.
2023-04-27 13:08:59 -04:00
Linus Probert
8b39eb9b1f wayland: Fixes a memory leak wheere primary selection isn't freed
(cherry picked from commit 43f65a6ef0)
2023-04-24 12:00:16 -07:00
Ozkan Sezer
0f2322acfc hidapi/mac: replace sprintf uses with snprintf.
Reference issues:
-  https://github.com/libusb/hidapi/pull/509
-  https://github.com/libusb/hidapi/pull/511

(cherry picked from commit ae9119c36b)
2023-04-24 10:46:49 -07:00
Ozkan Sezer
5f344c17c2 hidapi/mac: import mainstream commit c1b9d2ad
c1b9d2ad98
Properly handle the close of run loop on macOS
(https://github.com/libusb/hidapi/pull/522)
- as per documentation `kCFRunLoopRunStopped` should be handled once the runloop is closed via `CFRunLoopStop`;
- if it is not handled - a race condition/crash may happen on the latest macOS when a device gets disconnected while being open;

(cherry picked from commit 62d1a2c836)
2023-04-24 10:46:49 -07:00
Mingjie Shen
a688ecd6fa Check return value of SDL_malloc()
(cherry picked from commit a4604cb0d6)
2023-04-23 12:28:54 -04:00
Sam Lantinga
120bc77e91 Report PS3 accelerometer values in m/s2 instead of Gs
(cherry picked from commit 0467301baf)
2023-04-19 13:12:38 -07:00
Anonymous Maarten
535ec1a921 cmake: allow users of sdl2-config.cmake to not add -mwindows to the link options 2023-04-18 14:10:12 -04:00
Sam Lantinga
7ec9a4385a More defensive coding against dangling device pointers
(cherry picked from commit acadb6f873)
2023-04-06 13:21:44 -07:00
Sam Lantinga
6d7269815b Clarified the expected sensor value when a game controller is at rest
(cherry picked from commit 1a20ccb289)
2023-04-06 09:55:43 -07:00
Sam Lantinga
cb0cf14155 The latest Armor-X Pro firmware update fixes the sign on the Z axis of the sensors
(cherry picked from commit 558bbbb07a)
2023-04-06 09:55:39 -07:00
Cyril Dubet
7914234b26 Fix key code names for ISO keyboard layouts
(cherry picked from commit 60dcaff7eb)
2023-04-05 17:03:42 -07:00
Sam Lantinga
51dcc3bb0b The macOS minimum deployment target is now 10.11
Xcode 14.3 does not allow targeting 10.9, the minimum recommended version is 10.13 and the minimum possible version is 10.11.

(cherry picked from commit 73b2faea4e)
2023-04-05 11:40:50 -07:00
Sam Lantinga
f6363fde9a Fixed crash if joystick->hwdata != NULL && device->driver == NULL
This should never happen, but we're seeing it in the wild, so make sure that we can never call into a NULL device driver.

(cherry picked from commit e13b74ccf0)
2023-04-05 11:24:55 -07:00
Ozkan Sezer
f633915443 fix build after commit 22685556e5. 2023-04-05 02:10:56 +03:00
Sam Lantinga
57043825ba Fixed crash if dbus can't be initialized
(cherry picked from commit cf2c6fa58d)
2023-04-04 12:35:30 -07:00
Sam Lantinga
22685556e5 Don't probe for PlayStation controllers when we already know the controller type
Fixes https://github.com/libsdl-org/SDL/issues/7556

(cherry picked from commit 655a07bdd8)
2023-04-04 12:35:20 -07:00
Sam Lantinga
f444eac557 Fixed analog triggers on the DualSense controller
(cherry picked from commit a67d410501)
2023-04-04 12:35:20 -07:00
Jerome Duval
eb0d214c17 Haiku: use a BLooper for events.
only create a BApplication when it doesn't already exist.
2023-03-30 10:20:11 -07:00
Frank Praznik
55f74c3285 x11: Don't allow the changing of certain scancodes
The X11 driver uses scancodes derived from keysyms to map the scancodes for extended keys to the physical keyboard, however, this can be incorrect when using certain XKB options (e.g. caps:swapescape), which changes the keysyms emitted by certain keys, but does not imply that their scancodes or positions should be altered. Mark selected scancodes as being non-remappable so that their scancodes aren't changed by toggling XKB mapping options.
2023-03-30 11:20:28 -04:00
Wohlstand
2aeac8de51 include: Fixed a C++-style single line comment.
78725dc0cd
2023-03-29 21:43:15 +00:00
Stephen Kitt
6d01ffcd94 Split up CFLAGS construction so it can be overridden
CFLAGS currently takes care of two aspects of the build: optimisation
and debug symbols on one hand, the include path on the other. The
former should be overridable by users, the latter shouldn't.

This patch moves the include path flag to CPPFLAGS, which is
appropriate for pre-processor directives. This leaves CFLAGS with only
overridable flags.

Based on a patch by Roflcopter4:
https://github.com/joncampbell123/dosbox-x/pull/3850

Signed-off-by: Stephen Kitt <steve@sk2.org>
2023-03-29 07:26:34 -07:00
Sam Lantinga
c2ee45f5ff The Xinmotek Controller is used in multiple products with different mappings
The mapping included here is for the Ultimate Atari Fight Stick

(cherry picked from commit f1099f8e70)
2023-03-28 15:16:07 -07:00
Sam Lantinga
0bf63175ab Fixed gyro values for the Armor-X Pro controller
(cherry picked from commit 8df7b4d853)
2023-03-28 14:44:59 -07:00
Sam Lantinga
d043c8535b Fixed the accelerometer and gyro axes for the Armor-X Pro controller
(cherry picked from commit 37517557ae)
2023-03-28 12:29:33 -07:00
Anonymous Maarten
d2a2787783 Fix remaining -Wimplicit-fallthrough warnings 2023-03-28 19:24:33 +02:00
Anonymous Maarten
85fecbb10b video: fix warnings about unused variables when building without duff's loop
(cherry picked from commit 0c3777d566)
2023-03-28 10:21:36 -07:00
Anonymous Maarten
ec3e333fb8 testautomation_audio: fix -Wimplicit-fallthrough warning
(cherry picked from commit 11c70406c3)
2023-03-28 10:21:36 -07:00
Anonymous Maarten
1402d13556 video/blit: fix -Wimplicit-fallthrough warnings
(cherry picked from commit f7961b7c9a)
2023-03-28 10:21:35 -07:00
Anonymous Maarten
03c239ded9 testsurround: fix channel names
Used table in include/SDL3/SDL_audio.h as reference.

(cherry picked from commit e1b8a03239)
2023-03-28 10:21:35 -07:00
Sylvain
16c9bad786 Safety fix: clear "_this->wakeup_window" when destroying the window
(cherry picked from commit c838ccf0e3)
2023-03-28 08:29:24 -07:00
Sylvain
6574e5eb57 Safety fix: clear "_this->current_glwin" when destroying the window
(cherry picked from commit 0c048d98af)
2023-03-28 08:29:23 -07:00
Sylvain
4fa21ee5ed Fixed bug #7515 - Window still grabbed after destroying 2023-03-28 09:43:34 +02:00
Sam Lantinga
8bfbda1eab Fixed the accelerometer sensitivity for the Armor-X Pro controller
(cherry picked from commit 8029a767ee)
2023-03-27 14:33:59 -07:00
Sam Lantinga
93c289b475 Increased precision for PS4 sensor data conversion
(cherry picked from commit 3340864786)
2023-03-27 14:33:56 -07:00
Pierre Wendling
ed5a343d25 SDL_hidapi_steam.c: Fix compilation under c2x.
When N2935 is implemented, the enum breaks compilation. Use a #define of
the SDL booleans instead.

(cherry picked from commit 975039ce0d)
2023-03-27 09:02:46 -07:00
Pierre Wendling
0081174689 Fix clang-tidy error on LLVM 16.
Starting LLVM 16, clang-diagnostic-implicit-function-declaration is
treated as an error.
(cherry picked from commit ea093378a2)
2023-03-27 12:51:21 +03:00
Anonymous Maarten
cd64e0b6e3 SDL_blit_copy: Don't call potentially FPU using SDL_memcpy in SDL_memcpyMMX 2023-03-27 06:13:28 +00:00
Anonymous Maarten
51c10bef0b cmake: disable warnings in libm + warning about EMMS instruction
SDL_BlitCopyMMX ends with _mm_empty(), so the MMX state should be emptied.

(_mm_empty is the intrinsic function for emms)
2023-03-27 06:13:28 +00:00
Anonymous Maarten
d1dc195208 Implement _intel_fast_(memcpy|memset)
The classic Intel compiler generates calls to these functions when
building the SDL library with SDL_LIBC=OFF.
2023-03-27 06:13:28 +00:00
Anonymous Maarten
5e5b029d6c cmake: add /Q_no-use-libirc flag when building a no-libc library
The new Intel LLVM library needs this because when building SDL2
in release mode.
2023-03-27 06:13:28 +00:00
Anonymous Maarten
b58285b7ed ci: test with (old) Intel compiler + (new) oneAPI compiler 2023-03-27 06:13:28 +00:00
Anonymous Maarten
e5ebbdafd4 cmake: add support for building with Intel C compiler 2023-03-27 06:13:28 +00:00
Anonymous Maarten
977781d3f4 testautomation_math: avoid equality tests with INFINITY
Fixes this warning:
 warning: comparison with infinity always evaluates to false in fast floating point modes [-Wtautological-constant-compare]
2023-03-27 06:13:28 +00:00
Anonymous Maarten
984af1a725 cmake: new LLVM based Intel compiler does not recognize MSVC's /MP 2023-03-27 06:13:28 +00:00
Anonymous Maarten
5aa76de35f cpuinfo: use __cpuidex instead of __cpuid
The classic Intel Compiler does not clear the ecx register prior
to executing the cpuid opcode.
2023-03-27 06:13:28 +00:00
Anonymous Maarten
1158cff9ea cmake: increase threshold for stack probes
The /Gs argument controls the number of bytes that local variables
can occupy before a stack probe is initiated.
By setting it to a huge value, no calls to __chkstk are inserted.

This change is needed for the classic Intel C compiler to build SDL
with -DSDL_LIBC=OFF.
2023-03-27 06:13:28 +00:00
Anonymous Maarten
ae3a34a388 byteswap: Don't use intrinsic byteswap functions with Intel C compiler
It reroutes intrinsic _byteswap_u(short|long|int64) call to libc function.
2023-03-27 06:13:28 +00:00
Frank Praznik
c0824cd49a events: Increase the size of the name buffer when logging events
Event names have grown in length and are occasionally truncated when being logged (e.g. SDL_EVENT_WINDOW_PIXEL_SIZE_CHA). Increase the event name buffer size to handle the longer names.

(cherry picked from commit 203a2a76fc)
2023-03-26 22:01:17 -07:00
capehill
6ed29f47c9 testgles2_sdf: Call correct function to get shader info log
(cherry picked from commit b8c88cc584)
2023-03-26 22:00:41 -07:00
Karl Hedberg
9ed1b778ed Made the Android documentation more clear and understandable (#7535)
(cherry picked from commit 11142ec256)
2023-03-25 15:11:51 -07:00
Bartłomiej Dach
b970dd1beb Android: Fix mismatching JNI method signature
Another regression from commit dca3fd8307,
which was a backport of commit de3909a190
from SDL3 to SDL2. This time the regression is much less apparent,
however, due to two reasons:

- It only appears when the SDL project is ran on an actual device
  due to magic stringage.

- More importantly, the regression was partially hidden due to
  the nature of de3909a190.

  The commit which was backported added a single `I` to the JNI method
  signature in `SDL_android.c`, representing the added `int axis_mask`
  parameter. The parameter was added to both SDL2 and SDL3.

  However, notably, that `I` was added *after* commit
  fcafe40948, which removed the
  `int nballs` parameter from the joystick API, but only from the SDL3
  branch.

  Therefore, in totality, what should really have been a merge conflict,
  was obscured by the fact that the SDL3 branch ended up having
  a net-identical JNI signature to the SDL2 branch, due to having
  one bool param removed and one added - while, in fact, the SDL2 branch
  needed one bool param added and none removed.
2023-03-25 15:08:33 -07:00
Bartłomiej Dach
576df87240 Android: Fix missing type in SDLControllerManager
The missing type in question is causing compilation failures.
The error was introduced in dca3fd8307,
which was a backport of commit de3909a190
from SDL3 to SDL2.

Because `int nballs` was removed as a parameter from the controller
API in SDL3 in revision fcafe40948,
this change is only applicable to the SDL2 branch.
2023-03-25 15:08:33 -07:00
Sylvain
2dddaa7dc9 backport x11/sdl2 fixes
4b1378f

X11: fix size/position (test video_setWindowCenteredOnDisplay)

this fix x11 backend to correctly pass video_setWindowCenteredOnDisplay()

    get border values early (eg status bar)
    wait for size/position change to get valid values

d4d26e0

testautomation_video: if SDL_SetWindowSize/Position isn't honored, we should check there is an event
x11: send the events if various occasions
2023-03-25 10:27:17 +01:00
Ozkan Sezer
45a6ad8e57 wikiheaders.pl: make it work with older perl versions, e.g. 5.10. 2023-03-24 11:56:40 +03:00
Sam Lantinga
b57a6a1adf Added gamepad mapping for Flydigi Vader 2 with the latest firmware (6.0.4.9)
(cherry picked from commit ed0937598e)
2023-03-18 11:36:50 -07:00
Ivan Mogilko
d78072fcd4 Fixed SDL_RenderSetVSync does not update flags if simulated vsync is on
This lets the user to correctly detect current vsync state by reading SDL_RendererInfo.
Also fixes SetVSync's return value check (it may be positive for error too).
2023-03-17 14:55:04 -07:00
Ryan C. Gordon
446e0943da wasapi: Force WIN_CoInitialize duing device open.
Otherwise this won't work if you open a device on a background thread.

Fixes #7478.
2023-03-17 08:44:19 -07:00
Sylvain
23bce27b26 Change SDL_BLENDMODE_MUL for gl renderers
Add FIXME for PSP and DirectFB
2023-03-16 20:27:09 +01:00
Sylvain
c078dfcf6b Refresh generation of SDL_blit_auto.c after simplifying sdlgenblit.pl 2023-03-16 20:27:09 +01:00
Sylvain
18c4db678b Simplify SDL_BLENDMODE_MUL in sdlgenblit.pl 2023-03-16 20:27:09 +01:00
Sylvain
7d26ba754a Simplify SDL_BLENDMODE_MUL 2023-03-16 20:27:09 +01:00
Sylvain
bd70ce7f94 Refresh generation of SDL_blit_auto.c 2023-03-16 20:27:09 +01:00
Anonymous Maarten
ce4c54e2b2 cmake: get_filename_component(EXT) retturns extension including leading dot 2023-03-15 14:55:56 +01:00
Sam Lantinga
57ae9f466d Ignore the PS4 packet CRC if it's not being set correctly
This fixes handling the 8BitDo SN30 Pro with the 2.00 firmware in PS4 mode

Fixes https://github.com/libsdl-org/SDL/issues/7270

(cherry picked from commit 3951cae4a5)
2023-03-13 20:00:19 -07:00
Rudolf Polzer
dca3fd8307 Android: indicate gamepaddb entries where axis order changed.
Axis order was changed in 6f1f586086 to improve
default mappings.

(cherry picked from commit de3909a190)
2023-03-11 13:01:50 -08:00
Sam Lantinga
ab1670386f Added support for the trigger buttons on the Victrix Pro FS for PS5
(cherry picked from commit 8d7e61ea42364c256b76e7f6f2b6d6f90742bcb7)
2023-03-10 15:46:22 -08:00
Sam Lantinga
76e9d64b36 Removed space between sizeof and parentheses 2023-03-10 08:13:51 -08:00
Sam Lantinga
e9f9cb29fc Fixed build warning on Android
(cherry picked from commit 2af6f4a3e4)
2023-03-10 08:12:28 -08:00
Stephen Kitt
3e1d7e6a14 Specify bash for androidbuildlibs.sh
This script relies on string indexes in parameter expansions, which
aren't suppored by /bin/sh (e.g. dash).

Based on a patch by Roflcopter4:
https://github.com/joncampbell123/dosbox-x/pull/3850

Signed-off-by: Stephen Kitt <steve@sk2.org>
(cherry picked from commit bbfd5b3fb2)
2023-03-10 07:38:28 -08:00
Qrox
ef347776c2 Uses integer arithmetics in SDL_ResampleAudio
- Avoids precision loss caused by large floating point numbers.
- Adds unit test to test the signal-to-noise ratio and maximum error of resampler.
- Code cleanup

(cherry-picked from commit 20e17559e5)
2023-03-10 18:37:00 +03:00
Ozkan Sezer
5e35309913 fix bad merge of sizeof style patch 2023-03-10 08:32:24 +03:00
Sam Lantinga
71dc7169d9 Added header for SDL_Delay() 2023-03-09 17:18:40 -08:00
Sam Lantinga
1e6ffc6294 Removed a duplicate delay accidentally added during code refactor
(cherry picked from commit 926db1bd54)
2023-03-09 16:13:19 -08:00
Sam Lantinga
3f00fa16c6 Wait for the GCController framework to see IOKit devices
It occasionally takes a few millseconds for the GCController framework to handle the device notification and set up the device

Fixes the duplicate controller issue in https://github.com/libsdl-org/SDL/issues/6686

(cherry picked from commit 645823fc90)
2023-03-09 16:13:19 -08:00
Sam Lantinga
0d76380042 Code style: changed "sizeof foo" to "sizeof(foo)" (thanks @sezero!)
(cherry picked from commit c6443d86c9)
2023-03-09 15:23:59 -08:00
Sam Lantinga
46d143376a If the client rect is empty, use the last known window size
This happens on Windows 11 with fullscreen desktop windows when the desktop is brought up with the Windows+D shortcut.

Fixes https://github.com/libsdl-org/SDL/issues/7419

(cherry picked from commit 2ca727aec6)
2023-03-09 10:39:43 -08:00
Ozkan Sezer
22de91a947 Removed guard around the enabled assertions support code
Otherwise, SDL_assert_always() wouldn't work.

Fixes https://github.com/libsdl-org/SDL/issues/7433
2023-03-09 20:51:50 +03:00
Deve
1c2f825230 Fixed incorrect modifier keys handling on macOS
(cherry-picked from commit 45a58b7882)
2023-03-09 20:28:51 +03:00
Sam Lantinga
d9c07d9ef7 Fixed the documentation for SDL_SetRelativeMouseMode()
(cherry picked from commit fb0c3197e0)
2023-03-08 22:33:23 -08:00
Frank Praznik
8f7427c158 tests: Always set valid dimensions for the fullscreen mode 2023-03-08 19:46:37 -05:00
Frank Praznik
6a999d16fa wayland: Always use a scale factor of 1 for exclusive fullscreen emulation 2023-03-08 19:46:37 -05:00
Lokathor
cfd6b34b8f Make mappings for "Retrolink SNES Controller" with SDL_GAMECONTROLLER_USE_BUTTON_LABELS both on and off
I've only tested this on windows, but I went ahead and made the same changes for linux and mac because I assumed it's the same there and that we'd want to keep the three platforms in sync.

(cherry picked from commit b8bc4a234b)
2023-03-08 16:44:30 -08:00
Ozkan Sezer
a70964aaf4 fix SDL_FindFreePlayerIndex so it can really return -1. 2023-03-08 20:00:50 +03:00
Sam Lantinga
35c13196f0 Fixed uninitialized variable 2023-03-08 08:40:38 -08:00
Ozkan Sezer
bc87983310 tests: added -DHAVE_SIGNAL_H to CFLAGS in watcom makefiles 2023-03-08 18:56:50 +03:00
Sam Lantinga
f5c0760c6b Disassociate the SDLOpenGLContext from the view before deleting it
If we don't do this, the view will be blanked even if another context is current and rendering from that context won't be visible.

Fixes https://github.com/libsdl-org/SDL/issues/4986
2023-03-08 01:15:21 -08:00
Sam Lantinga
63e6c19b7d Use SDL_GL_DeleteContext instead of Cocoa_GL_DeleteContext for context cleanup
That will make the current context NULL before deleting the context.
2023-03-08 01:13:00 -08:00
Sam Lantinga
1bd9ebf533 If we're not the current fullscreen window and we don't want to be fullscreen, don't touch the current video mode
Fixes an assertion in qemu on macOS, which creates multiple hidden windows:
2023-03-07 09:56:55.304 qemu-system-i386[9931:2984587] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'NSWindowStyleMaskFullScreen cleared on a window outside of a full screen transition. Called from (
	0   AppKit                              0x00000001968f77ac __25-[NSWindow setStyleMask:]_block_invoke + 140
	1   AppKit                              0x00000001968f76cc NSPerformVisuallyAtomicChange + 108
	2   AppKit                              0x00000001968f7580 -[NSWindow setStyleMask:] + 188
	3   libSDL2-2.0.0.dylib                 0x0000000106531328 Cocoa_SetWindowFullscreen + 568
	4   libSDL2-2.0.0.dylib                 0x0000000106501700 SDL_UpdateFullscreenMode + 1316
	5   libSDL2-2.0.0.dylib                 0x0000000106504270 SDL_SetWindowFullscreen_REAL + 328
	6   libSDL2-2.0.0.dylib                 0x000000010650117c SDL_FinishWindowCreation + 100
	7   libSDL2-2.0.0.dylib                 0x0000000106500998 SDL_CreateWindow_REAL + 1812
	8   libSDL2-2.0.0.dylib                 0x00000001063efd54 SDL_CreateWindow + 76
	9   qemu-system-i386                    0x00000001050aa600 sdl2_window_create + 192
	10  qemu-system-i386                    0x00000001050a9fa0 sdl2_2d_switch + 196
	11  qemu-system-i386                    0x0000000104e9c784 displaychangelistener_display_console + 524
	12  qemu-system-i386                    0x0000000104e9e36c register_displaychangelistener + 264
	13  qemu-system-i386                    0x00000001050ab6d0 sdl2_display_init + 304
	14  qemu-system-i386                    0x000000010505c870 qemu_init + 13380
2023-03-07 10:10:43 -08:00
Sam Lantinga
e0e79419b6 Fixed which window we check flags for when updating fullscreen mode 2023-03-07 10:08:55 -08:00
Sam Lantinga
8fc10ac95c Added mapping for the Xbox Elite Core controller connected via Bluetooth on Android
(cherry picked from commit d08338ddc5)
2023-03-06 15:37:52 -08:00
divVerent
91ad208d18 Fix Xbox One gamepad axis assignment on SDL_JOYSTICK_ANDROID API (#7405)
(cherry picked from commit 6f1f586086)
2023-03-06 15:37:41 -08:00
Anonymous Maarten
6c495a92f0 cmake: use compatible interface properties to disallow linking to a different version of SDL 2023-03-03 23:41:18 +01:00
Michal Suchanek
96a2a6b945 evdev_kbd: Use current keymap
keymap can change over time, caching the keymap causes wrong keys
returned when user changes keymap during runtime

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
2023-03-03 14:30:02 -08:00
Ozkan Sezer
fd4bb4154b dynapi: replace uses of deprecated SDL_assert_state and SDL_assert_data 2023-03-03 03:01:02 +03:00
Ryan C. Gordon
46945354cc dataqueue: Make thread safe.
Each data queue gets its own mutex and each function obtains it.

Fixes #7390.

(cherry picked from commit 8b9a938413)
2023-03-02 16:43:44 -05:00
Ryan C. Gordon
f5bb286b76 dataqueue: Removed non-public SDL_ReserveSpaceInDataQueue function
This wasn't used, and it was just asking for trouble.

(cherry picked from commit f833e005e1)
2023-03-02 16:41:58 -05:00
Sam Lantinga
f47a08ab84 Fixed typo in previous cherry-pick 2023-03-01 16:47:48 -08:00
Sam Lantinga
660fc89967 Don't clobber an existing entry with a different version when adding a gamepad mapping
(cherry picked from commit 727c7d4e2f)
2023-03-01 16:41:44 -08:00
Sam Lantinga
6ff3e49b6f Follow the same pattern for releasing the window data in the UIKit driver
Possible fix for https://github.com/libsdl-org/SDL/issues/7361

(cherry picked from commit ebdb320651)
2023-02-28 16:15:01 -08:00
Ryan C. Gordon
e58a8639e3 docs: Removed bogus file from wiki bridge.
That was fixed to not do that again by 7e429a13d3
2023-02-28 13:40:35 -05:00
Ryan C. Gordon
5b7b3da701 Sync wiki -> headers. 2023-02-28 12:56:01 -05:00
Ryan C. Gordon
0a0dfdb2f9 wikiheaders: Sort pages before listing them in README/FrontPage.md.
(cherry picked from commit 99c38268cd)
2023-02-28 12:29:21 -05:00
Ryan C. Gordon
8572e19327 wikiheaders: Use Windows endlines in the source, Unix in the wiki.
(cherry picked from commit 7745c9b3ae)
2023-02-28 12:29:16 -05:00
Sam Lantinga
031348d377 Fixed SDL windows getting the maximized state after leaving fullscreen on macOS
(cherry picked from commit 2df08fb1b27b721998a1380a2acdbe1494b5591e)
2023-02-28 09:03:10 -08:00
Ryan C. Gordon
462d95ab4d wikiheaders: ignore wiki's README/FrontPage.md
(cherry picked from commit 6d1e14b792)
2023-02-28 11:56:20 -05:00
Ryan C. Gordon
a48bb80ea0 wikiheaders: Bridge README files in the docs directory to wiki.
Fixes #6026.

(cherry picked from commit 2506676f34)
2023-02-28 11:46:46 -05:00
Sam Lantinga
c0fb092425 Fixed locking up the Logitech F310 with the PlayStation controller detection
(cherry picked from commit da134a3039)
2023-02-28 08:37:18 -08:00
Ryan C. Gordon
37de5d4849 wikiheaders: fixed wikilinks in Markdown code sections.
(cherry picked from commit a479633455)
2023-02-27 23:08:55 -05:00
Sam Lantinga
715749f578 Added mapping for DualSense Edge Wireless Controller on Linux
This is a mapping when using evdev, not the more advanced HIDAPI support.

(cherry picked from commit 206fa4dafb)
2023-02-27 15:21:04 -08:00
David Carlier
0c7346ec3e USE_DEV_RANDOM close the file descriptor even in the rare case it can't read it 2023-02-26 14:00:32 +03:00
Torge Matthies
711a458be5 x11: Fix duplicate Xinput2 event reception
Passing True for owner_events in the XGrabPointer call makes all
XI_RawMotion events appear in the queue twice, with the only difference
between them being the value of XGenericEventCookie::cookie. These have
always been filtered out by a check in the XI_RawMotion handler,
however with a mouse that polls at more than 1 kHz frequency, there
also exist legitimate events that appear indistinguishable from these
duplicated events. These must not be filtered out, otherwise the
pointer may move at an inconsistent speed, appearing like a bad pointer
acceleration implementation.

Change owner_events to False in the XGrabPointer and remove the
duplicate event detection code to fix this.

Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
(cherry picked from commit f18b5656f6)
2023-02-25 10:05:43 -08:00
Ryan C. Gordon
171fba320f wikiheaders: Fix wikilinks inside code sections a little. Not perfect yet.
(cherry picked from commit 5b0351a672)
2023-02-24 14:30:34 -05:00
Sam Lantinga
ad09976eca Fixed relative mouse motion over remote desktop
Setting the cursor clip area to a single pixel prevents the relative mouse motion remote desktop warping from working, so the mouse is never recentered.

(cherry picked from commit daffe02b11)
2023-02-24 09:23:23 -08:00
Ryan C. Gordon
7abb748134 Sync wiki -> headers. 2023-02-24 11:47:13 -05:00
Ryan C. Gordon
858ae9900e wikiheaders: fixed see-also conversion
(cherry picked from commit d748a454a8)
2023-02-24 11:46:41 -05:00
Ryan C. Gordon
f87f0fe781 wikibridge: Fixes for manpage generation from Markdown format.
(cherry picked from commit 5ff49955ab)
2023-02-24 10:22:28 -05:00
Ryan C. Gordon
b3ea81b33f wikiheaders: Work to make the wiki exist primarily in Markdown format.
This adds a means to mass-convert the whole wiki to Markdown as a one-time
operation, and then some fixes to make --copy-to-headers correctly deal with
Markdown-formatted wiki pages.

(cherry picked from commit 936a51d5cc)
2023-02-24 09:48:37 -05:00
Sam Lantinga
3bf9c70a7c Changed the VID/PID used for the Backbone One controller on iOS
(cherry picked from commit 516e48515e)
2023-02-23 12:24:49 -08:00
Sam Lantinga
ea7103088f Added support for the Backbone One PlayStation Edition
(cherry picked from commit 59bf1c2853)
2023-02-23 11:59:10 -08:00
Sam Lantinga
a3a45f6709 Fixed view frame from flipping back and forth between landscape and portrait on iOS
(cherry picked from commit b2d913883c)
2023-02-23 11:59:00 -08:00
Ozkan Sezer
5a7ea76ed3 fix MSVC build failures in CI after commit 1e5e8e2f
(cherry picked from commit a2f8cf8fc0)
2023-02-22 13:31:44 -05:00
Ryan C. Gordon
9403c9e95a resampler: Work at double precision on x86-64 machines.
We get audio artifacts if we don't work at the higher precision, but
this is painful on CPUs that have to use a software fallback for this,
so for now (that is, until we have a better solution), get better output
on amd64 chips, where the cost is less painful.

(cherry picked from commit 1e5e8e2fda)
2023-02-22 13:29:31 -05:00
Sam Lantinga
13969f8567 De-duplicate Google Stadia controllers on macOS
(cherry picked from commit 87a83787a3)
2023-02-21 15:35:25 -08:00
Sam Lantinga
9be85b846b Rumbling the Google Stadia Controller over Bluetooth works on Linux and macOS
(cherry picked from commit 4aeec9d8c2)
2023-02-21 15:07:24 -08:00
Sam Lantinga
35c9b1042f Fixed the packet size for Xbox One controllers
(cherry picked from commit 021a7cfa13)
2023-02-21 12:48:10 -08:00
Sam Lantinga
31a57c05dc Fixed the share button on the ThrustMaster eSwap PRO Controller Xbox
(cherry picked from commit e4face7c1d)
2023-02-21 12:43:20 -08:00
Sam Lantinga
3dff5d3cbe Added support for the Turtle Beach REACT-R and Recon Xbox controllers
(cherry picked from commit 5fded632d6)
2023-02-21 11:29:45 -08:00
Sam Lantinga
4c9a79dddb Removed duplicated conditional
(cherry picked from commit 1a15d506a6)
2023-02-20 18:26:07 -08:00
Sam Lantinga
7c4f5e1def Fixed rumble caps for the Nintendo Joy-Con controllers
(cherry picked from commit 02cea5fca1)
2023-02-20 18:25:57 -08:00
Sam Lantinga
abe8dbbf1c Added support for the Razer Wolverine V2 controllers
(cherry picked from commit 4994654d4f)
2023-02-20 18:25:38 -08:00
Sam Lantinga
0efb31ef32 cocoa/gles: do not unload EGL when context is destroyed
(cherry picked from commit e8091b8983)
2023-02-20 10:43:15 -08:00
Marc-André Lureau
eb22fbc894 windows/gles: do not unload EGL when context is destroyed
It's legitimate to have multiple contexts.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
(cherry picked from commit 93861e1de0)
2023-02-20 10:42:18 -08:00
Marc-André Lureau
479bc2d5ed windows/gles: correct indentation
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
(cherry picked from commit 654965a628)
2023-02-20 10:41:45 -08:00
Ryan C. Gordon
e6e654e25c include: Fix symbols in public headers that start with an underscore.
Fixes #7352.
2023-02-20 11:38:26 -05:00
Sam Lantinga
7b06007266 Fixed typo (thanks @Iniquitatis!)
(cherry picked from commit ced02319a6)
2023-02-19 09:58:07 -08:00
Lauri Kasanen
7d55ccb8b0 Fix GetGlobalMouseState when xi2 is not available at runtime
(cherry picked from commit 0123d6311d)
2023-02-19 09:56:39 -08:00
Ozkan Sezer
da6bce4f76 SDL_x11dyn.h: include XInput2.h also for Xfixes
Fixes https://github.com/libsdl-org/SDL/issues/7343
2023-02-11 23:51:28 +03:00
Le Philousophe
74e8a6451b Fix window size in X11 when window manager refuses to resize
(cherry picked from commit a67ae8eed5)
2023-02-18 12:33:18 -08:00
Sam Lantinga
f741adc86c Added other names for the DragonRise Inc. Wired Wheel (thanks @felimwhiteley!)
(cherry picked from commit eede2066fb)
2023-02-17 11:30:49 -08:00
Anonymous Maarten
817141c162 ci: install pkg-config on Macos runner
(cherry picked from commit 86f0c69465)
2023-02-17 01:05:00 +03:00
Sam Lantinga
e86f494317 Hold the joystick lock while opening the HID device on non-Android platforms
On Windows the main thread can be enumerating DirectInput devices while the Windows.Gaming.Input thread is calling back with a new controller available, and in this case HIDAPI_IsDevicePresent() returned false since the controller initialization hadn't completed yet, creating a duplicate controller.

Fixes https://github.com/libsdl-org/SDL/issues/7304

(cherry picked from commit ece8a7bb8e)
2023-02-16 09:53:33 -08:00
Sylvain
d948e6c3c5 Fix potential de-referencing null pointer in SDL_EVDEV_kbd_keycode() 2023-02-16 08:23:22 +01:00
Sam Lantinga
e7376b7b74 Fixed Steam Runtime sandbox detection
Fixes hotplug issues on Steam Deck for Proton and native games

(cherry picked from commit bcd97b36d2)
2023-02-15 13:54:50 -08:00
Sam Lantinga
69b2baec5c Map the Android MENU button back to the SDL MENU key
Thanks to @AntTheAlchemist for the investigation!

Fixes https://github.com/libsdl-org/SDL/issues/7318

(cherry picked from commit beb6a2afdc)
2023-02-14 18:04:30 -08:00
Sam Lantinga
2c6995778e Fixed handling simple mode PS4 reports
Fixes https://github.com/libsdl-org/SDL/issues/7270

(cherry picked from commit 5925cd4ef3)
2023-02-14 17:53:37 -08:00
Ozkan Sezer
22df572979 look for clock_gettime() in libc first, then in librt if not found. 2023-02-13 22:28:02 +03:00
Ozkan Sezer
634705851d cmake: really fix detection of pthread_setname_np() on Apple platforms. 2023-02-13 11:56:10 +03:00
Ozkan Sezer
1194f52a5c cmake: fix detection of pthread_setname_np() on Apple platforms. 2023-02-13 11:55:40 +03:00
Sylvain
45e5f0f10b Fixed bug #7302 - Memory 'leak' in SDL_SetMouseSystemScale() 2023-02-13 09:43:13 +01:00
Knightly
a23d1af0ac Guard against _USE_MATH_DEFINES redefinition 2023-02-12 20:47:00 +03:00
Francisco Javier Trujillo Mata
2b66ef0df4 Fixed audio 2023-02-11 13:22:47 -08:00
Sam Lantinga
7285f0d441 Sorted controller list
(cherry picked from commit 68e2f23066)
2023-02-10 17:18:32 -08:00
Alfredo Escobar
ca3468cb55 Add Hori Pokken Tournament DX Pro Pad
(cherry picked from commit 76552e4780)
2023-02-10 17:17:00 -08:00
Bruce Mitchener
7d2012af87 emscripten: Update deprecated calls to EM_ASM*.
`EM_ASM_` and `EM_ASM_INT_V` are calls that have been deprecated
for a long time.

Since the return value isn't used for the call to `EM_ASM_`, it
can be replaced with `EM_ASM`.

`EM_ASM_INT_V` is now (for the last few years) `EM_ASM_INT`.

(cherry picked from commit a8e89f2567)
2023-02-10 07:11:31 -08:00
Sylvain
17515f4aef Backport simplify flags PR #7220 2023-02-09 17:19:46 -08:00
Sam Lantinga
f71178a16f Fixed MFI controller being opened while HIDAPI controller was being opened
This was the callstack:
    frame #3: 0x00000001004e1930 libSDL3.1.0.0.dylib`IOS_AddJoystickDevice(controller=0x0000600003b0c000, accelerometer=SDL_FALSE) at SDL_mfijoystick.m:528:14
    frame #4: 0x00000001004e1a54 libSDL3.1.0.0.dylib`__IOS_JoystickInit_block_invoke(.block_descriptor=0x0000000100547760, note=@"GCControllerDidConnectNotification") at SDL_mfijoystick.m:673:45
    frame #5: 0x000000018601e578 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 128
    frame #6: 0x00000001860bc074 CoreFoundation`___CFXRegistrationPost_block_invoke + 88
    frame #7: 0x00000001860bbfbc CoreFoundation`_CFXRegistrationPost + 440
    frame #8: 0x0000000185fefbac CoreFoundation`_CFXNotificationPost + 708
    frame #9: 0x0000000186edc72c Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 88
    frame #10: 0x000000019b054a18 GameController`__60-[_GCControllerManagerAppClient _onqueue_publishController:]_block_invoke + 156
    frame #11: 0x0000000185dc19dc libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #12: 0x0000000185dc3504 libdispatch.dylib`_dispatch_client_callout + 20
    frame #13: 0x0000000185dd1d1c libdispatch.dylib`_dispatch_main_queue_drain + 928
    frame #14: 0x0000000185dd196c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
    frame #15: 0x000000018606ad6c CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    frame #16: 0x00000001860287ec CoreFoundation`__CFRunLoopRun + 2036
    frame #17: 0x00000001860278a4 CoreFoundation`CFRunLoopRunSpecific + 612
    frame #18: 0x00000001003b1194 libSDL3.1.0.0.dylib`process_pending_events at hid.c:509:9
    frame #19: 0x00000001003aebe8 libSDL3.1.0.0.dylib`PLATFORM_hid_open_path(path="USB_054c_05c4_0x11a104290", bExclusive=0) at hid.c:823:2
    frame #20: 0x00000001003b051c libSDL3.1.0.0.dylib`SDL_hid_open_path_REAL(path="USB_054c_05c4_0x11a104290", bExclusive=0) at SDL_hidapi.c:1419:19
    frame #21: 0x00000001004dabdc libSDL3.1.0.0.dylib`HIDAPI_SetupDeviceDriver(device=0x0000600003518000, removed=0x000000016fdfee3c) at SDL_hidapijoystick.c:399:19
    frame #22: 0x00000001004da890 libSDL3.1.0.0.dylib`HIDAPI_AddDevice(info=0x000060000212c2d0, num_children=0, children=0x0000000000000000) at SDL_hidapijoystick.c:843:5
    frame #23: 0x00000001004d9148 libSDL3.1.0.0.dylib`HIDAPI_UpdateDeviceList at SDL_hidapijoystick.c:1000:21
    frame #24: 0x00000001004d9940 libSDL3.1.0.0.dylib`HIDAPI_JoystickDetect at SDL_hidapijoystick.c:1205:13
    frame #25: 0x00000001003bc6d8 libSDL3.1.0.0.dylib`SDL_UpdateJoysticks_REAL at SDL_joystick.c:1703:9
    frame #26: 0x00000001003a13a8 libSDL3.1.0.0.dylib`SDL_PumpEventsInternal(push_sentinel=SDL_FALSE) at SDL_events.c:855:9
    frame #27: 0x00000001003a1340 libSDL3.1.0.0.dylib`SDL_PumpEvents_REAL at SDL_events.c:879:5
    frame #28: 0x000000010038b380 libSDL3.1.0.0.dylib`SDL_PumpEvents at SDL_dynapi_procs.h:572:1
    frame #29: 0x0000000100004524 testgamepad`loop + 40
    frame #30: 0x00000001000063d8 testgamepad`main + 2140

(cherry picked from commit a9650d440a)
2023-02-09 12:07:42 -08:00
Sam Lantinga
d77eb8a8d5 Make sure we synchronously re-enable USB reporting mode for Switch controllers (thanks @SortaCore!)
Fixes https://github.com/libsdl-org/SDL/issues/3450

(cherry picked from commit b7c6fec10a)
2023-02-08 14:31:05 -08:00
Sam Lantinga
3fb9118cb6 Note the Google Stadia controller doesn't support rumble over Bluetooth
(cherry picked from commit 50575ed223)
2023-02-08 14:31:05 -08:00
Sam Lantinga
71fb4e3d76 Fixed mis-detecting the share button on the Xbox controller over NDIS
(cherry picked from commit 00e02de77b)
2023-02-08 14:31:05 -08:00
Sam Lantinga
2518e32de8 Dynamically update the serial number if it isn't available at first
This happens for Xbox One controllers using newer firmware connected over NDIS

(cherry picked from commit d1c72bb0bc)
2023-02-08 14:31:01 -08:00
Sam Lantinga
e8938fc66a Enable paddles on the Xbox Elite controller when connected over USB
(cherry picked from commit c4db0725e4)
2023-02-08 14:27:05 -08:00
Ozkan Sezer
fde6323662 fix build after the Logitech ChillStream patch. 2023-02-07 01:11:02 +03:00
Sam Lantinga
7154605982 Added support for the Logitech ChillStream
(cherry picked from commit 6f7edaf8920c504ebd3e797bd04ec1d2e46c4aa9)
2023-02-06 13:28:44 -08:00
Ozkan Sezer
c68cfcdb2d make sure to not enable SDL_PASSED_BEGINTHREAD_ENDTHREAD for WinRT 2023-02-07 00:21:56 +03:00
Ozkan Sezer
7bf3e28dc6 windows/SDL_systhread.c: remove some dead code. 2023-02-07 00:21:40 +03:00
Sam Lantinga
3fa5a2f794 Fixed warning running a command queue without any vertex operations
(cherry picked from commit f8b41919da)
2023-02-06 11:25:35 -08:00
Sean Ridenour
af5efadd9f Setting the same mouse cursor twice is a no-op
This fixes extremely poor event polling performance on MacOS when using
Dear ImGui, which sets the mouse cursor every frame.
2023-02-05 14:14:54 -05:00
Sam Lantinga
5b5a72e33c Sorted controller list
(cherry picked from commit 1c03ddefc3)
2023-02-05 08:44:46 -08:00
Antonis Geralis
58fa43e7c3 Added Elecom 8button gamepad
(cherry picked from commit 52cd9fcbb0)
2023-02-05 08:44:46 -08:00
Leonardo Brondani Schenkel
4266cf8504 Add Linux mapping for 8BitDo Pro 2 Wired Controller for Xbox
Without these mappings, this controller "kinda" works out of the box:
- `SDL_GameControllerMapping()` works because it will notice "Xbox" in
  the name and use the default XInput mappings
- `SDL_GameControllerMappingForGUID()` will not find any mapping

lsusb:
```
ID 2dc8:2000 8BitDo 8BitDo Pro 2 Wired Controller for Xbox
```

In Linux this controller is supported by two drivers:
- `xpad` (built-in to the kernel), exposes the controller name from the
  USB descriptor and the GUID starts with 03 (0x03 = BUS_USB)
- `xone` (https://github.com/medusalix/xone), exposes a virtual
  controller which is always named "Microsoft X-Box One pad" and the
  GUID starts with 06 (0x06 = BUS_VIRTUAL)

This commit adds the 2 GUIDs from both drivers so mappings will always
be found and the real controller name will always be reported.
2023-02-05 08:44:37 -08:00
Ozkan Sezer
4f7f72c257 replaced line comments in public header. 2023-02-04 10:02:10 +03:00
Anonymous Maarten
c5035d8ffd include: add comment documenting the change(s) to SDL_opengl_glext.h 2023-02-04 02:44:37 +01:00
Alynne
92779a5bd8 Adds Stadia BT mapping
(cherry picked from commit 4dea13e02f)
2023-02-03 15:02:47 -08:00
Anonymous Maarten
0dc4373aad opengl: make SDL_opengl_glext.h's include compatible with macos
- Mesa defines __gl_glext_h_
- Apple defines __glext_h_
2023-02-03 21:05:54 +01:00
Ozkan Sezer
06b305d232 dynapi: cast GetProcAddress() result to void* 2023-02-03 17:40:40 +03:00
Sam Lantinga
c4a493de97 Don't accept official mappings for controllers that aren't unique
For example, the DragonRise Inc. Generic USB Joystick
See https://github.com/gabomdq/SDL_GameControllerDB/issues/202 for details

(cherry picked from commit 673bc57649)
2023-02-02 08:41:57 -08:00
Sam Lantinga
4a87abc966 Fixed sort_controllers.py and resorted game controller database
(cherry picked from commit 917607c335)
2023-02-02 08:41:36 -08:00
Sam Lantinga
2290d71338 Added gamepad mappings for the Xin-Mo Dual Arcade Fightstick
(cherry picked from commit d29e1f3632)
2023-02-01 23:07:47 -08:00
Sasha Szpakowski
17ecb11ed6 macOS: fix initial Metal drawable size in certain multi-display setups
(cherry picked from commit baca26d727)
2023-02-01 22:42:12 -08:00
Anonymous Maarten
8800d40442 cmake: assume autotools static libraries with lib prefix and .a suffix 2023-02-01 19:05:44 +01:00
Ryan C. Gordon
7ac43cfb6b Note that version.rc is public domain.
This avoids potential concerns that customizing would qualify a build
of SDL as an "altered source version" under the zlib license.
2023-01-29 11:46:22 -05:00
Matt Durgavich
dfc56cfc0e Fix For issue #6948 (#6991)
MessageBoxes attached to a window in macOS should use modal APIs and not
use a poll/sleep pattern on the main thread. Sleeping the main thread
makes the NSWindow message loop sluggish and interferes with external
applications that need to send messages to that window, such as
VoiceOver.
2023-01-28 15:49:51 -08:00
Ryan C. Gordon
c83428475d wikiheaders: Link to the SDL3 wiki in the preamble.
Reference Issue #6568.
2023-01-26 14:45:12 -05:00
Ryan C. Gordon
d5680c5d20 wikiheaders: Allow markdown in the wikipreamble string.
Reference Issue #6568.

(cherry picked from commit a089b2ea19404f6dacd083327e13cae888b58993)
2023-01-26 10:23:21 -05:00
Ryan C. Gordon
1069c8931d wikiheaders: Add a \threadsafety tag to document threading details.
Reference Issue #7140.

(cherry picked from commit 01cba48d18)
2023-01-26 10:23:08 -05:00
Jiří Malák
507fc462db SDL_atomic.h: Update SDL_CPUPauseInstruction for Watcom. (#7157)
Appropriate CPU directive can be used in #pragma aux so that it is not
necessary to hardcode instruction bytes.
2023-01-26 17:00:02 +03:00
Anonymous Maarten
d9d84c8d73 ci: test PVR_PSP2 (gles/gl) and gib (gles) 2023-01-25 00:22:50 +01:00
Anonymous Maarten
e927e5d440 vita: add missing static libraries for using gles with pib 2023-01-25 00:22:50 +01:00
Anonymous Maarten
33ec2a5e94 vita: fix reformatting error in SDL_vtagl_pvr.c 2023-01-25 00:22:50 +01:00
Anonymous Maarten
a8a5bd3d6b cmake: allow disabling OpenGL support when building with GLES using PSP2-PVR 2023-01-25 00:22:50 +01:00
ds-sloth
038ccd764a Support MIN/MAX blend on opengles2 2023-01-23 06:09:58 -08:00
Anonymous Maarten
c0445c23bf vita: PVR needs to link to sceIme_stub library 2023-01-23 05:08:59 +01:00
ds-sloth
9670f233cc Support MIN/MAX blend on OpenGL + ES 2023-01-22 13:48:13 -08:00
Frank Praznik
ea179abdb7 wayland: Enforce or override libdecor minimum window size
libdecor plugins can change the min/max window size values internally to enforce a minimum window size, and errors and crashes can result if the window size is below the internal limit.

On versions of libdecor >= 0.1.1, the minimum width and height can be queried and the minimum required window size will be enforced. The application requested window size is still respected, however, the actual window may be slightly larger than the drawable area to accommodate the required libdecor minimum size.

On version 0.1.0 of libdecor, which lacks the function to retrieve the minimum size, the internal limits are overridden before committing a frame, so that the internal limits always match the window size as a workaround, even if the window is technically smaller than the plugin would normally allow.

(cherry picked from commit 423a82cd4b)
2023-01-22 08:20:34 -08:00
raphasamp
eabd88ed28 Update SDL_vitagles_pvr.c
This was broken unintentionally during #6545.(cherry picked from commit 9211c0b639)
2023-01-22 17:32:50 +03:00
PARTY MAN X
a44b646105 Blacklist Konami Amusement Controllers From HIDAPI.
Fixes issue #7118 by adding all Konami Amusement controllers to the
blacklist.  Additionally, the blacklist is changed to exclude a whole
vendor when the PID 0x0000 is used.
2023-01-21 22:03:57 -08:00
Ozkan Sezer
880ac537a5 typo fix to config.sub,
from https://lists.gnu.org/archive/html/config-patches/2023-01/msg00001.html
2023-01-21 10:15:02 +03:00
Guldoman
7b8f0ba8b7 wayland: Set APPLICATION scancode name to Menu
This mimics the behavior of the other platforms.

(cherry picked from commit 6c06f5ce93)
2023-01-19 15:06:18 -08:00
Ozkan Sezer
73a68c6ea5 regenerated configure script. 2023-01-18 21:56:10 +03:00
Frank Praznik
44dc90dcc8 autotools: Add check for libdecor get min/max functions 2023-01-18 10:32:43 -08:00
Fabian Greffrath
8efa1f8fc6 add support for libsamplerate's "linear" resampling mode
Fixes #6998
2023-01-16 16:31:34 -05:00
Sylvain
5d1e6b28d9 SDL_test_harness: fix memory leak when generated seed 2023-01-16 10:43:28 +01:00
Sylvain
c638b4a682 SDL_CreateAudioStream: check for invalid parameters 2023-01-16 09:26:05 +01:00
Anonymous Maarten
01a4cf8a10 ci: don't require EXTRA_ prefix on input environment variables 2023-01-15 17:29:37 +01:00
Anonymous Maarten
f51f7fbb94 n3ds: fix exported libraries of n3ds 2023-01-15 17:29:37 +01:00
Jon Daniel
b47b6e02fd fix prefix path not resolving symlinks 2023-01-15 01:30:24 +01:00
Francisco Javier Trujillo Mata
381312a02a Use filesystem drivers 2023-01-13 09:58:33 -08:00
Frank Praznik
f836b465aa Revert "wayland: Don't try to restore non-resizable windows"
This reverts commit e35c3872dc.

(cherry picked from commit 180afcdf39)
2023-01-12 18:00:11 -08:00
Frank Praznik
a47a045128 wayland: Don't try to restore non-resizable windows
Libdecor can crash if attempting to un-maximize a window that was not set as resizable.

(cherry picked from commit e35c3872dc)
2023-01-12 13:35:33 -08:00
Frank Praznik
e8ae155585 wayland: Perform a round trip when maximizing and restoring windows
Perform a round trip when maximizing and restoring windows so the changes have already taken effect when the associated functions return.

(cherry picked from commit 50f2eb7d41)
2023-01-12 13:35:20 -08:00
happyharryh
2cb422360c Fixed the hat_map to avoid segmentation fault
(cherry picked from commit 57e78f4cf5)
2023-01-12 06:56:59 -08:00
Narr the Reg
fa934dd4df hidapi: switch: Add user calibration support
(cherry picked from commit 9fa55d9cab)
2023-01-12 06:38:37 -08:00
Ozkan Sezer
6a52017724 SDL_dynapi.c: add extern "C" guards, just in case.. 2023-01-12 14:01:02 +03:00
Francisco Javier Trujillo Mata
32fd45cf48 Using UV instead of STQ 2023-01-11 15:12:14 -08:00
Francisco Javier Trujillo Mata
c5a09ca7a9 Remove dummy flag 2023-01-11 15:12:14 -08:00
Wohlstand
b425036808 SDLAudioManager.java: Fixed the support for Android older than API 23 2023-01-10 20:15:35 -08:00
Sam Lantinga
0479df53ca Updated copyright for 2023 2023-01-09 09:48:21 -08:00
yuanhecai
0b0d256a69 Fix loongarch64 support
HAS_LSX/LASX is modified as HAVE_LSX/LASX.
(cherry picked from commit 50af65a7dd)
2023-01-09 11:14:28 +03:00
Ozkan Sezer
d09d0aaab6 cmake (CheckPTHREAD): remove _GNU_SOURCE define after bug #7026 fix 2023-01-09 01:30:50 +03:00
Anonymous Maarten
460b7b247f cmake: do all compile tests with -D_GNU_SOURCE=1 2023-01-08 19:21:50 +01:00
Sam Lantinga
ebc2fb411f Fixed infinite loop shutting down WGI controllers
We are guaranteed that the lock will be held during shutdown, so if we are in InvokeRemoved(), it's because we're shutting down controllers and need to remove them from our internal list.

Fixes https://github.com/libsdl-org/SDL/issues/7016

(cherry picked from commit ac99db9fc8)
2023-01-08 09:35:55 -08:00
Ozkan Sezer
0d5467a6e9 cmake: check for math library functions even in the absence of libm
(Reference issue: https://github.com/libsdl-org/SDL/issues/7011)
2023-01-07 14:25:04 +03:00
Ozkan Sezer
305e7b55bd cmake: fix detection of library functions when -Werror is enabled.
(Reference issue: https://github.com/libsdl-org/SDL/issues/7011)
2023-01-07 14:25:04 +03:00
Guldoman
ad0d1e2ad5 wayland: Fallback to default cursor if chosen one wasn't found
(cherry picked from commit 5a42831345)
2023-01-06 14:55:06 -08:00
Sylvain
7bf4319eb2 fix computation of alpha in BlitRGBtoRGBPixelAlphaMMX3DNOW (see #6990)
( same as BlitRGBtoRGBPixelAlphaMMX )
2023-01-06 21:24:24 +01:00
Sylvain
0ebda87425 Fixed bug #6990: fix computation of alpha in BlitRGBtoRGBPixelAlphaMMX 2023-01-06 08:50:33 -08:00
Sam Lantinga
a099172754 Added support for the ThrustMaster eSwap PRO Controller Xbox
(cherry picked from commit 0357390fc2)
2023-01-03 15:24:32 -08:00
Sam Lantinga
988866ca4a Fixed line wrapping for HID packet dump
(cherry picked from commit e85839cd56)
2023-01-03 15:14:00 -08:00
Sam Lantinga
2cb7a0a0bb Added support for the ThrustMaster eSwap PRO Controller Xbox
(cherry picked from commit dacdb1c310)
2023-01-03 15:13:50 -08:00
Sam Lantinga
b8d5fa4aef Improved handling of binding buttons and axes
(cherry picked from commit 71f3bf90ed)
2023-01-03 12:50:20 -08:00
Sylvain
0a9f61fbf1 Wayland / Drag and Drop: find the current window 2023-01-03 19:07:28 +01:00
Ozkan Sezer
c7f22f0324 render/SDL_yuv_sw.c: fix build after commit d234f7a 2023-01-02 20:51:56 +03:00
Sylvain Becker
d234f7a498 SDL2: backport SDL_CalculateYUVSize() that checks for YUV size overflow (#6972) 2023-01-02 09:09:57 -08:00
Sylvain
2fd9e63f1a Android: orientation, check for exact match to "Portrait". (see #6959)
(Portrait is also contained in PortraitUpsideDown)
2023-01-02 09:48:26 +01:00
Sylvain
874ebed14d Android: inverse LandscapeLeft and LandscapeRight (see #6959)
LandscapeLeft has now been set to ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE and LandscapeRight to ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE in order to reflect the docs: https://wiki.libsdl.org/SDL2/SDL_HINT_ORIENTATIONS
2023-01-02 09:48:17 +01:00
Ozkan Sezer
5b904a103a windows: more HANDLE -> HMODULE changes. 2022-12-31 08:00:20 +03:00
Ozkan Sezer
0a8f9777a7 SDL_dynapi.c: LoadLibraryA() returns HMODULE. 2022-12-30 11:11:10 +03:00
Sam Lantinga
78d3a713de Fixed documentation for SDL_JoystickGetDeviceInstanceID
Fixes https://github.com/libsdl-org/SDL/issues/6946
2022-12-29 15:00:32 -08:00
Sam Lantinga
74229d4a41 Fixed keyboard scancode mapping for parenthesis
(thanks to @meyraud705 for tracking down the root cause!)

Fixes https://github.com/libsdl-org/SDL/issues/6787
Closes https://github.com/libsdl-org/SDL/pull/6937

(cherry picked from commit e1bd5bd071)
2022-12-29 14:55:46 -08:00
Sam Lantinga
29a4c5ebc2 Fixed getting the VID/PID of a virtual joystick
(cherry picked from commit e40a96155f)
2022-12-28 12:52:17 -08:00
Sam Lantinga
903df79b2d Make sure we match the same way when adding a mapping and looking up a mapping
Fixes https://github.com/libsdl-org/SDL/issues/6898

(cherry picked from commit 3db9112ef4)
2022-12-27 12:21:13 -08:00
Ozkan Sezer
d47ff8ae73 SDL_thread.h: fix SDL_CreateThreadWithStackSize macro for OS/2 2022-12-27 00:14:00 +03:00
Ozkan Sezer
738442b82a SDL_thread.h: fix beginthread param of SDL_CreateThreadWithStackSize for win32
(cherry-picked from commit 29ba5f5d64)
2022-12-27 00:11:55 +03:00
Vincent Hamm
68073c6276 Fix SDL_CreateThreadWithStackSize not passing staacksize with win32 static api 2022-12-26 11:22:41 -08:00
Sam Lantinga
920acb75c3 editorconfig: remove trailing whitespace in source code
(cherry picked from commit 7c67213cef)
2022-12-26 10:34:45 -08:00
Sam Lantinga
3dbc6a40ae render: only enable clipping when the rectangle is valid
Fixes https://github.com/libsdl-org/SDL/issues/6896

(cherry picked from commit 00f05dcf49)
2022-12-26 10:25:23 -08:00
João Henrique
af54c82138 kmsdrm: Fix wrong check on KMSDRM_CreateWindow.
A previous cleanup commit inverted a statement that checked the return value of
a KMSDRM_CreateSurfaces call during KMSDRM_CreateWindow, which causes the video
backend to always fail despite success.

This commit restores the intended behavior.

Fixes: 3c501b963d ("Clang-Tidy fixes (#6725)").
(cherry picked from commit 0187209f46)
2022-12-23 09:29:49 -08:00
Rudolf-Walter Kiss-Szakacs
232ed540db Add SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS. 2022-12-22 08:59:56 -08:00
Caleb Cornett
c542aef600 Fix GDK OpenGL build error 2022-12-20 23:22:55 -05:00
Caleb Cornett
abffa1194a Fix dynapi signature for SDL_GDKSuspendComplete 2022-12-20 23:17:50 -05:00
Caleb Cornett
3b3c141ff9 gdk: Add support for building with OpenGL on Xbox 2022-12-19 17:57:17 -05:00
Sam Lantinga
6969b3be3b Don't send Razer devices the Sony third-party query feature report
Some of them lock up or reset, and the vast majority of devices are not actually game controllers.

Fixes https://github.com/libsdl-org/SDL/issues/6733

(cherry picked from commit 83b29f9ce1)
2022-12-19 09:16:59 -08:00
Maido
311b02f0b5 Android active driver check (#6850)
Check if a driver is active before attempting to handle the devices.
Otherwise an assertion will fail.
2022-12-19 16:02:42 +01:00
Sylvain Becker
36c87d9f27 Android JAVA DetectDevices: 'is_capture' is inverted (#6845)
* Android JAVA DetectDevices: 'is_capture' is inversed
* Android Audio: adding audio device. also inverted capture, from jni side
2022-12-18 16:56:43 +01:00
Sylvain Becker
4e3fc0c1dc Android: make Detect devices common between aaudio and android driver. (#6828)
remove VLA, dynamic alloc, check max length get using GetIntArrayRegion
2022-12-18 12:08:24 +01:00
Sam Lantinga
187708e542 Fixed compiler warning
```
 ./src/thread/pthread/SDL_syssem.c:140:12: warning: variable 'retval' is used uninitialized whenever 'while' loop exits because its condition is false [-Wsometimes-uninitialized]
    while (sem_trywait(&sem->sem) != 0) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./src/thread/pthread/SDL_syssem.c:149:12: note: uninitialized use occurs here
    return retval;
           ^~~~~~
./src/thread/pthread/SDL_syssem.c:140:12: note: remove the condition if it is always true
    while (sem_trywait(&sem->sem) != 0) {
```

This was a legitimate bug, thank you clang!

Fixes https://github.com/libsdl-org/SDL/issues/6830

(cherry picked from commit b678a98024)
2022-12-17 06:59:19 -08:00
Sam Lantinga
3b0cd44158 Fixed compiler warning
```
 ./src/joystick/SDL_joystick.c:105:12: warning: no previous extern declaration for non-static variable 'SDL_joystick_lock' [-Wmissing-variable-declarations]
SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */
           ^
./src/joystick/SDL_joystick.c:105:1: note: declare 'static' if the variable is not intended to be used outside of this translation unit
SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */
^
```
1 warning generated.
2022-12-17 06:51:02 -08:00
Maido
741499dea7 Android audio device selection (#6824)
Make it possible to select a specific audio device for Android
2022-12-16 16:38:57 +01:00
Sam Lantinga
a53382e460 Sorted PS4 controllers, note that the NACON Wireless Controller for PS4 actually reports as an XInput device 2022-12-15 18:00:51 -08:00
Sam Lantinga
e99b9ca9c0 Note that the NACON Daija Arcade Stick is an arcade stick 2022-12-15 17:58:29 -08:00
Sylvain
8e72be3117 testime.c: fix wrong {} in switch 2022-12-15 14:39:05 +01:00
Sam Lantinga
7a9966af9d Fixed crash in SDL_PrivateGameControllerRefreshMapping() 2022-12-14 14:24:58 -08:00
Sam Lantinga
d59caffe2c Added support for clang thread-safety analysis
The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code.

Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change.

This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock.

To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
2022-12-14 09:29:19 -08:00
Sylvain Becker
582fb3901a DBus: add a reference to the connection
Fixed bug #6712
2022-12-14 17:46:52 +01:00
Sam Lantinga
c709741871 Detect display change when fullscreen desktop windows move displays
This happens when using Win+Alt+Left/Right on a resizable fullscreen desktop window on Windows

(cherry picked from commit 650e16a824)
2022-12-12 20:28:07 -08:00
Sam Lantinga
817454cfe6 Don't try to open the Razer Huntsman Elite keyboard as a controller 2022-12-12 18:00:57 -08:00
Ryan C. Gordon
e986c7984b wasapi: Fixed incorrect assertions.
Fixes #6795.

(cherry picked from commit 12486e144b)
2022-12-12 16:08:52 -05:00
Frank Praznik
dfd7efaf13 wayland: Set xdg surface geometry
It was previously thought that these function calls were unnecessary as the initial bug and reproduction case that necessitated their addition seemed to be fixed, but apparently there are still cases where this needs to be set explicitly. Set the xdg surface geometry at creation time and when the window size changes.

Partially reverts #6361.  This is not needed in the libdecor path, as libdecor calls this for the content surface internally.

(cherry picked from commit 90a964f132)
2022-12-12 11:22:18 -08:00
Sam Lantinga
802b5ef7dc Added support for the STRIKEPAD PS4 Grip Add-on to the HIDAPI driver
(cherry picked from commit 618340bf99)
2022-12-12 10:56:08 -08:00
Pierre Wendling
e580e087ff N3DS: Backport semaphore fixes from #6776. 2022-12-11 17:09:28 -08:00
nfarid
b79732b967 cmake: use FindALSA.cmake to find ALSA library 2022-12-11 23:23:45 +01:00
Sylvain
faa7e3cc2e Update DYNAPI SDL_WinRTRunApp() prototype which was wrong (see #6783) 2022-12-10 19:22:27 +01:00
Sylvain
5efc9bd194 SDL_dynapi_procs: fixed SDL_UIKitRunApp prototype (see #6783) 2022-12-10 19:22:08 +01:00
Ryan C. Gordon
4bae75387a docs: Note that you don't need to free SDL_GetDefaultCursor's results.
Reference Issue #6777.

(cherry picked from commit 16f8dfcef9)
2022-12-09 22:09:39 -05:00
Sam Lantinga
f57776836f Fixed build 2022-12-09 10:22:18 -08:00
Sam Lantinga
569fa3f57f Added test event logging for SDL_WINDOWEVENT_ICCPROF_CHANGED and SDL_WINDOWEVENT_DISPLAY_CHANGED 2022-12-09 10:13:18 -08:00
Sam Lantinga
be3b1cff0b Added logging for SDL_DISPLAYEVENT_MOVED 2022-12-08 17:03:29 -08:00
Sam Lantinga
ab479b4961 Make sure the display list is up to date for window placement 2022-12-08 17:01:18 -08:00
Sam Lantinga
264da8c127 Added SDL_DISPLAYEVENT_MOVED to detect when display positioning changes 2022-12-08 12:46:13 -08:00
Sam Lantinga
cfc7cac3c9 Fixed memory leak when removing existing displays 2022-12-08 12:43:23 -08:00
Frank Praznik
8b74be464f wayland: Handle the Num Lock and Caps Lock modifiers via modifier events
Num Lock and Caps Lock always need to be explicitly handled by the modifier handler function, or they won't be correctly set if active at application startup, or if the lock state is changed while the application lacks focus since a key press for these keys will never be received.  In these cases, the internal SDL modifier state can end up the inverse of the actual modifier state.

(cherry picked from commit 653e484da1)
2022-12-08 09:30:22 -08:00
Sam Lantinga
fc689a6cb3 Fixed build 2022-12-07 16:06:17 -08:00
Sam Lantinga
b4d547905d Use the correct name for the DualSense controllers
(cherry picked from commit 9a6bcca6b8)
2022-12-07 14:54:00 -08:00
Sam Lantinga
4ee36a9474 Added support for the DualSense Edge paddles
(cherry picked from commit 9339085593)
2022-12-07 14:48:36 -08:00
Sam Lantinga
c2b2f2a71e Clarified where the paddle locations are
(cherry picked from commit ea714956b6)
2022-12-07 14:47:07 -08:00
Sam Lantinga
d1b4810542 Fixed centering the D-pad on some joysticks
Fixes https://github.com/libsdl-org/SDL/issues/6767
2022-12-05 13:36:51 -08:00
Ozkan Sezer
bcccbbd894 tests: avoid redefinition warnings for MSVC _CRT_???_NO_DEPRECATE macros 2022-12-05 00:35:32 +03:00
Ozkan Sezer
4e465f25d0 reverted const removal from SDL_NewAudioStream in commit d0bbfdbfb. 2022-12-04 12:55:15 +03:00
Max Bachmann
7ac66972b7 Detect Logitech PRO Racing Wheel as wheel
(cherry picked from commit 5650046f93)
2022-12-03 08:22:05 -08:00
Sylvain
3e9ae3ea64 Fix wrong clang-tidy modification. This is an integer division. Thanks @meyraud705 (see PR #6725) 2022-12-03 13:39:03 +01:00
Sylvain
0a91a793cf Fix Conditional jump or move depends on uninitialised value(s)
eg ./testsprite2 --trackmem
2022-12-02 21:13:40 +01:00
Sam Lantinga
07d6d116ed Commented out syntax that causes Visual Studio 2019 to complain on every edit
(cherry picked from commit 4713db1484)
2022-12-02 00:43:46 -08:00
Frank Praznik
b5483f2c68 Fix formatting on Wayland and Pipewire function signatures
Fixes the formatting on some function signatures that clang-format missed.

(cherry picked from commit 378b1c286a)
2022-12-01 15:19:50 -08:00
Ozkan Sezer
b990e9145b build fixes after d0bbfdbfb8 2022-12-02 02:13:59 +03:00
Sam Lantinga
3bdc62215e Fixed Apple build after d0bbfdbfb8 2022-12-01 15:11:29 -08:00
Sam Lantinga
423c558e44 Detect the G923 (Xbox style) and PXN V900 (PS3 mode) as wheels
(cherry picked from commit 7237c56499)
2022-12-01 14:44:52 -08:00
Sam Lantinga
42238f88ea Fixed build after d0bbfdbfb8 2022-12-01 13:28:48 -08:00
Pierre Wendling
d0bbfdbfb8 Clang-Tidy fixes (#6725)
(cherry picked from commit 3c501b963d)
2022-12-01 13:08:50 -08:00
Sam Lantinga
e29c0661cc Removed check for _HAVE_STDINT_H, which nobody defines
Fixes https://github.com/libsdl-org/SDL/issues/6619
2022-12-01 12:54:02 -08:00
Ozkan Sezer
e57554ea65 SDL_main.h: added field to SDL_GDKSuspendComplete documentation. 2022-12-01 20:37:00 +03:00
Sylvain
09ee811f4b Small format changed (using clang-format 15.0.2-1)
(cherry picked from commit 778b8926b4)
2022-12-01 08:29:15 -08:00
Ozkan Sezer
b067ab9202 restore SDL_malloc.c original formatting.
(cherry picked from commit 45025799b7)
2022-11-30 18:18:06 -08:00
Sam Lantinga
6e40c7a9b8 Added support for the Logitech Cordless Precision PS3 controller 2022-11-30 17:03:29 -08:00
Sam Lantinga
01541bc350 Added support for the HORIPAD Pro for Xbox Series X 2022-11-30 16:42:00 -08:00
Sam Lantinga
4504c10f3b Re-enabled support for third party PS3 controllers 2022-11-30 16:37:20 -08:00
Sam Lantinga
7b1000013e Reverted code formatting for Apple platforms
We didn't get the merge right, and rather than tease out exactly what happened, I'm just reverting for now.
2022-11-30 15:51:17 -08:00
Sam Lantinga
9e997cc787 Fixed Victrix FS Pro V2 controller hang on reboot 2022-11-30 15:39:10 -08:00
Sam Lantinga
d87048fd5a Fixed crash if GetRectDisplayIndex() is called before SDL_VideoInit() 2022-11-30 14:37:34 -08:00
Sam Lantinga
6926d046c0 Fixed build after cherry-pick of 5750bcb174 from SDL3 2022-11-30 13:05:57 -08:00
Sam Lantinga
b8d85c6939 Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594

(cherry picked from commit 5750bcb174)
2022-11-30 12:57:41 -08:00
Sam Lantinga
5c4bc807f7 Revert "SDL_test_md5.h: fix MD5UINT4 type to be really 32 bits."
This reverts commit 8eeca8c7db as it's potentially an ABI break.
2022-11-30 05:59:56 -08:00
Ozkan Sezer
8eeca8c7db SDL_test_md5.h: fix MD5UINT4 type to be really 32 bits.
(cherry picked from commit 8901297437)
2022-11-30 05:59:03 -08:00
David Edmundson
d7664a6ef1 Support wayland fractional scale protocol
The new protocol adds support for more native communication of
fractional scaling.

Everything in the wayland backend already existed only our fractional
scale was calculated implicitly through a combination of output size
guesswork for fullscreen windows.

This new protocol makes that explicit, providing a more robust solution
and a solution for non-fullscreen surfaces. The fallback code is still
left in place for now whilst compositors gain support.
2022-11-29 16:37:02 -05:00
Anonymous Maarten
5df106603d cmake: move platform detection to cmake/sdl/paltform.cmake for re-use by SDL2-compat 2022-11-29 20:20:33 +01:00
Ryan C. Gordon
69f0223474 dynapi: Abstract out the environment variable name.
(cherry picked from commit cc487ffb801f862aec7e2b415e74c563c4d528d5)
2022-11-29 14:15:20 -05:00
pionere
724845110c video: fix error messages
- do not overwrite error message set by SDL_InitFormat (SDL_AllocFormat)
- set proper error message (Cocoa_Metal_CreateView)
- protect against allocation failure (UIKit_Metal_CreateView)

(cherry picked from commit cf0cb44df8)
2022-11-29 11:04:11 -08:00
Anonymous Maarten
84039e2514 cmake: use target_link_libraries to pass -Wl,--undefined=WinMain
(cherry-picked from commit e2060de714)
2022-11-29 21:15:21 +03:00
Sam Lantinga
2d24baaad4 Fixed building on Windows with SDL_VIDEO=OFF
Fixes https://github.com/libsdl-org/SDL/issues/6562
2022-11-29 09:26:29 -08:00
Sam Lantinga
b7cc4dce70 Fixed bug #6698 - VISA: wrong check sceKernelPollSema
(cherry picked from commit f077c69193)
2022-11-29 08:51:23 -08:00
pionere
0b7a9a8e9f thread: code style
(cherry picked from commit 461a38ff1a)
2022-11-29 08:47:52 -08:00
Sylvain
8cda5102fc Fixed bug #6698 - VISA: wrong check sceKernelPollSema 2022-11-29 16:16:10 +01:00
pionere
ee13e8c76b thread: return -1 from SDL_SemWaitTimeout if semaphore is NULL
(cherry picked from commit f6db1aba66)
2022-11-29 09:40:58 -05:00
pionere
fcd7d658dc thread: fix inconsistent return values
- SDL_CreateMutex returns NULL when the creation fails (ngage)
- SDL_SemValue returns 0 when the semaphore is NULL (n3ds)

(cherry picked from commit 6875e1c262)
2022-11-29 09:28:33 -05:00
Sam Lantinga
89e9f7b42b Added support for the Xbox Elite controller paddles with firmware version 5.13+ 2022-11-28 23:10:02 -08:00
Vasily Khoruzhick
b6c875a923 Add support for the 8BitDo Ultimate Wireless 2.4GHz Controller in DirectInput mode
Generated using controller map
2022-11-28 17:48:03 -08:00
Samuel Venable
a65d1bfb14 Fix broken solaris build. (missing brace).
missing brace.
2022-11-28 15:51:28 -08:00
Sam Lantinga
37d244ea81 Added support for the 8BitDo Ultimate Wired Controller in DirectInput mode, including the misc button and paddles 2022-11-28 14:49:07 -08:00
Sam Lantinga
a937b5c4ad Add 8BitDo to the list of Xbox 360 third party vendors
Allows detection of the 8BitDo Ultimate Wired Controller
2022-11-28 13:47:30 -08:00
Sylvain Becker
fb0ce375f0 Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line

(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
2022-11-28 12:33:03 -08:00
Samuel Venable
0739d237ad [skip ci] Solaris getexecname() returns argv[0]
`argv[0]`/`getexexname()` are not always absolute paths by default and can be modified to anything the developer wants them to be.

Consider using `readSymLink("/proc/self/path/a.out")` instead and `getexecname()` as the fallback, since the symlink will always be the correct absolute path (unless /proc is ot mounted, but it is by default on Solaris and Illumos platforms).

(cherry picked from commit 4f5e9fd5bd)
2022-11-27 21:38:01 -05:00
Markus Mittendrein
8145212103 SDL_ResampleAudio: Fix float accumulation error
While 78f97108f9 reduced the accumulation error, it was still big enough to cause distortions.
Fixes #6196.
2022-11-27 21:06:52 -05:00
Joshua Root
2df39e64ab Fix build with Xcode < 7
The _Nullable attribute is not available in older versions.

(cherry picked from commit 9a64aa6f95)
2022-11-26 20:36:54 -08:00
Sam Lantinga
8fddf146bf Temporary hack to address performance issues in https://github.com/libsdl-org/SDL/issues/6581#issuecomment-1327987916 (thanks @icculus!)
(cherry picked from commit 9c8369e097)
2022-11-26 13:11:26 -08:00
Ryan C. Gordon
3f5593d613 cocoa: Patched to compile on macOS SDK < 10.10.
Fixes #6586.

(cherry picked from commit fa5adcafd5)
2022-11-26 13:59:44 -05:00
Anonymous Maarten
dcd1252368 cmake: test for lsx and lasx intrinsics for loongarch 2022-11-25 21:50:43 +01:00
Anonymous Maarten
edb75bc29e cmake: make all assembly options depend on SDL_ASSEMBLY and architecture 2022-11-25 21:50:25 +01:00
Anonymous Maarten
660cec69b1 cmake: find libudev library so it gets priority 2022-11-25 21:37:42 +01:00
Anonymous Maarten
a2611edcf3 cmake: add support for some BSD's wscons input 2022-11-25 21:37:36 +01:00
Michael Fitzmayer
e19c532ebf Add bitdraw.h, remove non-working stub class
(cherry picked from commit 67f31a19a8)
2022-11-24 13:13:08 -08:00
Anonymous Maarten
e426617c9c cmake: add X11 include dir to check dirs 2022-11-24 21:00:26 +01:00
Sylvain Becker
192cdf3d04 SDL_mfijoystick.m: remove VLA, so that projects can be built with error on vla 2022-11-24 18:33:50 +03:00
Ozkan Sezer
64a5e7be98 added missing FGREP to Makefile.in. fixed syntax. regenerated configure. 2022-11-24 17:00:20 +03:00
Frank Praznik
66bd15555c wayland: Fix build when not using the shared Wayland libraries
Explicitly include the Wayland protocol headers when statically linking against the Wayland libraries or older system headers might be used instead of the local versions.

(cherry picked from commit 836eb22442)
2022-11-24 03:01:42 -08:00
Sam James
4c7156c1e6 Avoid use of deprecated egrep/fgrep
GNU grep 3.8 emits a deprecation warning on use of egrep/fgrep.

Signed-off-by: Sam James <sam@gentoo.org>
(cherry picked from commit 3e7952ce8a)
2022-11-24 02:59:41 -08:00
Joshua Root
33e5de31d8 vulkan_metal.h: Make compatible with ObjC ARC
Fixes #6598

(cherry picked from commit 239423e205)
2022-11-23 17:39:26 -08:00
Frank Praznik
3eaf56894e wayland: Fix libdecor_dispatch signature
The function returns an int, not a bool.

(cherry picked from commit f47169fcba)
2022-11-23 15:17:52 -08:00
Joshua Root
242ce20cbf SDL_mfijoystick.m: fix build with Xcode < 9
Fixes #6601.

(cherry picked from commit 53ca1f7702)
2022-11-23 12:48:26 -08:00
Joshua Root
f52e7199df Check build-time SDK in LoadMainMenuNibIfAvailable
Fixes building against OS X 10.7 SDK.

(cherry picked from commit f8cebeea59)
2022-11-23 12:28:43 -08:00
Joshua Root
e12c831b15 SDL_cocoaopengl.h: ensure CVDisplayLinkRef is defined
The typedef seems to be pulled in coincidentally with newer SDKs, but
older ones need to import the header explicitly.

(cherry picked from commit d2910904fb)
2022-11-23 12:22:40 -08:00
Ozkan Sezer
cd399caf6f fix dynapi after SDL_GDKSuspendComplete addition. 2022-11-23 22:50:10 +03:00
Ciro Mondueri
f6144dfe03 adds GDK suspend/resume basic handling (#6596) 2022-11-23 11:41:14 -08:00
SDL Wiki Bot
ac2fcfcb62 Sync SDL2 wiki -> header 2022-11-22 23:21:36 +00:00
Ryan C. Gordon
4ac2d45a06 Testing the wiki, disregard this commit. 2022-11-22 18:12:43 -05:00
Sam Lantinga
dce6ed56d7 Removed G29 from controller_type.c
We don't want the G29 to show up as a gamepad, Steam will create a virtual Xbox controller for it, which breaks racing games.
2022-11-22 10:56:44 -08:00
Sam Lantinga
e3d430b83e Revert "Added Linux mappings for the Logitech G29 in PS3 and PS4 modes"
This reverts commit 33a68f575f.

We don't want the G29 to show up as a gamepad, Steam will create a virtual Xbox controller for it, which breaks racing games.
2022-11-22 10:53:28 -08:00
Ryan C. Gordon
511bab5bbf .wikiheaders-options: Move SDL2 documentation to a subdirectory.
SDL3 will be the main thing now.
2022-11-22 13:05:08 -05:00
Anonymous Maarten
156bf7e6aa android.mk: LOCAL_EXPORT_C_INCLUDES does not need to add include subfolder 2022-11-22 09:41:23 -08:00
Sam Lantinga
938b720a9e Update SDL info and Xcode marketing version to 2.27.0 2022-11-22 09:19:21 -08:00
Sam Lantinga
44975d40ef Update SDL info and Xcode marketing version with version update scripts 2022-11-22 09:18:05 -08:00
Sam Lantinga
ea8f8b6dc3 Updated to version 2.27.0 for development 2022-11-21 16:36:10 -08:00
1198 changed files with 65243 additions and 65246 deletions

View File

@@ -16,8 +16,8 @@ AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: All AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: AllDefinitions AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine AlwaysBreakTemplateDeclarations: MultiLine
@@ -35,7 +35,7 @@ BraceWrapping:
AfterUnion: true AfterUnion: true
AfterExternBlock: false AfterExternBlock: false
BeforeElse: false BeforeElse: false
BeforeWhile: true BeforeWhile: false
IndentBraces: false IndentBraces: false
SplitEmptyFunction: true SplitEmptyFunction: true
SplitEmptyRecord: true SplitEmptyRecord: true
@@ -62,7 +62,8 @@ IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None
IndentExternBlock: NoIndent IndentExternBlock: NoIndent
SpaceAfterCStyleCast: true PointerAlignment: Right
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false SpacesInConditionalStatement: false
SpacesInContainerLiterals: true SpacesInContainerLiterals: true

View File

@@ -7,6 +7,8 @@ root = true
[*.{c,cg,cpp,gradle,h,java,m,metal,pl,py,S,sh,txt}] [*.{c,cg,cpp,gradle,h,java,m,metal,pl,py,S,sh,txt}]
indent_size = 4 indent_size = 4
indent_style = space indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{html,js,json,m4,yml,yaml,vcxproj,vcxproj.filters}] [*.{html,js,json,m4,yml,yaml,vcxproj,vcxproj.filters}]
indent_size = 2 indent_size = 2

16
.github/cmake/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.0)
project(ci_utils C CXX)
set(txt "CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER}
CFLAGS=${CMAKE_C_FLAGS}
CXXFLAGS=${CMAKE_CXX_FLAGS}
LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_C_STANDARD_LIBRARIES}
")
message("${txt}")
set(VAR_PATH "/tmp/env.txt" CACHE PATH "Where to write environment file")
message(STATUS "Writing CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS environment to ${VAR_PATH}")
file(WRITE "${VAR_PATH}" "${txt}")

View File

@@ -22,6 +22,11 @@ jobs:
- { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64 } - { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64 }
- { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh } - { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh }
- { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true } - { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
- { name: Intel oneAPI (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
- { name: Intel Compiler (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
- { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh } - { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
- { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true } - { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
- { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' } - { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
@@ -59,7 +64,21 @@ jobs:
if: runner.os == 'macOS' if: runner.os == 'macOS'
run: | run: |
brew install \ brew install \
ninja ninja \
pkg-config
- name: Setup Intel oneAPI
if: matrix.platform.intel
run: |
# Setup oneAPI repo
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update -y
# Install oneAPI
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Check that versioning is consistent - name: Check that versioning is consistent
# We only need to run this once: arbitrarily use the Linux/CMake build # We only need to run this once: arbitrarily use the Linux/CMake build
@@ -68,6 +87,7 @@ jobs:
- name: Configure (CMake) - name: Configure (CMake)
if: "! matrix.platform.autotools" if: "! matrix.platform.autotools"
run: | run: |
${{ matrix.platform.source_cmd }}
cmake -S . -B build -G Ninja \ cmake -S . -B build -G Ninja \
-DSDL_TESTS=ON \ -DSDL_TESTS=ON \
-DSDL_WERROR=ON \ -DSDL_WERROR=ON \
@@ -79,11 +99,13 @@ jobs:
- name: Build (CMake) - name: Build (CMake)
if: "! matrix.platform.autotools" if: "! matrix.platform.autotools"
run: | run: |
${{ matrix.platform.source_cmd }}
cmake --build build/ --config Release --verbose --parallel cmake --build build/ --config Release --verbose --parallel
- name: Run build-time tests (CMake) - name: Run build-time tests (CMake)
if: "! matrix.platform.autotools" if: "! matrix.platform.autotools"
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
export SDL_TESTS_QUICK=1 export SDL_TESTS_QUICK=1
ctest -VV --test-dir build/ ctest -VV --test-dir build/
if test "${{ runner.os }}" = "Linux"; then if test "${{ runner.os }}" = "Linux"; then
@@ -101,6 +123,7 @@ jobs:
if: matrix.platform.autotools if: matrix.platform.autotools
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
rm -fr build-autotools rm -fr build-autotools
mkdir build-autotools mkdir build-autotools
./autogen.sh ./autogen.sh
@@ -132,6 +155,7 @@ jobs:
if: matrix.platform.autotools if: matrix.platform.autotools
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
parallel="$(getconf _NPROCESSORS_ONLN)" parallel="$(getconf _NPROCESSORS_ONLN)"
make -j"${parallel}" -C build-autotools V=1 make -j"${parallel}" -C build-autotools V=1
if test "${{ runner.os }}" != "macOS" ; then if test "${{ runner.os }}" != "macOS" ; then
@@ -141,6 +165,7 @@ jobs:
if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }} if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
curdir="$(pwd)" curdir="$(pwd)"
parallel="$(getconf _NPROCESSORS_ONLN)" parallel="$(getconf _NPROCESSORS_ONLN)"
export SDL_TESTS_QUICK=1 export SDL_TESTS_QUICK=1
@@ -153,6 +178,7 @@ jobs:
if: matrix.platform.autotools if: matrix.platform.autotools
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
curdir="$(pwd)" curdir="$(pwd)"
parallel="$(getconf _NPROCESSORS_ONLN)" parallel="$(getconf _NPROCESSORS_ONLN)"
make -j"${parallel}" -C build-autotools install V=1 make -j"${parallel}" -C build-autotools install V=1
@@ -163,16 +189,19 @@ jobs:
echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
- name: Verify CMake configuration files - name: Verify CMake configuration files
run: | run: |
${{ matrix.platform.source_cmd }}
cmake -S cmake/test -B cmake_config_build -G Ninja \ cmake -S cmake/test -B cmake_config_build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
cmake --build cmake_config_build --verbose cmake --build cmake_config_build --verbose
- name: Verify sdl2-config - name: Verify sdl2-config
run: | run: |
${{ matrix.platform.source_cmd }}
export PATH=${{ env.SDL2_DIR }}/bin:$PATH export PATH=${{ env.SDL2_DIR }}/bin:$PATH
cmake/test/test_sdlconfig.sh cmake/test/test_sdlconfig.sh
- name: Verify sdl2.pc - name: Verify sdl2.pc
run: | run: |
${{ matrix.platform.source_cmd }}
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh cmake/test/test_pkgconfig.sh
- name: Distcheck (Autotools) - name: Distcheck (Autotools)
@@ -191,6 +220,7 @@ jobs:
if: "runner.os == 'Linux' && matrix.platform.autotools" if: "runner.os == 'Linux' && matrix.platform.autotools"
run: | run: |
set -eu set -eu
${{ matrix.platform.source_cmd }}
parallel="$(getconf _NPROCESSORS_ONLN)" parallel="$(getconf _NPROCESSORS_ONLN)"
sudo make -j"${parallel}" -C build-autotools install sudo make -j"${parallel}" -C build-autotools install
sudo make -j"${parallel}" -C build-autotools/test install sudo make -j"${parallel}" -C build-autotools/test install

View File

@@ -38,5 +38,18 @@ jobs:
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \ -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
cmake --build cmake_config_build --verbose cmake --build cmake_config_build --verbose
# Not running test_pkgconfig.sh and test_sdlconfig.sh - name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain
# as invoking the compiler manually is not supported run: |
cmake -S .github/cmake -B /tmp/cmake_extract \
-DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/3DS.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DVAR_PATH=/tmp/n3ds_env.txt
cat /tmp/n3ds_env.txt >> $GITHUB_ENV
- name: Verify sdl2-config
run: |
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
cmake/test/test_sdlconfig.sh
- name: Verify sdl2.pc
run: |
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh

View File

@@ -50,13 +50,13 @@ jobs:
- name: Verify sdl2-config - name: Verify sdl2-config
run: | run: |
export CC=mips64r5900el-ps2-elf-gcc export CC=mips64r5900el-ps2-elf-gcc
export LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
export PATH=${{ env.SDL2_DIR }}/bin:$PATH export PATH=${{ env.SDL2_DIR }}/bin:$PATH
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
cmake/test/test_sdlconfig.sh cmake/test/test_sdlconfig.sh
- name: Verify sdl2.pc - name: Verify sdl2.pc
run: | run: |
export CC=mips64r5900el-ps2-elf-gcc export CC=mips64r5900el-ps2-elf-gcc
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib" export LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh cmake/test/test_pkgconfig.sh

View File

@@ -39,12 +39,12 @@ jobs:
- name: Verify sdl2-config - name: Verify sdl2-config
run: | run: |
export CC=psp-gcc export CC=psp-gcc
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
export PATH=${{ env.SDL2_DIR }}/bin:$PATH export PATH=${{ env.SDL2_DIR }}/bin:$PATH
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
cmake/test/test_sdlconfig.sh cmake/test/test_sdlconfig.sh
- name: Verify sdl2.pc - name: Verify sdl2.pc
run: | run: |
export CC=psp-gcc export CC=psp-gcc
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
cmake/test/test_pkgconfig.sh cmake/test/test_pkgconfig.sh

View File

@@ -8,19 +8,61 @@ defaults:
jobs: jobs:
vita: vita:
name: ${{ matrix.platform.name }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: vitasdk/vitasdk:latest image: vitasdk/vitasdk:latest
strategy:
fail-fast: false
matrix:
platform:
- { name: GLES (pib), os: windows-latest, pib: true }
- { name: GLES (PVR_PSP2 + gl4es4vita), os: windows-latest, pvr: true }
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Install build requirements - name: Install build requirements
run: | run: |
apk update apk update
apk add cmake ninja pkgconf bash apk add cmake ninja pkgconf bash
- name: Configure PVR_PSP2 (GLES)
if: ${{ !!matrix.platform.pvr }}
run: |
pvr_psp2_version=3.9
# Configure PVR_PSP2 headers
wget https://github.com/GrapheneCt/PVR_PSP2/archive/refs/tags/v$pvr_psp2_version.zip -P/tmp
unzip /tmp/v$pvr_psp2_version.zip -d/tmp
cp -r /tmp/PVR_PSP2-$pvr_psp2_version/include/* ${VITASDK}/arm-vita-eabi/include
rm /tmp/v$pvr_psp2_version.zip
# Configure PVR_PSP2 stub libraries
wget https://github.com/GrapheneCt/PVR_PSP2/releases/download/v$pvr_psp2_version/vitasdk_stubs.zip -P/tmp
unzip /tmp/vitasdk_stubs.zip -d/tmp/pvr_psp2_stubs
find /tmp/pvr_psp2_stubs -type f -name "*.a" -exec cp {} ${VITASDK}/arm-vita-eabi/lib \;
rm /tmp/vitasdk_stubs.zip
rm -rf /tmp/pvr_psp2_stubs
- name: Configure gl4es4vita (OpenGL)
if: ${{ !!matrix.platform.pvr }}
run: |
gl4es4vita_version=1.1.4
# Configure gl4es4vita headers
wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/include.zip -P/tmp
unzip -o /tmp/include.zip -d${VITASDK}/arm-vita-eabi/include
rm /tmp/include.zip
# Configure gl4es4vita stub libraries
wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/vitasdk_stubs.zip -P/tmp
unzip /tmp/vitasdk_stubs.zip -d${VITASDK}/arm-vita-eabi/lib
- name: Configure CMake - name: Configure CMake
run: | run: |
cmake -S . -B build -G Ninja \ cmake -S . -B build -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \ -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \
-DVIDEO_VITA_PIB=${{ !!matrix.platform.pib }} \
-DVIDEO_VITA_PVR=${{ !!matrix.platform.pvr }} \
-DSDL_WERROR=ON \ -DSDL_WERROR=ON \
-DSDL_TESTS=ON \ -DSDL_TESTS=ON \
-DSDL_INSTALL_TESTS=ON \ -DSDL_INSTALL_TESTS=ON \

6
.gitignore vendored
View File

@@ -62,6 +62,11 @@ cmake-build-*
xcuserdata xcuserdata
*.xcworkspace *.xcworkspace
# for QtCreator
CMakeLists.txt.user
build*/
*.pro.user*
# for Visual C++ # for Visual C++
.vs .vs
Debug Debug
@@ -173,6 +178,7 @@ test/testyuv
test/torturethread test/torturethread
builddir/ builddir/
!build-scripts/
debian/*.debhelper.log debian/*.debhelper.log
debian/*.substvars debian/*.substvars
debian/*.tar.gz debian/*.tar.gz

View File

@@ -1,7 +1,8 @@
projectfullname = SDL_mixer projectfullname = SDL2
projectshortname = SDL_mixer projectshortname = SDL2
incsubdir = include incsubdir = include
wikisubdir = wikisubdir = SDL2
readmesubdir = docs
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_) apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
mainincludefname = SDL.h mainincludefname = SDL.h
versionfname = include/SDL_version.h versionfname = include/SDL_version.h
@@ -10,6 +11,7 @@ versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z
selectheaderregex = \ASDL.*?\.h\Z selectheaderregex = \ASDL.*?\.h\Z
projecturl = https://libsdl.org/ projecturl = https://libsdl.org/
wikiurl = https://wiki.libsdl.org wikiurl = https://wiki.libsdl.org/SDL2
bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new
warn_about_missing = 0 warn_about_missing = 0
wikipreamble = (This is the legacy documentation for stable SDL2, the current stable version; [SDL3](https://wiki.libsdl.org/SDL3/) is the current development version.)

View File

@@ -12,7 +12,7 @@ LOCAL_MODULE := SDL2
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
$(subst $(LOCAL_PATH)/,, \ $(subst $(LOCAL_PATH)/,, \
@@ -63,7 +63,6 @@ LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
LOCAL_CFLAGS += \ LOCAL_CFLAGS += \
-Wall -Wextra \ -Wall -Wextra \
-Wdocumentation \ -Wdocumentation \
-Wdocumentation-unknown-command \
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wunreachable-code-break \ -Wunreachable-code-break \
-Wunneeded-internal-declaration \ -Wunneeded-internal-declaration \
@@ -78,6 +77,8 @@ LOCAL_CFLAGS += \
# Warnings we haven't fixed (yet) # Warnings we haven't fixed (yet)
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
LOCAL_CXXFLAGS += -std=gnu++11
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
LOCAL_LDFLAGS := -Wl,--no-undefined LOCAL_LDFLAGS := -Wl,--no-undefined

View File

@@ -2,7 +2,7 @@ if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there") message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
endif() endif()
cmake_minimum_required(VERSION 3.0.0) cmake_minimum_required(VERSION 3.0.0...3.5)
project(SDL2 C CXX) project(SDL2 C CXX)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
@@ -18,6 +18,9 @@ endif()
set(EXTRA_LIBS) set(EXTRA_LIBS)
set(EXTRA_LDFLAGS) set(EXTRA_LDFLAGS)
set(CMAKE_DEPENDS)
set(PKGCONFIG_DEPENDS)
# This is a virtual "library" that just exists to collect up compiler and # This is a virtual "library" that just exists to collect up compiler and
# linker options that used to be global to this CMake project. When you # linker options that used to be global to this CMake project. When you
# specify it as part of a real library's target_link_libraries(), that # specify it as part of a real library's target_link_libraries(), that
@@ -27,16 +30,10 @@ set(EXTRA_LDFLAGS)
add_library(sdl-build-options INTERFACE) add_library(sdl-build-options INTERFACE)
if(WINDOWS_STORE) if(WINDOWS_STORE)
cmake_minimum_required(VERSION 3.11.0)
target_compile_definitions(sdl-build-options INTERFACE "-DSDL_BUILDING_WINRT=1") target_compile_definitions(sdl-build-options INTERFACE "-DSDL_BUILDING_WINRT=1")
target_compile_options(sdl-build-options INTERFACE "-ZW") target_compile_options(sdl-build-options INTERFACE "-ZW")
endif() endif()
# Build in parallel under Visual Studio. Not enabled by default.
if(MSVC)
target_compile_options(sdl-build-options INTERFACE "/MP")
endif()
# CMake 3.0 expands the "if(${A})" in "set(OFF 1);set(A OFF);if(${A})" to "if(1)" # CMake 3.0 expands the "if(${A})" in "set(OFF 1);set(A OFF);if(${A})" to "if(1)"
# CMake 3.24+ emits a warning when not set. # CMake 3.24+ emits a warning when not set.
unset(OFF) unset(OFF)
@@ -74,6 +71,7 @@ find_package(PkgConfig)
list(APPEND CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake) include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
include(${SDL2_SOURCE_DIR}/cmake/sdlplatform.cmake)
include(${SDL2_SOURCE_DIR}/cmake/CheckCPUArchitecture.cmake) include(${SDL2_SOURCE_DIR}/cmake/CheckCPUArchitecture.cmake)
# Enable large file support on 32-bit glibc, so that we can access files # Enable large file support on 32-bit glibc, so that we can access files
@@ -85,7 +83,7 @@ endif()
# See docs/release_checklist.md # See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2) set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 26) set(SDL_MINOR_VERSION 28)
set(SDL_MICRO_VERSION 0) set(SDL_MICRO_VERSION 0)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
@@ -135,8 +133,12 @@ set(SDL_GENERATED_HEADERS)
#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}") #message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
# General settings & flags check_cpu_architecture(x86 SDL_CPU_X86)
set(LIBRARY_OUTPUT_DIRECTORY "build") check_cpu_architecture(x64 SDL_CPU_X64)
check_cpu_architecture(arm32 SDL_CPU_ARM32)
check_cpu_architecture(arm64 SDL_CPU_ARM64)
check_cpu_architecture(loongarch64 SDL_CPU_LOONGARCH64)
# Check for 64 or 32 bit # Check for 64 or 32 bit
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P}) set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@@ -152,56 +154,7 @@ if(NOT LIBTYPE)
endif() endif()
# Get the platform # Get the platform
if(WIN32) SDL_DetectCMakePlatform()
if(NOT WINDOWS)
set(WINDOWS TRUE)
endif()
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(LINUX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(FREEBSD TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(NETBSD TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(OPENBSD TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(GNU TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(BSDI TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(FREEBSD TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SYSV5 TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
set(SOLARIS TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(HPUX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(AIX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(MINIX TRUE)
endif()
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(DARWIN TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(MACOSX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
set(TVOS TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
if(CMAKE_VERSION VERSION_LESS 3.14)
set(IOS TRUE)
endif()
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
message_error("BeOS support has been removed as of SDL 2.0.2.")
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(HAIKU TRUE)
elseif(NINTENDO_3DS)
set(N3DS TRUE)
endif()
# Don't mistake osx for unix # Don't mistake osx for unix
if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT RISCOS) if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT RISCOS)
@@ -254,7 +207,7 @@ else()
endif() endif()
# Compiler info # Compiler info
if(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_ID MATCHES "Clang|IntelLLVM")
set(USE_CLANG TRUE) set(USE_CLANG TRUE)
set(OPT_DEF_ASM TRUE) set(OPT_DEF_ASM TRUE)
# Visual Studio 2019 v16.2 added support for Clang/LLVM. # Visual Studio 2019 v16.2 added support for Clang/LLVM.
@@ -268,20 +221,18 @@ elseif(CMAKE_COMPILER_IS_GNUCC)
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+ elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
set(OPT_DEF_ASM TRUE) set(OPT_DEF_ASM TRUE)
#set(CMAKE_C_FLAGS "/ZI /WX- / #set(CMAKE_C_FLAGS "/ZI /WX- /
elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
set(OPT_DEF_ASM TRUE)
set(USE_INTELCC TRUE)
else() else()
set(OPT_DEF_ASM FALSE) set(OPT_DEF_ASM FALSE)
endif() endif()
if(USE_GCC OR USE_CLANG) if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(OPT_DEF_GCC_ATOMICS ON) set(OPT_DEF_GCC_ATOMICS ON)
endif() endif()
# Default option knobs # Default option knobs
if(APPLE OR ARCH_64 OR MSVC_CLANG)
if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm")
set(OPT_DEF_SSEMATH ON)
endif()
endif()
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS) if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
set(OPT_DEF_LIBC ON) set(OPT_DEF_LIBC ON)
endif() endif()
@@ -294,6 +245,11 @@ if(NOT ("$ENV{CFLAGS}" STREQUAL ""))
endif() endif()
endif() endif()
# Build in parallel under Visual Studio. Not enabled by default.
if(MSVC AND NOT USE_CLANG)
target_compile_options(sdl-build-options INTERFACE "/MP")
endif()
if(MSVC) if(MSVC)
option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
if(SDL_FORCE_STATIC_VCRT) if(SDL_FORCE_STATIC_VCRT)
@@ -336,6 +292,8 @@ if(WINDOWS)
set(CMAKE_SHARED_LIBRARY_PREFIX "") set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif() endif()
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -D_GNU_SOURCE=1")
# Emscripten toolchain has a nonempty default value for this, and the checks # Emscripten toolchain has a nonempty default value for this, and the checks
# in this file need to change that, so remember the original value, and # in this file need to change that, so remember the original value, and
# restore back to that afterwards. For check_function_exists() to work in # restore back to that afterwards. For check_function_exists() to work in
@@ -369,7 +327,6 @@ endif()
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so # All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
# you only need to have a platform override them if they are disabling. # you only need to have a platform override them if they are disabling.
set(OPT_DEF_ASM TRUE)
if(EMSCRIPTEN) if(EMSCRIPTEN)
# Set up default values for the currently supported set of subsystems: # Set up default values for the currently supported set of subsystems:
# Emscripten/Javascript does not have assembly support, a dynamic library # Emscripten/Javascript does not have assembly support, a dynamic library
@@ -433,18 +390,21 @@ set_option(SDL2_DISABLE_UNINSTALL "Disable uninstallation of SDL2" OFF)
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto") option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON) #set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
dep_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE "Use SSE assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE2 "Use SSE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE3 "Use SSE3 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_MMX "Use MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_ALTIVEC "Use Altivec assembly routines" ON "SDL_ASSEMBLY" OFF)
dep_option(SDL_ARMSIMD "Use SIMD assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
dep_option(SDL_ARMNEON "Use NEON assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
dep_option(SDL_LSX "Use LSX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
dep_option(SDL_LASX "Use LASX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
set_option(SDL_LIBC "Use the system C library" ${OPT_DEF_LIBC}) set_option(SDL_LIBC "Use the system C library" ${OPT_DEF_LIBC})
set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS}) set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
set_option(SDL_MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
set_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
set_option(SDL_SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
set_option(SDL_ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
set_option(SDL_ARMSIMD "use SIMD assembly blitters on ARM" OFF)
set_option(SDL_ARMNEON "use NEON assembly blitters on ARM" OFF)
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF) dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON) set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
set_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON) set_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON)
@@ -511,6 +471,7 @@ set_option(SDL_HIDAPI "Enable the HIDAPI subsystem" ON)
dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI OFF) dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI OFF)
dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF) dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF)
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF) dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
set_option(SDL_LIBUDEV "Enable libudev support" ON)
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF) set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "") option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "")
set_option(SDL_CCACHE "Use Ccache to speed up build" ON) set_option(SDL_CCACHE "Use Ccache to speed up build" ON)
@@ -527,26 +488,6 @@ set_option(SDL_INSTALL_TESTS "Install test-cases" OFF)
set(HAVE_STATIC_PIC "${SDL_STATIC_PIC}") set(HAVE_STATIC_PIC "${SDL_STATIC_PIC}")
if(SDL_WERROR)
if(MSVC)
cmake_push_check_state(RESET)
check_c_compiler_flag(/WX HAVE_WX)
if(HAVE_WX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
elseif(USE_GCC OR USE_CLANG)
cmake_push_check_state(RESET)
check_c_compiler_flag(-Werror HAVE_WERROR)
if(HAVE_WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -Werror")
endif()
cmake_pop_check_state()
endif()
endif()
if(SDL_HIDAPI) if(SDL_HIDAPI)
if(HIDAPI_ONLY_LIBUSB) if(HIDAPI_ONLY_LIBUSB)
set(SDL_HIDAPI_LIBUSB ON CACHE BOOL "" FORCE) set(SDL_HIDAPI_LIBUSB ON CACHE BOOL "" FORCE)
@@ -585,6 +526,15 @@ file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/video/*.c ${SDL2_SOURCE_DIR}/src/video/*.c
${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c) ${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
if(USE_INTELCC)
# warning #39: division by zero
# warning #239: floating point underflow
# warning #264: floating-point value does not fit in required floating-point type
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_exp.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd239 -wd264")
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_log.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd39")
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_log10.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd39")
endif()
set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 1) set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 1)
if(SDL_ASSERTIONS MATCHES "^(auto|)$") if(SDL_ASSERTIONS MATCHES "^(auto|)$")
@@ -613,7 +563,7 @@ if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF")
endif() endif()
# Compiler option evaluation # Compiler option evaluation
if(USE_GCC OR USE_CLANG) if(USE_GCC OR USE_CLANG OR USE_INTELCC)
# Check for -Wall first, so later things can override pieces of it. # Check for -Wall first, so later things can override pieces of it.
# Note: clang-cl treats -Wall as -Weverything (which is very loud), # Note: clang-cl treats -Wall as -Weverything (which is very loud),
# /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough. # /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough.
@@ -691,6 +641,11 @@ if(USE_GCC OR USE_CLANG)
list(APPEND EXTRA_CFLAGS "-Wshadow") list(APPEND EXTRA_CFLAGS "-Wshadow")
endif() endif()
check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
list(APPEND EXTRA_CFLAGS "-Wno-unused-local-typedefs")
endif()
if(APPLE) if(APPLE)
cmake_push_check_state(RESET) cmake_push_check_state(RESET)
# FIXME: don't use deprecated declarations # FIXME: don't use deprecated declarations
@@ -751,7 +706,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
endif() endif()
if(SDL_ASSEMBLY) if(SDL_ASSEMBLY)
if(USE_GCC OR USE_CLANG) if(USE_GCC OR USE_CLANG OR USE_INTELCC)
# TODO: Those all seem to be quite GCC specific - needs to be # TODO: Those all seem to be quite GCC specific - needs to be
# reworked for better compiler support # reworked for better compiler support
set(HAVE_ASSEMBLY TRUE) set(HAVE_ASSEMBLY TRUE)
@@ -835,8 +790,9 @@ if(SDL_ASSEMBLY)
#ifndef __SSE2__ #ifndef __SSE2__
#error Assembler CPP flag not enabled #error Assembler CPP flag not enabled
#endif #endif
int main(int argc, char **argv) { return 0; }" HAVE_SSE2) int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE2)
if(HAVE_SSE2) if(CPU_SUPPORTS_SSE2)
set(HAVE_SSE2 TRUE)
list(APPEND EXTRA_CFLAGS "-msse2") list(APPEND EXTRA_CFLAGS "-msse2")
endif() endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
@@ -858,8 +814,9 @@ if(SDL_ASSEMBLY)
#ifndef __SSE3__ #ifndef __SSE3__
#error Assembler CPP flag not enabled #error Assembler CPP flag not enabled
#endif #endif
int main(int argc, char **argv) { return 0; }" HAVE_SSE3) int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE3)
if(HAVE_SSE3) if(CPU_SUPPORTS_SSE3)
set(HAVE_SSE3 TRUE)
list(APPEND EXTRA_CFLAGS "-msse3") list(APPEND EXTRA_CFLAGS "-msse3")
endif() endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
@@ -892,9 +849,9 @@ if(SDL_ASSEMBLY)
vector unsigned int vzero() { vector unsigned int vzero() {
return vec_splat_u32(0); return vec_splat_u32(0);
} }
int main(int argc, char **argv) { return 0; }" HAVE_ALTIVEC) int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_ALTIVEC)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR) if(CPU_SUPPORTS_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
list(APPEND EXTRA_CFLAGS "-maltivec") list(APPEND EXTRA_CFLAGS "-maltivec")
set(SDL_ALTIVEC_BLITTERS 1) set(SDL_ALTIVEC_BLITTERS 1)
@@ -904,6 +861,39 @@ if(SDL_ASSEMBLY)
endif() endif()
endif() endif()
if(SDL_LSX)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_FLAGS "-mlsx")
check_c_source_compiles("
#ifndef __loongarch_sx
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LSX)
check_include_file("lsxintrin.h" HAVE_LSXINTRIN_H)
cmake_pop_check_state()
if(CPU_SUPPORTS_LSX AND HAVE_LSXINTRIN_H)
list(APPEND EXTRA_CFLAGS "-mlsx")
set(HAVE_LSX TRUE)
endif()
endif()
if(SDL_LASX)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_FLAGS "-mlasx")
check_c_source_compiles("
#ifndef __loongarch_asx
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LASX)
check_include_file("lasxintrin.h" HAVE_LASXINTRIN_H)
cmake_pop_check_state()
if(CPU_SUPPORTS_LASX AND HAVE_LASXINTRIN_H)
list(APPEND EXTRA_CFLAGS "-mlasx")
set(HAVE_LASX TRUE)
endif()
endif()
if(SDL_ARMSIMD) if(SDL_ARMSIMD)
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
@@ -962,12 +952,22 @@ if(SDL_ASSEMBLY)
# TODO: SDL_cpuinfo.h needs to support the user's configuration wish # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
# for MSVC - right now it is always activated # for MSVC - right now it is always activated
if(NOT ARCH_64) if(NOT ARCH_64)
if(SDL_MMX)
set(HAVE_MMX TRUE) set(HAVE_MMX TRUE)
endif()
if(SDL_3DNOW)
set(HAVE_3DNOW TRUE) set(HAVE_3DNOW TRUE)
endif() endif()
endif()
if(SDL_SSE)
set(HAVE_SSE TRUE) set(HAVE_SSE TRUE)
endif()
if(SDL_SSE2)
set(HAVE_SSE2 TRUE) set(HAVE_SSE2 TRUE)
endif()
if(SDL_SSE3)
set(HAVE_SSE3 TRUE) set(HAVE_SSE3 TRUE)
endif()
check_include_file("immintrin.h" HAVE_IMMINTRIN_H) check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
endif() endif()
endif() endif()
@@ -1067,6 +1067,7 @@ if(SDL_LIBC)
check_library_exists(m pow "" HAVE_LIBM) check_library_exists(m pow "" HAVE_LIBM)
if(HAVE_LIBM) if(HAVE_LIBM)
set(CMAKE_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m)
endif()
foreach(_FN foreach(_FN
atan atan2 atanf atan2f ceil ceilf copysign copysignf cos cosf atan atan2 atanf atan2f ceil ceilf copysign copysignf cos cosf
exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f
@@ -1076,6 +1077,7 @@ if(SDL_LIBC)
set(_HAVEVAR "HAVE_${_UPPER}") set(_HAVEVAR "HAVE_${_UPPER}")
check_symbol_exists("${_FN}" "math.h" ${_HAVEVAR}) check_symbol_exists("${_FN}" "math.h" ${_HAVEVAR})
endforeach() endforeach()
if(HAVE_LIBM)
set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_LIBRARIES)
if(NOT VITA) if(NOT VITA)
list(APPEND EXTRA_LIBS m) list(APPEND EXTRA_LIBS m)
@@ -1117,6 +1119,10 @@ else()
set(HAVE_STDARG_H 1) set(HAVE_STDARG_H 1)
set(HAVE_STDDEF_H 1) set(HAVE_STDDEF_H 1)
check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stdint.h HAVE_STDINT_H)
if(MSVC AND USE_CLANG)
check_c_compiler_flag("/Q_no-use-libirc" HAS_Q_NO_USE_LIBIRC )
endif()
endif() endif()
endif() endif()
@@ -1485,6 +1491,18 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
ioctl(0, KDENABIO, 1); ioctl(0, KDENABIO, 1);
return 0; return 0;
}" HAVE_INPUT_KBIO) }" HAVE_INPUT_KBIO)
elseif(OPENBSD OR NETBSD)
check_c_source_compiles("
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsksymdef.h>
#include <dev/wscons/wsksymvar.h>
#include <sys/ioctl.h>
int main(int argc, char **argv) {
struct wskbd_map_data data;
ioctl(0, WSKBDIO_GETMAP, &data);
return 0;
}" HAVE_INPUT_WSCONS)
endif() endif()
if(HAVE_INPUT_EVENTS) if(HAVE_INPUT_EVENTS)
@@ -1506,7 +1524,11 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
set(SDL_INPUT_FBSDKBIO 1) set(SDL_INPUT_FBSDKBIO 1)
endif() endif()
check_include_file("libudev.h" HAVE_LIBUDEV_H) if(HAVE_INPUT_WSCONS)
set(SDL_INPUT_WSCONS 1)
endif()
CheckLibUDev()
check_include_file("sys/inotify.h" HAVE_SYS_INOTIFY_H) check_include_file("sys/inotify.h" HAVE_SYS_INOTIFY_H)
check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY_INIT) check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY_INIT)
check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1) check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
@@ -1616,14 +1638,14 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
CheckPTHREAD() CheckPTHREAD()
if(SDL_CLOCK_GETTIME) if(SDL_CLOCK_GETTIME)
check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME_LIBRT)
if(FOUND_CLOCK_GETTIME_LIBRT)
list(APPEND EXTRA_LIBS rt)
set(HAVE_CLOCK_GETTIME 1)
else()
check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME_LIBC) check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME_LIBC)
if(FOUND_CLOCK_GETTIME_LIBC) if(FOUND_CLOCK_GETTIME_LIBC)
set(HAVE_CLOCK_GETTIME 1) set(HAVE_CLOCK_GETTIME 1)
else()
check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME_LIBRT)
if(FOUND_CLOCK_GETTIME_LIBRT)
set(HAVE_CLOCK_GETTIME 1)
list(APPEND EXTRA_LIBS rt)
endif() endif()
endif() endif()
endif() endif()
@@ -1703,7 +1725,7 @@ elseif(WINDOWS)
if(MSVC AND NOT SDL_LIBC) if(MSVC AND NOT SDL_LIBC)
# Prevent codegen that would use the VC runtime libraries. # Prevent codegen that would use the VC runtime libraries.
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-") set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE") set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
endif() endif()
@@ -2484,6 +2506,9 @@ elseif(VITA)
set(SDL_VIDEO_OPENGL_ES2 1) set(SDL_VIDEO_OPENGL_ES2 1)
list(APPEND EXTRA_LIBS list(APPEND EXTRA_LIBS
pib pib
libScePiglet_stub_weak
taihen_stub_weak
SceShaccCg_stub_weak
) )
set(HAVE_VIDEO_VITA_PIB ON) set(HAVE_VIDEO_VITA_PIB ON)
set(SDL_VIDEO_VITA_PIB 1) set(SDL_VIDEO_VITA_PIB 1)
@@ -2496,7 +2521,6 @@ elseif(VITA)
check_include_file(gpu_es4/psp2_pvr_hint.h HAVE_PVR_H) check_include_file(gpu_es4/psp2_pvr_hint.h HAVE_PVR_H)
if(HAVE_PVR_H) if(HAVE_PVR_H)
target_compile_definitions(sdl-build-options INTERFACE "-D__psp2__") target_compile_definitions(sdl-build-options INTERFACE "-D__psp2__")
check_include_file(gl4esinit.h HAVE_GL4ES_H)
set(SDL_VIDEO_OPENGL_EGL 1) set(SDL_VIDEO_OPENGL_EGL 1)
set(HAVE_OPENGLES TRUE) set(HAVE_OPENGLES TRUE)
set(SDL_VIDEO_OPENGL_ES 1) set(SDL_VIDEO_OPENGL_ES 1)
@@ -2507,11 +2531,14 @@ elseif(VITA)
list(APPEND EXTRA_LIBS list(APPEND EXTRA_LIBS
libgpu_es4_ext_stub_weak libgpu_es4_ext_stub_weak
libIMGEGL_stub_weak libIMGEGL_stub_weak
SceIme_stub
) )
set(HAVE_VIDEO_VITA_PVR ON) set(HAVE_VIDEO_VITA_PVR ON)
set(SDL_VIDEO_VITA_PVR 1) set(SDL_VIDEO_VITA_PVR 1)
if(SDL_OPENGL)
check_include_file(gl4esinit.h HAVE_GL4ES_H)
if(HAVE_GL4ES_H) if(HAVE_GL4ES_H)
set(HAVE_OPENGL TRUE) set(HAVE_OPENGL TRUE)
set(SDL_VIDEO_OPENGL 1) set(SDL_VIDEO_OPENGL 1)
@@ -2519,6 +2546,7 @@ elseif(VITA)
list(APPEND EXTRA_LIBS libGL_stub) list(APPEND EXTRA_LIBS libGL_stub)
set(SDL_VIDEO_VITA_PVR_OGL 1) set(SDL_VIDEO_VITA_PVR_OGL 1)
endif() endif()
endif()
else() else()
set(HAVE_VIDEO_VITA_PVR OFF) set(HAVE_VIDEO_VITA_PVR OFF)
@@ -2547,19 +2575,6 @@ elseif(VITA)
SceProcessmgr_stub SceProcessmgr_stub
m m
) )
if(HAVE_VITA_PIB)
list(PREPEND EXTRA_LIBS
pib
libScePiglet_stub
SceShaccCg_stub
taihen_stub
)
endif()
if(HAVE_VITA_PVR)
list(PREPEND EXTRA_LIBS
SceIme_stub
)
endif()
endif() endif()
set(HAVE_ARMSIMD TRUE) set(HAVE_ARMSIMD TRUE)
@@ -2642,7 +2657,7 @@ elseif(PSP)
) )
if(NOT SDL2_DISABLE_SDL2MAIN) if(NOT SDL2_DISABLE_SDL2MAIN)
list(INSERT SDL_LIBS 0 "-lSDL2main") list(INSERT SDL_LIBS 0 "-lSDL2main")
endif(NOT SDL2_DISABLE_SDL2MAIN) endif()
elseif(PS2) elseif(PS2)
list(APPEND EXTRA_CFLAGS "-DPS2" "-D__PS2__" "-I$ENV{PS2SDK}/ports/include" "-I$ENV{PS2DEV}/gsKit/include") list(APPEND EXTRA_CFLAGS "-DPS2" "-D__PS2__" "-I$ENV{PS2SDK}/ports/include" "-I$ENV{PS2DEV}/gsKit/include")
@@ -2840,6 +2855,17 @@ elseif(N3DS)
else() else()
message_error("SDL_FILE must be enabled to build on N3DS") message_error("SDL_FILE must be enabled to build on N3DS")
endif() endif()
if(NOT SDL2_DISABLE_SDL2MAIN)
list(INSERT SDL_LIBS 0 "-lSDL2main")
endif()
foreach(lib ${CMAKE_C_STANDARD_LIBRARIES})
if(lib MATCHES "^-l")
string(SUBSTRING "${lib}" 2 -1 lib)
endif()
list(APPEND EXTRA_LIBS ${lib})
endforeach()
endif() endif()
if(HAVE_VULKAN AND NOT SDL_LOADSO) if(HAVE_VULKAN AND NOT SDL_LOADSO)
@@ -2926,6 +2952,26 @@ if(NOT SDLMAIN_SOURCES)
file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c) file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
endif() endif()
if(SDL_WERROR)
if(MSVC)
cmake_push_check_state(RESET)
check_c_compiler_flag(/WX HAVE_WX)
if(HAVE_WX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC)
cmake_push_check_state(RESET)
check_c_compiler_flag(-Werror HAVE_WERROR)
if(HAVE_WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -Werror")
endif()
cmake_pop_check_state()
endif()
endif()
# Append the -MMD -MT flags # Append the -MMD -MT flags
# if(DEPENDENCY_TRACKING) # if(DEPENDENCY_TRACKING)
# if(COMPILER_IS_GNUCC) # if(COMPILER_IS_GNUCC)
@@ -2942,7 +2988,7 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_build_type)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include-config-${lower_build_type}") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include-config-${lower_build_type}")
# 3. generate SDL_config in an build_type-dependent folder (which should be first in the include search path) # 3. generate SDL_config in an build_type-dependent folder (which should be first in the include search path)
file(GENERATE file(GENERATE
OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h" OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
INPUT "${SDL2_BINARY_DIR}/SDL_config.h.intermediate") INPUT "${SDL2_BINARY_DIR}/SDL_config.h.intermediate")
# Prepare the flags and remove duplicates # Prepare the flags and remove duplicates
@@ -2993,9 +3039,9 @@ else()
endif() endif()
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake" configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
"${SDL2_BINARY_DIR}/include/SDL_revision.h") "${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h")
# Copy all non-generated headers to "${SDL2_BINARY_DIR}/include" # Copy all non-generated headers to "${SDL2_BINARY_DIR}/include/SDL2"
# This is done to avoid the inclusion of a pre-generated SDL_config.h # This is done to avoid the inclusion of a pre-generated SDL_config.h
file(GLOB SDL2_INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h) file(GLOB SDL2_INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
set(SDL2_COPIED_INCLUDE_FILES) set(SDL2_COPIED_INCLUDE_FILES)
@@ -3004,7 +3050,7 @@ foreach(_hdr IN LISTS SDL2_INCLUDE_FILES)
list(REMOVE_ITEM SDL2_INCLUDE_FILES "${_hdr}") list(REMOVE_ITEM SDL2_INCLUDE_FILES "${_hdr}")
else() else()
get_filename_component(_name "${_hdr}" NAME) get_filename_component(_name "${_hdr}" NAME)
set(_bin_hdr "${SDL2_BINARY_DIR}/include/${_name}") set(_bin_hdr "${SDL2_BINARY_DIR}/include/SDL2/${_name}")
list(APPEND SDL2_COPIED_INCLUDE_FILES "${_bin_hdr}") list(APPEND SDL2_COPIED_INCLUDE_FILES "${_bin_hdr}")
add_custom_command(OUTPUT "${_bin_hdr}" add_custom_command(OUTPUT "${_bin_hdr}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_hdr}" "${_bin_hdr}" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_hdr}" "${_bin_hdr}"
@@ -3059,6 +3105,7 @@ string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_STATIC_LIBS "$
if(NOT SDL_SHARED) if(NOT SDL_SHARED)
string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_LIBS "${SDL_LIBS}") string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_LIBS "${SDL_LIBS}")
endif() endif()
listtostr(PKGCONFIG_DEPENDS PKGCONFIG_DEPENDS)
if(SDL_STATIC AND SDL_SHARED AND NOT sdl_static_libname STREQUAL "SDL2") if(SDL_STATIC AND SDL_SHARED AND NOT sdl_static_libname STREQUAL "SDL2")
message(STATUS "\"pkg-config --static --libs sdl2\" will return invalid information") message(STATUS "\"pkg-config --static --libs sdl2\" will return invalid information")
@@ -3139,7 +3186,7 @@ if (SDL_ASAN)
endif() endif()
endif() endif()
if(SDL_CCACHE) if(SDL_CCACHE AND NOT CMAKE_VERSION VERSION_LESS 3.4)
cmake_minimum_required(VERSION 3.4) cmake_minimum_required(VERSION 3.4)
find_program(CCACHE_BINARY ccache) find_program(CCACHE_BINARY ccache)
if(CCACHE_BINARY) if(CCACHE_BINARY)
@@ -3150,6 +3197,8 @@ if(SDL_CCACHE)
else() else()
set(HAVE_CCACHE OFF) set(HAVE_CCACHE OFF)
endif() endif()
else()
set(HAVE_CCACHE OFF)
endif() endif()
if(SDL_TESTS) if(SDL_TESTS)
@@ -3235,22 +3284,27 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
add_dependencies(SDL2main sdl_headers_copy) add_dependencies(SDL2main sdl_headers_copy)
# alias target for in-tree builds # alias target for in-tree builds
add_library(SDL2::SDL2main ALIAS SDL2main) add_library(SDL2::SDL2main ALIAS SDL2main)
target_include_directories(SDL2main BEFORE PRIVATE "${SDL2_BINARY_DIR}/include" PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>") target_include_directories(SDL2main BEFORE
PRIVATE "${SDL2_BINARY_DIR}/include"
PRIVATE "${SDL2_BINARY_DIR}/include/SDL2"
PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2"
)
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>) target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
if (WIN32) if (WIN32)
target_link_libraries(SDL2main PRIVATE shell32) target_link_libraries(SDL2main PRIVATE shell32)
endif() endif()
if(MINGW OR CYGWIN) if(MINGW OR CYGWIN)
cmake_minimum_required(VERSION 3.13)
if(CMAKE_SIZEOF_VOID_P EQUAL 4) if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>") target_link_libraries(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>")
else() else()
target_link_options(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>") target_link_libraries(SDL2main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>")
endif() endif()
endif() endif()
if (NOT ANDROID) if (NOT ANDROID)
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}") set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
endif() endif()
set_property(TARGET SDL2main APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL2main PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif() endif()
if(ANDROID) if(ANDROID)
@@ -3268,7 +3322,7 @@ endif()
if(APPLE) if(APPLE)
foreach(SOURCE_FILE ${SOURCE_FILES}) foreach(SOURCE_FILE ${SOURCE_FILES})
get_filename_component(FILE_EXTENSION ${SOURCE_FILE} EXT) get_filename_component(FILE_EXTENSION ${SOURCE_FILE} EXT)
if(FILE_EXTENSION STREQUAL "m") if(FILE_EXTENSION STREQUAL ".m")
set_property(SOURCE ${SOURCE_FILE} APPEND_STRING PROPERTY COMPILE_FLAGS " -x objective-c") set_property(SOURCE ${SOURCE_FILE} APPEND_STRING PROPERTY COMPILE_FLAGS " -x objective-c")
endif() endif()
endforeach() endforeach()
@@ -3281,11 +3335,13 @@ if(SDL_SHARED)
add_library(SDL2::SDL2 ALIAS SDL2) add_library(SDL2::SDL2 ALIAS SDL2)
set_target_properties(SDL2 PROPERTIES POSITION_INDEPENDENT_CODE TRUE) set_target_properties(SDL2 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(NOT SDL_LIBC) if(NOT SDL_LIBC)
check_cpu_architecture(x86 HAS_X86) if(SDL_CPU_X86)
if(HAS_X86)
# FIXME: should be added for all architectures (missing symbols for ARM) # FIXME: should be added for all architectures (missing symbols for ARM)
target_link_libraries(SDL2 PRIVATE "-nodefaultlib:MSVCRT") target_link_libraries(SDL2 PRIVATE "-nodefaultlib:MSVCRT")
endif() endif()
if(HAS_Q_NO_USE_LIBIRC)
target_compile_options(SDL2 PRIVATE /Q_no-use-libirc)
endif()
endif() endif()
if(APPLE) if(APPLE)
# FIXME: Remove SOVERSION in SDL3 # FIXME: Remove SOVERSION in SDL3
@@ -3315,18 +3371,19 @@ if(SDL_SHARED)
if(MSVC AND NOT SDL_LIBC AND NOT MSVC_CLANG AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") if(MSVC AND NOT SDL_LIBC AND NOT MSVC_CLANG AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
# Don't try to link with the default set of libraries. # Don't try to link with the default set of libraries.
if(NOT WINDOWS_STORE) if(NOT WINDOWS_STORE)
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB") set_property(TARGET SDL2 APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB")
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
endif() endif()
set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB") set_property(TARGET SDL2 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " /NODEFAULTLIB")
endif() endif()
# FIXME: if CMAKE_VERSION >= 3.13, use target_link_options for EXTRA_LDFLAGS # FIXME: if CMAKE_VERSION >= 3.13, use target_link_options for EXTRA_LDFLAGS
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD}) target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD} ${CMAKE_DEPENDS})
target_include_directories(SDL2 PUBLIC target_include_directories(SDL2 PUBLIC
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
)
# This picks up all the compiler options and such we've accumulated up to here. # This picks up all the compiler options and such we've accumulated up to here.
target_link_libraries(SDL2 PRIVATE $<BUILD_INTERFACE:sdl-build-options>) target_link_libraries(SDL2 PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
if(MINGW OR CYGWIN) if(MINGW OR CYGWIN)
@@ -3338,8 +3395,10 @@ if(SDL_SHARED)
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}") set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
endif() endif()
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library # Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL2_SHARED TRUE)
set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED) set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL2_SHARED TRUE)
set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif() endif()
if(SDL_STATIC) if(SDL_STATIC)
@@ -3353,20 +3412,24 @@ if(SDL_STATIC)
target_compile_definitions(SDL2-static PRIVATE SDL_STATIC_LIB) target_compile_definitions(SDL2-static PRIVATE SDL_STATIC_LIB)
# TODO: Win32 platforms keep the same suffix .lib for import and static # TODO: Win32 platforms keep the same suffix .lib for import and static
# libraries - do we need to consider this? # libraries - do we need to consider this?
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS}) target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${CMAKE_DEPENDS})
target_include_directories(SDL2-static PUBLIC target_include_directories(SDL2-static PUBLIC
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
)
# This picks up all the compiler options and such we've accumulated up to here. # This picks up all the compiler options and such we've accumulated up to here.
target_link_libraries(SDL2-static PRIVATE $<BUILD_INTERFACE:sdl-build-options>) target_link_libraries(SDL2-static PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
if(NOT ANDROID) if(NOT ANDROID)
set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}") set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
endif() endif()
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library # Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL2_SHARED FALSE)
set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED) set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL2_SHARED FALSE)
set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MAJOR_VERSION=${SDL_MAJOR_VERSION}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MAJOR_VERSION=${SDL_MAJOR_VERSION}")
@@ -3384,10 +3447,13 @@ if(SDL_TEST)
EXPORT_NAME SDL2test) EXPORT_NAME SDL2test)
target_include_directories(SDL2_test PUBLIC target_include_directories(SDL2_test PUBLIC
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>" "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS}) target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS})
set_property(TARGET SDL2_test APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
set_property(TARGET SDL2_test PROPERTY INTERFACE_SDL_VERSION "SDL2")
endif() endif()
##### Installation targets ##### ##### Installation targets #####
@@ -3492,6 +3558,7 @@ if(NOT SDL2_DISABLE_INSTALL)
FILES FILES
${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake
${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake
DESTINATION "${SDL_INSTALL_CMAKEDIR}" DESTINATION "${SDL_INSTALL_CMAKEDIR}"
COMPONENT Devel COMPONENT Devel
) )
@@ -3499,8 +3566,8 @@ if(NOT SDL2_DISABLE_INSTALL)
install( install(
FILES FILES
${SDL2_INCLUDE_FILES} ${SDL2_INCLUDE_FILES}
"${SDL2_BINARY_DIR}/include/SDL_revision.h" "${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h"
"${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h" "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2)
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE) string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)

View File

@@ -1,4 +1,4 @@
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -27,6 +27,7 @@ LDFLAGS = @BUILD_LDFLAGS@
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@ EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
LIBTOOL = @LIBTOOL@ LIBTOOL = @LIBTOOL@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
FGREP = @FGREP@
AR = @AR@ AR = @AR@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
RC = @RC@ RC = @RC@
@@ -130,7 +131,7 @@ HDRS = \
begin_code.h \ begin_code.h \
close_code.h close_code.h
SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test) SDLTEST_HDRS = $(shell ls $(srcdir)/include | $(FGREP) SDL_test)
LT_AGE = @LT_AGE@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@ LT_CURRENT = @LT_CURRENT@

View File

@@ -1,7 +1,7 @@
# Makefile to build the SDL library # Makefile to build the SDL library
INCLUDE = -I./include CPPFLAGS = -I./include
CFLAGS = -g -O2 $(INCLUDE) CFLAGS = -g -O2
AR = ar AR = ar
RANLIB = ranlib RANLIB = ranlib

View File

@@ -14,7 +14,7 @@
LIBNAME = SDL2 LIBNAME = SDL2
MAJOR_VERSION = 2 MAJOR_VERSION = 2
MINOR_VERSION = 26 MINOR_VERSION = 28
MICRO_VERSION = 0 MICRO_VERSION = 0
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2 DESCRIPTION = Simple DirectMedia Layer 2

View File

@@ -5,7 +5,7 @@
LIBNAME = SDL2 LIBNAME = SDL2
MAJOR_VERSION = 2 MAJOR_VERSION = 2
MINOR_VERSION = 26 MINOR_VERSION = 28
MICRO_VERSION = 0 MICRO_VERSION = 0
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)

View File

@@ -30,6 +30,18 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
set(SDL2_SDL2test_FOUND TRUE) set(SDL2_SDL2test_FOUND TRUE)
endif() endif()
include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake")
set(SDL_ALSA @SDL_ALSA@)
set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@)
if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static)
sdlFindALSA()
endif()
unset(SDL_ALSA)
unset(SDL_ALSA_SHARED)
check_required_components(SDL2) check_required_components(SDL2)
# Create SDL2::SDL2 alias for static-only builds # Create SDL2::SDL2 alias for static-only builds

View File

@@ -1,5 +1,5 @@
/* /*
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -239,17 +239,17 @@ LoadSprite(const char *file)
/* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */ /* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h); sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h);
if (!sprites[i]) { if (!sprites[i]) {
return (-1); return -1;
} }
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) { if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
SDL_DestroyTexture(sprites[i]); SDL_DestroyTexture(sprites[i]);
return (-1); return -1;
} }
} }
/* We're ready to roll. :) */ /* We're ready to roll. :) */
return (0); return 0;
} }
void void
@@ -364,8 +364,9 @@ loop()
#endif #endif
} }
for (i = 0; i < state->num_windows; ++i) { for (i = 0; i < state->num_windows; ++i) {
if (state->windows[i] == NULL) if (state->windows[i] == NULL) {
continue; continue;
}
DrawSprites(state->renderers[i], sprites[i]); DrawSprites(state->renderers[i], sprites[i]);
} }
} }
@@ -382,7 +383,7 @@ main(int argc, char *argv[])
/* Initialize test framework */ /* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO); state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
if (!state) { if (state == NULL) {
return 1; return 1;
} }
@@ -445,7 +446,7 @@ main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */ /* Create the windows, initialize the renderers, and load the textures */
sprites = sprites =
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites)); (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) { if (sprites == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2); quit(2);
} }

View File

@@ -137,6 +137,7 @@
<DebugInformationFormat>OldStyle</DebugInformationFormat> <DebugInformationFormat>OldStyle</DebugInformationFormat>
<OmitDefaultLibName>true</OmitDefaultLibName> <OmitDefaultLibName>true</OmitDefaultLibName>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View File

@@ -68,6 +68,8 @@ if(EXISTS "${_sdl2_library}" AND EXISTS "${_sdl2_dll_library}")
IMPORTED_LOCATION "${_sdl2_dll_library}" IMPORTED_LOCATION "${_sdl2_dll_library}"
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
INTERFACE_SDL2_SHARED "ON" INTERFACE_SDL2_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL2"
) )
endif() endif()
set(SDL2_SDL2_FOUND TRUE) set(SDL2_SDL2_FOUND TRUE)
@@ -84,6 +86,8 @@ if(EXISTS "${_sdl2main_library}")
set_target_properties(SDL2::SDL2main set_target_properties(SDL2::SDL2main
PROPERTIES PROPERTIES
IMPORTED_LOCATION "${_sdl2main_library}" IMPORTED_LOCATION "${_sdl2main_library}"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL2"
) )
endif() endif()
set(SDL2_SDL2main_FOUND TRUE) set(SDL2_SDL2main_FOUND TRUE)
@@ -100,6 +104,8 @@ if(EXISTS "${_sdl2test_library}")
PROPERTIES PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
IMPORTED_LOCATION "${_sdl2test_library}" IMPORTED_LOCATION "${_sdl2test_library}"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL2"
) )
endif() endif()
set(SDL2_SDL2test_FOUND TRUE) set(SDL2_SDL2test_FOUND TRUE)

View File

@@ -1,6 +1,16 @@
This is a list of major changes in SDL's version history. This is a list of major changes in SDL's version history.
---------------------------------------------------------------------------
2.28.0:
---------------------------------------------------------------------------
General:
* Added SDL_HasWindowSurface() and SDL_DestroyWindowSurface() to switch between the window surface and rendering APIs
* Added a display event SDL_DISPLAYEVENT_MOVED which is sent when the primary monitor changes or displays change position relative to each other
* Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
2.26.0: 2.26.0:
--------------------------------------------------------------------------- ---------------------------------------------------------------------------

View File

@@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer)
/* create ship texture from surface */ /* create ship texture from surface */
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (!ship) { if (ship == NULL) {
fatalError("could not create ship texture"); fatalError("could not create ship texture");
} }
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
@@ -145,7 +145,7 @@ initializeTextures(SDL_Renderer *renderer)
} }
/* create space texture from surface */ /* create space texture from surface */
space = SDL_CreateTextureFromSurface(renderer, bmp_surface); space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (!space) { if (space == NULL) {
fatalError("could not create space texture"); fatalError("could not create space texture");
} }
SDL_FreeSurface(bmp_surface); SDL_FreeSurface(bmp_surface);

View File

@@ -84,14 +84,16 @@ stepParticles(double deltaTime)
/* is the particle actually active, or is it marked for deletion? */ /* is the particle actually active, or is it marked for deletion? */
if (curr->isActive) { if (curr->isActive) {
/* is the particle off the screen? */ /* is the particle off the screen? */
if (curr->y > screen_h) if (curr->y > screen_h) {
curr->isActive = 0; curr->isActive = 0;
else if (curr->y < 0) } else if (curr->y < 0) {
curr->isActive = 0; curr->isActive = 0;
if (curr->x > screen_w) }
if (curr->x > screen_w) {
curr->isActive = 0; curr->isActive = 0;
else if (curr->x < 0) } else if (curr->x < 0) {
curr->isActive = 0; curr->isActive = 0;
}
/* step velocity, then step position */ /* step velocity, then step position */
curr->yvel += ACCEL * deltaMilliseconds; curr->yvel += ACCEL * deltaMilliseconds;
@@ -133,15 +135,17 @@ stepParticles(double deltaTime)
} }
/* if we're a dust particle, shrink our size */ /* if we're a dust particle, shrink our size */
if (curr->type == dust) if (curr->type == dust) {
curr->size -= deltaMilliseconds * 0.010f; curr->size -= deltaMilliseconds * 0.010f;
}
} }
/* if we're still active, pack ourselves in the array next /* if we're still active, pack ourselves in the array next
to the last active guy (pack the array tightly) */ to the last active guy (pack the array tightly) */
if (curr->isActive) if (curr->isActive) {
*(slot++) = *curr; *(slot++) = *curr;
}
} /* endif (curr->isActive) */ } /* endif (curr->isActive) */
curr++; curr++;
} }
@@ -188,8 +192,9 @@ explodeEmitter(struct particle *emitter)
int i; int i;
for (i = 0; i < 200; i++) { for (i = 0; i < 200; i++) {
if (num_active_particles >= MAX_PARTICLES) if (num_active_particles >= MAX_PARTICLES) {
return; return;
}
/* come up with a random angle and speed for new particle */ /* come up with a random angle and speed for new particle */
float theta = randomFloat(0, 2.0f * 3.141592); float theta = randomFloat(0, 2.0f * 3.141592);
@@ -226,8 +231,9 @@ void
spawnTrailFromEmitter(struct particle *emitter) spawnTrailFromEmitter(struct particle *emitter)
{ {
if (num_active_particles >= MAX_PARTICLES) if (num_active_particles >= MAX_PARTICLES) {
return; return;
}
/* select the particle at the slot at the end of our array */ /* select the particle at the slot at the end of our array */
struct particle *p = &particles[num_active_particles]; struct particle *p = &particles[num_active_particles];
@@ -262,8 +268,9 @@ void
spawnEmitterParticle(GLfloat x, GLfloat y) spawnEmitterParticle(GLfloat x, GLfloat y)
{ {
if (num_active_particles >= MAX_PARTICLES) if (num_active_particles >= MAX_PARTICLES) {
return; return;
}
/* find particle at endpoint of array */ /* find particle at endpoint of array */
struct particle *p = &particles[num_active_particles]; struct particle *p = &particles[num_active_particles];

View File

@@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer)
/* convert RGBA surface to texture */ /* convert RGBA surface to texture */
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (!texture) { if (texture == NULL) {
fatalError("could not create texture"); fatalError("could not create texture");
} }
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);

View File

@@ -165,7 +165,7 @@ loadFont(void)
{ {
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp"); SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
if (!surface) { if (surface == NULL) {
printf("Error loading bitmap: %s\n", SDL_GetError()); printf("Error loading bitmap: %s\n", SDL_GetError());
return 0; return 0;
} else { } else {
@@ -183,7 +183,7 @@ loadFont(void)
SDL_BlitSurface(surface, NULL, converted, NULL); SDL_BlitSurface(surface, NULL, converted, NULL);
/* create our texture */ /* create our texture */
texture = SDL_CreateTextureFromSurface(renderer, converted); texture = SDL_CreateTextureFromSurface(renderer, converted);
if (!texture) { if (texture == NULL) {
printf("texture creation failed: %s\n", SDL_GetError()); printf("texture creation failed: %s\n", SDL_GetError());
} else { } else {
/* set blend mode for our texture */ /* set blend mode for our texture */

View File

@@ -207,10 +207,10 @@ playSound(struct sound *s)
break; break;
} }
/* if this channel's sound is older than the oldest so far, set it to oldest */ /* if this channel's sound is older than the oldest so far, set it to oldest */
if (mixer.channels[i].timestamp < if (mixer.channels[i].timestamp < mixer.channels[oldest_channel].timestamp) {
mixer.channels[oldest_channel].timestamp)
oldest_channel = i; oldest_channel = i;
} }
}
/* no empty channels, take the oldest one */ /* no empty channels, take the oldest one */
if (selected_channel == -1) if (selected_channel == -1)

View File

@@ -58,11 +58,11 @@ main(int argc, char *argv[])
/* create window and renderer */ /* create window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI); window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
if (!window) { if (window == NULL) {
fatalError("Could not initialize Window"); fatalError("Could not initialize Window");
} }
renderer = SDL_CreateRenderer(window, -1, 0); renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) { if (renderer == NULL) {
fatalError("Could not create renderer"); fatalError("Could not create renderer");
} }

View File

@@ -63,7 +63,7 @@ initializeTexture(SDL_Renderer *renderer)
brush = brush =
SDL_CreateTextureFromSurface(renderer, bmp_surface); SDL_CreateTextureFromSurface(renderer, bmp_surface);
SDL_FreeSurface(bmp_surface); SDL_FreeSurface(bmp_surface);
if (!brush) { if (brush == NULL) {
fatalError("could not create brush texture"); fatalError("could not create brush texture");
} }
/* additive blending -- laying strokes on top of eachother makes them brighter */ /* additive blending -- laying strokes on top of eachother makes them brighter */

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.26.0</string> <string>2.28.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>SDLX</string> <string>SDLX</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.26.0</string> <string>2.28.0</string>
</dict> </dict>
</plist> </plist>

View File

@@ -9528,8 +9528,8 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES; DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 2601.0.0; DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
DYLIB_CURRENT_VERSION = 2601.0.0; DYLIB_CURRENT_VERSION = 2801.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES; GCC_ALTIVEC_EXTENSIONS = YES;
@@ -9558,7 +9558,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@loader_path/Frameworks", "@loader_path/Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.9; MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2;
PRODUCT_NAME = SDL2; PRODUCT_NAME = SDL2;
STRIP_STYLE = "non-global"; STRIP_STYLE = "non-global";
@@ -9570,7 +9570,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO; CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.0.17; MARKETING_VERSION = 2.28.0;
OTHER_LDFLAGS = "-liconv"; OTHER_LDFLAGS = "-liconv";
}; };
name = Release; name = Release;
@@ -9613,8 +9613,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 2601.0.0; DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
DYLIB_CURRENT_VERSION = 2601.0.0; DYLIB_CURRENT_VERSION = 2801.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@@ -9643,7 +9643,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@loader_path/Frameworks", "@loader_path/Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.9; MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = NO; ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2;
PRODUCT_NAME = SDL2; PRODUCT_NAME = SDL2;
@@ -9656,7 +9656,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO; CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.0.17; MARKETING_VERSION = 2.28.0;
OTHER_LDFLAGS = "-liconv"; OTHER_LDFLAGS = "-liconv";
}; };
name = Debug; name = Debug;
@@ -9862,8 +9862,8 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 2601.0.0; DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
DYLIB_CURRENT_VERSION = 2601.0.0; DYLIB_CURRENT_VERSION = 2801.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
@@ -9914,8 +9914,8 @@
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 2601.0.0; DYLIB_COMPATIBILITY_VERSION = 2801.0.0;
DYLIB_CURRENT_VERSION = 2601.0.0; DYLIB_CURRENT_VERSION = 2801.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;

View File

@@ -1,4 +1,4 @@
Title SDL 2.0.0 Title SDL 2.28.0
Version 1 Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org) Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks DefaultLocation /Library/Frameworks

View File

@@ -57,6 +57,8 @@ if(NOT TARGET SDL2::SDL2)
INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2" INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
INTERFACE_SDL2_SHARED "ON" INTERFACE_SDL2_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
INTERFACE_SDL_VERSION "SDL2"
) )
endif() endif()
set(SDL2_SDL2_FOUND TRUE) set(SDL2_SDL2_FOUND TRUE)

View File

@@ -1,6 +1,6 @@
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -186,7 +186,7 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead // Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
// of TRANSPORT_LE. Let's force ourselves to connect low energy. // of TRANSPORT_LE. Let's force ourselves to connect low energy.
private BluetoothGatt connectGatt(boolean managed) { private BluetoothGatt connectGatt(boolean managed) {
if (Build.VERSION.SDK_INT >= 23) { if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
try { try {
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE); return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
} catch (Exception e) { } catch (Exception e) {

View File

@@ -251,6 +251,8 @@ public class HIDDeviceManager {
0x20d6, // PowerA 0x20d6, // PowerA
0x24c6, // PowerA 0x24c6, // PowerA
0x2c22, // Qanba 0x2c22, // Qanba
0x2dc8, // 8BitDo
0x9886, // ASTRO Gaming
}; };
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC && if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
@@ -271,14 +273,16 @@ public class HIDDeviceManager {
final int XB1_IFACE_SUBCLASS = 71; final int XB1_IFACE_SUBCLASS = 71;
final int XB1_IFACE_PROTOCOL = 208; final int XB1_IFACE_PROTOCOL = 208;
final int[] SUPPORTED_VENDORS = { final int[] SUPPORTED_VENDORS = {
0x044f, // Thrustmaster
0x045e, // Microsoft 0x045e, // Microsoft
0x0738, // Mad Catz 0x0738, // Mad Catz
0x0e6f, // PDP 0x0e6f, // PDP
0x0f0d, // Hori 0x0f0d, // Hori
0x10f5, // Turtle Beach
0x1532, // Razer Wildcat 0x1532, // Razer Wildcat
0x20d6, // PowerA 0x20d6, // PowerA
0x24c6, // PowerA 0x24c6, // PowerA
0x2dc8, /* 8BitDo */ 0x2dc8, // 8BitDo
0x2e24, // Hyperkin 0x2e24, // Hyperkin
}; };
@@ -353,13 +357,13 @@ public class HIDDeviceManager {
private void initializeBluetooth() { private void initializeBluetooth() {
Log.d(TAG, "Initializing Bluetooth"); Log.d(TAG, "Initializing Bluetooth");
if (Build.VERSION.SDK_INT <= 30 && if (Build.VERSION.SDK_INT <= 30 /* Android 11.0 (R) */ &&
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) { mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH"); Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
return; return;
} }
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) { if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18 /* Android 4.3 (JELLY_BEAN_MR2) */)) {
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE"); Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
return; return;
} }
@@ -573,7 +577,7 @@ public class HIDDeviceManager {
try { try {
final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31 final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
int flags; int flags;
if (Build.VERSION.SDK_INT >= 31) { if (Build.VERSION.SDK_INT >= 31 /* Android 12.0 (S) */) {
flags = FLAG_MUTABLE; flags = FLAG_MUTABLE;
} else { } else {
flags = 0; flags = 0;

View File

@@ -52,7 +52,7 @@ class HIDDeviceUSB implements HIDDevice {
@Override @Override
public String getSerialNumber() { public String getSerialNumber() {
String result = null; String result = null;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
try { try {
result = mDevice.getSerialNumber(); result = mDevice.getSerialNumber();
} }
@@ -74,7 +74,7 @@ class HIDDeviceUSB implements HIDDevice {
@Override @Override
public String getManufacturerName() { public String getManufacturerName() {
String result = null; String result = null;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
result = mDevice.getManufacturerName(); result = mDevice.getManufacturerName();
} }
if (result == null) { if (result == null) {
@@ -86,7 +86,7 @@ class HIDDeviceUSB implements HIDDevice {
@Override @Override
public String getProductName() { public String getProductName() {
String result = null; String result = null;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
result = mDevice.getProductName(); result = mDevice.getProductName();
} }
if (result == null) { if (result == null) {

View File

@@ -29,6 +29,7 @@ public class SDL {
// This function stores the current activity (SDL or not) // This function stores the current activity (SDL or not)
public static void setContext(Context context) { public static void setContext(Context context) {
SDLAudioManager.setContext(context);
mContext = context; mContext = context;
} }

View File

@@ -60,7 +60,7 @@ import java.util.Locale;
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener { public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
private static final String TAG = "SDL"; private static final String TAG = "SDL";
private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MAJOR_VERSION = 2;
private static final int SDL_MINOR_VERSION = 26; private static final int SDL_MINOR_VERSION = 28;
private static final int SDL_MICRO_VERSION = 0; private static final int SDL_MICRO_VERSION = 0;
/* /*
// Display InputType.SOURCE/CLASS of events and devices // Display InputType.SOURCE/CLASS of events and devices
@@ -93,7 +93,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class; s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= 23) {
tst = InputDevice.SOURCE_BLUETOOTH_STYLUS; tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
if ((s & tst) == tst) src += " BLUETOOTH_STYLUS"; if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
s2 &= ~tst; s2 &= ~tst;
@@ -107,7 +107,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
if ((s & tst) == tst) src += " GAMEPAD"; if ((s & tst) == tst) src += " GAMEPAD";
s2 &= ~tst; s2 &= ~tst;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= 21) {
tst = InputDevice.SOURCE_HDMI; tst = InputDevice.SOURCE_HDMI;
if ((s & tst) == tst) src += " HDMI"; if ((s & tst) == tst) src += " HDMI";
s2 &= ~tst; s2 &= ~tst;
@@ -146,7 +146,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
if ((s & tst) == tst) src += " TOUCHSCREEN"; if ((s & tst) == tst) src += " TOUCHSCREEN";
s2 &= ~tst; s2 &= ~tst;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (Build.VERSION.SDK_INT >= 18) {
tst = InputDevice.SOURCE_TOUCH_NAVIGATION; tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
if ((s & tst) == tst) src += " TOUCH_NAVIGATION"; if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
s2 &= ~tst; s2 &= ~tst;
@@ -170,7 +170,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
*/ */
public static boolean mIsResumedCalled, mHasFocus; public static boolean mIsResumedCalled, mHasFocus;
public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24); public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */);
// Cursor types // Cursor types
// private static final int SDL_SYSTEM_CURSOR_NONE = -1; // private static final int SDL_SYSTEM_CURSOR_NONE = -1;
@@ -224,9 +224,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
protected static SDLGenericMotionListener_API12 getMotionListener() { protected static SDLGenericMotionListener_API12 getMotionListener() {
if (mMotionListener == null) { if (mMotionListener == null) {
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26 /* Android 8.0 (O) */) {
mMotionListener = new SDLGenericMotionListener_API26(); mMotionListener = new SDLGenericMotionListener_API26();
} else if (Build.VERSION.SDK_INT >= 24) { } else if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
mMotionListener = new SDLGenericMotionListener_API24(); mMotionListener = new SDLGenericMotionListener_API24();
} else { } else {
mMotionListener = new SDLGenericMotionListener_API12(); mMotionListener = new SDLGenericMotionListener_API12();
@@ -393,7 +393,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
mHIDDeviceManager = HIDDeviceManager.acquire(this); mHIDDeviceManager = HIDDeviceManager.acquire(this);
// Set up the surface // Set up the surface
mSurface = createSDLSurface(getApplication()); mSurface = createSDLSurface(this);
mLayout = new RelativeLayout(this); mLayout = new RelativeLayout(this);
mLayout.addView(mSurface); mLayout.addView(mSurface);
@@ -404,7 +404,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
SDLActivity.onNativeOrientationChanged(mCurrentOrientation); SDLActivity.onNativeOrientationChanged(mCurrentOrientation);
try { try {
if (Build.VERSION.SDK_INT < 24) { if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) {
mCurrentLocale = getContext().getResources().getConfiguration().locale; mCurrentLocale = getContext().getResources().getConfiguration().locale;
} else { } else {
mCurrentLocale = getContext().getResources().getConfiguration().getLocales().get(0); mCurrentLocale = getContext().getResources().getConfiguration().getLocales().get(0);
@@ -588,6 +588,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
mHIDDeviceManager = null; mHIDDeviceManager = null;
} }
SDLAudioManager.release(this);
if (SDLActivity.mBrokenLibraries) { if (SDLActivity.mBrokenLibraries) {
super.onDestroy(); super.onDestroy();
return; return;
@@ -766,7 +768,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
} }
break; break;
case COMMAND_CHANGE_WINDOW_STYLE: case COMMAND_CHANGE_WINDOW_STYLE:
if (Build.VERSION.SDK_INT >= 19) { if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
if (context instanceof Activity) { if (context instanceof Activity) {
Window window = ((Activity) context).getWindow(); Window window = ((Activity) context).getWindow();
if (window != null) { if (window != null) {
@@ -841,7 +843,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
msg.obj = data; msg.obj = data;
boolean result = commandHandler.sendMessage(msg); boolean result = commandHandler.sendMessage(msg);
if (Build.VERSION.SDK_INT >= 19) { if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
if (command == COMMAND_CHANGE_WINDOW_STYLE) { if (command == COMMAND_CHANGE_WINDOW_STYLE) {
// Ensure we don't return until the resize has actually happened, // Ensure we don't return until the resize has actually happened,
// or 500ms have passed. // or 500ms have passed.
@@ -969,15 +971,18 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
/* If set, hint "explicitly controls which UI orientations are allowed". */ /* If set, hint "explicitly controls which UI orientations are allowed". */
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) { if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
} else if (hint.contains("LandscapeRight")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else if (hint.contains("LandscapeLeft")) { } else if (hint.contains("LandscapeLeft")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
} else if (hint.contains("LandscapeRight")) {
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
} }
if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) { /* exact match to 'Portrait' to distinguish with PortraitUpsideDown */
boolean contains_Portrait = hint.contains("Portrait ") || hint.endsWith("Portrait");
if (contains_Portrait && hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
} else if (hint.contains("Portrait")) { } else if (contains_Portrait) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
} else if (hint.contains("PortraitUpsideDown")) { } else if (hint.contains("PortraitUpsideDown")) {
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
@@ -1090,7 +1095,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
// thus SDK version 27. If we are in DeX mode and not API 27 or higher, as a result, // thus SDK version 27. If we are in DeX mode and not API 27 or higher, as a result,
// we should stick to relative mode. // we should stick to relative mode.
// //
if ((Build.VERSION.SDK_INT < 27) && isDeXMode()) { if (Build.VERSION.SDK_INT < 27 /* Android 8.1 (O_MR1) */ && isDeXMode()) {
return false; return false;
} }
@@ -1180,7 +1185,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */
public static boolean isDeXMode() { public static boolean isDeXMode() {
if (Build.VERSION.SDK_INT < 24) { if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) {
return false; return false;
} }
try { try {
@@ -1617,7 +1622,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
private final Runnable rehideSystemUi = new Runnable() { private final Runnable rehideSystemUi = new Runnable() {
@Override @Override
public void run() { public void run() {
if (Build.VERSION.SDK_INT >= 19) { if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
@@ -1670,7 +1675,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888); Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888);
++mLastCursorID; ++mLastCursorID;
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
try { try {
mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY)); mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY));
} catch (Exception e) { } catch (Exception e) {
@@ -1686,7 +1691,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */
public static void destroyCustomCursor(int cursorID) { public static void destroyCustomCursor(int cursorID) {
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
try { try {
mCursors.remove(cursorID); mCursors.remove(cursorID);
} catch (Exception e) { } catch (Exception e) {
@@ -1700,7 +1705,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
*/ */
public static boolean setCustomCursor(int cursorID) { public static boolean setCustomCursor(int cursorID) {
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
try { try {
mSurface.setPointerIcon(mCursors.get(cursorID)); mSurface.setPointerIcon(mCursors.get(cursorID));
} catch (Exception e) { } catch (Exception e) {
@@ -1755,7 +1760,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
cursor_type = 1002; //PointerIcon.TYPE_HAND; cursor_type = 1002; //PointerIcon.TYPE_HAND;
break; break;
} }
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
try { try {
mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type)); mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type));
} catch (Exception e) { } catch (Exception e) {
@@ -1769,7 +1774,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */
public static void requestPermission(String permission, int requestCode) { public static void requestPermission(String permission, int requestCode) {
if (Build.VERSION.SDK_INT < 23) { if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
nativePermissionResult(requestCode, true); nativePermissionResult(requestCode, true);
return; return;
} }
@@ -1798,7 +1803,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
i.setData(Uri.parse(url)); i.setData(Uri.parse(url));
int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK; int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT; flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
} else { } else {
flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
@@ -2002,6 +2007,18 @@ class SDLInputConnection extends BaseInputConnection {
@Override @Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) { public boolean deleteSurroundingText(int beforeLength, int afterLength) {
if (Build.VERSION.SDK_INT <= 29 /* Android 10.0 (Q) */) {
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions>/14560344/android-backspace-in-webview-baseinputconnection
// and https://bugzilla.libsdl.org/show_bug.cgi?id=2265
if (beforeLength > 0 && afterLength == 0) {
// backspace(s)
while (beforeLength-- > 0) {
nativeGenerateScancodeForUnichar('\b');
}
return true;
}
}
if (!super.deleteSurroundingText(beforeLength, afterLength)) { if (!super.deleteSurroundingText(beforeLength, afterLength)) {
return false; return false;
} }

View File

@@ -1,5 +1,8 @@
package org.libsdl.app; package org.libsdl.app;
import android.content.Context;
import android.media.AudioDeviceCallback;
import android.media.AudioDeviceInfo;
import android.media.AudioFormat; import android.media.AudioFormat;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.AudioRecord; import android.media.AudioRecord;
@@ -8,16 +11,49 @@ import android.media.MediaRecorder;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
public class SDLAudioManager import java.util.Arrays;
{
public class SDLAudioManager {
protected static final String TAG = "SDLAudio"; protected static final String TAG = "SDLAudio";
protected static AudioTrack mAudioTrack; protected static AudioTrack mAudioTrack;
protected static AudioRecord mAudioRecord; protected static AudioRecord mAudioRecord;
protected static Context mContext;
private static final int[] NO_DEVICES = {};
private static AudioDeviceCallback mAudioDeviceCallback;
public static void initialize() { public static void initialize() {
mAudioTrack = null; mAudioTrack = null;
mAudioRecord = null; mAudioRecord = null;
mAudioDeviceCallback = null;
if(Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */)
{
mAudioDeviceCallback = new AudioDeviceCallback() {
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
Arrays.stream(addedDevices).forEach(deviceInfo -> addAudioDevice(deviceInfo.isSink(), deviceInfo.getId()));
}
@Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
Arrays.stream(removedDevices).forEach(deviceInfo -> removeAudioDevice(deviceInfo.isSink(), deviceInfo.getId()));
}
};
}
}
public static void setContext(Context context) {
mContext = context;
if (context != null) {
registerAudioDeviceCallback();
}
}
public static void release(Context context) {
unregisterAudioDeviceCallback(context);
} }
// Audio // Audio
@@ -35,7 +71,7 @@ public class SDLAudioManager
} }
} }
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) { protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
int channelConfig; int channelConfig;
int sampleSize; int sampleSize;
int frameSize; int frameSize;
@@ -43,14 +79,14 @@ public class SDLAudioManager
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz"); Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
/* On older devices let's use known good settings */ /* On older devices let's use known good settings */
if (Build.VERSION.SDK_INT < 21) { if (Build.VERSION.SDK_INT < 21 /* Android 5.0 (LOLLIPOP) */) {
if (desiredChannels > 2) { if (desiredChannels > 2) {
desiredChannels = 2; desiredChannels = 2;
} }
} }
/* AudioTrack has sample rate limitation of 48000 (fixed in 5.0.2) */ /* AudioTrack has sample rate limitation of 48000 (fixed in 5.0.2) */
if (Build.VERSION.SDK_INT < 22) { if (Build.VERSION.SDK_INT < 22 /* Android 5.1 (LOLLIPOP_MR1) */) {
if (sampleRate < 8000) { if (sampleRate < 8000) {
sampleRate = 8000; sampleRate = 8000;
} else if (sampleRate > 48000) { } else if (sampleRate > 48000) {
@@ -59,7 +95,7 @@ public class SDLAudioManager
} }
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) { if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
int minSDKVersion = (isCapture ? 23 : 21); int minSDKVersion = (isCapture ? 23 /* Android 6.0 (M) */ : 21 /* Android 5.0 (LOLLIPOP) */);
if (Build.VERSION.SDK_INT < minSDKVersion) { if (Build.VERSION.SDK_INT < minSDKVersion) {
audioFormat = AudioFormat.ENCODING_PCM_16BIT; audioFormat = AudioFormat.ENCODING_PCM_16BIT;
} }
@@ -120,7 +156,7 @@ public class SDLAudioManager
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER; channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
break; break;
case 8: case 8:
if (Build.VERSION.SDK_INT >= 23) { if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND; channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
} else { } else {
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround"); Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
@@ -201,6 +237,10 @@ public class SDLAudioManager
return null; return null;
} }
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */ && deviceId != 0) {
mAudioRecord.setPreferredDevice(getOutputAudioDeviceInfo(deviceId));
}
mAudioRecord.startRecording(); mAudioRecord.startRecording();
} }
@@ -224,6 +264,10 @@ public class SDLAudioManager
return null; return null;
} }
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */ && deviceId != 0) {
mAudioTrack.setPreferredDevice(getInputAudioDeviceInfo(deviceId));
}
mAudioTrack.play(); mAudioTrack.play();
} }
@@ -238,11 +282,73 @@ public class SDLAudioManager
return results; return results;
} }
private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) {
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS))
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
.findFirst()
.orElse(null);
} else {
return null;
}
}
private static AudioDeviceInfo getOutputAudioDeviceInfo(int deviceId) {
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS))
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
.findFirst()
.orElse(null);
} else {
return null;
}
}
private static void registerAudioDeviceCallback() {
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
audioManager.registerAudioDeviceCallback(mAudioDeviceCallback, null);
}
}
private static void unregisterAudioDeviceCallback(Context context) {
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
}
}
/** /**
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) { public static int[] getAudioOutputDevices() {
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames); if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
} else {
return NO_DEVICES;
}
}
/**
* This method is called by SDL using JNI.
*/
public static int[] getAudioInputDevices() {
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
} else {
return NO_DEVICES;
}
}
/**
* This method is called by SDL using JNI.
*/
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames, deviceId);
} }
/** /**
@@ -254,6 +360,11 @@ public class SDLAudioManager
return; return;
} }
if (android.os.Build.VERSION.SDK_INT < 21 /* Android 5.0 (LOLLIPOP) */) {
Log.e(TAG, "Attempted to make an incompatible audio call with uninitialized audio! (floating-point output is supported since Android 5.0 Lollipop)");
return;
}
for (int i = 0; i < buffer.length;) { for (int i = 0; i < buffer.length;) {
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING); int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
if (result > 0) { if (result > 0) {
@@ -326,18 +437,22 @@ public class SDLAudioManager
/** /**
* This method is called by SDL using JNI. * This method is called by SDL using JNI.
*/ */
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) { public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames); return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames, deviceId);
} }
/** This method is called by SDL using JNI. */ /** This method is called by SDL using JNI. */
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) { public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
return 0;
} else {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING); return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
} }
}
/** This method is called by SDL using JNI. */ /** This method is called by SDL using JNI. */
public static int captureReadShortBuffer(short[] buffer, boolean blocking) { public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
if (Build.VERSION.SDK_INT < 23) { if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
return mAudioRecord.read(buffer, 0, buffer.length); return mAudioRecord.read(buffer, 0, buffer.length);
} else { } else {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING); return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
@@ -346,7 +461,7 @@ public class SDLAudioManager
/** This method is called by SDL using JNI. */ /** This method is called by SDL using JNI. */
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) { public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
if (Build.VERSION.SDK_INT < 23) { if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
return mAudioRecord.read(buffer, 0, buffer.length); return mAudioRecord.read(buffer, 0, buffer.length);
} else { } else {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING); return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
@@ -391,4 +506,9 @@ public class SDLAudioManager
} }
public static native int nativeSetupJNI(); public static native int nativeSetupJNI();
public static native void removeAudioDevice(boolean isCapture, int deviceId);
public static native void addAudioDevice(boolean isCapture, int deviceId);
} }

View File

@@ -24,7 +24,7 @@ public class SDLControllerManager
public static native int nativeAddJoystick(int device_id, String name, String desc, public static native int nativeAddJoystick(int device_id, String name, String desc,
int vendor_id, int product_id, int vendor_id, int product_id,
boolean is_accelerometer, int button_mask, boolean is_accelerometer, int button_mask,
int naxes, int nhats, int nballs); int naxes, int axis_mask, int nhats, int nballs);
public static native int nativeRemoveJoystick(int device_id); public static native int nativeRemoveJoystick(int device_id);
public static native int nativeAddHaptic(int device_id, String name); public static native int nativeAddHaptic(int device_id, String name);
public static native int nativeRemoveHaptic(int device_id); public static native int nativeRemoveHaptic(int device_id);
@@ -42,7 +42,7 @@ public class SDLControllerManager
public static void initialize() { public static void initialize() {
if (mJoystickHandler == null) { if (mJoystickHandler == null) {
if (Build.VERSION.SDK_INT >= 19) { if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
mJoystickHandler = new SDLJoystickHandler_API19(); mJoystickHandler = new SDLJoystickHandler_API19();
} else { } else {
mJoystickHandler = new SDLJoystickHandler_API16(); mJoystickHandler = new SDLJoystickHandler_API16();
@@ -50,7 +50,7 @@ public class SDLControllerManager
} }
if (mHapticHandler == null) { if (mHapticHandler == null) {
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26 /* Android 8.0 (O) */) {
mHapticHandler = new SDLHapticHandler_API26(); mHapticHandler = new SDLHapticHandler_API26();
} else { } else {
mHapticHandler = new SDLHapticHandler(); mHapticHandler = new SDLHapticHandler();
@@ -168,6 +168,32 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
arg1Axis = MotionEvent.AXIS_GAS; arg1Axis = MotionEvent.AXIS_GAS;
} }
// Make sure the AXIS_Z is sorted between AXIS_RY and AXIS_RZ.
// This is because the usual pairing are:
// - AXIS_X + AXIS_Y (left stick).
// - AXIS_RX, AXIS_RY (sometimes the right stick, sometimes triggers).
// - AXIS_Z, AXIS_RZ (sometimes the right stick, sometimes triggers).
// This sorts the axes in the above order, which tends to be correct
// for Xbox-ish game pads that have the right stick on RX/RY and the
// triggers on Z/RZ.
//
// Gamepads that don't have AXIS_Z/AXIS_RZ but use
// AXIS_LTRIGGER/AXIS_RTRIGGER are unaffected by this.
//
// References:
// - https://developer.android.com/develop/ui/views/touch-and-input/game-controllers/controller-input
// - https://www.kernel.org/doc/html/latest/input/gamepad.html
if (arg0Axis == MotionEvent.AXIS_Z) {
arg0Axis = MotionEvent.AXIS_RZ - 1;
} else if (arg0Axis > MotionEvent.AXIS_Z && arg0Axis < MotionEvent.AXIS_RZ) {
--arg0Axis;
}
if (arg1Axis == MotionEvent.AXIS_Z) {
arg1Axis = MotionEvent.AXIS_RZ - 1;
} else if (arg1Axis > MotionEvent.AXIS_Z && arg1Axis < MotionEvent.AXIS_RZ) {
--arg1Axis;
}
return arg0Axis - arg1Axis; return arg0Axis - arg1Axis;
} }
} }
@@ -210,7 +236,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
mJoysticks.add(joystick); mJoysticks.add(joystick);
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc,
getVendorId(joystickDevice), getProductId(joystickDevice), false, getVendorId(joystickDevice), getProductId(joystickDevice), false,
getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0); getButtonMask(joystickDevice), joystick.axes.size(), getAxisMask(joystick.axes), joystick.hats.size()/2, 0);
} }
} }
} }
@@ -291,6 +317,9 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
public int getVendorId(InputDevice joystickDevice) { public int getVendorId(InputDevice joystickDevice) {
return 0; return 0;
} }
public int getAxisMask(List<InputDevice.MotionRange> ranges) {
return -1;
}
public int getButtonMask(InputDevice joystickDevice) { public int getButtonMask(InputDevice joystickDevice) {
return -1; return -1;
} }
@@ -308,6 +337,43 @@ class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
return joystickDevice.getVendorId(); return joystickDevice.getVendorId();
} }
@Override
public int getAxisMask(List<InputDevice.MotionRange> ranges) {
// For compatibility, keep computing the axis mask like before,
// only really distinguishing 2, 4 and 6 axes.
int axis_mask = 0;
if (ranges.size() >= 2) {
// ((1 << SDL_GAMEPAD_AXIS_LEFTX) | (1 << SDL_GAMEPAD_AXIS_LEFTY))
axis_mask |= 0x0003;
}
if (ranges.size() >= 4) {
// ((1 << SDL_GAMEPAD_AXIS_RIGHTX) | (1 << SDL_GAMEPAD_AXIS_RIGHTY))
axis_mask |= 0x000c;
}
if (ranges.size() >= 6) {
// ((1 << SDL_GAMEPAD_AXIS_LEFT_TRIGGER) | (1 << SDL_GAMEPAD_AXIS_RIGHT_TRIGGER))
axis_mask |= 0x0030;
}
// Also add an indicator bit for whether the sorting order has changed.
// This serves to disable outdated gamecontrollerdb.txt mappings.
boolean have_z = false;
boolean have_past_z_before_rz = false;
for (InputDevice.MotionRange range : ranges) {
int axis = range.getAxis();
if (axis == MotionEvent.AXIS_Z) {
have_z = true;
} else if (axis > MotionEvent.AXIS_Z && axis < MotionEvent.AXIS_RZ) {
have_past_z_before_rz = true;
}
}
if (have_z && have_past_z_before_rz) {
// If both these exist, the compare() function changed sorting order.
// Set a bit to indicate this fact.
axis_mask |= 0x8000;
}
return axis_mask;
}
@Override @Override
public int getButtonMask(InputDevice joystickDevice) { public int getButtonMask(InputDevice joystickDevice) {
int button_mask = 0; int button_mask = 0;
@@ -743,7 +809,7 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
@Override @Override
public boolean supportsRelativeMouse() { public boolean supportsRelativeMouse() {
return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)); return (!SDLActivity.isDeXMode() || Build.VERSION.SDK_INT >= 27 /* Android 8.1 (O_MR1) */);
} }
@Override @Override
@@ -753,7 +819,7 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
@Override @Override
public boolean setRelativeMouseEnabled(boolean enabled) { public boolean setRelativeMouseEnabled(boolean enabled) {
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) { if (!SDLActivity.isDeXMode() || Build.VERSION.SDK_INT >= 27 /* Android 8.1 (O_MR1) */) {
if (enabled) { if (enabled) {
SDLActivity.getContentView().requestPointerCapture(); SDLActivity.getContentView().requestPointerCapture();
} else { } else {

View File

@@ -116,7 +116,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
int nDeviceHeight = height; int nDeviceHeight = height;
try try
{ {
if (Build.VERSION.SDK_INT >= 17) { if (Build.VERSION.SDK_INT >= 17 /* Android 4.2 (JELLY_BEAN_MR1) */) {
DisplayMetrics realMetrics = new DisplayMetrics(); DisplayMetrics realMetrics = new DisplayMetrics();
mDisplay.getRealMetrics( realMetrics ); mDisplay.getRealMetrics( realMetrics );
nDeviceWidth = realMetrics.widthPixels; nDeviceWidth = realMetrics.widthPixels;
@@ -163,7 +163,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
// Don't skip in MultiWindow. // Don't skip in MultiWindow.
if (skip) { if (skip) {
if (Build.VERSION.SDK_INT >= 24) { if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
if (SDLActivity.mSingleton.isInMultiWindowMode()) { if (SDLActivity.mSingleton.isInMultiWindowMode()) {
Log.v("SDL", "Don't skip in Multi-Window"); Log.v("SDL", "Don't skip in Multi-Window");
skip = false; skip = false;

View File

@@ -126,8 +126,8 @@ if $cygwin ; then
# Now convert the arguments - kludge to limit ourselves to /bin/sh # Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0 i=0
for arg in "$@" ; do for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK=`echo "$arg"|grep -E -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option CHECK2=`echo "$arg"|grep -E -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# #
# Build the Android libraries without needing a project # Build the Android libraries without needing a project
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.) # (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)

View File

@@ -0,0 +1,32 @@
#!/bin/sh
cd "$(dirname $0)/../src"
echo "Running clang-format in $(pwd)"
find . -regex '.*\.[chm]p*' -exec clang-format -i {} \;
# Revert third-party code
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/arm \
video/khronos \
video/x11/edid-parse.c \
video/yuv2rgb
clang-format -i hidapi/SDL_hidapi.c
# Revert generated code
git checkout dynapi/SDL_dynapi_overrides.h
git checkout dynapi/SDL_dynapi_procs.h
git checkout render/metal/SDL_shaders_metal_*.h
echo "clang-format complete!"

View File

@@ -1075,7 +1075,7 @@ case $cpu-$vendor in
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586 cpu=i586
;; ;;
pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
cpu=i686 cpu=i686
;; ;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -395,7 +395,7 @@ int main(void)
printf( printf(
"/*\n" "/*\n"
" Simple DirectMedia Layer\n" " Simple DirectMedia Layer\n"
" Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>\n" " Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>\n"
"\n" "\n"
" This software is provided 'as-is', without any express or implied\n" " This software is provided 'as-is', without any express or implied\n"
" warranty. In no event will the authors be held liable for any damages\n" " warranty. In no event will the authors be held liable for any damages\n"

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -113,7 +113,7 @@ int main(void)
printf( printf(
"/*\n" "/*\n"
" Simple DirectMedia Layer\n" " Simple DirectMedia Layer\n"
" Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>\n" " Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>\n"
"\n" "\n"
" This software is provided 'as-is', without any express or implied\n" " This software is provided 'as-is', without any express or implied\n"
" warranty. In no event will the authors be held liable for any damages\n" " warranty. In no event will the authors be held liable for any damages\n"

View File

@@ -4,6 +4,8 @@
set -eu set -eu
cd `dirname $0`/..
ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h) ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h) ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h) ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
@@ -139,6 +141,25 @@ else
not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version" not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
fi fi
version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info)
if [ "$ref_version" = "$version" ]; then
ok "SDL.info Title $version"
else
not_ok "SDL.info Title $version disagrees with SDL_version.h $ref_version"
fi
marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
ref="$ref_version
$ref_version"
if [ "$ref" = "$marketing" ]; then
ok "project.pbxproj MARKETING_VERSION is consistent"
else
not_ok "project.pbxproj MARKETING_VERSION is inconsistent, expected $ref, got $marketing"
fi
# For simplicity this assumes we'll never break ABI before SDL 3. # For simplicity this assumes we'll never break ABI before SDL 3.
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj) dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)

View File

@@ -30,6 +30,10 @@ echo "Updating version to '$NEWVERSION' ..."
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file. # !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
perl -w -pi -e 's/(Title SDL )\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/pkg-support/SDL.info
perl -w -pi -e 's/(MARKETING_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
DYVER=`expr $MINOR \* 100 + 1` DYVER=`expr $MINOR \* 100 + 1`
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj

View File

@@ -10,6 +10,7 @@ my $projectfullname = 'Simple Directmedia Layer';
my $projectshortname = 'SDL'; my $projectshortname = 'SDL';
my $wikisubdir = ''; my $wikisubdir = '';
my $incsubdir = 'include'; my $incsubdir = 'include';
my $readmesubdir = undef;
my $apiprefixregex = undef; my $apiprefixregex = undef;
my $versionfname = 'include/SDL_version.h'; my $versionfname = 'include/SDL_version.h';
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z'; my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
@@ -22,10 +23,12 @@ my $wikiurl = 'https://wiki.libsdl.org';
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new'; my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
my $srcpath = undef; my $srcpath = undef;
my $wikipath = undef; my $wikipath = undef;
my $wikireadmesubdir = 'README';
my $warn_about_missing = 0; my $warn_about_missing = 0;
my $copy_direction = 0; my $copy_direction = 0;
my $optionsfname = undef; my $optionsfname = undef;
my $wikipreamble = undef; my $wikipreamble = undef;
my $changeformat = undef;
foreach (@ARGV) { foreach (@ARGV) {
$warn_about_missing = 1, next if $_ eq '--warn-about-missing'; $warn_about_missing = 1, next if $_ eq '--warn-about-missing';
@@ -36,6 +39,9 @@ foreach (@ARGV) {
if (/\A--options=(.*)\Z/) { if (/\A--options=(.*)\Z/) {
$optionsfname = $1; $optionsfname = $1;
next; next;
} elsif (/\A--changeformat=(.*)\Z/) {
$changeformat = $1;
next;
} }
$srcpath = $_, next if not defined $srcpath; $srcpath = $_, next if not defined $srcpath;
$wikipath = $_, next if not defined $wikipath; $wikipath = $_, next if not defined $wikipath;
@@ -67,6 +73,7 @@ if (defined $optionsfname) {
$projectshortname = $val, next if $key eq 'projectshortname'; $projectshortname = $val, next if $key eq 'projectshortname';
$wikisubdir = $val, next if $key eq 'wikisubdir'; $wikisubdir = $val, next if $key eq 'wikisubdir';
$incsubdir = $val, next if $key eq 'incsubdir'; $incsubdir = $val, next if $key eq 'incsubdir';
$readmesubdir = $val, next if $key eq 'readmesubdir';
$versionmajorregex = $val, next if $key eq 'versionmajorregex'; $versionmajorregex = $val, next if $key eq 'versionmajorregex';
$versionminorregex = $val, next if $key eq 'versionminorregex'; $versionminorregex = $val, next if $key eq 'versionminorregex';
$versionpatchregex = $val, next if $key eq 'versionpatchregex'; $versionpatchregex = $val, next if $key eq 'versionpatchregex';
@@ -131,6 +138,7 @@ sub wordwrap_with_bullet_indent { # don't call this directly.
my $usual_prefix = ' ' x $bulletlen; my $usual_prefix = ' ' x $bulletlen;
foreach (@wrappedlines) { foreach (@wrappedlines) {
s/\s*\Z//;
$retval .= "$prefix$_\n"; $retval .= "$prefix$_\n";
$prefix = $usual_prefix; $prefix = $usual_prefix;
} }
@@ -255,10 +263,30 @@ sub wikify_chunk {
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>"; $str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
} }
} elsif ($wikitype eq 'md') { } elsif ($wikitype eq 'md') {
# convert `code` things first, so they aren't mistaken for other markdown items.
my $codedstr = '';
while ($str =~ s/\A(.*?)(\`.*?\`)//ms) {
my $codeblock = $2;
$codedstr .= wikify_chunk($wikitype, $1, undef, undef);
if (defined $apiprefixregex) {
# Convert obvious API things to wikilinks, even inside `code` blocks,
# BUT ONLY IF the entire code block is the API thing,
# So something like "just call `SDL_Whatever`" will become
# "just call [`SDL_Whatever`](SDL_Whatever)", but
# "just call `SDL_Whatever(7)`" will not. It's just the safest
# way to do this without resorting to wrapping things in html <code> tags.
$codeblock =~ s/\A\`($apiprefixregex[a-zA-Z0-9_]+)\`\Z/[`$1`]($1)/gms;
}
$codedstr .= $codeblock;
}
# Convert obvious API things to wikilinks. # Convert obvious API things to wikilinks.
if (defined $apiprefixregex) { if (defined $apiprefixregex) {
$str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[$1]($1)/gms; $str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[$1]($1)/gms;
} }
$str = $codedstr . $str;
if (defined $code) { if (defined $code) {
$str .= "```$codelang$code```"; $str .= "```$codelang$code```";
} }
@@ -325,6 +353,11 @@ sub dewikify_chunk {
# bullets # bullets
$str =~ s/^\* /- /gm; $str =~ s/^\* /- /gm;
} elsif ($wikitype eq 'md') {
# Dump obvious wikilinks. The rest can just passthrough.
if (defined $apiprefixregex) {
$str =~ s/\[(\`?$apiprefixregex[a-zA-Z0-9_]+\`?)\]\($apiprefixregex[a-zA-Z0-9_]+\)/$1/gms;
}
} }
if (defined $code) { if (defined $code) {
@@ -355,6 +388,30 @@ sub dewikify_chunk {
# bullets # bullets
$str =~ s/^\* /\n\\\(bu /gm; $str =~ s/^\* /\n\\\(bu /gm;
} elsif ($wikitype eq 'md') {
# Dump obvious wikilinks.
if (defined $apiprefixregex) {
$str =~ s/\[(\`?$apiprefixregex[a-zA-Z0-9_]+\`?)\]\($apiprefixregex[a-zA-Z0-9_]+\)/\n.BR $1\n/gms;
}
# links
$str =~ s/\[(.*?)]\((https?\:\/\/.*?)\)/\n.URL "$2" "$1"\n/g;
# <code></code> is also popular. :/
$str =~ s/\s*\`(.*?)\`\s*/\n.BR $1\n/gms;
# bold+italic
$str =~ s/\s*\*\*\*(.*?)\*\*\*\s*/\n.BI $1\n/gms;
# bold
$str =~ s/\s*\*\*(.*?)\*\*\s*/\n.B $1\n/gms;
# italic
$str =~ s/\s*\*(.*?)\*\s*/\n.I $1\n/gms;
# bullets
$str =~ s/^\- /\n\\\(bu /gm;
} else { } else {
die("Unexpected wikitype when converting to manpages\n"); # !!! FIXME: need to handle Markdown wiki pages. die("Unexpected wikitype when converting to manpages\n"); # !!! FIXME: need to handle Markdown wiki pages.
} }
@@ -399,6 +456,23 @@ sub dewikify {
return $retval; return $retval;
} }
sub filecopy {
my $src = shift;
my $dst = shift;
my $endline = shift;
$endline = "\n" if not defined $endline;
open(COPYIN, '<', $src) or die("Failed to open '$src' for reading: $!\n");
open(COPYOUT, '>', $dst) or die("Failed to open '$dst' for writing: $!\n");
while (<COPYIN>) {
chomp;
s/[ \t\r\n]*\Z//;
print COPYOUT "$_$endline";
}
close(COPYOUT);
close(COPYIN);
}
sub usage { sub usage {
die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n"); die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n");
} }
@@ -415,6 +489,7 @@ my @standard_wiki_sections = (
'Function Parameters', 'Function Parameters',
'Return Value', 'Return Value',
'Remarks', 'Remarks',
'Thread Safety',
'Version', 'Version',
'Code Examples', 'Code Examples',
'Related Functions' 'Related Functions'
@@ -438,9 +513,15 @@ my %headerfuncshasdoxygen = (); # $headerfuncschunk{"SDL_OpenAudio"} -> 1 if t
my $incpath = "$srcpath"; my $incpath = "$srcpath";
$incpath .= "/$incsubdir" if $incsubdir ne ''; $incpath .= "/$incsubdir" if $incsubdir ne '';
my $wikireadmepath = "$wikipath/$wikireadmesubdir";
my $readmepath = undef;
if (defined $readmesubdir) {
$readmepath = "$srcpath/$readmesubdir";
}
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n"); opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
next if not $dent =~ /$selectheaderregex/; # just selected headers. next if not $dent =~ /$selectheaderregex/; # just selected headers.
open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n"); open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n");
@@ -588,8 +669,8 @@ my %wikitypes = (); # contains string of wiki page extension, like $wikitypes{"
my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}. my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}.
my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks' my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks'
opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n"); opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n");
while (readdir(DH)) { while (my $d = readdir(DH)) {
my $dent = $_; my $dent = $d;
my $type = ''; my $type = '';
if ($dent =~ /\.(md|mediawiki)\Z/) { if ($dent =~ /\.(md|mediawiki)\Z/) {
$type = $1; $type = $1;
@@ -726,13 +807,14 @@ if ($copy_direction == 1) { # --copy-to-headers
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it. next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
my $wikitype = $wikitypes{$fn}; my $wikitype = $wikitypes{$fn};
my $sectionsref = $wikifuncs{$fn}; my $sectionsref = $wikifuncs{$fn};
my $remarks = %$sectionsref{'Remarks'}; my $remarks = $sectionsref->{'Remarks'};
my $params = %$sectionsref{'Function Parameters'}; my $params = $sectionsref->{'Function Parameters'};
my $returns = %$sectionsref{'Return Value'}; my $returns = $sectionsref->{'Return Value'};
my $version = %$sectionsref{'Version'}; my $threadsafety = $sectionsref->{'Thread Safety'};
my $related = %$sectionsref{'Related Functions'}; my $version = $sectionsref->{'Version'};
my $deprecated = %$sectionsref{'Deprecated'}; my $related = $sectionsref->{'Related Functions'};
my $brief = %$sectionsref{'[Brief]'}; my $deprecated = $sectionsref->{'Deprecated'};
my $brief = $sectionsref->{'[Brief]'};
my $addblank = 0; my $addblank = 0;
my $str = ''; my $str = '';
@@ -797,6 +879,33 @@ if ($copy_direction == 1) { # --copy-to-headers
$str .= "${whitespace}$_\n"; $str .= "${whitespace}$_\n";
} }
} }
} elsif ($wikitype eq 'md') {
my $l;
$l = shift @lines;
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\|\s*\|\s*\Z/);
$l = shift @lines;
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\-*\s*\|\s*\-*\s*\|\s*\Z/);
while (scalar(@lines) >= 1) {
$l = shift @lines;
if ($l =~ /\A\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*\Z/) {
my $name = $1;
my $desc = $2;
$name =~ s/\A\*\*(.*?)\*\*/$1/;
$name =~ s/\A\'\'\'(.*?)\'\'\'/$1/;
#print STDERR "FN: $fn NAME: $name DESC: $desc\n";
my $whitespacelen = length($name) + 8;
my $whitespace = ' ' x $whitespacelen;
$desc = wordwrap($desc, -$whitespacelen);
my @desclines = split /\n/, $desc;
my $firstline = shift @desclines;
$str .= "\\param $name $firstline\n";
foreach (@desclines) {
$str .= "${whitespace}$_\n";
}
} else {
last; # we seem to have run out of table.
}
}
} else { } else {
die("write me"); die("write me");
} }
@@ -821,6 +930,21 @@ if ($copy_direction == 1) { # --copy-to-headers
} }
} }
if (defined $threadsafety) {
# !!! FIXME: lots of code duplication in all of these.
$str .= "\n" if $addblank; $addblank = 1;
my $v = dewikify($wikitype, $threadsafety);
my $whitespacelen = length("\\threadsafety") + 1;
my $whitespace = ' ' x $whitespacelen;
$v = wordwrap($v, -$whitespacelen);
my @desclines = split /\n/, $v;
my $firstline = shift @desclines;
$str .= "\\threadsafety $firstline\n";
foreach (@desclines) {
$str .= "${whitespace}$_\n";
}
}
if (defined $version) { if (defined $version) {
# !!! FIXME: lots of code duplication in all of these. # !!! FIXME: lots of code duplication in all of these.
$str .= "\n" if $addblank; $addblank = 1; $str .= "\n" if $addblank; $addblank = 1;
@@ -845,6 +969,7 @@ if ($copy_direction == 1) { # --copy-to-headers
s/\A(\:|\* )//; s/\A(\:|\* )//;
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func" s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain. s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
s/\[(.*?)\]\(.*?\)/$1/; # in case some wikilinks remain.
s/\A\/*//; s/\A\/*//;
$str .= "\\sa $_\n"; $str .= "\\sa $_\n";
} }
@@ -905,11 +1030,32 @@ if ($copy_direction == 1) { # --copy-to-headers
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n"); rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
} }
if (defined $readmepath) {
if ( -d $wikireadmepath ) {
mkdir($readmepath); # just in case
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
while (readdir(DH)) {
my $dent = $_;
if ($dent =~ /\A(.*?)\.md\Z/) { # we only bridge Markdown files here.
next if $1 eq 'FrontPage';
filecopy("$wikireadmepath/$dent", "$readmepath/README-$dent", "\r\n");
}
}
closedir(DH);
}
}
} elsif ($copy_direction == -1) { # --copy-to-wiki } elsif ($copy_direction == -1) { # --copy-to-wiki
if (defined $changeformat) {
$dewikify_mode = $changeformat;
$wordwrap_mode = $changeformat;
}
foreach (keys %headerfuncs) { foreach (keys %headerfuncs) {
my $fn = $_; my $fn = $_;
next if not $headerfuncshasdoxygen{$fn}; next if not $headerfuncshasdoxygen{$fn};
my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW. my $origwikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'md'; # default to MarkDown for new stuff.
my $wikitype = (defined $changeformat) ? $changeformat : $origwikitype;
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md') and ($wikitype ne 'manpage')); die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md') and ($wikitype ne 'manpage'));
#print("$fn\n"); next; #print("$fn\n"); next;
@@ -1047,6 +1193,21 @@ if ($copy_direction == 1) { # --copy-to-headers
} }
$desc =~ s/[\s\n]+\Z//ms; $desc =~ s/[\s\n]+\Z//ms;
$sections{'Version'} = wordwrap(wikify($wikitype, $desc)) . "\n"; $sections{'Version'} = wordwrap(wikify($wikitype, $desc)) . "\n";
} elsif ($l =~ /\A\\threadsafety\s+(.*)\Z/) {
my $desc = $1;
while (@doxygenlines) {
my $subline = $doxygenlines[0];
$subline =~ s/\A\s*//;
last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing.
shift @doxygenlines; # dump this line from the array; we're using it.
if ($subline eq '') { # empty line, make sure it keeps the newline char.
$desc .= "\n";
} else {
$desc .= " $subline";
}
}
$desc =~ s/[\s\n]+\Z//ms;
$sections{'Thread Safety'} = wordwrap(wikify($wikitype, $desc)) . "\n";
} elsif ($l =~ /\A\\sa\s+(.*)\Z/) { } elsif ($l =~ /\A\\sa\s+(.*)\Z/) {
my $sa = $1; my $sa = $1;
$sa =~ s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func" $sa =~ s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
@@ -1125,8 +1286,25 @@ if ($copy_direction == 1) { # --copy-to-headers
push @$wikisectionorderref, '[footer]'; push @$wikisectionorderref, '[footer]';
} }
# If changing format, convert things that otherwise are passed through unmolested.
if (defined $changeformat) {
if (($dewikify_mode eq 'md') and ($origwikitype eq 'mediawiki')) {
$$sectionsref{'[footer]'} =~ s/\[\[(Category[a-zA-Z0-9_]+)\]\]/[$1]($1)/g;
} elsif (($dewikify_mode eq 'mediawiki') and ($origwikitype eq 'md')) {
$$sectionsref{'[footer]'} =~ s/\[(Category[a-zA-Z0-9_]+)\]\(.*?\)/[[$1]]/g;
}
foreach (keys %only_wiki_sections) {
my $sect = $_;
if (defined $$sectionsref{$sect}) {
$$sectionsref{$sect} = wikify($wikitype, dewikify($origwikitype, $$sectionsref{$sect}));
}
}
}
# !!! FIXME: This won't be CategoryAPI if we eventually handle things other than functions. # !!! FIXME: This won't be CategoryAPI if we eventually handle things other than functions.
my $footer = $$sectionsref{'[footer]'}; my $footer = $$sectionsref{'[footer]'};
if ($wikitype eq 'mediawiki') { if ($wikitype eq 'mediawiki') {
$footer =~ s/\[\[CategoryAPI\]\],?\s*//g; $footer =~ s/\[\[CategoryAPI\]\],?\s*//g;
$footer = '[[CategoryAPI]]' . (($footer eq '') ? "\n" : ", $footer"); $footer = '[[CategoryAPI]]' . (($footer eq '') ? "\n" : ", $footer");
@@ -1137,10 +1315,11 @@ if ($copy_direction == 1) { # --copy-to-headers
$$sectionsref{'[footer]'} = $footer; $$sectionsref{'[footer]'} = $footer;
if (defined $wikipreamble) { if (defined $wikipreamble) {
my $wikified_preamble = wikify($wikitype, $wikipreamble);
if ($wikitype eq 'mediawiki') { if ($wikitype eq 'mediawiki') {
print FH "====== $wikipreamble ======\n"; print FH "====== $wikified_preamble ======\n";
} elsif ($wikitype eq 'md') { } elsif ($wikitype eq 'md') {
print FH "###### $wikipreamble\n"; print FH "###### $wikified_preamble\n";
} else { die("Unexpected wikitype '$wikitype'\n"); } } else { die("Unexpected wikitype '$wikitype'\n"); }
} }
@@ -1185,9 +1364,51 @@ if ($copy_direction == 1) { # --copy-to-headers
print FH "\n\n"; print FH "\n\n";
close(FH); close(FH);
if (defined $changeformat and ($origwikitype ne $wikitype)) {
system("cd '$wikipath' ; git mv '$_.${origwikitype}' '$_.${wikitype}'");
unlink("$wikipath/$_.${origwikitype}");
}
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n"); rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
} }
if (defined $readmepath) {
if ( -d $readmepath ) {
mkdir($wikireadmepath); # just in case
opendir(DH, $readmepath) or die("Can't opendir '$readmepath': $!\n");
while (my $d = readdir(DH)) {
my $dent = $d;
if ($dent =~ /\AREADME\-(.*?\.md)\Z/) { # we only bridge Markdown files here.
my $wikifname = $1;
next if $wikifname eq 'FrontPage.md';
filecopy("$readmepath/$dent", "$wikireadmepath/$wikifname", "\n");
}
}
closedir(DH);
my @pages = ();
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
while (my $d = readdir(DH)) {
my $dent = $d;
if ($dent =~ /\A(.*?)\.(mediawiki|md)\Z/) {
my $wikiname = $1;
next if $wikiname eq 'FrontPage';
push @pages, $wikiname;
}
}
closedir(DH);
open(FH, '>', "$wikireadmepath/FrontPage.md") or die("Can't open '$wikireadmepath/FrontPage.md': $!\n");
print FH "# All READMEs available here\n\n";
foreach (sort @pages) {
my $wikiname = $_;
print FH "- [$wikiname]($wikiname)\n";
}
close(FH);
}
}
} elsif ($copy_direction == -2) { # --copy-to-manpages } elsif ($copy_direction == -2) { # --copy-to-manpages
# This only takes from the wiki data, since it has sections we omit from the headers, like code examples. # This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
@@ -1235,14 +1456,15 @@ if ($copy_direction == 1) { # --copy-to-headers
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it. next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
my $wikitype = $wikitypes{$fn}; my $wikitype = $wikitypes{$fn};
my $sectionsref = $wikifuncs{$fn}; my $sectionsref = $wikifuncs{$fn};
my $remarks = %$sectionsref{'Remarks'}; my $remarks = $sectionsref->{'Remarks'};
my $params = %$sectionsref{'Function Parameters'}; my $params = $sectionsref->{'Function Parameters'};
my $returns = %$sectionsref{'Return Value'}; my $returns = $sectionsref->{'Return Value'};
my $version = %$sectionsref{'Version'}; my $version = $sectionsref->{'Version'};
my $related = %$sectionsref{'Related Functions'}; my $threadsafety = $sectionsref->{'Thread Safety'};
my $examples = %$sectionsref{'Code Examples'}; my $related = $sectionsref->{'Related Functions'};
my $deprecated = %$sectionsref{'Deprecated'}; my $examples = $sectionsref->{'Code Examples'};
my $brief = %$sectionsref{'[Brief]'}; my $deprecated = $sectionsref->{'Deprecated'};
my $brief = $sectionsref->{'[Brief]'};
my $decl = $headerdecls{$fn}; my $decl = $headerdecls{$fn};
my $str = ''; my $str = '';
@@ -1329,6 +1551,28 @@ if ($copy_direction == 1) { # --copy-to-headers
$str .= ".I $name\n"; $str .= ".I $name\n";
$str .= "$desc\n"; $str .= "$desc\n";
} }
} elsif ($wikitype eq 'md') {
my $l;
$l = shift @lines;
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\|\s*\|\s*\Z/);
$l = shift @lines;
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\-*\s*\|\s*\-*\s*\|\s*\Z/);
while (scalar(@lines) >= 1) {
$l = shift @lines;
if ($l =~ /\A\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*\Z/) {
my $name = $1;
my $desc = $2;
$name =~ s/\A\*\*(.*?)\*\*/$1/;
$name =~ s/\A\'\'\'(.*?)\'\'\'/$1/;
$desc = dewikify($wikitype, $desc);
$str .= ".TP\n";
$str .= ".I $name\n";
$str .= "$desc\n";
} else {
last; # we seem to have run out of table.
}
}
} else { } else {
die("write me"); die("write me");
} }
@@ -1346,6 +1590,11 @@ if ($copy_direction == 1) { # --copy-to-headers
$dewikify_manpage_code_indent = 1; $dewikify_manpage_code_indent = 1;
} }
if (defined $threadsafety) {
$str .= ".SH THREAD SAFETY\n";
$str .= dewikify($wikitype, $threadsafety) . "\n";
}
if (defined $version) { if (defined $version) {
$str .= ".SH AVAILABILITY\n"; $str .= ".SH AVAILABILITY\n";
$str .= dewikify($wikitype, $version) . "\n"; $str .= dewikify($wikitype, $version) . "\n";
@@ -1361,8 +1610,11 @@ if ($copy_direction == 1) { # --copy-to-headers
s/\A(\:|\* )//; s/\A(\:|\* )//;
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func" s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain. s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
s/\[(.*?)\]\(.*?\)/$1/; # in case some wikilinks remain.
s/\A\*\s*\Z//;
s/\A\/*//; s/\A\/*//;
s/\A\.BR\s+//; # dewikify added this, but we want to handle it. s/\A\.BR\s+//; # dewikify added this, but we want to handle it.
s/\A\.I\s+//; # dewikify added this, but we want to handle it.
s/\A\s+//; s/\A\s+//;
s/\s+\Z//; s/\s+\Z//;
next if $_ eq ''; next if $_ eq '';

View File

@@ -32,6 +32,8 @@ function(check_cpu_architecture ARCH VARIABLE)
_internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE}) _internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE})
elseif(ARCH STREQUAL "arm64") elseif(ARCH STREQUAL "arm64")
_internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE})
elseif(ARCH STREQUAL "loongarch64")
_internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE})
else() else()
message(WARNING "Unknown CPU architectures (${ARCH}).") message(WARNING "Unknown CPU architectures (${ARCH}).")
set(${VARIABLE} FALSE) set(${VARIABLE} FALSE)

View File

@@ -29,7 +29,7 @@ ENDMACRO()
# Message Output # Message Output
macro(MESSAGE_WARN _TEXT) macro(MESSAGE_WARN _TEXT)
message(STATUS "*** WARNING: ${_TEXT}") message(WARNING "${_TEXT}")
endmacro() endmacro()
macro(MESSAGE_ERROR _TEXT) macro(MESSAGE_ERROR _TEXT)
@@ -64,7 +64,7 @@ macro(MESSAGE_TESTED_OPTION _NAME)
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}") message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
endmacro() endmacro()
macro(LISTTOSTR _LIST _OUTPUT) function(LISTTOSTR _LIST _OUTPUT)
if(${ARGC} EQUAL 3) if(${ARGC} EQUAL 3)
# prefix for each element # prefix for each element
set(_LPREFIX ${ARGV2}) set(_LPREFIX ${ARGV2})
@@ -73,10 +73,12 @@ macro(LISTTOSTR _LIST _OUTPUT)
endif() endif()
# Do not use string(REPLACE ";" " ") here to avoid messing up list # Do not use string(REPLACE ";" " ") here to avoid messing up list
# entries # entries
set(res)
foreach(_ITEM ${${_LIST}}) foreach(_ITEM ${${_LIST}})
set(${_OUTPUT} "${${_OUTPUT}} ${_LPREFIX}${_ITEM}") set(res "${res} ${_LPREFIX}${_ITEM}")
endforeach() endforeach()
endmacro() set(${_OUTPUT} "${res}" PARENT_SCOPE)
endfunction()
macro(LISTTOSTRREV _LIST _OUTPUT) macro(LISTTOSTRREV _LIST _OUTPUT)
if(${ARGC} EQUAL 3) if(${ARGC} EQUAL 3)

View File

@@ -1,4 +1,5 @@
include(CMakeParseArguments) include(CMakeParseArguments)
include(${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake)
macro(FindLibraryAndSONAME _LIB) macro(FindLibraryAndSONAME _LIB)
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN}) cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
@@ -6,6 +7,13 @@ macro(FindLibraryAndSONAME _LIB)
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}") string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS}) find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*")
set(${_LNAME}_SHARED TRUE)
else()
set(${_LNAME}_SHARED FALSE)
endif()
if(${_LNAME}_LIB) if(${_LNAME}_LIB)
# reduce the library name for shared linking # reduce the library name for shared linking
@@ -83,26 +91,35 @@ endmacro()
# - HAVE_SDL_LOADSO opt # - HAVE_SDL_LOADSO opt
macro(CheckALSA) macro(CheckALSA)
if(SDL_ALSA) if(SDL_ALSA)
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H) sdlFindALSA()
if(HAVE_ASOUNDLIB_H) if(ALSA_FOUND)
CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND) file(GLOB ALSA_SOURCES "${SDL2_SOURCE_DIR}/src/audio/alsa/*.c")
endif()
if(HAVE_LIBASOUND)
set(HAVE_ALSA TRUE)
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
list(APPEND SOURCE_FILES ${ALSA_SOURCES}) list(APPEND SOURCE_FILES ${ALSA_SOURCES})
set(SDL_AUDIO_DRIVER_ALSA 1) set(SDL_AUDIO_DRIVER_ALSA 1)
if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO) set(HAVE_ALSA TRUE)
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading") set(HAVE_ALSA_SHARED FALSE)
endif() if(SDL_ALSA_SHARED)
if(HAVE_SDL_LOADSO)
FindLibraryAndSONAME("asound") FindLibraryAndSONAME("asound")
if(SDL_ALSA_SHARED AND ASOUND_LIB AND HAVE_SDL_LOADSO) if(ASOUND_LIB AND ASOUND_SHARED)
target_include_directories(sdl-build-options INTERFACE $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>)
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"") set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
set(HAVE_ALSA_SHARED TRUE) set(HAVE_ALSA_SHARED TRUE)
else() else()
list(APPEND EXTRA_LIBS asound) message(WARNING "Unable to find asound shared object")
endif()
else()
message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading")
endif()
endif()
if(NOT HAVE_ALSA_SHARED)
list(APPEND CMAKE_DEPENDS ALSA::ALSA)
list(APPEND PKGCONFIG_DEPENDS alsa)
endif() endif()
set(HAVE_SDL_AUDIO TRUE) set(HAVE_SDL_AUDIO TRUE)
else()
set(HAVE_ALSA FALSE)
message(WARNING "Unable to found the alsa development library")
endif() endif()
endif() endif()
endmacro() endmacro()
@@ -400,6 +417,7 @@ endmacro()
# - SDL_X11_SHARED opt # - SDL_X11_SHARED opt
# - HAVE_SDL_LOADSO opt # - HAVE_SDL_LOADSO opt
macro(CheckX11) macro(CheckX11)
cmake_push_check_state(RESET)
if(SDL_X11) if(SDL_X11)
foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss) foreach(_LIB X11 Xext Xcursor Xi Xfixes Xrandr Xrender Xss)
FindLibraryAndSONAME("${_LIB}") FindLibraryAndSONAME("${_LIB}")
@@ -422,6 +440,7 @@ macro(CheckX11)
if(X_INCLUDEDIR) if(X_INCLUDEDIR)
list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}") list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
list(APPEND CMAKE_REQUIRED_INCLUDES ${X_INCLUDEDIR})
endif() endif()
find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X_INCLUDEDIR}") find_file(HAVE_XCURSOR_H NAMES "X11/Xcursor/Xcursor.h" HINTS "${X_INCLUDEDIR}")
@@ -597,6 +616,7 @@ macro(CheckX11)
# Prevent Mesa from including X11 headers # Prevent Mesa from including X11 headers
list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11") list(APPEND EXTRA_CFLAGS "-DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11")
endif() endif()
cmake_pop_check_state()
endmacro() endmacro()
macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL) macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL)
@@ -714,6 +734,17 @@ macro(CheckWayland)
else() else()
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES}) list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
endif() endif()
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_FLAGS ${PKG_LIBDECOR_CFLAGS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${PKG_LIBDECOR_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${PKG_LIBDECOR_LINK_LIBRARIES})
check_symbol_exists(libdecor_frame_get_max_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE)
check_symbol_exists(libdecor_frame_get_min_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
if(HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE AND HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
set(SDL_HAVE_LIBDECOR_GET_MIN_MAX 1)
endif()
cmake_pop_check_state()
endif() endif()
endif() endif()
@@ -946,7 +977,6 @@ macro(CheckPTHREAD)
list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS}) list(APPEND SDL_CFLAGS ${PTHREAD_CFLAGS})
check_c_source_compiles(" check_c_source_compiles("
#define _GNU_SOURCE 1
#include <pthread.h> #include <pthread.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
@@ -957,7 +987,6 @@ macro(CheckPTHREAD)
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1) set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
else() else()
check_c_source_compiles(" check_c_source_compiles("
#define _GNU_SOURCE 1
#include <pthread.h> #include <pthread.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
@@ -988,10 +1017,13 @@ macro(CheckPTHREAD)
check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H) check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
if (HAVE_PTHREAD_H) if (HAVE_PTHREAD_H)
check_c_source_compiles(" check_c_source_compiles("
#define _GNU_SOURCE 1
#include <pthread.h> #include <pthread.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef __APPLE__
pthread_setname_np(\"\");
#else
pthread_setname_np(pthread_self(),\"\"); pthread_setname_np(pthread_self(),\"\");
#endif
return 0; return 0;
}" HAVE_PTHREAD_SETNAME_NP) }" HAVE_PTHREAD_SETNAME_NP)
if (HAVE_PTHREAD_NP_H) if (HAVE_PTHREAD_NP_H)
@@ -1291,3 +1323,16 @@ macro(CheckKMSDRM)
endif() endif()
endif() endif()
endmacro() endmacro()
macro(CheckLibUDev)
if(SDL_LIBUDEV)
check_include_file("libudev.h" have_libudev_header)
if(have_libudev_header)
set(HAVE_LIBUDEV_H TRUE)
FindLibraryAndSONAME(udev)
if(UDEV_LIB_SONAME)
set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
endif()
endif()
endif()
endmacro()

9
cmake/sdlfind.cmake Normal file
View File

@@ -0,0 +1,9 @@
macro(sdlFindALSA)
find_package(ALSA MODULE)
if(ALSA_FOUND AND (NOT TARGET ALSA::ALSA) )
add_Library(ALSA::ALSA UNKNOWN IMPORTED)
set_property(TARGET ALSA::ALSA PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
set_property(TARGET ALSA::ALSA APPEND PROPERTY IMPORTED_LOCATION ${ALSA_LIBRARY})
endif()
endmacro()

55
cmake/sdlplatform.cmake Normal file
View File

@@ -0,0 +1,55 @@
macro(SDL_DetectCMakePlatform)
set(SDL_CMAKE_PLATFORM )
# Get the platform
if(WIN32)
set(SDL_CMAKE_PLATFORM WINDOWS)
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(SDL_CMAKE_PLATFORM LINUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(SDL_CMAKE_PLATFORM FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(SDL_CMAKE_PLATFORM NETBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(SDL_CMAKE_PLATFORM OPENBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(SDL_CMAKE_PLATFORM GNU)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(SDL_CMAKE_PLATFORM BSDI)
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(SDL_CMAKE_PLATFORM FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SDL_CMAKE_PLATFORM SYSV5)
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
set(SDL_CMAKE_PLATFORM SOLARIS)
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(SDL_CMAKE_PLATFORM HPUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(SDL_CMAKE_PLATFORM AIX)
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(SDL_CMAKE_PLATFORM MINIX)
endif()
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(SDL_CMAKE_PLATFORM DARWIN)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(SDL_CMAKE_PLATFORM MACOSX)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
set(SDL_CMAKE_PLATFORM TVOS)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
if(CMAKE_VERSION VERSION_LESS 3.14)
set(SDL_CMAKE_PLATFORM IOS)
endif()
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
message_error("BeOS support has been removed as of SDL 2.0.2.")
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(SDL_CMAKE_PLATFORM HAIKU)
elseif(NINTENDO_3DS)
set(SDL_CMAKE_PLATFORM N3DS)
endif()
if(SDL_CMAKE_PLATFORM)
set(${SDL_CMAKE_PLATFORM} TRUE)
endif()
endmacro()

View File

@@ -13,7 +13,7 @@ case "$machine" in
*android* ) *android* )
EXEPREFIX="lib" EXEPREFIX="lib"
EXESUFFIX=".so" EXESUFFIX=".so"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared" LDFLAGS="$LDFLAGS -shared"
;; ;;
* ) * )
EXEPREFIX="" EXEPREFIX=""
@@ -25,20 +25,20 @@ set -e
# Get the canonical path of the folder containing this script # Get the canonical path of the folder containing this script
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)") testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
CFLAGS="$( pkg-config sdl2 --cflags )" SDL_CFLAGS="$( pkg-config sdl2 --cflags )"
LDFLAGS="$( pkg-config sdl2 --libs )" SDL_LDFLAGS="$( pkg-config sdl2 --libs )"
STATIC_LDFLAGS="$( pkg-config sdl2 --libs --static )" SDL_STATIC_LDFLAGS="$( pkg-config sdl2 --libs --static )"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $CFLAGS $EXTRA_CFLAGS" compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $SDL_CFLAGS $CFLAGS"
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS" link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS" static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
echo "-- CC: $CC" echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS" echo "-- CFLAGS: $CFLAGS"
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
echo "-- LDFLASG: $LDFLAGS" echo "-- LDFLASG: $LDFLAGS"
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS" echo "-- SDL_CFLAGS: $SDL_CFLAGS"
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS" echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
echo "-- COMPILE: $compile_cmd" echo "-- COMPILE: $compile_cmd"
echo "-- LINK: $link_cmd" echo "-- LINK: $link_cmd"

View File

@@ -13,7 +13,7 @@ case "$machine" in
*android* ) *android* )
EXEPREFIX="lib" EXEPREFIX="lib"
EXESUFFIX=".so" EXESUFFIX=".so"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared" LDFLAGS="$LDFLAGS -shared"
;; ;;
* ) * )
EXEPREFIX="" EXEPREFIX=""
@@ -25,20 +25,20 @@ set -e
# Get the canonical path of the folder containing this script # Get the canonical path of the folder containing this script
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)") testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
CFLAGS="$( sdl2-config --cflags )" SDL_CFLAGS="$( sdl2-config --cflags )"
LDFLAGS="$( sdl2-config --libs )" SDL_LDFLAGS="$( sdl2-config --libs )"
STATIC_LDFLAGS="$( sdl2-config --static-libs )" SDL_STATIC_LDFLAGS="$( sdl2-config --static-libs )"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $EXTRA_CFLAGS" compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $SDL_CFLAGS"
link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS" link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS" static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
echo "-- CC: $CC" echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS" echo "-- CFLAGS: $CFLAGS"
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
echo "-- LDFLAGS: $LDFLAGS" echo "-- LDFLAGS: $LDFLAGS"
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS" echo "-- SDL_CFLAGS: $SDL_CFLAGS"
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS" echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
echo "-- COMPILE: $compile_cmd" echo "-- COMPILE: $compile_cmd"
echo "-- LINK: $link_cmd" echo "-- LINK: $link_cmd"

379
configure vendored
View File

@@ -677,6 +677,7 @@ ENABLE_STATIC_TRUE
ENABLE_SHARED_FALSE ENABLE_SHARED_FALSE
ENABLE_SHARED_TRUE ENABLE_SHARED_TRUE
PKGCONFIG_LIBS_PRIV PKGCONFIG_LIBS_PRIV
PKGCONFIG_DEPENDS
SDL_RLD_FLAGS SDL_RLD_FLAGS
SDL_STATIC_LIBS SDL_STATIC_LIBS
SDL_LIBS SDL_LIBS
@@ -2448,6 +2449,58 @@ printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_member } # ac_fn_c_check_member
# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR
# ------------------------------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR.
ac_fn_check_decl ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
as_decl_name=`echo $2|sed 's/ *(.*//'`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
printf %s "checking whether $as_decl_name is declared... " >&6; }
if eval test \${$3+y}
then :
printf %s "(cached) " >&6
else $as_nop
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
eval ac_save_FLAGS=\$$6
as_fn_append $6 " $5"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main (void)
{
#ifndef $as_decl_name
#ifdef __cplusplus
(void) $as_decl_use;
#else
(void) $as_decl_name;
#endif
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
eval "$3=yes"
else $as_nop
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
eval $6=\$ac_save_FLAGS
fi
eval ac_res=\$$3
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_check_decl
ac_configure_args_raw= ac_configure_args_raw=
for ac_arg for ac_arg
do do
@@ -3453,7 +3506,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md # See docs/release_checklist.md
SDL_MAJOR_VERSION=2 SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=26 SDL_MINOR_VERSION=28
SDL_MICRO_VERSION=0 SDL_MICRO_VERSION=0
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
@@ -17652,6 +17705,79 @@ printf "%s\n" "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP" EGREP="$ac_cv_path_EGREP"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
printf %s "checking for fgrep... " >&6; }
if test ${ac_cv_path_FGREP+y}
then :
printf %s "(cached) " >&6
else $as_nop
if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
then ac_cv_path_FGREP="$GREP -F"
else
if test -z "$FGREP"; then
ac_path_FGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_prog in fgrep
do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_FGREP" || continue
# Check for GNU ac_path_FGREP and select it if it is found.
# Check for GNU $ac_path_FGREP
case `"$ac_path_FGREP" --version 2>&1` in
*GNU*)
ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
*)
ac_count=0
printf %s 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
printf "%s\n" 'FGREP' >> "conftest.nl"
"$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_FGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_FGREP="$ac_path_FGREP"
ac_path_FGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_FGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_FGREP"; then
as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_FGREP=$FGREP
fi
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
printf "%s\n" "$ac_cv_path_FGREP" >&6; }
FGREP="$ac_cv_path_FGREP"
# Find a good install program. We prefer a C program (faster), # Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or # so one script is as good as another. But avoid the broken or
@@ -18292,8 +18418,8 @@ base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
find_lib() find_lib()
{ {
gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'` gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | $FGREP programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'` gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | $FGREP libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'` env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
host_lib_path="" host_lib_path=""
@@ -23099,6 +23225,41 @@ printf "%s\n" "$need_gcc_Wno_multichar" >&6; }
fi fi
} }
CheckUnusedLocalTypedefs()
{
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wunused-local-typedefs option" >&5
printf %s "checking for GCC -Wunused-local-typedefs option... " >&6; }
have_gcc_unused_local_typedefs=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int x = 0;
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
have_gcc_unused_local_typedefs=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_unused_local_typedefs" >&5
printf "%s\n" "$have_gcc_unused_local_typedefs" >&6; }
CFLAGS="$save_CFLAGS"
if test x$have_gcc_unused_local_typedefs = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
fi
}
CheckWayland() CheckWayland()
{ {
# Check whether --enable-video-wayland was given. # Check whether --enable-video-wayland was given.
@@ -23329,6 +23490,122 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR \"$decor_lib\""
else else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
fi fi
saved_cflags=$CFLAGS
CFLAGS="$CFLAGS $DECOR_CFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5
printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }
if test ${ac_cv_c_undeclared_builtin_options+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_save_CFLAGS=$CFLAGS
ac_cv_c_undeclared_builtin_options='cannot detect'
for ac_arg in '' -fno-builtin; do
CFLAGS="$ac_save_CFLAGS $ac_arg"
# This test program should *not* compile successfully.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
(void) strchr;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
else $as_nop
# This test program should compile successfully.
# No library function is consistently available on
# freestanding implementations, so test against a dummy
# declaration. Include always-available headers on the
# off chance that they somehow elicit warnings.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <float.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
extern void ac_decl (int, char *);
int
main (void)
{
(void) ac_decl (0, (char *) 0);
(void) ac_decl;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
if test x"$ac_arg" = x
then :
ac_cv_c_undeclared_builtin_options='none needed'
else $as_nop
ac_cv_c_undeclared_builtin_options=$ac_arg
fi
break
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
done
CFLAGS=$ac_save_CFLAGS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5
printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; }
case $ac_cv_c_undeclared_builtin_options in #(
'cannot detect') :
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot make $CC report undeclared builtins
See \`config.log' for more details" "$LINENO" 5; } ;; #(
'none needed') :
ac_c_undeclared_builtin_options='' ;; #(
*) :
ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;;
esac
ac_fn_check_decl "$LINENO" "libdecor_frame_get_min_content_size" "ac_cv_have_decl_libdecor_frame_get_min_content_size" "#include <libdecor.h>
" "$ac_c_undeclared_builtin_options" "CFLAGS"
if test "x$ac_cv_have_decl_libdecor_frame_get_min_content_size" = xyes
then :
ac_have_decl=1
else $as_nop
ac_have_decl=0
fi
printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE $ac_have_decl" >>confdefs.h
if test $ac_have_decl = 1
then :
libdecor_get_min_max=yes
fi
ac_fn_check_decl "$LINENO" "libdecor_frame_get_max_content_size" "ac_cv_have_decl_libdecor_frame_get_max_content_size" "#include <libdecor.h>
" "$ac_c_undeclared_builtin_options" "CFLAGS"
if test "x$ac_cv_have_decl_libdecor_frame_get_max_content_size" = xyes
then :
ac_have_decl=1
else $as_nop
ac_have_decl=0
fi
printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE $ac_have_decl" >>confdefs.h
if test $ac_have_decl = 1
then :
libdecor_get_min_max=yes
fi
if test x$libdecor_get_min_max = xyes; then
printf "%s\n" "#define SDL_HAVE_LIBDECOR_GET_MIN_MAX 1" >>confdefs.h
fi
CFLAGS="$saved_cflags"
fi fi
fi fi
fi fi
@@ -28162,52 +28439,6 @@ else $as_nop
fi fi
if test x$enable_clock_gettime = xyes; then if test x$enable_clock_gettime = xyes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
printf %s "checking for clock_gettime in -lrt... " >&6; }
if test ${ac_cv_lib_rt_clock_gettime+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-lrt $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char clock_gettime ();
int
main (void)
{
return clock_gettime ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_rt_clock_gettime=yes
else $as_nop
ac_cv_lib_rt_clock_gettime=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
printf "%s\n" "$ac_cv_lib_rt_clock_gettime" >&6; }
if test "x$ac_cv_lib_rt_clock_gettime" = xyes
then :
have_clock_gettime=yes
fi
if test x$have_clock_gettime = xyes; then
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5
printf %s "checking for clock_gettime in -lc... " >&6; } printf %s "checking for clock_gettime in -lc... " >&6; }
if test ${ac_cv_lib_c_clock_gettime+y} if test ${ac_cv_lib_c_clock_gettime+y}
@@ -28252,7 +28483,52 @@ fi
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
EXTRA_LDFLAGS="$EXTRA_LDFLAGS" else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
printf %s "checking for clock_gettime in -lrt... " >&6; }
if test ${ac_cv_lib_rt_clock_gettime+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-lrt $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char clock_gettime ();
int
main (void)
{
return clock_gettime ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_rt_clock_gettime=yes
else $as_nop
ac_cv_lib_rt_clock_gettime=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
printf "%s\n" "$ac_cv_lib_rt_clock_gettime" >&6; }
if test "x$ac_cv_lib_rt_clock_gettime" = xyes
then :
have_clock_gettime=yes
fi
if test x$have_clock_gettime = xyes; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
fi fi
fi fi
fi fi
@@ -28330,6 +28606,7 @@ printf "%s\n" "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h
} }
CheckWarnAll CheckWarnAll
CheckUnusedLocalTypedefs
CheckNoStrictAliasing CheckNoStrictAliasing
CheckEventSignals CheckEventSignals
@@ -29800,6 +30077,8 @@ done
PKGCONFIG_DEPENDS=""
if test x$enable_shared = xyes; then if test x$enable_shared = xyes; then
PKGCONFIG_LIBS_PRIV=" PKGCONFIG_LIBS_PRIV="
Libs.private:" Libs.private:"

View File

@@ -12,7 +12,7 @@ orig_CFLAGS="$CFLAGS"
dnl Set various version strings - taken gratefully from the GTk sources dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md # See docs/release_checklist.md
SDL_MAJOR_VERSION=2 SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=26 SDL_MINOR_VERSION=28
SDL_MICRO_VERSION=0 SDL_MICRO_VERSION=0
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
@@ -62,6 +62,7 @@ AC_PROG_AWK
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX
AC_PROG_EGREP AC_PROG_EGREP
AC_PROG_FGREP
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
@@ -180,8 +181,8 @@ base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
dnl Function to find a library in the compiler search path dnl Function to find a library in the compiler search path
find_lib() find_lib()
{ {
gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | $FGREP programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`] gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | $FGREP libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`] env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
if test "$cross_compiling" = yes; then if test "$cross_compiling" = yes; then
host_lib_path="" host_lib_path=""
@@ -1673,6 +1674,27 @@ dnl Haiku headers use multicharacter constants all over the place. Ignore these
fi fi
} }
dnl See if GCC's -Wunused-local-typedefs is supported and disable it
dnl because it triggers on gcc 4.8.4 for compile time asserts inside
dnl of functions.
CheckUnusedLocalTypedefs()
{
AC_MSG_CHECKING(for GCC -Wunused-local-typedefs option)
have_gcc_unused_local_typedefs=no
save_CFLAGS="$CFLAGS"
CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
int x = 0;
]],[])], [have_gcc_unused_local_typedefs=yes],[])
AC_MSG_RESULT($have_gcc_unused_local_typedefs)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_unused_local_typedefs = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
fi
}
dnl Check for Wayland dnl Check for Wayland
CheckWayland() CheckWayland()
{ {
@@ -1786,6 +1808,14 @@ dnl See if libdecor is available
else else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS" EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
fi fi
saved_cflags=$CFLAGS
CFLAGS="$CFLAGS $DECOR_CFLAGS"
AC_CHECK_DECLS([libdecor_frame_get_min_content_size, libdecor_frame_get_max_content_size], [libdecor_get_min_max=yes], [ ], [[#include <libdecor.h>]])
if test x$libdecor_get_min_max = xyes; then
AC_DEFINE(SDL_HAVE_LIBDECOR_GET_MIN_MAX, 1, [ ])
fi
CFLAGS="$saved_cflags"
fi fi
fi fi
fi fi
@@ -3672,15 +3702,14 @@ CheckClockGettime()
[AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=yes]])], [AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=yes]])],
, enable_clock_gettime=yes) , enable_clock_gettime=yes)
if test x$enable_clock_gettime = xyes; then if test x$enable_clock_gettime = xyes; then
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
if test x$have_clock_gettime = xyes; then
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
else
AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes) AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
if test x$have_clock_gettime = xyes; then if test x$have_clock_gettime = xyes; then
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ]) AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
EXTRA_LDFLAGS="$EXTRA_LDFLAGS" else
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
if test x$have_clock_gettime = xyes; then
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
fi fi
fi fi
fi fi
@@ -3738,6 +3767,7 @@ CheckVirtualJoystick()
dnl Do this on all platforms, before everything else (other things might want to override it). dnl Do this on all platforms, before everything else (other things might want to override it).
CheckWarnAll CheckWarnAll
CheckUnusedLocalTypedefs
CheckNoStrictAliasing CheckNoStrictAliasing
dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow. dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.
@@ -4860,6 +4890,8 @@ AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS) AC_SUBST(SDL_LIBS)
AC_SUBST(SDL_STATIC_LIBS) AC_SUBST(SDL_STATIC_LIBS)
AC_SUBST(SDL_RLD_FLAGS) AC_SUBST(SDL_RLD_FLAGS)
PKGCONFIG_DEPENDS=""
AC_SUBST(PKGCONFIG_DEPENDS)
if test x$enable_shared = xyes; then if test x$enable_shared = xyes; then
PKGCONFIG_LIBS_PRIV=" PKGCONFIG_LIBS_PRIV="
Libs.private:" Libs.private:"

View File

@@ -68,14 +68,22 @@ Finally, a word of caution: re running androidbuild.sh wipes any changes you may
done in the build directory for the app! done in the build directory for the app!
For more complex projects, follow these instructions: For more complex projects, follow these instructions:
1. Copy the android-project directory wherever you want to keep your projects 1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
and rename it to the name of your project.
2. Move or symlink this SDL directory into the "<project>/app/jni" directory
3. Edit "<project>/app/jni/src/Android.mk" to include your source files
4a. If you want to use Android Studio, simply open your <project> directory and start building. (The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
(This is needed as the source of SDL has to be compiled by the Android compiler)
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device 4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
@@ -83,9 +91,9 @@ For more complex projects, follow these instructions:
If you already have a project that uses CMake, the instructions change somewhat: If you already have a project that uses CMake, the instructions change somewhat:
1. Do points 1 and 2 from the instruction above. 1. Do points 1 and 2 from the instruction above.
2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build 2. Edit "YOURPROJECT/app/build.gradle" to comment out or remove sections containing ndk-build
and uncomment the cmake sections. Add arguments to the CMake invocation as needed. and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to 3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)" as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of in your CMakeLists.txt file. Also be aware that you should use add_library() instead of

View File

@@ -25,3 +25,4 @@ cmake --install build
- SDL2main should be used to ensure ROMFS is enabled. - SDL2main should be used to ensure ROMFS is enabled.
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function. - By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory. - `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -125,8 +125,6 @@ typedef struct SDL_AssertData
const struct SDL_AssertData *next; const struct SDL_AssertData *next;
} SDL_AssertData; } SDL_AssertData;
#if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */ /* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *, const char *,
@@ -151,9 +149,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
#define SDL_enabled_assert(condition) \ #define SDL_enabled_assert(condition) \
do { \ do { \
while ( !(condition) ) { \ while ( !(condition) ) { \
static struct SDL_AssertData sdl_assert_data = { \ static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
0, 0, #condition, 0, 0, 0, 0 \
}; \
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \ continue; /* go again. */ \
@@ -164,8 +160,6 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
} \ } \
} while (SDL_NULL_WHILE_LOOP_CONDITION) } while (SDL_NULL_WHILE_LOOP_CONDITION)
#endif /* enabled assertions support code */
/* Enable various levels of assertions. */ /* Enable various levels of assertions. */
#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
# define SDL_assert(condition) SDL_disabled_assert(condition) # define SDL_assert(condition) SDL_disabled_assert(condition)

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -249,9 +249,8 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
#define SDL_CPUPauseInstruction() __yield() #define SDL_CPUPauseInstruction() __yield()
#elif defined(__WATCOMC__) && defined(__386__) #elif defined(__WATCOMC__) && defined(__386__)
/* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */
extern __inline void SDL_CPUPauseInstruction(void); extern __inline void SDL_CPUPauseInstruction(void);
#pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h" #pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause"
#else #else
#define SDL_CPUPauseInstruction() #define SDL_CPUPauseInstruction()
#endif #endif

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -52,7 +52,7 @@ typedef enum
dstA = dstA */ dstA = dstA */
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
dstA = (srcA * dstA) + (dstA * (1-srcA)) */ dstA = dstA */
SDL_BLENDMODE_INVALID = 0x7FFFFFFF SDL_BLENDMODE_INVALID = 0x7FFFFFFF
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -332,6 +332,7 @@
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@ #cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@
#cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@ #cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@
#cmakedefine SDL_INPUT_WSCONS @SDL_INPUT_WSCONS@
#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@ #cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@
#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@ #cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
#cmakedefine SDL_JOYSTICK_WGI @SDL_JOYSTICK_WGI@ #cmakedefine SDL_JOYSTICK_WGI @SDL_JOYSTICK_WGI@
@@ -359,6 +360,7 @@
#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ #cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@
#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ #cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@
#cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@ #cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@
#cmakedefine SDL_UDEV_DYNAMIC @SDL_UDEV_DYNAMIC@
/* Enable various sensor drivers */ /* Enable various sensor drivers */
#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@ #cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
@@ -539,7 +541,9 @@
#cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@ #cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@
#cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@ #cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #cmakedefine SDL_HAVE_LIBDECOR_GET_MIN_MAX @SDL_HAVE_LIBDECOR_GET_MIN_MAX@
#if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -491,4 +491,7 @@
/* Enable dynamic libsamplerate support */ /* Enable dynamic libsamplerate support */
#undef SDL_LIBSAMPLERATE_DYNAMIC #undef SDL_LIBSAMPLERATE_DYNAMIC
/* Libdecor get min/max content size functions */
#undef SDL_HAVE_LIBDECOR_GET_MIN_MAX
#endif /* SDL_config_h_ */ #endif /* SDL_config_h_ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -34,7 +34,7 @@
#define HAVE_STDARG_H 1 #define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -52,7 +52,7 @@
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ /* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600) #if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t; typedef signed __int8 int8_t;

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -209,16 +209,21 @@
#define SDL_VIDEO_DRIVER_DUMMY 1 #define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDOWS 1 #define SDL_VIDEO_DRIVER_WINDOWS 1
/* #ifndef SDL_VIDEO_RENDER_D3D
#define SDL_VIDEO_RENDER_D3D 1
#endif*/
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
#define SDL_VIDEO_RENDER_D3D11 1
#endif
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H) #if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
#define SDL_VIDEO_RENDER_D3D12 1 #define SDL_VIDEO_RENDER_D3D12 1
#endif #endif
/* Enable OpenGL support */
#ifndef SDL_VIDEO_OPENGL
#define SDL_VIDEO_OPENGL 1
#endif
#ifndef SDL_VIDEO_OPENGL_WGL
#define SDL_VIDEO_OPENGL_WGL 1
#endif
#ifndef SDL_VIDEO_RENDER_OGL
#define SDL_VIDEO_RENDER_OGL 1
#endif
/* Enable system power support */ /* Enable system power support */
/*#define SDL_POWER_WINDOWS 1*/ /*#define SDL_POWER_WINDOWS 1*/
#define SDL_POWER_HARDWIRED 1 #define SDL_POWER_HARDWIRED 1

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -140,7 +140,7 @@ extern "C" {
#if HAS_BUILTIN_BSWAP16 #if HAS_BUILTIN_BSWAP16
#define SDL_Swap16(x) __builtin_bswap16(x) #define SDL_Swap16(x) __builtin_bswap16(x)
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_ushort) #pragma intrinsic(_byteswap_ushort)
#define SDL_Swap16(x) _byteswap_ushort(x) #define SDL_Swap16(x) _byteswap_ushort(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP #elif defined(__i386__) && !HAS_BROKEN_BSWAP
@@ -189,7 +189,7 @@ SDL_Swap16(Uint16 x)
#if HAS_BUILTIN_BSWAP32 #if HAS_BUILTIN_BSWAP32
#define SDL_Swap32(x) __builtin_bswap32(x) #define SDL_Swap32(x) __builtin_bswap32(x)
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_ulong)
#define SDL_Swap32(x) _byteswap_ulong(x) #define SDL_Swap32(x) _byteswap_ulong(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP #elif defined(__i386__) && !HAS_BROKEN_BSWAP
@@ -241,7 +241,7 @@ SDL_Swap32(Uint32 x)
#if HAS_BUILTIN_BSWAP64 #if HAS_BUILTIN_BSWAP64
#define SDL_Swap64(x) __builtin_bswap64(x) #define SDL_Swap64(x) __builtin_bswap64(x)
#elif defined(_MSC_VER) && (_MSC_VER >= 1400) #elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
#pragma intrinsic(_byteswap_uint64) #pragma intrinsic(_byteswap_uint64)
#define SDL_Swap64(x) _byteswap_uint64(x) #define SDL_Swap64(x) _byteswap_uint64(x)
#elif defined(__i386__) && !HAS_BROKEN_BSWAP #elif defined(__i386__) && !HAS_BROKEN_BSWAP

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -724,10 +724,10 @@ typedef enum
SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT,
SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */ SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */ SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */ SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */ SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */ SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */ SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
SDL_CONTROLLER_BUTTON_MAX SDL_CONTROLLER_BUTTON_MAX
} SDL_GameControllerButton; } SDL_GameControllerButton;

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -377,6 +377,17 @@ extern "C" {
*/ */
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" #define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
/**
* \brief A variable that controls whether the on-screen keyboard should be shown when text input is active
*
* The variable can be set to the following values:
* "0" - Do not show the on-screen keyboard
* "1" - Show the on-screen keyboard
*
* The default value is "1". This hint must be set before text input is activated.
*/
#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
/** /**
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs * \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
* *
@@ -1310,6 +1321,8 @@ extern "C" {
* *
* This variable can be one of the following values: * This variable can be one of the following values:
* "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape" * "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape"
*
* Since SDL 2.0.22 this variable accepts a comma-separated list of values above.
*/ */
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION" #define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION"
@@ -1954,6 +1967,28 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING" #define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
/**
* \brief Controls whether menus can be opened with their keyboard shortcut (Alt+mnemonic).
*
* If the mnemonics are enabled, then menus can be opened by pressing the Alt
* key and the corresponding mnemonic (for example, Alt+F opens the File menu).
* However, in case an invalid mnemonic is pressed, Windows makes an audible
* beep to convey that nothing happened. This is true even if the window has
* no menu at all!
*
* Because most SDL applications don't have menus, and some want to use the Alt
* key for other purposes, SDL disables mnemonics (and the beeping) by default.
*
* Note: This also affects keyboard events: with mnemonics enabled, when a
* menu is opened from the keyboard, you will not receive a KEYUP event for
* the mnemonic key, and *might* not receive one for Alt.
*
* This variable can be set to the following values:
* "0" - Alt+mnemonic does nothing, no beeping. (default)
* "1" - Alt+mnemonic opens menus, invalid mnemonics produce a beep.
*/
#define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS"
/** /**
* \brief A variable controlling whether the windows message loop is processed by SDL * \brief A variable controlling whether the windows message loop is processed by SDL
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -44,6 +44,7 @@
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_guid.h" #include "SDL_guid.h"
#include "SDL_mutex.h"
#include "begin_code.h" #include "begin_code.h"
/* Set up for C function definitions, even when using C++ */ /* Set up for C function definitions, even when using C++ */
@@ -66,6 +67,9 @@ extern "C" {
/** /**
* The joystick structure used to identify an SDL joystick * The joystick structure used to identify an SDL joystick
*/ */
#ifdef SDL_THREAD_SAFETY_ANALYSIS
extern SDL_mutex *SDL_joystick_lock;
#endif
struct _SDL_Joystick; struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick;
@@ -131,7 +135,7 @@ typedef enum
* *
* \since This function is available since SDL 2.0.7. * \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
/** /**
@@ -146,7 +150,7 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
* *
* \since This function is available since SDL 2.0.7. * \since This function is available since SDL 2.0.7.
*/ */
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
/** /**
* Count the number of joysticks attached to the system. * Count the number of joysticks attached to the system.
@@ -284,13 +288,12 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
/** /**
* Get the instance ID of a joystick. * Get the instance ID of a joystick.
* *
* This can be called before any joysticks are opened. If the index is out of * This can be called before any joysticks are opened.
* range, this function will return -1.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system
* \returns the instance id of the selected joystick. If called on an invalid * \returns the instance id of the selected joystick. If called on an invalid
* index, this function returns zero * index, this function returns -1.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
*/ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -40,7 +40,7 @@
* an SDLK_* constant for those keys that do not generate characters. * an SDLK_* constant for those keys that do not generate characters.
* *
* A special exception is the number keys at the top of the keyboard which * A special exception is the number keys at the top of the keyboard which
* always map to SDLK_0...SDLK_9, regardless of layout. * map to SDLK_0...SDLK_9 on AZERTY layouts.
*/ */
typedef Sint32 SDL_Keycode; typedef Sint32 SDL_Keycode;

Some files were not shown because too many files have changed in this diff Show More