Commit Graph

170 Commits

Author SHA1 Message Date
SDL Wiki Bot 026d3c2306 Sync SDL3 wiki -> header 2024-09-18 15:33:11 +00:00
Sam Lantinga a90ad3b0e2 Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
2024-09-18 08:32:30 -07:00
Sam Lantinga 6fc6e3dc7e Use SDL_bool where appropriate in SDL events
This involved changing button state from Uint8 to SDL_bool, and made SDL_PRESSED and SDL_RELEASED unnecessary.

Fixes https://github.com/libsdl-org/SDL/issues/10069
2024-09-09 14:00:19 -07:00
Ryan C. Gordon 050aa4d084
include: Filling in more documentation gaps. 2024-09-09 02:49:43 -04:00
Maia fa892d15b7 include files with required types directly 2024-09-07 08:37:46 -07:00
Evan Hemsley 42a0df91bf
Add padding for non-32-bit-aligned types in structs (#10701) 2024-09-05 09:52:57 -07:00
Sam Lantinga f827c1322c Renamed SDL_Del* to SDL_Remove* 2024-08-31 07:46:28 -07:00
SDL Wiki Bot 85bbc6028a Sync SDL3 wiki -> header 2024-08-27 17:33:28 +00:00
Sam Lantinga 9ff3446f03 Use SDL_bool instead an int return code in the SDL API
Most SDL functions used to indicate success or failure using an int return code. These functions have been changed to return SDL_bool.

Here is a coccinelle patch to change code that previously compared the return value to 0 and changes it to a boolean test:
@ bool_return_type  @
identifier func =~ "^(SDL_AddEventWatch|SDL_AddHintCallback|SDL_AddSurfaceAlternateImage|SDL_AddVulkanRenderSemaphores|SDL_BindAudioStream|SDL_BindAudioStreams|SDL_BlitSurface|SDL_BlitSurface9Grid|SDL_BlitSurfaceScaled|SDL_BlitSurfaceTiled|SDL_BlitSurfaceTiledWithScale|SDL_BlitSurfaceUnchecked|SDL_BlitSurfaceUncheckedScaled|SDL_CaptureMouse|SDL_ClearAudioStream|SDL_ClearClipboardData|SDL_ClearComposition|SDL_ClearError|SDL_ClearProperty|SDL_ClearSurface|SDL_CloseIO|SDL_CloseStorage|SDL_ConvertAudioSamples|SDL_ConvertEventToRenderCoordinates|SDL_ConvertPixels|SDL_ConvertPixelsAndColorspace|SDL_CopyFile|SDL_CopyProperties|SDL_CopyStorageFile|SDL_CreateDirectory|SDL_CreateStorageDirectory|SDL_CreateWindowAndRenderer|SDL_DateTimeToTime|SDL_DestroyWindowSurface|SDL_DetachVirtualJoystick|SDL_DisableScreenSaver|SDL_EnableScreenSaver|SDL_EnumerateDirectory|SDL_EnumerateProperties|SDL_EnumerateStorageDirectory|SDL_FillSurfaceRect|SDL_FillSurfaceRects|SDL_FlashWindow|SDL_FlipSurface|SDL_FlushAudioStream|SDL_FlushRenderer|SDL_GL_DestroyContext|SDL_GL_GetAttribute|SDL_GL_GetSwapInterval|SDL_GL_LoadLibrary|SDL_GL_MakeCurrent|SDL_GL_SetAttribute|SDL_GL_SetSwapInterval|SDL_GL_SwapWindow|SDL_GetAudioDeviceFormat|SDL_GetAudioStreamFormat|SDL_GetCameraFormat|SDL_GetClosestFullscreenDisplayMode|SDL_GetCurrentRenderOutputSize|SDL_GetCurrentTime|SDL_GetDXGIOutputInfo|SDL_GetDateTimeLocalePreferences|SDL_GetDisplayBounds|SDL_GetDisplayUsableBounds|SDL_GetGDKDefaultUser|SDL_GetGDKTaskQueue|SDL_GetGamepadSensorData|SDL_GetGamepadTouchpadFinger|SDL_GetHapticEffectStatus|SDL_GetJoystickBall|SDL_GetMasksForPixelFormat|SDL_GetPathInfo|SDL_GetRectUnion|SDL_GetRectUnionFloat|SDL_GetRenderClipRect|SDL_GetRenderColorScale|SDL_GetRenderDrawBlendMode|SDL_GetRenderDrawColor|SDL_GetRenderDrawColorFloat|SDL_GetRenderLogicalPresentation|SDL_GetRenderLogicalPresentationRect|SDL_GetRenderOutputSize|SDL_GetRenderSafeArea|SDL_GetRenderScale|SDL_GetRenderVSync|SDL_GetRenderViewport|SDL_GetSensorData|SDL_GetStorageFileSize|SDL_GetStoragePathInfo|SDL_GetSurfaceAlphaMod|SDL_GetSurfaceBlendMode|SDL_GetSurfaceClipRect|SDL_GetSurfaceColorKey|SDL_GetSurfaceColorMod|SDL_GetTextInputArea|SDL_GetTextureAlphaMod|SDL_GetTextureAlphaModFloat|SDL_GetTextureBlendMode|SDL_GetTextureColorMod|SDL_GetTextureColorModFloat|SDL_GetTextureScaleMode|SDL_GetTextureSize|SDL_GetWindowAspectRatio|SDL_GetWindowBordersSize|SDL_GetWindowMaximumSize|SDL_GetWindowMinimumSize|SDL_GetWindowPosition|SDL_GetWindowRelativeMouseMode|SDL_GetWindowSafeArea|SDL_GetWindowSize|SDL_GetWindowSizeInPixels|SDL_GetWindowSurfaceVSync|SDL_HideCursor|SDL_HideWindow|SDL_Init|SDL_InitHapticRumble|SDL_InitSubSystem|SDL_LoadWAV|SDL_LoadWAV_IO|SDL_LockAudioStream|SDL_LockProperties|SDL_LockSurface|SDL_LockTexture|SDL_LockTextureToSurface|SDL_MaximizeWindow|SDL_MinimizeWindow|SDL_MixAudio|SDL_OpenURL|SDL_OutOfMemory|SDL_PauseAudioDevice|SDL_PauseAudioStreamDevice|SDL_PauseHaptic|SDL_PlayHapticRumble|SDL_PremultiplyAlpha|SDL_PremultiplySurfaceAlpha|SDL_PushEvent|SDL_PutAudioStreamData|SDL_RaiseWindow|SDL_ReadStorageFile|SDL_ReadSurfacePixel|SDL_ReadSurfacePixelFloat|SDL_RegisterApp|SDL_ReloadGamepadMappings|SDL_RemovePath|SDL_RemoveStoragePath|SDL_RemoveTimer|SDL_RenamePath|SDL_RenameStoragePath|SDL_RenderClear|SDL_RenderCoordinatesFromWindow|SDL_RenderCoordinatesToWindow|SDL_RenderFillRect|SDL_RenderFillRects|SDL_RenderGeometry|SDL_RenderGeometryRaw|SDL_RenderLine|SDL_RenderLines|SDL_RenderPoint|SDL_RenderPoints|SDL_RenderPresent|SDL_RenderRect|SDL_RenderRects|SDL_RenderTexture|SDL_RenderTexture9Grid|SDL_RenderTextureRotated|SDL_RenderTextureTiled|SDL_RequestAndroidPermission|SDL_RestoreWindow|SDL_ResumeAudioDevice|SDL_ResumeAudioStreamDevice|SDL_ResumeHaptic|SDL_RumbleGamepad|SDL_RumbleGamepadTriggers|SDL_RumbleJoystick|SDL_RumbleJoystickTriggers|SDL_RunHapticEffect|SDL_SaveBMP|SDL_SaveBMP_IO|SDL_SendAndroidMessage|SDL_SendGamepadEffect|SDL_SendJoystickEffect|SDL_SendJoystickVirtualSensorData|SDL_SetAppMetadata|SDL_SetAppMetadataProperty|SDL_SetAudioDeviceGain|SDL_SetAudioPostmixCallback|SDL_SetAudioStreamFormat|SDL_SetAudioStreamFrequencyRatio|SDL_SetAudioStreamGain|SDL_SetAudioStreamGetCallback|SDL_SetAudioStreamInputChannelMap|SDL_SetAudioStreamOutputChannelMap|SDL_SetAudioStreamPutCallback|SDL_SetBooleanProperty|SDL_SetClipboardData|SDL_SetClipboardText|SDL_SetCursor|SDL_SetFloatProperty|SDL_SetGamepadLED|SDL_SetGamepadMapping|SDL_SetGamepadPlayerIndex|SDL_SetGamepadSensorEnabled|SDL_SetHapticAutocenter|SDL_SetHapticGain|SDL_SetJoystickLED|SDL_SetJoystickPlayerIndex|SDL_SetJoystickVirtualAxis|SDL_SetJoystickVirtualBall|SDL_SetJoystickVirtualButton|SDL_SetJoystickVirtualHat|SDL_SetJoystickVirtualTouchpad|SDL_SetLinuxThreadPriority|SDL_SetLinuxThreadPriorityAndPolicy|SDL_SetLogPriorityPrefix|SDL_SetMemoryFunctions|SDL_SetNumberProperty|SDL_SetPaletteColors|SDL_SetPointerProperty|SDL_SetPointerPropertyWithCleanup|SDL_SetPrimarySelectionText|SDL_SetRenderClipRect|SDL_SetRenderColorScale|SDL_SetRenderDrawBlendMode|SDL_SetRenderDrawColor|SDL_SetRenderDrawColorFloat|SDL_SetRenderLogicalPresentation|SDL_SetRenderScale|SDL_SetRenderTarget|SDL_SetRenderVSync|SDL_SetRenderViewport|SDL_SetScancodeName|SDL_SetStringProperty|SDL_SetSurfaceAlphaMod|SDL_SetSurfaceBlendMode|SDL_SetSurfaceColorKey|SDL_SetSurfaceColorMod|SDL_SetSurfaceColorspace|SDL_SetSurfacePalette|SDL_SetSurfaceRLE|SDL_SetTLS|SDL_SetTextInputArea|SDL_SetTextureAlphaMod|SDL_SetTextureAlphaModFloat|SDL_SetTextureBlendMode|SDL_SetTextureColorMod|SDL_SetTextureColorModFloat|SDL_SetTextureScaleMode|SDL_SetThreadPriority|SDL_SetWindowAlwaysOnTop|SDL_SetWindowAspectRatio|SDL_SetWindowBordered|SDL_SetWindowFocusable|SDL_SetWindowFullscreen|SDL_SetWindowFullscreenMode|SDL_SetWindowHitTest|SDL_SetWindowIcon|SDL_SetWindowKeyboardGrab|SDL_SetWindowMaximumSize|SDL_SetWindowMinimumSize|SDL_SetWindowModalFor|SDL_SetWindowMouseGrab|SDL_SetWindowMouseRect|SDL_SetWindowOpacity|SDL_SetWindowPosition|SDL_SetWindowRelativeMouseMode|SDL_SetWindowResizable|SDL_SetWindowShape|SDL_SetWindowSize|SDL_SetWindowSurfaceVSync|SDL_SetWindowTitle|SDL_SetiOSAnimationCallback|SDL_ShowAndroidToast|SDL_ShowCursor|SDL_ShowMessageBox|SDL_ShowSimpleMessageBox|SDL_ShowWindow|SDL_ShowWindowSystemMenu|SDL_StartTextInput|SDL_StartTextInputWithProperties|SDL_StopHapticEffect|SDL_StopHapticEffects|SDL_StopHapticRumble|SDL_StopTextInput|SDL_SyncWindow|SDL_TimeToDateTime|SDL_TryLockMutex|SDL_TryLockRWLockForReading|SDL_TryLockRWLockForWriting|SDL_TryWaitSemaphore|SDL_UnlockAudioStream|SDL_UpdateHapticEffect|SDL_UpdateNVTexture|SDL_UpdateTexture|SDL_UpdateWindowSurface|SDL_UpdateWindowSurfaceRects|SDL_UpdateYUVTexture|SDL_Vulkan_CreateSurface|SDL_Vulkan_LoadLibrary|SDL_WaitConditionTimeout|SDL_WaitSemaphoreTimeout|SDL_WarpMouseGlobal|SDL_WriteStorageFile|SDL_WriteSurfacePixel|SDL_WriteSurfacePixelFloat)$";
@@
(
  func(
  ...
  )
- == 0
|
- func(
+ !func(
  ...
  )
- < 0
|
- func(
+ !func(
  ...
  )
- != 0
|
- func(
+ !func(
  ...
  )
- == -1
)
2024-08-27 10:31:46 -07:00
SDL Wiki Bot a7fa375275 Sync SDL3 wiki -> header 2024-08-10 02:09:54 +00:00
Ryan C. Gordon a9d70dbacb pen: Rework public API.
This changes the API in various ways, and updates the backends for this.

Overall, this is a massive simplification of the API, as most future backends
can't support the previously-offered API.

This also removes the testautomation pen code (not only did these interfaces
change completely, it also did something no other test did: mock the internal
API), and replaces testpen.c with a different implementation (the existing
code was fine, it was just easier to start from scratch than update it).
2024-08-09 22:09:23 -04:00
SDL Wiki Bot 57fa3bc08e Sync SDL3 wiki -> header 2024-08-06 15:00:23 +00:00
Sam Lantinga 627cb8acd0 SDL_EventFilter functions now return SDL_bool 2024-08-06 07:59:45 -07:00
SDL Wiki Bot b5c0921196 Sync SDL3 wiki -> header 2024-08-03 02:37:43 +00:00
Anonymous Maarten f57c597c60 Added SDL_GetWindowFromEvent 2024-08-03 02:37:11 +00:00
Sam Lantinga a6407e88da Document the events that need to be handled in a callback 2024-07-30 07:52:13 -07:00
Sam Lantinga 4f55271571 Removed temporary memory from the API
It was intended to make the API easier to use, but various automatic garbage collection all had flaws, and making the application periodically clean up temporary memory added cognitive load to using the API, and in many cases was it was difficult to restructure threaded code to handle this.

So, we're largely going back to the original system, where the API returns allocated results and you free them.

In addition, to solve the problems we originally wanted temporary memory for:
* Short strings with a finite count, like device names, get stored in a per-thread string pool.
* Events continue to use temporary memory internally, which is cleaned up on the next event processing cycle.
2024-07-26 20:59:14 -07:00
SDL Wiki Bot 2137e6eed1 Sync SDL3 wiki -> header 2024-07-26 17:05:33 +00:00
Sam Lantinga 5e513ecc7f Don't automatically free temporary memory, let the application call SDL_FreeTemporaryMemory() when it's ready.
Also mark up all functions that return temporary memory with SDL_DECLSPEC_TEMP, to help people implementing language bindings.

Fixes https://github.com/libsdl-org/SDL/issues/10378
2024-07-26 10:05:03 -07:00
SDL Wiki Bot a1a8278029 Sync SDL3 wiki -> header 2024-07-26 00:47:35 +00:00
Sam Lantinga 750aef2bee Clarified that temporary memory shouldn't be kept beyond the current function scope or event handling. 2024-07-25 17:47:00 -07:00
Sam Lantinga b98e1e9ef0 Fixed the render viewport not updating when the metal view resizes
When the phone is in portrait mode and the window is in landscape mode, the view changes orientation after layoutSubviews runs. In this case we need some way of notifying the application that the Metal view has changed.
2024-07-24 16:12:29 -07:00
Sam Lantinga ca4bd4b63c Android life cycle behavior more closely matches iOS
This change also decouples the pause/resume handling from the video subsystem on Android, so applications that don't use SDL for video can get application life cycle events.

The semantics for the life cycle events are that they need to be handled in an event watch callback, and once they've been delivered, the application will block until it's been resumed. SDL_HINT_ANDROID_BLOCK_ON_PAUSE can be used to control that behavior, and if that's set to "0", then the application will continue to run in the background at low CPU usage until being resumed or stopped.

SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO has been removed, and the audio will be paused when the application is paused.

Fixes https://github.com/libsdl-org/SDL/issues/3193
2024-07-24 05:11:13 -07:00
Sam Lantinga 457ca3995c Added SDL_GetWindowSafeArea()
Fixes https://github.com/libsdl-org/SDL/issues/3243
2024-07-23 17:06:04 -07:00
SDL Wiki Bot 2aea74aa84 Sync SDL3 wiki -> header 2024-07-22 22:19:38 +00:00
Sam Lantinga a36be94ad1 More clarification on temporary memory 2024-07-22 15:19:26 -07:00
SDL Wiki Bot 40cb3fb74a Sync SDL3 wiki -> header 2024-07-22 14:35:35 +00:00
Sam Lantinga ff1d351390 Removed SDL_FreeTemporaryMemory()
This was just causing confusion and anxiety. SDL temporary memory will be automatically freed on the main thread when processing events and on other threads when it ages out after a second. The application can free it directly by calling SDL_ClaimTemporaryMemory() to get ownership of the pointer, if necessary.
2024-07-22 07:34:25 -07:00
SDL Wiki Bot 230f2a684d Sync SDL3 wiki -> header 2024-07-22 12:59:19 +00:00
Sam Lantinga 685e381735 Add an overview of how to handle temporary memory 2024-07-22 05:58:19 -07:00
SDL Wiki Bot 975457cfb6 Sync SDL3 wiki -> header 2024-07-19 19:23:24 +00:00
Sam Lantinga 71a60d4c0e Updated documentation for functions that return temporary memory 2024-07-19 12:22:03 -07:00
Sam Lantinga fd9fe1bb7b Renamed event memory to temporary memory, since it's not just used for events 2024-07-19 12:22:03 -07:00
Sam Lantinga ef884c8aa6 Transfer event memory between the local pool and the event queue
This allows threads to free memory from their local pool without affecting events that are queued, and to transfer memory ownership cleanly between threads that are queuing and dequeuing events.
2024-07-19 12:22:03 -07:00
Sam Lantinga f95ecac300 Added SDL_ClaimEventMemory() 2024-07-19 12:22:03 -07:00
Sam Lantinga 2816745f48 Allow passing a pointer to SDL_FreeEventMemory()
Also clarify in the documentation that you should not call SDL_FreeEventMemory(NULL) from your main thread.
2024-07-19 12:22:03 -07:00
Sam Lantinga 217330a7b3 Made return value descriptions more consistent across the API 2024-07-19 12:22:03 -07:00
Sam Lantinga d73c7311d5 Clarify that the SDL_GetStringRule means that SDL will automatically free the memory later. 2024-07-19 12:22:03 -07:00
Sam Lantinga 8c25129458 SDL_EVENT_WINDOW_LAST should be SDL_EVENT_WINDOW_HDR_STATE_CHANGED
Fixes https://github.com/libsdl-org/SDL/issues/10299
2024-07-16 22:43:02 -07:00
SDL Wiki Bot d65a8146b9 Sync SDL3 wiki -> header 2024-07-16 19:03:15 +00:00
Sam Lantinga 4aeabb3c3b Made event and temporary string memory thread-local and added SDL_FreeEventMemory()
Fixes https://github.com/libsdl-org/SDL/issues/10283
2024-07-16 12:01:51 -07:00
Sam Lantinga 9797c5d0c0 Renamed CameraDevice to Camera
This is consistent with the rest of the SDL API
2024-07-14 13:01:53 -07:00
Sam Lantinga 1162a1cb8e Added SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED and SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED 2024-07-12 18:09:14 -07:00
Frank Praznik 74cc06db1b Remove the SDL_EVENT_WINDOW_TAKE_FOCUS event
This was added by the Unreal Engine to handle the input focus for popups and dialogs, window types for which SDL3 has built-in, cross-platform support.

This was only ever implemented in X11, and the only purpose was to hint that a client application may want to call the SDL_SetWindowInputFocus() function, which has since been removed, rendering it pointless now.
2024-07-03 15:08:21 -04:00
SDL Wiki Bot f787790243 Sync SDL3 wiki -> header 2024-07-01 20:57:56 +00:00
Sam Lantinga d9dc4b320a The keycode in key events is the base, unmodified, keycode for the current keyboard layout 2024-07-01 13:56:49 -07:00
Sam Lantinga ed2022a175 Added SDL_EVENT_TEXT_EDITING_CANDIDATES
This allows applications that have set SDL_HINT_IME_SHOW_UI to "0" to get candidates lists they can draw themselves.

Fixes https://github.com/libsdl-org/SDL/issues/4855
2024-06-28 17:09:22 -07:00
Ryan C. Gordon 9fd54b724f
include: Added documentation for SDL_PRESSED and SDL_RELEASED.
Fixes #10069.
2024-06-26 14:08:56 -04:00
SDL Wiki Bot 3d121d9bc7 Sync SDL3 wiki -> header 2024-06-25 03:32:46 +00:00
Sam Lantinga 377014c430 Added some documentation to the SDL_EVENT_TEXT_EDITING event 2024-06-24 20:32:03 -07:00