Commit Graph

11281 Commits (ca2fe7be1a68d12a5ffb91f0db73019971bb9f96)

Author SHA1 Message Date
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
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
Kelly Gravelyn bb6abd7b03 Remove OutDir and IntDir from GDK projects 2022-12-10 09:50:47 -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 a38ea6bad2
SDL_assert: remove old define for obsolete naming 2022-12-10 17:21:51 +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
Ryan C. Gordon 16f8dfcef9
docs: Note that you don't need to free SDL_GetDefaultCursor's results.
Reference Issue #6777.
2022-12-09 22:08:40 -05: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 be3b1cff0bc2e3e28ae53beb3cc97ab42e8447ab)
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 ab479b49611e8f34573509cfece7e159faa922d6)
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 264da8c127f8bf8930fa62f106763855efbf2a93)
2022-12-08 12:47:56 -08:00
Sam Lantinga 98fa97de91 Fixed memory leak when removing existing displays
(cherry picked from commit cfc7cac3c9f33fada3d3da1ba974f33ddb4ddfc5)
2022-12-08 12:46:50 -08:00