mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-07 11:58:12 +00:00

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 )
828 lines
29 KiB
C
828 lines
29 KiB
C
/*
|
|
Simple DirectMedia Layer
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. If you use this software
|
|
in a product, an acknowledgment in the product documentation would be
|
|
appreciated but is not required.
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
/**
|
|
* # CategorySystem
|
|
*
|
|
* Platform-specific SDL API functions.
|
|
*/
|
|
|
|
#ifndef SDL_system_h_
|
|
#define SDL_system_h_
|
|
|
|
#include <SDL3/SDL_stdinc.h>
|
|
#include <SDL3/SDL_error.h>
|
|
#include <SDL3/SDL_keyboard.h>
|
|
#include <SDL3/SDL_render.h>
|
|
#include <SDL3/SDL_video.h>
|
|
|
|
#include <SDL3/SDL_begin_code.h>
|
|
/* Set up for C function definitions, even when using C++ */
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/*
|
|
* Platform specific functions for Windows
|
|
*/
|
|
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
|
|
|
|
typedef struct tagMSG MSG;
|
|
|
|
/**
|
|
* A callback to be used with SDL_SetWindowsMessageHook.
|
|
*
|
|
* This callback may modify the message, and should return SDL_TRUE if the
|
|
* message should continue to be processed, or SDL_FALSE to prevent further
|
|
* processing.
|
|
*
|
|
* As this is processing a message directly from the Windows event loop, this
|
|
* callback should do the minimum required work and return quickly.
|
|
*
|
|
* \param userdata the app-defined pointer provided to
|
|
* SDL_SetWindowsMessageHook.
|
|
* \param msg a pointer to a Win32 event structure to process.
|
|
* \returns SDL_TRUE to let event continue on, SDL_FALSE to drop it.
|
|
*
|
|
* \threadsafety This may only be called (by SDL) from the thread handling the
|
|
* Windows event loop.
|
|
*
|
|
* \since This datatype is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_SetWindowsMessageHook
|
|
* \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
|
|
*/
|
|
typedef SDL_bool (SDLCALL *SDL_WindowsMessageHook)(void *userdata, MSG *msg);
|
|
|
|
/**
|
|
* Set a callback for every Windows message, run before TranslateMessage().
|
|
*
|
|
* The callback may modify the message, and should return SDL_TRUE if the
|
|
* message should continue to be processed, or SDL_FALSE to prevent further
|
|
* processing.
|
|
*
|
|
* \param callback the SDL_WindowsMessageHook function to call.
|
|
* \param userdata a pointer to pass to every iteration of `callback`.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_WindowsMessageHook
|
|
* \sa SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata);
|
|
|
|
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */
|
|
|
|
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
|
|
|
|
/**
|
|
* Get the D3D9 adapter index that matches the specified display.
|
|
*
|
|
* The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
|
|
* controls on which monitor a full screen application will appear.
|
|
*
|
|
* \param displayID the instance of the display to query.
|
|
* \returns the D3D9 adapter index on success or -1 on
|
|
* failure; call SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID);
|
|
|
|
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
|
|
|
|
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
|
|
|
|
/**
|
|
* Get the DXGI Adapter and Output indices for the specified display.
|
|
*
|
|
* The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
|
|
* `EnumOutputs` respectively to get the objects required to create a DX10 or
|
|
* DX11 device and swap chain.
|
|
*
|
|
* \param displayID the instance of the display to query.
|
|
* \param adapterIndex a pointer to be filled in with the adapter index.
|
|
* \param outputIndex a pointer to be filled in with the output index.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
|
|
|
|
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) */
|
|
|
|
/*
|
|
* Platform specific functions for UNIX
|
|
*/
|
|
|
|
typedef union _XEvent XEvent;
|
|
typedef SDL_bool (SDLCALL *SDL_X11EventHook)(void *userdata, XEvent *xevent);
|
|
|
|
/**
|
|
* Set a callback for every X11 event.
|
|
*
|
|
* The callback may modify the event, and should return SDL_TRUE if the event
|
|
* should continue to be processed, or SDL_FALSE to prevent further
|
|
* processing.
|
|
*
|
|
* \param callback the SDL_X11EventHook function to call.
|
|
* \param userdata a pointer to pass to every iteration of `callback`.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata);
|
|
|
|
/* Platform specific functions for Linux*/
|
|
#ifdef SDL_PLATFORM_LINUX
|
|
|
|
/**
|
|
* Sets the UNIX nice value for a thread.
|
|
*
|
|
* This uses setpriority() if possible, and RealtimeKit if available.
|
|
*
|
|
* \param threadID the Unix thread ID to change priority of.
|
|
* \param priority the new, Unix-specific, priority value.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriority(Sint64 threadID, int priority);
|
|
|
|
/**
|
|
* Sets the priority (not nice level) and scheduling policy for a thread.
|
|
*
|
|
* This uses setpriority() if possible, and RealtimeKit if available.
|
|
*
|
|
* \param threadID the Unix thread ID to change priority of.
|
|
* \param sdlPriority the new SDL_ThreadPriority value.
|
|
* \param schedPolicy the new scheduling policy (SCHED_FIFO, SCHED_RR,
|
|
* SCHED_OTHER, etc...).
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetLinuxThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
|
|
|
|
#endif /* SDL_PLATFORM_LINUX */
|
|
|
|
/*
|
|
* Platform specific functions for iOS
|
|
*/
|
|
#ifdef SDL_PLATFORM_IOS
|
|
|
|
/**
|
|
* The prototype for an Apple iOS animation callback.
|
|
*
|
|
* This datatype is only useful on Apple iOS.
|
|
*
|
|
* After passing a function pointer of this type to
|
|
* SDL_SetiOSAnimationCallback, the system will call that function pointer at
|
|
* a regular interval.
|
|
*
|
|
* \param userdata what was passed as `callbackParam` to
|
|
* SDL_SetiOSAnimationCallback as `callbackParam`.
|
|
*
|
|
* \since This datatype is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_SetiOSAnimationCallback
|
|
*/
|
|
typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata);
|
|
|
|
/**
|
|
* Use this function to set the animation callback on Apple iOS.
|
|
*
|
|
* The function prototype for `callback` is:
|
|
*
|
|
* ```c
|
|
* void callback(void *callbackParam);
|
|
* ```
|
|
*
|
|
* Where its parameter, `callbackParam`, is what was passed as `callbackParam`
|
|
* to SDL_SetiOSAnimationCallback().
|
|
*
|
|
* This function is only available on Apple iOS.
|
|
*
|
|
* For more information see:
|
|
*
|
|
* https://wiki.libsdl.org/SDL3/README/ios
|
|
*
|
|
* Note that if you use the "main callbacks" instead of a standard C `main`
|
|
* function, you don't have to use this API, as SDL will manage this for you.
|
|
*
|
|
* Details on main callbacks are here:
|
|
*
|
|
* https://wiki.libsdl.org/SDL3/README/main-functions
|
|
*
|
|
* \param window the window for which the animation callback should be set.
|
|
* \param interval the number of frames after which **callback** will be
|
|
* called.
|
|
* \param callback the function to call for every frame.
|
|
* \param callbackParam a pointer that is passed to `callback`.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_SetiOSEventPump
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
|
|
|
/**
|
|
* Use this function to enable or disable the SDL event pump on Apple iOS.
|
|
*
|
|
* This function is only available on Apple iOS.
|
|
*
|
|
* \param enabled SDL_TRUE to enable the event pump, SDL_FALSE to disable it.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_SetiOSAnimationCallback
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(SDL_bool enabled);
|
|
|
|
#endif /* SDL_PLATFORM_IOS */
|
|
|
|
|
|
/*
|
|
* Platform specific functions for Android
|
|
*/
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
|
|
/**
|
|
* Get the Android Java Native Interface Environment of the current thread.
|
|
*
|
|
* This is the JNIEnv one needs to access the Java virtual machine from native
|
|
* code, and is needed for many Android APIs to be usable from C.
|
|
*
|
|
* The prototype of the function in SDL's code actually declare a void* return
|
|
* type, even if the implementation returns a pointer to a JNIEnv. The
|
|
* rationale being that the SDL headers can avoid including jni.h.
|
|
*
|
|
* \returns a pointer to Java native interface object (JNIEnv) to which the
|
|
* current thread is attached, or NULL on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_GetAndroidActivity
|
|
*/
|
|
extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidJNIEnv(void);
|
|
|
|
/**
|
|
* Retrieve the Java instance of the Android activity class.
|
|
*
|
|
* The prototype of the function in SDL's code actually declares a void*
|
|
* return type, even if the implementation returns a jobject. The rationale
|
|
* being that the SDL headers can avoid including jni.h.
|
|
*
|
|
* The jobject returned by the function is a local reference and must be
|
|
* released by the caller. See the PushLocalFrame() and PopLocalFrame() or
|
|
* DeleteLocalRef() functions of the Java native interface:
|
|
*
|
|
* https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html
|
|
*
|
|
* \returns the jobject representing the instance of the Activity class of the
|
|
* Android application, or NULL on failure; call SDL_GetError() for
|
|
* more information.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_GetAndroidJNIEnv
|
|
*/
|
|
extern SDL_DECLSPEC void * SDLCALL SDL_GetAndroidActivity(void);
|
|
|
|
/**
|
|
* Query Android API level of the current device.
|
|
*
|
|
* - API level 35: Android 15 (VANILLA_ICE_CREAM)
|
|
* - API level 34: Android 14 (UPSIDE_DOWN_CAKE)
|
|
* - API level 33: Android 13 (TIRAMISU)
|
|
* - API level 32: Android 12L (S_V2)
|
|
* - API level 31: Android 12 (S)
|
|
* - API level 30: Android 11 (R)
|
|
* - API level 29: Android 10 (Q)
|
|
* - API level 28: Android 9 (P)
|
|
* - API level 27: Android 8.1 (O_MR1)
|
|
* - API level 26: Android 8.0 (O)
|
|
* - API level 25: Android 7.1 (N_MR1)
|
|
* - API level 24: Android 7.0 (N)
|
|
* - API level 23: Android 6.0 (M)
|
|
* - API level 22: Android 5.1 (LOLLIPOP_MR1)
|
|
* - API level 21: Android 5.0 (LOLLIPOP, L)
|
|
* - API level 20: Android 4.4W (KITKAT_WATCH)
|
|
* - API level 19: Android 4.4 (KITKAT)
|
|
* - API level 18: Android 4.3 (JELLY_BEAN_MR2)
|
|
* - API level 17: Android 4.2 (JELLY_BEAN_MR1)
|
|
* - API level 16: Android 4.1 (JELLY_BEAN)
|
|
* - API level 15: Android 4.0.3 (ICE_CREAM_SANDWICH_MR1)
|
|
* - API level 14: Android 4.0 (ICE_CREAM_SANDWICH)
|
|
* - API level 13: Android 3.2 (HONEYCOMB_MR2)
|
|
* - API level 12: Android 3.1 (HONEYCOMB_MR1)
|
|
* - API level 11: Android 3.0 (HONEYCOMB)
|
|
* - API level 10: Android 2.3.3 (GINGERBREAD_MR1)
|
|
*
|
|
* \returns the Android API level.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void);
|
|
|
|
/**
|
|
* Query if the application is running on Android TV.
|
|
*
|
|
* \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
|
|
|
|
/**
|
|
* Query if the application is running on a Chromebook.
|
|
*
|
|
* \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
|
|
|
|
/**
|
|
* Query if the application is running on a Samsung DeX docking station.
|
|
*
|
|
* \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
|
|
|
/**
|
|
* Trigger the Android system back button behavior.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_SendAndroidBackButton(void);
|
|
|
|
/**
|
|
* See the official Android developer guide for more information:
|
|
* http://developer.android.com/guide/topics/data/data-storage.html
|
|
*
|
|
* \since This macro is available since SDL 3.0.0.
|
|
*/
|
|
#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
|
|
#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
|
|
|
|
/**
|
|
* Get the path used for internal storage for this Android application.
|
|
*
|
|
* This path is unique to your application and cannot be written to by other
|
|
* applications.
|
|
*
|
|
* Your internal storage path is typically:
|
|
* `/data/data/your.app.package/files`.
|
|
*
|
|
* This is a C wrapper over `android.content.Context.getFilesDir()`:
|
|
*
|
|
* https://developer.android.com/reference/android/content/Context#getFilesDir()
|
|
*
|
|
* \returns the path used for internal storage or NULL on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_GetAndroidExternalStorageState
|
|
*/
|
|
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidInternalStoragePath(void);
|
|
|
|
/**
|
|
* Get the current state of external storage for this Android application.
|
|
*
|
|
* The current state of external storage, a bitmask of these values:
|
|
* `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`.
|
|
*
|
|
* If external storage is currently unavailable, this will return 0.
|
|
*
|
|
* \returns the current state of external storage, or 0 if external storage is
|
|
* currently unavailable.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_GetAndroidExternalStoragePath
|
|
*/
|
|
extern SDL_DECLSPEC Uint32 SDLCALL SDL_GetAndroidExternalStorageState(void);
|
|
|
|
/**
|
|
* Get the path used for external storage for this Android application.
|
|
*
|
|
* This path is unique to your application, but is public and can be written
|
|
* to by other applications.
|
|
*
|
|
* Your external storage path is typically:
|
|
* `/storage/sdcard0/Android/data/your.app.package/files`.
|
|
*
|
|
* This is a C wrapper over `android.content.Context.getExternalFilesDir()`:
|
|
*
|
|
* https://developer.android.com/reference/android/content/Context#getExternalFilesDir()
|
|
*
|
|
* \returns the path used for external storage for this application on success
|
|
* or NULL on failure; call SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*
|
|
* \sa SDL_GetAndroidExternalStorageState
|
|
*/
|
|
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void);
|
|
|
|
/**
|
|
* Get the path used for caching data for this Android application.
|
|
*
|
|
* This path is unique to your application, but is public and can be written
|
|
* to by other applications.
|
|
*
|
|
* Your cache path is typically: `/data/data/your.app.package/cache/`.
|
|
*
|
|
* This is a C wrapper over `android.content.Context.getCacheDir()`:
|
|
*
|
|
* https://developer.android.com/reference/android/content/Context#getCacheDir()
|
|
*
|
|
* \returns the path used for caches for this application on success or NULL
|
|
* on failure; call SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
|
|
|
|
|
|
typedef void (SDLCALL *SDL_RequestAndroidPermissionCallback)(void *userdata, const char *permission, SDL_bool granted);
|
|
|
|
/**
|
|
* Request permissions at runtime, asynchronously.
|
|
*
|
|
* You do not need to call this for built-in functionality of SDL; recording
|
|
* from a microphone or reading images from a camera, using standard SDL APIs,
|
|
* will manage permission requests for you.
|
|
*
|
|
* This function never blocks. Instead, the app-supplied callback will be
|
|
* called when a decision has been made. This callback may happen on a
|
|
* different thread, and possibly much later, as it might wait on a user to
|
|
* respond to a system dialog. If permission has already been granted for a
|
|
* specific entitlement, the callback will still fire, probably on the current
|
|
* thread and before this function returns.
|
|
*
|
|
* If the request submission fails, this function returns -1 and the callback
|
|
* will NOT be called, but this should only happen in catastrophic conditions,
|
|
* like memory running out. Normally there will be a yes or no to the request
|
|
* through the callback.
|
|
*
|
|
* \param permission the permission to request.
|
|
* \param cb the callback to trigger when the request has a response.
|
|
* \param userdata an app-controlled pointer that is passed to the callback.
|
|
* \returns SDL_TRUE if the request was submitted, SDL_FALSE if there was an error
|
|
* submitting. The result of the request is only ever reported
|
|
* through the callback, not this return value.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroidPermissionCallback cb, void *userdata);
|
|
|
|
/**
|
|
* Shows an Android toast notification.
|
|
*
|
|
* Toasts are a sort of lightweight notification that are unique to Android.
|
|
*
|
|
* https://developer.android.com/guide/topics/ui/notifiers/toasts
|
|
*
|
|
* Shows toast in UI thread.
|
|
*
|
|
* For the `gravity` parameter, choose a value from here, or -1 if you don't
|
|
* have a preference:
|
|
*
|
|
* https://developer.android.com/reference/android/view/Gravity
|
|
*
|
|
* \param message text message to be shown.
|
|
* \param duration 0=short, 1=long.
|
|
* \param gravity where the notification should appear on the screen.
|
|
* \param xoffset set this parameter only when gravity >=0.
|
|
* \param yoffset set this parameter only when gravity >=0.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
|
|
|
|
/**
|
|
* Send a user command to SDLActivity.
|
|
*
|
|
* Override "boolean onUnhandledMessage(Message msg)" to handle the message.
|
|
*
|
|
* \param command user command that must be greater or equal to 0x8000.
|
|
* \param param user parameter.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SendAndroidMessage(Uint32 command, int param);
|
|
|
|
#endif /* SDL_PLATFORM_ANDROID */
|
|
|
|
/*
|
|
* Platform specific functions for WinRT
|
|
*/
|
|
#ifdef SDL_PLATFORM_WINRT
|
|
|
|
/**
|
|
* WinRT / Windows Phone path types
|
|
*
|
|
* \since This enum is available since SDL 3.0.0.
|
|
*/
|
|
typedef enum SDL_WinRT_Path
|
|
{
|
|
/** The installed app's root directory.
|
|
Files here are likely to be read-only. */
|
|
SDL_WINRT_PATH_INSTALLED_LOCATION,
|
|
|
|
/** The app's local data store. Files may be written here */
|
|
SDL_WINRT_PATH_LOCAL_FOLDER,
|
|
|
|
/** The app's roaming data store. Unsupported on Windows Phone.
|
|
Files written here may be copied to other machines via a network
|
|
connection.
|
|
*/
|
|
SDL_WINRT_PATH_ROAMING_FOLDER,
|
|
|
|
/** The app's temporary data store. Unsupported on Windows Phone.
|
|
Files written here may be deleted at any time. */
|
|
SDL_WINRT_PATH_TEMP_FOLDER
|
|
} SDL_WinRT_Path;
|
|
|
|
|
|
/**
|
|
* WinRT Device Family
|
|
*
|
|
* \since This enum is available since SDL 3.0.0.
|
|
*/
|
|
typedef enum SDL_WinRT_DeviceFamily
|
|
{
|
|
/** Unknown family */
|
|
SDL_WINRT_DEVICEFAMILY_UNKNOWN,
|
|
|
|
/** Desktop family*/
|
|
SDL_WINRT_DEVICEFAMILY_DESKTOP,
|
|
|
|
/** Mobile family (for example smartphone) */
|
|
SDL_WINRT_DEVICEFAMILY_MOBILE,
|
|
|
|
/** XBox family */
|
|
SDL_WINRT_DEVICEFAMILY_XBOX,
|
|
} SDL_WinRT_DeviceFamily;
|
|
|
|
|
|
/**
|
|
* Retrieve a WinRT defined path on the local file system.
|
|
*
|
|
* Not all paths are available on all versions of Windows. This is especially
|
|
* true on Windows Phone. Check the documentation for the given SDL_WinRT_Path
|
|
* for more information on which path types are supported where.
|
|
*
|
|
* Documentation on most app-specific path types on WinRT can be found on
|
|
* MSDN, at the URL:
|
|
*
|
|
* https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
|
|
*
|
|
* \param pathType the type of path to retrieve, one of SDL_WinRT_Path.
|
|
* \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if
|
|
* the path is not available for any reason; call SDL_GetError() for
|
|
* more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC const char * SDLCALL SDL_GetWinRTFSPath(SDL_WinRT_Path pathType);
|
|
|
|
/**
|
|
* Detects the device family of WinRT platform at runtime.
|
|
*
|
|
* \returns a value from the SDL_WinRT_DeviceFamily enum.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_GetWinRTDeviceFamily();
|
|
|
|
#endif /* SDL_PLATFORM_WINRT */
|
|
|
|
/**
|
|
* Query if the current device is a tablet.
|
|
*
|
|
* If SDL can't determine this, it will return SDL_FALSE.
|
|
*
|
|
* \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
|
|
|
|
/* Functions used by iOS app delegates to notify SDL about state changes. */
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationWillTerminate.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void);
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationDidReceiveMemoryWarning.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void);
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationWillResignActive.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterBackground(void);
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationDidEnterBackground.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void);
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationWillEnterForeground.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void);
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationDidBecomeActive.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidEnterForeground(void);
|
|
|
|
#ifdef SDL_PLATFORM_IOS
|
|
|
|
/**
|
|
* Let iOS apps with external event handling report
|
|
* onApplicationDidChangeStatusBarOrientation.
|
|
*
|
|
* This functions allows iOS apps that have their own event handling to hook
|
|
* into SDL to generate SDL events. This maps directly to an iOS-specific
|
|
* event, but since it doesn't do anything iOS-specific internally, it is
|
|
* available on all platforms, in case it might be useful for some specific
|
|
* paradigm. Most apps do not need to use this directly; SDL's internal event
|
|
* code will handle all this for windows created by SDL_CreateWindow!
|
|
*
|
|
* \threadsafety It is safe to call this function from any thread.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void);
|
|
#endif
|
|
|
|
/*
|
|
* Functions used only by GDK
|
|
*/
|
|
#ifdef SDL_PLATFORM_GDK
|
|
typedef struct XTaskQueueObject *XTaskQueueHandle;
|
|
typedef struct XUser *XUserHandle;
|
|
|
|
/**
|
|
* Gets a reference to the global async task queue handle for GDK,
|
|
* initializing if needed.
|
|
*
|
|
* Once you are done with the task queue, you should call
|
|
* XTaskQueueCloseHandle to reduce the reference count to avoid a resource
|
|
* leak.
|
|
*
|
|
* \param outTaskQueue a pointer to be filled in with task queue handle.
|
|
* \returns SDL_TRUE on success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKTaskQueue(XTaskQueueHandle *outTaskQueue);
|
|
|
|
/**
|
|
* Gets a reference to the default user handle for GDK.
|
|
*
|
|
* This is effectively a synchronous version of XUserAddAsync, which always
|
|
* prefers the default user and allows a sign-in UI.
|
|
*
|
|
* \param outUserHandle a pointer to be filled in with the default user
|
|
* handle.
|
|
* \returns SDL_TRUE if success or SDL_FALSE on failure; call
|
|
* SDL_GetError() for more information.
|
|
*
|
|
* \since This function is available since SDL 3.0.0.
|
|
*/
|
|
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetGDKDefaultUser(XUserHandle *outUserHandle);
|
|
|
|
#endif
|
|
|
|
/* Ends C function definitions when using C++ */
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#include <SDL3/SDL_close_code.h>
|
|
|
|
#endif /* SDL_system_h_ */
|