Commit graph

7066 commits

Author SHA1 Message Date
Sam Lantinga dacdb1c310 Added support for the ThrustMaster eSwap PRO Controller Xbox 2023-01-03 15:12:18 -08:00
Sylvain 86658f2ca7 Wayland / Drag and Drop: find the current window 2023-01-03 08:18:08 -08:00
Sam Lantinga 9c1a9ecb4b Removed non-float versions of SDL render API drawing functions
This simplifies the API and removes a level of API translation between the int variants of the functions and the float implementation

Fixes https://github.com/libsdl-org/SDL/issues/6656
2023-01-03 08:16:58 -08:00
Sylvain bf76fc6b05 Fixed bug #6816 - SDL_RenderSetVSync doesn't disable vsync for software renderer 2023-01-03 06:38:11 -08:00
Sam Lantinga 38b138cd0a Fixed rounding of floating point values in snprintf 2023-01-03 06:35:25 -08:00
Sam Lantinga 72f0056961 Simulate NTSC timings for Windows desktop display modes 2023-01-03 06:35:25 -08:00
Sam Lantinga e3c1749f5b The refresh rate in SDL_DisplayMode is now a float 2023-01-03 06:35:25 -08:00
Sylvain Becker 851b0e16be
Add SDL_GetRenderVSync (see #6495) (#6965) 2023-01-02 11:21:02 -08:00
Sylvain Becker 023f067903
Update GL_GetSwapInterval for backends (#6963) 2023-01-02 10:15:05 -08:00
Mathieu Eyraud fa5475ba9f Fix joystick instance id check 2023-01-02 09:04:18 -08:00
Mathieu Eyraud ea6f0ae683 Fix use after free in SDL_GetGamepads 2023-01-02 09:03:49 -08:00
Mathieu Eyraud 721ece7ba0
Fix memory leak in SDL_SW_CreateYUVTexture 2023-01-02 10:22:44 +01:00
Sylvain Becker 8a13533949
Handle error return value for SDL_GetSwapInterval 2023-01-01 08:20:41 -08:00
Sam Lantinga a515f51ac0 Removed public joystick locking API
All joystick functions are thread-safe and you can now get an atomic list of joysticks with SDL_GetJoysticks()

Fixes https://github.com/libsdl-org/SDL/issues/6956
2022-12-31 09:24:14 -08:00
Ozkan Sezer 321c30db57 windows: more HANDLE -> HMODULE changes. 2022-12-31 08:00:00 +03:00
Ozkan Sezer 929da2c28e SDL_dynapi.c: LoadLibraryA() returns HMODULE. 2022-12-30 11:11:10 +03:00
Sam Lantinga 324c0b76a0 Removed SDL_HasGamepads(), SDL_HasJoysticks(), and SDL_HasSensors()
Also cleaned up logic for whether we need to poll for events:
- We need to periodically poll for joysticks to handle hotplug.
- We need to frequently poll for joysticks and sensors when they're open so their state can be updated
2022-12-29 23:20:26 -08:00
Sam Lantinga 7f23d71b6a Added SDL_modf() and SDL_modff()
This function is useful for accumulating relative mouse motion if you want to only handle whole pixel movement.
e.g.
static float dx_frac, dy_frac;
float dx, dy;

/* Accumulate new motion with previous sub-pixel motion */
dx = event.motion.xrel + dx_frac;
dy = event.motion.yrel + dy_frac;

/* Split the integral and fractional motion, dx and dy will contain whole pixel deltas */
dx_frac = SDL_modff(dx, &dx);
dy_frac = SDL_modff(dy, &dy);
if (dx != 0.0f || dy != 0.0f) {
    ...
}
2022-12-29 23:12:19 -08:00
Sam Lantinga ead4f122e4 Added basic support for %g snprintf format specifier 2022-12-29 23:12:19 -08:00
Sam Lantinga cefbeb582f Mouse coordinates are floating point
You can get sub-pixel mouse coordinates and motion depending on the platform and display scaling.

Fixes https://github.com/libsdl-org/SDL/issues/2999
2022-12-29 23:12:19 -08:00
Sam Lantinga 98678b5d8d SDL API renaming: SDL_Alloc*/SDL_Free* -> SDL_Create*/SDL_Destroy*
Fixes https://github.com/libsdl-org/SDL/issues/6945
2022-12-29 15:07:15 -08:00
Sam Lantinga e1bd5bd071 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
2022-12-29 14:55:18 -08:00
Sam Lantinga 1b90107fdb Spell out "Float" in function names 2022-12-29 14:50:31 -08:00
Sylvain Becker d7d3c22dbf
Remove more reserved identifiers (#6925) 2022-12-29 13:58:16 -08:00
Sylvain 88630b85f5 SDL_GL_SwapWindow() returns an error code 2022-12-29 08:40:51 -08:00
Sam Lantinga abd051f89e Re-sorted SDL 3.0 API list 2022-12-28 19:55:19 -08:00
Sam Lantinga 80890f3aae SDL API renaming: SDL_render.h
Fixes https://github.com/libsdl-org/SDL/issues/6883
2022-12-28 19:40:25 -08:00
Sam Lantinga ea0c2f55be SDL API renaming: *Is* functions
Feedback from @icculus:
"IsTablet" uses "is" as a form of "to be" ...like, the actual question is of its nature.

The rest is just a superfluous word in the question and it flows as better English with if (RectEmpty) than if (IsRectEmpty)

Fixes https://github.com/libsdl-org/SDL/issues/6932
2022-12-28 19:40:25 -08:00
Sam Lantinga 66351fd4ba Replace tri-state functions SDL_EventState(), SDL_GetJoystickEventState(), SDL_GetGamepadEventState(), SDL_ShowCursor()
`SDL_QUERY`, `SDL_IGNORE`, `SDL_ENABLE`, and `SDL_DISABLE` have been removed.

SDL_EventState() has been replaced with SDL_SetEventEnabled()
SDL_GetEventState() has been replaced with SDL_EventEnabled()
SDL_GameControllerEventState has been replaced with SDL_SetGamepadEventsEnabled() and SDL_GamepadEventsEnabled()
SDL_JoystickEventState has been replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()

SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()

Fixes https://github.com/libsdl-org/SDL/issues/6929
2022-12-28 17:49:34 -08:00
Sam Lantinga 61232de1ab Sort the initial SDL 3.0 symbols 2022-12-28 14:29:03 -08:00
Sylvain 71eb78e790
X11: fix removing SDL_WINDOW_HIDDEN flags (thanks @zturtleman) 2022-12-28 23:18:00 +01:00
Sam Lantinga e4e7a8baff Reset the dynamic API for SDL 3.0 2022-12-28 13:53:06 -08:00
Sam Lantinga 16092f58bb Updated gamepad, joystick, sensor APIs, removing device indices
Instead of indexing into an internal list of devices which requires locking, we return a list of device IDs which can then be queried individually.

Reference: https://github.com/libsdl-org/SDL/issues/6889
2022-12-28 13:10:27 -08:00
Sam Lantinga e40a96155f Fixed getting the VID/PID of a virtual joystick 2022-12-28 12:51:54 -08:00
Sylvain aa46ff8f4b Remove SDL_WINDOW_SHOW flag, as redundant with SDL_WINDOW_HIDDEN 2022-12-28 12:16:57 -08:00
Zack Middleton e512809246 Fixup PS2/PSP SDL_RunApp()
Make PS2/PSP use the mainFunction argument for SDL_RunApp().

Make PSP SDL_RunApp() return the value from mainFunction().

Make PS2 SDL_RunApp() call SDL_SetMainReady() like all other
SDL_RunApp() functions. (It doesn't affect anything for PS2 as
SDL_MAIN_NEEDED isn't defined.)
2022-12-28 05:57:10 -08:00
Sam Lantinga 36d4395c97 SDL API renaming: internal functions 2022-12-27 15:05:51 -08:00
Sylvain 25336d053a Remove underscore for _SDL_iconv_t
And change the name, not to have the same for pointer and data
2022-12-27 12:41:09 -08:00
Sylvain Becker 07808d6a03
Remove underscore in guard header defines (#6922) 2022-12-27 12:31:12 -08:00
Sam Lantinga 3db9112ef4 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
2022-12-27 12:16:46 -08:00
Sylvain 81cd84f456 Remove reserved underscore SDL_joystick 2022-12-27 11:34:13 -08:00
Sam Lantinga ab2d007982 More gamepad renaming 2022-12-27 11:31:54 -08:00
Sam Lantinga 58aecf0a54 SDL API renaming: SDL_rect.h
Fixes https://github.com/libsdl-org/SDL/issues/6887
2022-12-27 11:01:11 -08:00
Sam Lantinga a28d1d59be More gamepad renaming 2022-12-27 10:42:45 -08:00
Sam Lantinga 701e965235 Removed leading underscore in structure names
Fixes https://github.com/libsdl-org/SDL/issues/6856
Closes https://github.com/libsdl-org/SDL/pull/6914
Closes https://github.com/libsdl-org/SDL/pull/6915
Closes https://github.com/libsdl-org/SDL/pull/6916
Closes https://github.com/libsdl-org/SDL/pull/6917
Closes https://github.com/libsdl-org/SDL/pull/6918
Closes https://github.com/libsdl-org/SDL/pull/6919
2022-12-27 10:35:53 -08:00
Sam Lantinga 960e9044b3 Fixed test code after gamepad event rename 2022-12-27 10:28:43 -08:00
Sam Lantinga ad8a6d2b05 Split SDL gamepad internal functions into SDL_gamepad_c.h 2022-12-27 10:23:28 -08:00
Sam Lantinga 659abc721a SDL API renaming: SDL_gamecontroller.h
SDL_gamecontroller.h has been renamed SDL_gamepad.h, and all APIs have been renamed to match.

Fixes https://github.com/libsdl-org/SDL/issues/6885
2022-12-27 09:47:24 -08:00
Sam Lantinga c6969df4d7 SDL API renaming: SDL_video.h
Fixes https://github.com/libsdl-org/SDL/issues/6880
2022-12-27 06:38:34 -08:00
Sam Lantinga cc0296c934 SDL API renaming: SDL_surface.h
Fixes https://github.com/libsdl-org/SDL/issues/6884
2022-12-27 06:36:39 -08:00
Sam Lantinga 2db699f48e SDL API renaming: SDL_sensor.h
Fixes https://github.com/libsdl-org/SDL/issues/6888
2022-12-27 06:23:39 -08:00
Sam Lantinga 0d54115235 SDL API renaming: SDL_render.h
Fixes https://github.com/libsdl-org/SDL/issues/6883
2022-12-27 06:21:13 -08:00
Sam Lantinga 083e436a1a SDL API renaming: SDL_pixels.h
Fixes https://github.com/libsdl-org/SDL/issues/6886
2022-12-27 06:08:31 -08:00
Sam Lantinga fc478c1bc0 SDL API renaming: SDL_joystick.h
Fixes https://github.com/libsdl-org/SDL/issues/6881
2022-12-27 05:50:46 -08:00
Sylvain Becker aa0053141b
Remove SDL_VideoInit / Quit. Prefer SDL_SubSytemInit / Quit (#6913) 2022-12-27 05:42:48 -08:00
Sam Lantinga 713ba2e31a SDL API renaming: SDL_audio.h
Fixes https://github.com/libsdl-org/SDL/issues/6879
2022-12-27 05:32:55 -08:00
Sylvain Becker 47170d288e
Don't export SDL_AudioInit/Quit, use SDL_InitSubsystem instead (#6912)
* Don't export SDL_AudioInit/Quit, use SDL_InitSubsystem instead

* Update README

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2022-12-27 05:22:22 -08:00
Sylvain 3fb0c8b54a Remove/Rename SDL_FreeWAV() to SDL_free() 2022-12-27 05:14:52 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
Sam Lantinga 00f05dcf49 render: only enable clipping when the rectangle is valid
Fixes https://github.com/libsdl-org/SDL/issues/6896
2022-12-26 10:24:25 -08:00
Sam Lantinga cc49f1e279 Fixed crash if mutex functions are used before any mutex has been created 2022-12-26 09:49:36 -08:00
avafinger 12e0e6d130 SDL3 with Hardware Acceleration for ROCKCHIP platform (mali blob) 2022-12-26 08:50:51 -08:00
Frank Praznik abdfa809db Prepend key modifier enum values with 'SDL_' 2022-12-23 20:35:49 -08:00
Ryan C. Gordon 1cf2b566af cpu: Removed 3DNow! support and SDL_Has3DNow().
Reference Issue #6636.
2022-12-23 09:30:56 -08:00
João Henrique 0187209f46 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)").
2022-12-23 09:27:51 -08:00
meyraud705 126c60cb45 Add "SDL_" prefix to RW_SEEK macros 2022-12-23 09:25:37 -08:00
Sam Lantinga 6649309c83 Converted default_cursor.h from ANSI to UTF-8 2022-12-22 17:06:46 -08:00
Rudolf-Walter Kiss-Szakacs cc7b6f9e49 Add SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS.
(cherry picked from commit 232ed540db)
2022-12-22 10:06:02 -08:00
Shawn Hoffman 927c4d4aa4 fix string literal constness warnings
# Conflicts:
#	src/video/winrt/SDL_winrtvideo.cpp
2022-12-22 10:03:40 -08:00
Sam Lantinga 909b513c33 Made SDL_WINDOWEVENT_* and SDL_DISPLAYEVENT_* first class event types
Fixes https://github.com/libsdl-org/SDL/issues/6772
2022-12-22 07:38:13 -08:00
Anonymous Maarten 4676d1d31e android: register all methods using JNI_OnLoad 2022-12-21 23:00:58 -08:00
Anonymous Maarten 3b8548cdcf android: fix java fingerprint fo nativeAddJoystick 2022-12-21 09:39:22 -08:00
Anonymous Maarten 9421828e7e gendynapi.py: add android native symbols to SDL_dynapi.sym 2022-12-21 09:39:22 -08:00
Anonymous Maarten 063cb60659 gendynapi.py: use pathlib + uppercase global variables 2022-12-21 09:39:22 -08:00
Caleb Cornett 19039b6ca4 Fix GDK OpenGL build error 2022-12-20 23:18:04 -05:00
Caleb Cornett 3ebfb15469 gdk: Add support for building with OpenGL on Xbox 2022-12-19 17:57:06 -05:00
Sam Lantinga 83b29f9ce1 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
2022-12-19 09:14:55 -08:00
Maido 94a0e5ea8d
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:10 +01:00
Sylvain Becker 5bf8bc2241
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:55:59 +01:00
Sylvain Becker 186687bda9
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:07:38 +01:00
Sam Lantinga d305bc6d55 Fixed order of operations problem when tearing down the window
Make sure the window framebuffer is cleaned up before shutting down OpenGL, as it might be implemented using an OpenGL texture.

Fixes this call stack:
```
(gdb) p _this
$1 = (SDL_VideoDevice *) 0x42e360
(gdb) p _this->egl_data
$2 = (struct SDL_EGL_VideoData *) 0x0
```
2022-12-17 07:09:24 -08:00
Sam Lantinga b678a98024 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
2022-12-17 06:58:02 -08:00
Sam Lantinga 9c9e6e3aa3 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.

(cherry picked from commit 3b0cd44158)
2022-12-17 06:54:33 -08:00
Maido abf5cc5203
Android audio device selection (#6824)
Make it possible to select a specific audio device for Android
2022-12-16 16:40:02 +01:00
Sam Lantinga 6570febd47 Sorted PS4 controllers, note that the NACON Wireless Controller for PS4 actually reports as an XInput device
(cherry picked from commit a53382e460)
2022-12-15 18:02:24 -08:00
Sam Lantinga 0da118ce45 Note that the NACON Daija Arcade Stick is an arcade stick
(cherry picked from commit e99b9ca9c0)
2022-12-15 18:02:15 -08:00
Daniel Gibson c3bf253b09 Remove SDL3_main from build systems, remove most of src/main/*
XCode is still missing, and src/main/winrt/SDL3-WinRTResource*
still need to find a new home
2022-12-15 08:01:01 -08:00
Daniel Gibson 63d3fb469d Move src/main/haiku/ to src/core/
turns out that this wasn't even built as a static libSDLmain,
but as part of the (possibly dynamic) libSDL3
2022-12-15 08:01:01 -08:00
Daniel Gibson 989a8ca90e Port PSP SDL_main to header-only + SDL_RunApp() 2022-12-15 08:01:01 -08:00
Daniel Gibson b1b3bd654d Port PS2 SDL_main to header-only + SDL_RunApp() 2022-12-15 08:01:01 -08:00
Daniel Gibson 544f2c7982 Port ngage to header-only SDL_main + SDL_RunApp()
For some reason, ngage doesn't seem to be handled in any of the
build systems, so I couldn't add SDL_ngage_runapp.cpp to any buildscript
2022-12-15 08:01:01 -08:00
Daniel Gibson 7bfc41db3c Unify all the SDL_*RunApp() functions into just SDL_RunApp()
makes the SDL_main code shorter

Also added a generic SDL_RunApp() implementation for platforms that
don't really need it.

Some platforms (that use SDL_main but haven't been ported yet) are
still missing, but are added in the following commits.
2022-12-15 08:01:01 -08:00
Daniel Gibson 1de559248e PortNintendo 3DS SDL_main to header-only + SDL_N3DSRunApp()
and move the #undef main and #define main SDL_main to the start/end of
SDL_main_impl.h instead of repeating it in every platform implementation

Thanks to SDL_N3DSRunApp we don't need the #include <3ds.h> in
SDL_main_impl.h - that caused conflicts with testthread.c, because both
have (different) ThreadFunc typedefs.
2022-12-15 08:01:01 -08:00
Daniel Gibson 2aee3e654d Remove SDL_main from VS Solutions in VisualC/ and VisualC-GDK/
and update README-visualc.md and README-gdk.md accordingly

Also moved src/main/windows/version.rc to src/core/windows/
and adjusted VS solutions, CMakeLists.txt and versioning scripts
in build-scripts/ accordingly.

This will eventually allow us to remove all of src/main/

# Conflicts:
#	VisualC/tests/testgesture/testgesture.vcxproj
2022-12-15 08:01:01 -08:00
Daniel Gibson 28b93451dc Make WinRT's SDL_main header-only
As the implementation requires C++, the user will have to include
SDL_main.h in a C++ source file (that needs to be compiled with /ZW).
It's ok to keep the standard main() implementation in plain C and use
an otherwise empty C++ source file for the SDL_main implementation part,
if both source files #include <SDL3/SDL_main.h>

Including SDL_main.h in a C source file will print a message at
compilation (when building for WinRT or possibly other not yet implemented
platforms that require C++ for main), to remind the user of also
including it in a .cpp source file. This message/warning can be disabled
with #define SDL_MAIN_NOIMPL before including SDL_main.h in the C file.
When including it in a .cpp file, there will be a compiler error with
helpful message if it's not compiled with /ZW

For this I renamend _SDL_MAIN_NOIMPL to SDL_MAIN_NOIMPL, because now it's
not for internal use only anymore, but also useful for users (that want
their main() function in a different file than the SDL_main implementation)

Add a project for the testdraw2.c test to the WinRT solution to at least
get some minimal testing on WinRT.
I won't add all tests because it's a lot of manual clicking per test,
but this should be better than nothing :)
2022-12-15 08:01:01 -08:00
Daniel Gibson 8e0693c982 Make iOS/tvOS (uikit) SDL_main header-only
Also adjusted iOS demo's includes to <SDL3/..> and explicit SDL_main.h

untested, I don't have Xcode (or a Mac, for that matter)

The xcode projects (for both Xcode-iOS/ and Xcode/) will probably
have to be adjusted for the SDL_main changes to work, but now at least
the iOS demo source should work as is :)
2022-12-15 08:01:01 -08:00
Daniel Gibson 28ecbbf0b5 Make GDK's SDL_main header-only 2022-12-15 08:01:01 -08:00
Daniel Gibson 2d0eaea1cc Add missing SDL_main.h includes to remaining libSDLmain implementations
this should hopefully make the automated builds work again

(this commit can probably be removed once all affected platforms are
converted to header-only SDL_main)
2022-12-15 08:01:01 -08:00
Daniel Gibson ca2fe7be1a Implement SDL_main as header-only lib for Win32
(remaining platforms will follow)

SDL_main.h is *not* included by SDL.h anymore, users are supposed to
include it directly now, usually only in the file they implement main() in.
If they need the header elsewhere or don't want SDL_main to implement
main() (but only call SDL_SetMainReady() or whatever), they
can #define SDL_MAIN_HANDLED first, same as before.
For SDL-internal usage, I added _SDL_MAIN_NOIMPL, which *also* skips the
implementation and `#define main SDL_main`, but still defines
SDL_MAIN_AVAILABLE and SDL_MAIN_NEEDED in SDL_main.h, as before.

To make the implementaion in the header shorter and avoid including windows.h,
I moved most of the Win32 SDL_main code into SDL3.dll via SDL_Win32RunApp(),
so the header-only part is just the different main functions calling
SDL_Win32RunApp(SDL_main, NULL)

Note that I changed changed the return value and type of OutOfMemory()
to return -1 instead of FALSE, so main() (or WinMain() or whatever)
returns -1 instead of 0 in case of an out-of-memory error

Compared to original Win32 SDL_main, I tweaked the part of the
implementation in SDL_main_impl.h a bit to avoid linker warnings
and conflicts with stuff from windows.h:

- replaced windows.h with own define of WINAPI
  and typedef-ing HINSTANCE and LPSTR.
  This prevents conflicts between all the generically-named #defines and
  types in windows.h and user code (like DrawState in some SDL tests)
- only using one of main() or wmain() gets rid of a MSVC linker error
  ("warning LNK4067: ambiguous entry point")
  If this still causes problems, we might try getting rid of wmain(),
  seemed to me like MSVC can use regular main() in UNICODE mode as well
- simplified the UNICODE logic for that - while this is not exactly
  equivalent to the old, it should make sense and Works For Me
2022-12-15 08:01:01 -08:00
Ryan C. Gordon c637031294
rwops: Fixed another Windows build failure. 2022-12-15 00:16:02 -05:00
Ryan C. Gordon 4075748e41
rwops: Removed unused variable in Windows-specific code. 2022-12-15 00:09:32 -05:00
Brian Kirkpatrick e35730ac54 fixed const error when compiling for mutated total_need value in SDL_rwops.c 2022-12-14 20:25:40 -08:00
Sam Lantinga 980208b814 Fixed crash in SDL_PrivateGameControllerRefreshMapping()
(cherry picked from commit 7a9966af9d)
2022-12-14 20:24:14 -08:00
Ryan C. Gordon 72c1f73bc5
rwops: Make read and write work like POSIX, not stdio.
This simplifies some things, clarifies some things, and also allows
for the possibility of RWops that offer non-blocking i/o (although
none of the current built-in ones do, intentionally, we could add this
later if we choose, or people could provide things like network socket
RWops implementations now, etc.

Fixes #6729.
2022-12-14 15:47:13 -05:00
Frank Praznik e9a9afaded wayland: Look up pressed keys via keycodes instead of scancodes on keyboard entry
On window focus, look up the pressed modifier keys via keycodes instead of scancodes to handle the case of remapped keys, as xkb remapping changes the associated keycode, not the scancode.
2022-12-14 11:31:40 -08:00
Sam Lantinga 3a940ba8ee Updated gendynapi.py to handle thread-safety annotations 2022-12-14 09:59:56 -08:00
Sam Lantinga 5c29b58e95 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:53:39 -08:00
Sylvain Becker 02493579b5
DBus: add a reference to the connection
Fixed bug #6712
2022-12-14 11:41:35 -05:00
Sylvain Becker e0ee9fa80c
Fix build (#6808) 2022-12-14 09:47:15 +01:00
Ryan C. Gordon 5a2d0b69c8
render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer.
Fixes #6625.
2022-12-13 23:27:35 -05:00
Ryan C. Gordon a76053352c
gesture: Removed the gesture API from SDL3.
Fixes #6758.
2022-12-13 14:54:37 -05:00
Simon McVittie 45ebdfb1dc emscripten: Replace a stray reference to SDL2 with SDL3
Entirely untested, but I'm fairly sure this is what was intended.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-13 09:03:11 -05:00
Sam Lantinga 650e16a824 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
2022-12-12 20:26:17 -08:00
Sam Lantinga a506d798d8 Don't try to open the Razer Huntsman Elite keyboard as a controller
(cherry picked from commit 817454cfe6)
2022-12-12 18:01:32 -08:00
Ryan C. Gordon 12486e144b
wasapi: Fixed incorrect assertions.
Fixes #6795.
2022-12-12 16:07:48 -05:00
Frank Praznik 90a964f132 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.
2022-12-12 11:21:20 -08:00
Sam Lantinga 618340bf99 Added support for the STRIKEPAD PS4 Grip Add-on to the HIDAPI driver 2022-12-12 10:55:38 -08:00
Pierre Wendling 053ce39d67
N3DS: Semaphore fixes. (#6776)
* N3DS: Make Sem waits cooperative friendly.

The 3DS has a cooperative threading model. Sleeping after TryWait and
WaitTimeout avoid starving other threads. It inccurs a runtime penalty,
but it's better than having to hard reset your console to recover from
a deadlock.
2022-12-11 11:27:16 -08:00
Sylvain e5a470d0d3
Update DYNAPI SDL_WinRTRunApp() prototype which was wrong (see #6783) 2022-12-10 17:54:16 +01:00
Sylvain 3d190ebcb4
SDL_dynapi_procs: fixed SDL_UIKitRunApp prototype (see #6783) 2022-12-10 17:45:56 +01:00
Sylvain f906c52ee6
SDL_assert: remove old naming convention (see #6783) 2022-12-10 17:19:00 +01:00
Sylvain 2905b6d65a
SDL_dynapi_procs: update wrong naming conventions with SDL_AssertState/Data (see #6783) 2022-12-10 17:15:14 +01:00
Sylvain 99baebf5eb
SDL_dynapi_procs.h: one more space (for diff purpose) 2022-12-09 20:42:01 +01:00
Sylvain b7008e4614
SDL_dynapi_procs: remove extra ' ' 2022-12-09 20:36:34 +01:00
Sylvain cce1341b5b
gendynapi.py: don't generate parameter for '...' - corrected 2022-12-09 20:34:13 +01:00
Sylvain f442d0a0ef
Revert "gendynapi.py: don't generate parameter for '...'"
This reverts commit ea8c7df91b.
2022-12-09 20:33:14 +01:00
Sylvain ea8c7df91b
gendynapi.py: don't generate parameter for '...' 2022-12-09 20:22:44 +01:00
Sylvain 5f89987d7f
Fixed extra 'space' (see #6783 Thanks @sezero !) 2022-12-09 20:09:17 +01:00
Sam Lantinga 3736005fc4 Added test event logging for SDL_WINDOWEVENT_ICCPROF_CHANGED and SDL_WINDOWEVENT_DISPLAY_CHANGED 2022-12-09 10:23:00 -08:00
Sylvain b116dd8eb8
gendynapi.py: add comment for OS-specific API (Thanks @DanielGibson!) 2022-12-09 09:27:19 +01:00
Sam Lantinga cfa493c97f Use the current timestamp for keyboard hook events
Fixes https://github.com/libsdl-org/SDL/issues/6771
2022-12-08 23:13:13 -08:00
Sam Lantinga 5bc80abe0d Added logging for SDL_DISPLAYEVENT_MOVED
(cherry picked from commit be3b1cff0b)
2022-12-08 17:04:27 -08:00
Sam Lantinga 7d1bf0a9fe Make sure the display list is up to date for window placement
(cherry picked from commit ab479b4961)
2022-12-08 17:04:11 -08:00
Sam Lantinga a4a80360f5 Added SDL_DISPLAYEVENT_MOVED to detect when display positioning changes
(cherry picked from commit 264da8c127)
2022-12-08 12:47:56 -08:00
Sam Lantinga 98fa97de91 Fixed memory leak when removing existing displays
(cherry picked from commit cfc7cac3c9)
2022-12-08 12:46:50 -08:00
Frank Praznik 653e484da1 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.
2022-12-08 09:29:37 -08:00
Sylvain e93769d2c9 Extract the name of a callback paramter 2022-12-08 08:55:27 -08:00
Sylvain 67a4094eea Rewrite + gendynapi into python 2022-12-08 08:55:27 -08:00
Sylvain c265fb74b0 Renamed AUDIODRIVER and VIDEODRIVER hint/env to AUDIO_DRIVER and VIDEO_DRIVER 2022-12-08 09:50:09 -05:00
Ryan C. Gordon 7ca0d15d64
events: Changed SDL_GetEventState from a macro to a function.
Fixes #6773.
2022-12-08 00:08:51 -05:00
Sam Lantinga 9a6bcca6b8 Use the correct name for the DualSense controllers 2022-12-07 14:53:33 -08:00
Sam Lantinga 9339085593 Added support for the DualSense Edge paddles 2022-12-07 14:25:53 -08:00
Sam Lantinga a71ac0eb06 Revert "Add window title to app_ids for different"
This reverts commit 39eab4bf44.

From @Kontrabant:
Making windows use the window title as the app ID by default doesn't seem like the right direction. The app ID is used by window managers to group windows from the same application together for switching between with alt-tilde and such functionality, and giving each window it's own app ID would break this.
2022-12-07 07:39:40 -08:00
Frank Praznik 30bb8f616d wayland: Pass through event timestamps of 0
Always pass through event timestamps of 0 so the current time will be used for the event.
2022-12-06 09:17:00 -08:00
Lei.Huang 39eab4bf44 Add window title to app_ids for different
"app_ids" can be used for multiple windows

Signed-off-by: Lei.Huang <leihuang@amd.com>
2022-12-05 21:30:03 -05:00
Sam Lantinga e8b1dfef9b Fixed centering the D-pad on some joysticks
Fixes https://github.com/libsdl-org/SDL/issues/6767
2022-12-05 13:33:04 -08:00
Sam Lantinga fcafe40948 Removed balls from the joystick API
They were only used by one joystick decades ago, so removing them for SDL3

Fixes https://github.com/libsdl-org/SDL/issues/6766
2022-12-05 13:17:18 -08:00
Sam Lantinga 75f1eb9216 Don't assume evdev events and SDL_GetTicks() use the same time source
The evdev events are in the same time base as gettimeofday(), but SDL_GetTicks() might be using clock_gettime()
2022-12-05 10:40:16 -08:00
Sam Lantinga 57d34f2e10 Make sure we never get a zero tick_start value 2022-12-05 10:17:38 -08:00
Sam Lantinga c468d93760 Removed unnecessary conversion from nanoseconds to milliseconds in SDL_GetTicks() 2022-12-05 10:11:22 -08:00
Sam Lantinga 82b01035d1 Reduce the chance of overflow when calculating nanosecond time
Fixes https://github.com/libsdl-org/SDL/issues/6762
2022-12-05 09:43:30 -08:00
Ozkan Sezer ed6d401616 gendynapi.pl: fix "Use of uninitialized value $7" after commit 0f9482e.
Reference issue: https://github.com/libsdl-org/SDL/issues/6740.
2022-12-05 20:29:56 +03:00
Sylvain af5bda5ef3 Fix warnings 'macro argument should be enclosed in parentheses' 2022-12-05 09:06:44 -08:00
Frank Praznik 8cafde5ecc wayland: Add high-resolution event timestamp support
Add the protocol for high-resolution timestamp events and subscribe to them if available.

Event timestamps are now handled natively in nanoseconds as much as possible to avoid error-prone conversions.

Variables have been appended with _ms or _ns where appropriate, to avoid ambiguity.
2022-12-04 16:56:26 -08:00
Ozkan Sezer d6327a00fb re-applied the SDL_NewAudioStream deconstification, including to its definition
we should keep this to SDL3 only.
2022-12-04 20:50:20 +03:00
Sam Lantinga d3ba6529e6 Fixed windows build 2022-12-04 09:39:55 -08:00
Cameron Cawley ee0e9e979c Move intrinsic includes into a private header 2022-12-04 09:34:10 -08:00
Sam Lantinga b4da4ed95a Removed SDL_SensorGetDataWithTimestamp() and SDL_GameControllerGetSensorDataWithTimestamp()
If you care about timestamps you'll also want to catch all of the sensor events instead of just polling the current state. For example, Nintendo Switch controllers generate 3 sensor events with distinct values for each polling interval.
2022-12-04 09:29:28 -08:00
Sam Lantinga b8760a3ffe The timestamp_us member of the sensor events has been renamed sensor_timestamp and now represents nanoseconds. 2022-12-04 09:29:28 -08:00
Sam Lantinga 73f4aeee6a Pass the event timestamp for joystick events
This allows the application to get more fine grained information about controller event timing, and group events that happened together.
2022-12-04 09:29:28 -08:00
Sam Lantinga f32cdfa096 Fixed presentation reset calculation (thanks @zturtleman!) 2022-12-04 09:28:03 -08:00
Ozkan Sezer 25e62193f4 just revert the const removal from SDL_NewAudioStream in commit d0bbfdb 2022-12-04 12:56:50 +03:00
Ozkan Sezer 202eaeea11 replace windows timeapi.h with mmsystem.h for better compatibility. 2022-12-04 12:50:04 +03:00
Ozkan Sezer 36a43eac00 apply const removal changes from SDL_NewAudioStream to dynapi side too. 2022-12-04 12:47:20 +03:00
Frank Praznik 1f40b9de96 wayland: Pass event timestamps to SDL
SDL events support system timestamps now, so pass them through.
2022-12-03 21:17:35 -08:00
Sylvain Becker 4ffa7f868d
Fixed bug libsdl-org#6745 - Check for overflow in SDL_CalculateYUVSize (#6747)
Fixed bug #6745 - Check for overflow in SDL_CalculateYUVSize
2022-12-03 21:22:14 +01:00
Max Bachmann 5650046f93 Detect Logitech PRO Racing Wheel as wheel 2022-12-03 08:21:18 -08:00
Sylvain 021d0b7300
Fix wrong clang-tidy modification. This is an integer division. Thanks @meyraud705 (see PR #6725) 2022-12-03 13:36:09 +01:00
Ozkan Sezer 0f9482ebc3 reran gendynapi.pl to add SDL_GetTicksNS / SDL_DelayNS to SDL_dynapi.sym 2022-12-03 00:33:50 +03:00
Jan Engelhardt 1878674477 build: add symbol versioning for SDL
If a program built against one version of SDL is run in an
environment where there is an earlier version of the SDL .so library
installed, the result varies depending on platform configuration; in
the best case, it won't start at all, at worst it aborts in the
middle of the user doing "something important" (systems implementing
lazy symbol resolution). verdefs on the other hand are always checked
on startup.

The dependency information present in programs and shared libraries
is not only of value to the dynamic linker, but also to a
distribution's package management. If the dynamic linker is able to
tell that a program is not runnable per the above, a package manager
is able to come to the same conclusion — and block the installation
of a nonfunctional program+library ensemble.

Because there are a lot more symbols than there are libraries (I am
going to throw in "10^4 to 1 or worse"), package managers generally
do not evaluate symbols, but only e.g. the SONAME, NEEDED and VERNEED
fields/blocks. Because the SONAME is the same between two SDL
versions like 2.0.24, and 2.0.26, everything rests on having verdefs.

This patch proposes the addition of verdefs.
2022-12-02 13:05:37 -08:00
Sylvain Becker 92cd2c0a74
Enable creation of yuv SDL_Surfaces (#6735) 2022-12-02 12:53:48 -08:00
Sam Lantinga 0a3262e819 Pass the OS event timestamp for keyboard, mouse, and touch events where possible
Currently implemented for Windows and Apple platforms
2022-12-02 12:37:41 -08:00
Sam Lantinga 1f4cc733a1 Removed the nanosecond versions of event and thread primitive waits from the public API
It's not clear applications need this level of precision yet, so let's leave these private for now.
2022-12-02 12:37:41 -08:00
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00
Sylvain 764b899a13
Fix Conditional jump or move depends on uninitialised value(s)
eg ./testsprite2 --trackmem
2022-12-02 21:11:33 +01:00
Ozkan Sezer a3d7dd2464 SDL_sysfilesystem.c (SDL_GetBasePath): fixed the solaris code path.
Reference issue: https://github.com/libsdl-org/SDL/pull/6681
2022-12-02 06:23:30 +03:00
Ozkan Sezer ab916e8a61 fixed corrupted (zero-sized) SDL3-WinRTResource_BlankCursor.cur.
(copied from SDL2 branch with renaming.)
2022-12-02 03:32:00 +03:00
Frank Praznik 378b1c286a Fix formatting on Wayland and Pipewire function signatures
Fixes the formatting on some function signatures that clang-format missed.
2022-12-01 15:13:28 -08:00
Sylvain Becker ab1f4172e3
Remove SDL_GL_CONTEXT_EGL #6657 (#6683) 2022-12-01 14:53:37 -08:00
Sam Lantinga 7237c56499 Detect the G923 (Xbox style) and PXN V900 (PS3 mode) as wheels 2022-12-01 14:43:34 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sylvain Becker 932f61348d
Remove mask versions of SDL_CreateRGBSurface* #6701 (#6711)
* Rename SDL_CreateRGBSurface{,From} to SDL_CreateSurface{,From}, which now takes a format parameter
2022-12-01 08:04:02 -08:00
Sylvain 778b8926b4
Small format changed (using clang-format 15.0.2-1) 2022-12-01 09:39:08 +01:00
Ozkan Sezer 45025799b7 restore SDL_malloc.c original formatting. 2022-11-30 17:28:26 -08:00
Sam Lantinga 36c5d5cc65 Added support for the Logitech Cordless Precision PS3 controller 2022-11-30 17:18:00 -08:00
Sam Lantinga 4f9c2b3e2e Added support for the HORIPAD Pro for Xbox Series X 2022-11-30 17:17:44 -08:00
Sam Lantinga e2df0a9d5a Re-enabled support for third party PS3 controllers 2022-11-30 17:17:15 -08:00
Sam Lantinga 27e8eb4ca8 Fixed Victrix FS Pro V2 controller hang on reboot
(cherry picked from commit 9e997cc787)
2022-11-30 15:39:48 -08:00
Sam Lantinga f8c3528c55 Fixed crash if GetRectDisplayIndex() is called before SDL_VideoInit()
(cherry picked from commit d87048fd5a)
2022-11-30 14:38:25 -08:00
Sam Lantinga 1e2dfdb019 Removed the OpenGL ES 1.0 2D render implementation
In SDL3 we plan to make more use of shaders in the 2D render API, and this minimizes the number of platforms we have to consider for new features. OpenGL ES 2.0 or newer is supported on all modern iOS and Android devices.
2022-11-30 13:39:37 -08:00
Sam Lantinga 5750bcb174
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
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Sam Lantinga 6ca7212b75 Fixed unreachable code warning 2022-11-29 18:03:58 -08:00
Ethan Lee f9f7db4e08 video: Prefer Wayland over X11 (take 2!) 2022-11-29 16:35:36 -05:00
David Edmundson 6d2b74db66 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:35:12 -05:00
Ryan C. Gordon a3225ae6de
dynapi: Abstract out the environment variable name. 2022-11-29 14:13:07 -05:00
pionere cf0cb44df8 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)
2022-11-29 10:59:40 -08:00
Sylvain Becker fc4fc5295f
Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_Create… (#6685)
* Remove depth field from SDL_CreateRGBSurfaceWithFormat and SDL_CreateRGBSurfaceWithFormatFrom
* Removed unused 'flags' parameter from SDL_CreateRGBSurface and SDL_CreateRGBSurfaceWithFormat
* Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat
2022-11-29 09:40:09 -08:00
Sam Lantinga 6873082c34 Fixed building on Windows with SDL_VIDEO=OFF
Fixes https://github.com/libsdl-org/SDL/issues/6562
2022-11-29 09:29:42 -08:00
Sam Lantinga f077c69193 Fixed bug #6698 - VISA: wrong check sceKernelPollSema 2022-11-29 08:50:51 -08:00
pionere 461a38ff1a thread: code style 2022-11-29 08:44:10 -08:00
Sylvain 38c281fbc0
Fixed bug #6698 - VISA: wrong check sceKernelPollSema 2022-11-29 16:14:23 +01:00
pionere f6db1aba66 thread: return -1 from SDL_SemWaitTimeout if semaphore is NULL 2022-11-29 09:40:32 -05:00
pionere 6875e1c262 thread: fix inconsistent return values
- SDL_CreateMutex returns NULL when the creation fails (ngage)
- SDL_SemValue returns 0 when the semaphore is NULL (n3ds)
2022-11-29 09:26:12 -05:00
Sam Lantinga b5076ef5e3 Added support for the Xbox Elite controller paddles with firmware version 5.13+ 2022-11-28 23:15:23 -08:00
Vasily Khoruzhick dbaeb2b9e9 Add support for the 8BitDo Ultimate Wireless 2.4GHz Controller in DirectInput mode
Generated using controller map
2022-11-28 17:47:09 -08:00
Sam Lantinga 04399e1fc2 Added support for the 8BitDo Ultimate Wired Controller in DirectInput mode, including the misc button and paddles 2022-11-28 14:54:56 -08:00
Sam Lantinga 5efca283d3 Add 8BitDo to the list of Xbox 360 third party vendors
Allows detection of the 8BitDo Ultimate Wired Controller
2022-11-28 14:54:36 -08:00
Sam Lantinga c2432f8d0d Rename SDLmain to SDL_main and SDLtest to SDL_test for consistency with other SDL libraries 2022-11-28 10:57:59 -08:00
Sam Lantinga b4ebb3b568 Windows borderless windows interact better with the window manager
This behavior more closely matches other platform where the window is borderless but still interacts with the window manager (e.g. task bar shows above it, it can be resized to fit within usable desktop area, etc.)

If you want a borderless window the size of the desktop that looks like a fullscreen window, then you should use the SDL_WINDOW_FULLSCREEN_DESKTOP flag.

Fixes https://github.com/libsdl-org/SDL/issues/6659
2022-11-28 09:32:39 -08:00
Sam Lantinga 62f4fc6f35 Be explicit that we support the MSB variants of the 1bpp and 4bpp surface formats
Fixes https://github.com/libsdl-org/SDL/issues/6242
2022-11-28 09:06:44 -08:00
Samuel Venable 4f5e9fd5bd [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).
2022-11-27 21:29:07 -05:00
Markus Mittendrein f3c466ec1e
SDL_ResampleAudio: Fix float accumulation error
While 78f97108f9 reduced the accumulation error, it was still big enough to cause distortions.
Fixes #6196.

(cherry picked from commit 8145212103)
2022-11-27 21:15:44 -05:00
Sylvain Becker 6a2200823c
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
2022-11-27 08:38:43 -08:00
Sasha Szpakowski 80a9397459 Remove SDL_HINT_IDLE_TIMER_DISABLED.
SDL_DisableScreenSaver can be used instead. Fixes #6660.
2022-11-27 08:23:02 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Joshua Root 9a64aa6f95 Fix build with Xcode < 7
The _Nullable attribute is not available in older versions.
2022-11-26 20:35:57 -08:00
Sam Lantinga 9c8369e097 Temporary hack to address performance issues in https://github.com/libsdl-org/SDL/issues/6581#issuecomment-1327987916 (thanks @icculus!) 2022-11-26 13:09:50 -08:00
Sam Lantinga bb5568ac4f Fixed HAVE_SIGNAL_SUPPORT typo in commit 63f307fe1f (thanks @sezero!) 2022-11-26 12:52:23 -08:00
Sam Lantinga a268c841e3 Remove references to STDC_HEADERS (thanks @sezero!) 2022-11-26 12:51:20 -08:00
Sam Lantinga 581f1ca5c8 We should only mark functions as inline if necessary for performance 2022-11-26 11:18:24 -08:00
Ryan C. Gordon fa5adcafd5 cocoa: Patched to compile on macOS SDK < 10.10.
Fixes #6586.
2022-11-26 13:57:45 -05:00
Ozkan Sezer 141bc25198 SDL_rwops.c: reduce ifdefs, and mark SDL_RWFromFP() as SDL_INLINE. 2022-11-26 20:11:20 +03:00
Ryan C. Gordon 80c1ddbe97
dynapi: Bumped dynapi version to 2, so SDL2 libs don't conflict. 2022-11-26 09:49:18 -05:00
Sam Lantinga ce9f3173cd Only use memset_pattern4() if we have string.h on Apple platforms 2022-11-26 05:25:57 -08:00
Sam Lantinga bde808cd87 Fixed some warnings when building on Linux with -DSDL_LIBC=OFF 2022-11-26 05:18:26 -08:00
Sam Lantinga e9014ee769 Fixed evdev using standard C functions instead of SDL functions 2022-11-26 05:01:03 -08:00
Sam Lantinga 45cbee81df Fixed kmsdrm using standard C functions instead of SDL functions 2022-11-26 04:58:55 -08:00
Sam Lantinga 63f307fe1f Remove SDL_config.h from the public headers
The SDL headers are no longer dependent on the build configuration.

Fixes https://github.com/libsdl-org/SDL/issues/6643 and https://github.com/libsdl-org/SDL/issues/6641
2022-11-26 04:48:36 -08:00
Sam Lantinga b6b29fd071 Updated Metal shaders 2022-11-25 16:07:09 -08:00
Sam Lantinga cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00
Frank Praznik 873ec097ea x11: Remove deprecated/defunct X11 hints
SDL_HINT_VIDEO_X11_FORCE_EGL was deprecated in favor of the more general SDL_HINT_VIDEO_FORCE_EGL, and Xinerama and Xvidmode support was previously removed from SDL, rendering their associated hints nonfunctional.
2022-11-25 13:46:47 -08:00
Sam Lantinga 346eeba210 Removed SDL_GetRevisionNumber()
Fixes https://github.com/libsdl-org/SDL/issues/6620
2022-11-25 13:36:14 -08:00
slime ac8fbb7040 Remove SDL_CalculateGammaRamp. 2022-11-25 13:28:56 -08:00
slime 52f4cc843d Remove SDL_SetWindowBrightness and SDL_SetWindowGammaRamp. 2022-11-25 13:28:56 -08:00
Ozkan Sezer ab8df9096c fix copy/paste typo in previous commit. 2022-11-25 23:20:00 +03:00
Ozkan Sezer f3fe8ea7ad fix CI windows errors again (because of unused stdio reader callbacks.) 2022-11-25 23:15:02 +03:00
Ozkan Sezer de0cca91d4 fix CI windows errors because of SDL_RWFromFP() 2022-11-25 22:55:30 +03:00
Ozkan Sezer 0b8309da0c renamed SDL PI constants to SDL_PI_D and SDL_PI_F. 2022-11-25 22:35:24 +03:00
Sam Lantinga 05139f4a2e Removed SDL_RWFromFP from the public API
This will blow up if the SDL library and the application have a different C runtime, which can easily happen on Windows.
2022-11-25 10:46:26 -08:00
Sam Lantinga 670f1df469 Removed SDL_stdinc.h dependency on HAVE_M_PI, added SDL_M_PIl (double) and SDL_M_PIf (float) instead 2022-11-25 10:33:37 -08:00
Sam Lantinga fa3814ddf1 Removed SDL_rwops.h dependency on stdio.h 2022-11-25 09:55:42 -08:00
Michael Fitzmayer 67f31a19a8 Add bitdraw.h, remove non-working stub class 2022-11-24 13:12:36 -08:00
Sylvain Becker 4f780c7319 SDL_mfijoystick.m: remove VLA, so that projects can be built with error on vla 2022-11-24 16:07:03 +01:00
Frank Praznik 836eb22442 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.
2022-11-24 03:00:56 -08:00
Sam James 3e7952ce8a 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>
2022-11-24 02:58:20 -08:00
Joshua Root 239423e205 vulkan_metal.h: Make compatible with ObjC ARC
Fixes #6598
2022-11-23 17:37:38 -08:00
Frank Praznik f47169fcba wayland: Fix libdecor_dispatch signature
The function returns an int, not a bool.
2022-11-23 15:16:37 -08:00
Sam Lantinga 003fd11de8 Regenerated dynamic API after SDL_syswm.h update 2022-11-23 14:34:21 -08:00
Sam Lantinga b0840eb32e Updated SDL_syswm.h for SDL 3.0
* The header is no longer dependent on SDL build configuration
* The structures are versioned separately from the rest of SDL
* SDL_GetWindowWMInfo() now returns a standard result code and is passed the version expected by the application
* Updated WhatsNew.txt and docs/README-migration.md with the first API changes in SDL 3.0
2022-11-23 14:05:59 -08:00