Commit Graph

361 Commits

Author SHA1 Message Date
Anthony e59344ad46 Update proguard-rules.pro in-line with commit 9ff3446
A couple of JNI methods changed from returning int to boolean.
2024-09-16 08:47:44 -07:00
Anders Jenbo ee377793fe Spell "unknown" correctly 2024-09-13 12:29:25 -07: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
Anthony 459d3a8bbd
Add messageBox to proguard-rules.pro (#10570)
I missed this out from the previous update, oops!
2024-08-20 07:41:52 -07:00
Anthony 8a6fd058b4 Update proguard-rules.pro in line with recent changes
Also sort methods and add a note about preserving unused native method nativeGetHint.
2024-08-09 19:18:29 -07:00
Susko3 e3cf20e1cc
Remove `createSDLMainRunnable()` in favour of `main()` to fix multiple issues when providing custom main/runnable code (#10434)
This allows managed applications (eg. Java, C#) to override main() to their liking.
2024-08-03 06:34:38 -07:00
Sam Lantinga 81f8e6aba6 Added SDL_StartTextInputWithProperties()
This allows you to customize the text input so you can have numeric text entry, hidden passwords, etc.

Fixes https://github.com/libsdl-org/SDL/issues/7101
Fixes https://github.com/libsdl-org/SDL/issues/7965
Fixes https://github.com/libsdl-org/SDL/issues/9439
2024-08-02 14:49:37 -07:00
Anonymous Maarten 0c5bb532c3 Remove support for building a SDL3 library from gradle 2024-08-01 17:48:49 +00:00
Anonymous Maarten 349540f73f Document the new SDL3 Android archive artifact 2024-08-01 17:48:49 +00:00
Sam Lantinga 691cf15e75 Removed the ancient Android audio driver
OpenSLES is well supported on Android 4.0 and later.
2024-07-29 08:05:36 -07:00
Anthony 7cd23bfb6a Respect Android's auto-rotate setting when choosing orientation 2024-07-27 09:38:41 -07:00
Anthony d6554a9505 Fix running on Android 9 and older 2024-07-25 04:41:43 -07:00
Sam Lantinga 31730bef1a Fixed running on Android 10 and older (thanks @AntTheAlchemist!) 2024-07-24 13:37:40 -07:00
Anthony 27f86cbe18 Update proguard-rules.pro to include onNativeInsetsChanged 2024-07-24 10:22:45 -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
Anonymous Maarten 50ae47af5e android: create android project in create-android-project.py python script
This script supersedes androidbuild.sh, and also supports using a SDL3 prefab archive
2024-07-05 21:12:26 +02:00
Sam Lantinga a04596c9a7 Added support for the ROG RAIKIRI 2024-07-03 13:54:00 -07:00
Blaž Tomažič 0383333b54 android: add an option to manually pass the context when loading a native library
(cherry picked from commit b444e656cd)
2024-06-20 10:38:59 -07:00
Blaž Tomažič 3b5f35138e android: actually use ReLinker
When loading libraries the `SDL.mContext` is still `null`. This results in
relinker code path in `SDL.loadLibrary(...)` always throwing a null exception
and fallbacking to system loader.

Fix it by passing the context explicitly.

(cherry picked from commit 6a2dd96ac7)
2024-06-20 09:36:17 -07:00
Anonymous Maarten 1a68d846de Create a functional CMake project using androidbuild.sh 2024-06-18 00:11:44 +02:00
Sam Lantinga 8ab1ffca8a Fixed requesting USB permission on Android 14 (thanks @ikhoeyZX!)
Fixes https://github.com/libsdl-org/SDL/issues/9831
2024-06-17 15:10:33 -07:00
Miku AuahDark 3373667faa Android: Use SCREEN_ORIENTATION_FULL_USER instead of SCREEN_ORIENTATION_FULL_SENSOR for resizable window.
The former will respect user orientation lock setting while the latter does not.
2024-06-17 07:44:05 -07:00
Ryan C. Gordon 38f0214e8a audio: Refer to audio devices to "playback" and "recording".
Fixes #9619.
2024-06-15 01:08:12 -04:00
Anthony 3c5b1b52ac Update proguard-rules.pro for recent haptic changes 2024-06-05 14:54:42 -07:00
Sam Lantinga f879411627 Added support for gamepad rumble on Android
Tested with the DualSense controller over Bluetooth on Android 12

Fixes https://github.com/libsdl-org/SDL/issues/7847
2024-06-05 09:53:56 -07:00
mechakotik 8f88c32ca6 android: Default to custom theme in styles.xml
Custom theme file exists in project, but is not used by app, which is kinda unintuitive. Using it by default so people who not familiar with Android development won't spend lots of time troubleshooting.
2024-05-31 09:04:06 -07:00
Sam Lantinga 9259d532da isVRHeadset returns true for Pico headsets 2024-05-23 17:39:06 -07:00
Anonymous Maarten e10666397e ci: build simple Android SDL app using gradle 2024-05-22 20:19:18 +02:00
Sam Lantinga 9b7f88e512 Pass the VR controller "back" button to the application on the Oculus Quest 2024-05-13 21:01:04 -07:00
Miku AuahDark 86fada6faa Android: Implement open and save file dialog. 2024-05-06 09:33:48 -07:00
Miku AuahDark 33ae7e38d6
Android: Allow SDL_IOFromFile to open content:// URI. (#9696) 2024-05-06 09:05:49 -07:00
Sam Lantinga d95f5bad24 Updated to version 3.1.2 for the preview release 2024-05-01 09:34:25 -07:00
Susko3 5045680628 Override `onTrimMemory()` instead of `onLowMemory()`
https://developer.android.com/reference/android/content/ComponentCallbacks#onLowMemory()

> Preferably, you should implement ComponentCallbacks2#onTrimMemory from ComponentCallbacks2 [...].
> That API is available for API level 14 and higher, so you should only use this onLowMemory() method as a fallback for older versions.

Since the SDL3 min api level is 19, there's no need for `onLowMemory()` compat.
2024-04-30 08:54:19 -07:00
Sam Lantinga 17d4f8d699 Updated to version 3.1.1 for the preview release 2024-04-01 17:03:46 -07:00
Sam Lantinga 36e73bdda4 Updated to version 3.1.0 for the preview release 2024-03-24 06:16:02 -07:00
Sylvain 1855ce68af Fix bug #9331 - SDL3 Android crash getVibrator() == null 2024-03-23 16:31:21 -07:00
Frosty-J f9d018c808 Add flag to registerReceiver on Android 2024-03-10 09:01:07 -07:00
Sam Lantinga 1cae52bbac Added JNI native methods to proguard-rules.pro (thanks @AntTheAlchemist!)
Fixes https://github.com/libsdl-org/SDL/issues/3563
2024-02-25 08:40:47 -08:00
Ryan C. Gordon 2613e3da24 camera: Rewrote Android support.
This does something a little weird, in that it doesn't care what
`__ANDROID_API__` is set to, but will attempt to dlopen the system
libraries, like we do for many other platform-specific pieces of SDL.

This allows us to a) not bump the minimum required Android version, which is
extremely ancient but otherwise still working, doing the right thing on old
and new hardware in the field, and b) not require the app to link against
more libraries than it previously did before the feature was available.

The downside is that it's a little messy, but it's okay for now, I think.
2024-02-20 15:56:26 -05:00
Michał Janiszewski 631b05b211 Drop stray trailing whitespace for android-project 2024-02-16 09:22:23 -05:00
Sam Lantinga 9ce7fe2848 Removed SDL_HINT_ACCELEROMETER_AS_JOYSTICK
Sensors are a first-class object in SDL and we haven't gotten any feedback that this feature is useful these days.

Closes https://github.com/libsdl-org/SDL/pull/7879
2024-02-12 09:54:33 -08:00
Sam Lantinga a31dc6dfcb Switched SDL_TouchID and SDL_FingerID to be Uint64 with 0 being an invalid value 2024-01-18 10:55:24 -08:00
Amir Kadyrov dd2d809407 AndroidShowToast: make OneShotTask members private final 2024-01-01 08:31:34 -08:00
Sam Lantinga bb0e0ae080 Added a runtime check for BLUETOOTH_CONNECT in addition to BLUETOOTH (thanks @perepujal!)
Fixes https://github.com/libsdl-org/SDL/issues/8731
2023-12-24 06:50:42 -08:00
Sam Lantinga 9d13be743b Make sure we're rendering whenever the activity might be visible, even if we don't have focus.
This fixes rendering when a system dialog is over the application
2023-12-18 19:21:00 -08:00
Sam Lantinga 58a5f5cbe8 Allow sendCommand() to be overridden by derived classes
In this case it's used to prevent switching to windowed mode when destroying and recreating the main window
2023-12-13 10:13:17 -08:00
Sam Lantinga 3c5e9e6112 We can wait up to 500ms in onNativeSurfaceDestroyed(), so wait at least that long in onDestroy() 2023-12-07 14:30:44 -08:00
Zack Middleton 5e9b0820f3 Add cursors for X11/Wayland window resizing 2023-11-21 08:34:13 -08:00
Sam Lantinga 9302d7732d Fixed touch normalized coordinates
When converting normalized coordinates to pixel coordinates, the valid range is 0 to (width or height) - 1, and the pixel coordinate of width or height is past the edge of the window.

Fixes https://github.com/libsdl-org/SDL/issues/2913
2023-11-05 06:55:39 -08:00
Sam Lantinga 5dce4bc716 Makes SDLInputConnection and DummyEdit public classes (thanks Cole!)
I've added an additional patch that expands on the same basic idea as the first one; it makes SDLInputConnection and DummyEdit into public classes so that they can be overridden from the Xamarin end if their functionality needs to be extended. (In my case, I need to change the type of software keyboard that's displayed.)

Fixes https://github.com/libsdl-org/SDL/issues/2785
2023-11-04 23:22:55 -07:00