Commit graph

7066 commits

Author SHA1 Message Date
Frank Praznik e35c3872dc 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.
2023-01-12 13:34:36 -08:00
Frank Praznik 50f2eb7d41 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.
2023-01-12 13:34:36 -08:00
Sam Lantinga 6dc50a78fc Fixed window never being shown on iOS 2023-01-12 12:45:55 -08:00
happyharryh 57e78f4cf5 Fixed the hat_map to avoid segmentation fault 2023-01-12 06:55:35 -08:00
Sam Lantinga 1bf1c866fe Handle new SDL_rwops error codes in SDL_LoadFile_RW()
Thanks @BeWorld2018!
2023-01-12 06:53:07 -08:00
Ozkan Sezer 2ec9a20204 SDL_dynapi.c: add extern "C" guards, just in case.. 2023-01-12 14:01:32 +03:00
Anonymous Maarten 67d517907b log: fix unused-variable warning when configuring SDL with -DSDL_LIBC=OFF 2023-01-11 16:31:27 -08:00
Francisco Javier Trujillo Mata 7f610cd969 Using UV instead of STQ 2023-01-11 15:10:51 -08:00
Francisco Javier Trujillo Mata 555183257d Remove dummy flag 2023-01-11 15:10:51 -08:00
Ozkan Sezer 30516fd3a6 joystick/vita: add some sanity check to SDL_GetJoystickInstanceID result
Reference issue: https://github.com/libsdl-org/SDL/issues/7051
2023-01-11 21:56:50 +03:00
Ozkan Sezer f046788a5a joystick/vita: fix index value use returned by SDL_GetJoystickInstanceID
Reference issue: https://github.com/libsdl-org/SDL/issues/7051
2023-01-11 21:56:50 +03:00
Ozkan Sezer 85924687fd fix SDL_GetSensorInstanceID() return code upon failure.
Reference issue: https://github.com/libsdl-org/SDL/issues/7051
2023-01-11 21:56:50 +03:00
Ozkan Sezer 0621a67350 fix SDL_GetJoystickInstanceID() return code upon failure
Reference issue: https://github.com/libsdl-org/SDL/issues/7051
2023-01-11 21:56:50 +03:00
Sam Lantinga 21a1508ceb Re-add JNI_OnLoad to the symbols list so Android symbols are resolved properly 2023-01-10 21:15:21 -08:00
Sam Lantinga 237086c917 Fixed Xcode 14.2 warnings 2023-01-10 15:51:14 -08:00
Sam Lantinga dc280c17a0 Moved SDL_intrin.h back into the public headers for application use 2023-01-10 15:50:35 -08:00
Elad Lahav 413af2f5f1 Addressed comments 2023-01-10 06:19:40 -08:00
Elad Lahav 38b35a3414 Allow the use of posix_spawn() instead of vfork/execlp() 2023-01-10 06:19:40 -08:00
Sam Lantinga 56522034db Fixed building with Visual Studio 2010 2023-01-09 18:30:23 -08:00
Narr the Reg 9fa55d9cab hidapi: switch: Add user calibration support 2023-01-09 18:07:54 -08:00
Sam Lantinga 2aa9569b3e Replaced SDL_SIMDAlloc(), SDL_SIMDRealloc(), and SDL_SIMDFree() with SDL_aligned_alloc() and SDL_aligned_free()
Fixes https://github.com/libsdl-org/SDL/issues/5641
2023-01-09 18:01:59 -08:00
Anonymous Maarten aa7fdd6624 haiku: remove unused variable in SDL_BApp.h 2023-01-10 02:39:09 +01:00
Anonymous Maarten f85ef6fc3c haiku: fix use of SDL_ConvertSurfaceFormat 2023-01-10 02:39:09 +01:00
Sam Lantinga e9b86eebf3 Functions which return function pointers now return SDL_FunctionPointer instead of void*
This fixes the clang warning "Cast between pointer-to-function and pointer-to-object is an extension"

You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.

Fixes https://github.com/libsdl-org/SDL/issues/2866
2023-01-09 15:46:21 -08:00
Sam Lantinga 5feebcdce0 SDL_AddHintCallback() now returns a standard int result instead of void
Fixes https://github.com/libsdl-org/SDL/issues/7035
2023-01-09 12:09:30 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sam Lantinga c663e6d568 Revert "Always allow controller events for virtual joysticks regardless of focus state"
This reverts commit d94f2a9ee5.

