Commit Graph

11302 Commits (9c9e6e3aa3757d4e8deb8b56843c86ce6bedfa68)

Author SHA1 Message Date
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 3b0cd441584ada86c4456afb4e8b3edaf2173073)
2022-12-17 06:54:33 -08:00
Sylvain dce2546534
Revert wrong comment in SDL_surface.h for SDL3 (see #6824) 2022-12-16 16:42:06 +01: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
Sylvain b461d9e183
testautomation_rwops: update test because of change in SDL_RWwrite.
when it's not possible to write to memory ( mem_writeconst ), error code is -1 (see #6818)
2022-12-16 10:24:19 +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 a53382e460f43873ce5362460af6a47a528a6425)
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 e99b9ca9c0c4c5a03d0a9088bee623218ac840a5)
2022-12-15 18:02:15 -08:00
Sam Lantinga 5a45d2e58b Updated Xcode project for SDL_main as a header-only library 2022-12-15 10:53:44 -08:00
Daniel Gibson ab554c8392 Update doc/README-* for header-only SDL_main 2022-12-15 08:01:01 -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 22e22ba196 Add SDL_main.h includes to tests
.. including cmake/test/*.c, whatever that does

(this is needed now because SDL.h doesn't include SDL_main.h anymore)
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
Sylvain ffaf451558
testime.c: fix wrong {} in switch 2022-12-15 14:26:18 +01:00
Sylvain ff3f4236f2
testime.c: add valid cast, since the variable as been tested non negative before 2022-12-15 14:22:11 +01:00
Sylvain 48955cce0e
test/testime.c: put back size_t 2022-12-15 14:19:02 +01:00
Sylvain deba9f4b8b
testime.c: fix various warnings + test error code from SDL_RWread, changing bytesRead to Sint64 (thanks Ozkan) see #6818 2022-12-15 14:11:08 +01:00
Sylvain Becker 1e6d4649c0
fixed build rwops (#6818)
* Fixed build
2022-12-15 10:06:15 +01: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
Ryan C. Gordon 83559503c4
test: patched to compile. 2022-12-14 23:25:09 -05:00
Sam Lantinga 980208b814 Fixed crash in SDL_PrivateGameControllerRefreshMapping()
(cherry picked from commit 7a9966af9d7f4817b72d28a5af38751b0968d1ca)
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
Ozkan Sezer 1230a8fde8 fix (hopefully) MSVC builds after gesture removal. 2022-12-14 00:50:20 +03:00
Ryan C. Gordon a76053352c
gesture: Removed the gesture API from SDL3.
Fixes #6758.
2022-12-13 14:54:37 -05:00
Simon McVittie 07fa2769b8 cmake: Fix detection of ALSA::ALSA for static linking
This was still conditional on whether SDL2::SDL2-static exists, but
it's now SDL3 that matters.

Resolves: https://github.com/libsdl-org/SDL/issues/6801
Fixes: 9eb4d1f "cmake: use FindALSA.cmake to find ALSA libraries"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-13 09:03:48 -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
Simon McVittie 4a46a9e372 .gitignore: Replace all SDL2 with SDL3
Some of these are probably unnecessary now that Autotools (with its
optional in-tree builds) has been deleted in favour of CMake (with
mandatory out-of-tree builds), but let's be consistent.

Spotted while doing a `git grep` for other bugs of the same form as #6801.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-13 09:02:28 -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 817454cfe6db826f6cf6688952e28ee07b27a89a)
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
Anonymous Maarten 9eb4d1f020 cmake: use FindALSA.cmake to find ALSA libraries
Co-authored-by: nfarid <54642193+nfarid@users.noreply.github.com>
2022-12-12 01:37:01 +01:00