Rather than changing behavior, we'll set SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS in the joystick tests
2023-01-09 09:05:40 -08:00
Anonymous Maarten f91a747549 include: SDL_dynapi.h depends on platform defines 2023-01-08 21:37:54 +01:00
Sam Lantinga d94f2a9ee5 Always allow controller events for virtual joysticks regardless of focus state
Refrence https://github.com/libsdl-org/SDL/pull/7024
2023-01-08 10:48:46 -08:00
Sam Lantinga ac99db9fc8 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
2023-01-08 09:35:17 -08:00
Anonymous Maarten f53d797cca cmake: generate git hash using GetRevisionDescription CMake module
This allows the build system (ninja/make/VS) to detect whether the current
checkout git commit has changed. If so, SDL_revision.h will be updated.
2023-01-08 18:20:56 +01:00
Hunter Kvalevog 0953367967 SDL_Vulkan_GetInstanceExtensions: Remove window
Remove the unused `window` parameter from
SDL_Vulkan_GetInstanceExtensions, which is never used by any of the
backends.
2023-01-08 07:55:34 -08:00
Anonymous Maarten ec14487e1d unix/SDL_systimer.c: add ';' to statement 2023-01-08 01:04:06 +01:00
Sylvain 13ab100317
Fixed bug #6990: fix computation of alpha in BlitRGBtoRGBPixelAlphaMMX
backport from SDL2 branch
2023-01-06 21:29:01 +01:00
Sylvain 93e2903ac5 Add SDL_PlayAudioDevice() to play audio. Remove pause_on param from SDL_PauseAudioDevice() 2023-01-06 09:15:39 -08:00
Frank Praznik 230ad2a201 wayland: Handle modifier keys internally
Modifier keys on Wayland can be remapped, latched/locked, and defer the system modifier state changes to key release events instead of key press events, which the default SDL modifier handling code doesn't deal with correctly. Track and set the modifier keys internally to deal with the plethora of various combinations that the system key modifiers can be in and correctly reflect the actual system state to SDL applications.
2023-01-05 10:39:19 -08:00
Frank Praznik d2917918c0 events: Add function to send keystrokes and not update the modifier state
Add SDL_SendKeyboardKeyIgnoreModifiers() function and repurpose the source parameter for the SDL_SendKeyboardKeyInternal() function to use as a generic set of keyboard flags.
2023-01-05 10:39:19 -08:00
Matt Durgavich 59ad6793b9
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-05 08:54:27 -08:00
Sylvain 2d7f8d7d51 Remove legacy SDL_Audio functions that acts on device id == 1 2023-01-05 09:40:06 -05:00
Guldoman 5a42831345 wayland: Fallback to default cursor if chosen one wasn't found 2023-01-04 21:28:26 -08:00
Sam Lantinga 0bbf6cc379 Test text rendering APIs take floating point coordinates 2023-01-04 16:45:02 -08:00
Sam Lantinga 4f978456a8 Renamed SDL_GAMEPADDEVICEREMAPPED to SDL_GAMEPADREMAPPED 2023-01-04 14:32:37 -08:00
Deve eddaf870f5 Avoid textinput events when pasting from clipboard on iOS.
I handle command+C and command+V shortcuts for copy/paste from clipboard using
SDL_GetClipboardText/SDL_SetClipboardText. But on iOS command+V shortcut is
also handled by system, so that I also get textinput event with that clipboard
text. And thus the application gets this clipboard text twice (from
SDL_GetClipboardText and from textinput event).

I assume that intended behavior is that command+V shouldn't generate textinput
events. At least as far as I know ctrl+V on other platforms does nothing. This
commit disables paste action for UITextField, so that textinput event isn't
generated anymore.
2023-01-04 13:52:15 -08:00
Sam Lantinga c823f26f18 Revert "Removed public joystick locking API"
This reverts commit a515f51ac0.

We still need joystick locking to protect the gamepad mappings
2023-01-04 13:51:40 -08:00
Sylvain 6863f0b2d8 Add SDL_WindowID type for SDL_Window id 2023-01-04 09:21:52 -08:00
Sam Lantinga 86c6376140 Fixed integral constant overflow 2023-01-04 08:54:46 -08:00
Sam Lantinga aaaf7423ac Fixed build 2023-01-03 16:17:10 -08:00
Sam Lantinga 32c077216c Fixed warnings 2023-01-03 15:59:35 -08:00
Sam Lantinga 49af0d1b89 Fixed build 2023-01-03 15:35:18 -08:00
Sam Lantinga e85839cd56 Fixed line wrapping for HID packet dump 2023-01-03 15:12:47 -08:00
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