Commit Graph
499 Commits
Author SHA1 Message Date
Anthony 8fd4bf5d83 Fix initial window size and fullscreen toggle behaviour across APIs 2026-08-02 13:16:56 -07:00
Anthony 13b0a36ae9 Fix edge-to-edge layout for Android 11 and above
if setDecorFitsSystemWindows is done too late, then the initial window size won't be the right size. 

Zeroing the safe zone is nonsense, as it's handled correctly elsewhere.
2026-08-02 13:16:08 -07:00
Anthony 513ebb5c47 Add setBackButtonTrapEnabled to proguard
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Skipped
Build (All) / level2 (push) Skipped
2026-07-30 06:03:05 -07:00
Sam Lantinga 6880bed495 Fixed java.lang.ClassNotFoundException: Didn't find class "android.window.OnBackInvokedCallback" on Android 8.0
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Canceled after 0s
Build (All) / level2 (push) Canceled after 0s
2026-07-29 19:45:40 -07:00
Rachel Blackman 412a7c5db6 Use the modern OnBackInvokedCallback method to trap the back button on newer Android devices (#16052)
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Canceled after 0s
Build (All) / level2 (push) Canceled after 0s
2026-07-27 15:43:23 -07:00
Ryan C. Gordon df7b937361 android: Fix pen creating phantom mouse events in relative mode.
Build (All) / Create test plan (push) Canceled after 0s
Build (All) / level1 (push) Canceled after 0s
Build (All) / level2 (push) Canceled after 0s
This mostly just unifies code that was handling this case elsewhere already.

Fixes #15620.
2026-07-17 12:59:26 -04:00
klirktag 8408a664e2 Android: restore the system bars when leaving fullscreen on API 30+
My old PR #15867 switched the fullscreen path to WindowInsetsController.hide() for API 30+, because the legacy setSystemUiVisibility() flags are ignored on API 30+.

The leaving fullscreen path was left untouched: it still calls setSystemUiVisibility(SYSTEM_UI_FLAG_VISIBLE), which is equally ignored on API 30+.

As a result, once fullscreen had hidden the status/navigation bars, they never came back when returning to windowed mode.
2026-07-15 08:15:18 -07:00
brentfpage 46dcc0c554 for 'pinch end' events on mobile devices, send dummy value -1 for (focus|span)_(x|y) 2026-07-06 05:52:47 -07:00
Anthony 7418e1aef1 Update proguard-rules.pro 2026-07-03 09:22:45 -07:00
Holden Ramsey 2919e1899f Android: decouple JNI setup from unused subsystems
Query the natively compiled-in subsystems at runtime so the Java side
only registers and initializes the managers that exist, fixing
UnsatisfiedLinkError when SDL is built with a subsystem disabled
(e.g. -DSDL_AUDIO_DISABLED).

- Add SDL.setupJNI(int subsystems) plus SDL_INIT_* Java constants;
  SDLActivity passes an overridable getInitSubsystems() mask so custom
  activities can skip Java-side setup for unused subsystems.
- Distinguish compiled from requested subsystems: JNI registration
  follows nativeGetCompiledSubsystems(), while manager initialization
  and surface/layout creation follow the requested-and-compiled mask.
- Gate HIDDeviceManager.acquire() (USB/BLE device scanning) on a new
  nativeIsHIDAPIEnabled() query so HIDAPI-less builds never touch it.
- Gate SDLControllerManager.initializeDeviceListener() and the
  joystick key-event path on the controller subsystem; gate the
  clipboard handler on video, mirroring the native guards.
- Guard the SDLControllerManager JNI bindings with
  SDL_ANDROID_NEED_CONTROLLER_MANAGER (joystick or haptic enabled).
- Skip layout updates in ShowTextInputTask when no layout exists
  (video disabled).
- Reorganize SDL_android.h/.c into guarded per-subsystem groups with
  matching ordering.
2026-07-02 11:30:47 -07:00
Holden Ramsey 7a6eed4ec8 Android: decouple video/audio subsystems from JNI initialization
Allow Android embedders to use SDL without the full video/audio Java
layer by gating subsystem-specific code behind SDL_VIDEO_DISABLED and
SDL_AUDIO_DISABLED preprocessor flags.

This enables applications that only need joystick/gamepad support
(e.g. Qt-based apps like QGroundControl) to build SDL without shipping
stub Java classes for unused subsystems.

Changes:
- Split SDLActivity JNI method table into core (lifecycle, hints,
  permissions) and video (surface, input, clipboard, orientation)
- Gate SDLAudioManager and SDLInputConnection JNI registration
- Make checkJNIReady() subsystem-aware: no longer requires
  mAudioManagerClass when SDL_AUDIO_DISABLED
- Group method ID resolution by subsystem in nativeSetupJNI()
- Guard all video/audio function implementations and declarations
- Keep display orientation accessors always available (needed by camera)
- Add subsystem-selective SDL.setupJNI(int)/initialize(int) to SDL.java
  with backwards-compatible zero-arg overloads
- Guard SDL_VIDEO_DRIVER_ANDROID and related defines in
  SDL_build_config_android.h
2026-06-26 10:59:54 -07:00
Brent Page 65091012b4 Add more information for pinch gestures on mobile (#15092) 2026-06-21 20:30:50 -07:00
ripdog 35ebc3db89 Android: honor suggested filename in ShowSaveFileDialog 2026-06-21 11:09:36 -05:00
Semphriss d474769878 Detect device form factor (#12584) 2026-06-21 08:33:13 -07:00
klirktag 5317703567 Android: hide system bars via WindowInsetsController on API 30+
The immersive-fullscreen code hid the status and navigation bars with the
deprecated View.setSystemUiVisibility() flags plus FLAG_FULLSCREEN. On
Android 15+ (API 35), edge-to-edge is enforced for apps targeting SDK 35+
and those flags are ignored, so the bars never hide (e.g. on a Samsung
S25). Android 14 and below still honour them, which is why older devices
were unaffected.

Hide/show the system bars with WindowInsetsController on API 30+ (using
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE for sticky-immersive), keeping the
legacy setSystemUiVisibility() path for API < 30. The minimum supported
version is unchanged.

(cherry picked from commit a442367706)
2026-06-21 08:26:48 -07:00
Sam Lantinga acc06bce35 android: fixed crash adding joysticks before joysticks are initialized
Fixes https://github.com/libsdl-org/SDL/issues/15777
2026-06-08 14:35:42 -07:00
Sylvain 72d14c281c Fixed bug #13850: SDLControllerManager, we can use isVirtual() since API > 16
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-06-06 07:58:47 -07:00
Sam Lantinga 8549aae829 Make initializeDeviceListener() and shutdownDeviceListener() public 2026-06-04 09:26:33 -07:00
Sam Lantinga 36c5809b09 Added SDLControllerManager::shutdownDeviceListener() 2026-06-04 09:19:53 -07:00
Sam Lantinga e5bbef0dbc Fixed detecting PS4 controllers on Android 2026-06-04 09:19:28 -07:00
Sylvain Becker fc3a96e47a Android: remove pollInputDevice() in favor of InputDeviceListener (#15659)
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-06-03 20:38:04 -07:00
Sam Lantinga 42fc082b5e Fixed java.lang.NullPointerException
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
From @AntTheAlchemist:
This is an interesting one, on a Xiaomi MiTV. Caused by a camera device, full stack:
android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args -> org.libsdl.app.HIDDeviceManager$1.onReceive -> handleUsbDeviceAttached -> connectHIDDeviceUSB -> getSerialNumber -> android.hardware.usb.UsbDevice.getSerialNumber -> android.hardware.usb.IUsbSerialReader$Stub.onTransact -> com.android.server.usb.UsbSerialReader.getSerial -> UsbUserPermissionManager.checkPermission -> hasPermission -> isCameraDevicePresent
2026-06-02 16:51:58 -07:00
Sam Lantinga 75270a4264 Handle java.util.ConcurrentModificationException while unregistering sensor listeners
We're still seeing this frequently when unregistering PlayStation controller sensors. We don't know what else is modifying the sensor list, but if we end up getting this exception we'll retry after a short sleep.
2026-06-02 16:51:58 -07:00
NY00123 ed2c8036a7 Android: Remove unused accelerometer-related code and definitions
That also covers removal of the call `SDLActivity.onNativeAccel`,
plus a change of comment under SDL_android.c.

Definitions were previously used while an accelerometer could be listed as a joystick.
2026-05-29 13:14:09 -07:00
Sam Lantinga 7103ed4167 Fixed Steam Controller rumble on Android (thanks @Packetdancer!) 2026-05-28 11:39:58 -07:00
Sam Lantinga f6ffa69890 Add support for new Steam Controller input report on mobile devices 2026-05-28 11:39:58 -07:00
Rachel Blackman ac177763aa Ensure we release exclusive USB access to controllers when backgrounded. #15694
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-05-26 17:40:52 -07:00
NY00123 199d509820 Android: Skip duplicated joystick axes during poll
Resolves https://github.com/libsdl-org/SDL/issues/15414
2026-05-26 15:54:33 -07:00
Sam Lantinga 3545bad589 Process repeated joystick key events on Android
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
This prevents them from being interpreted as keyboard keys by the Java code, and if internally we are treating them as keyboard keys, they'll be repeated properly.

Fixes https://github.com/libsdl-org/SDL/issues/15664
2026-05-21 06:53:17 -07:00
Sam Lantinga 47c8dcc968 android: handle sensor registration synchronized in one place 2026-05-20 15:55:24 -07:00
Sam Lantinga 8c89a076a7 Fixed deadlock introduced by 7222c04fbf
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
It turns out this change causes a deadlock:
The main UI thread calls synchronized handleMotionEvent() which then calls SDL_LockJoysticks()
The main app thread calls SDL_LockJoysticks() and then synchronized pollInputDevices()
2026-05-17 12:22:12 -07:00
Sam Lantinga b19ecb4032 Reapply "Change controller sensor state on the main UI thread on Android"
This reverts commit 02975994c1.

Accidentally reverted the wrong commit
2026-05-17 12:15:48 -07:00
Sam Lantinga 02975994c1 Revert "Change controller sensor state on the main UI thread on Android"
This reverts commit c362f1341f.

It turns out this change causes a deadlock:
The main UI thread calls synchronized handleMotionEvent() which then calls SDL_LockJoysticks()
The main app thread calls SDL_LockJoysticks() and then synchronized pollInputDevices()
2026-05-17 12:04:11 -07:00
Sam Lantinga a95ce7e734 Detect the GameSir Super Nova in Xbox 360 mode 2026-05-15 10:13:15 -07:00
Anthony bd146867e4 Update showFileDialog in proguard-rules.pro
to match changes in 439ffd1
2026-05-15 08:59:35 -07:00
crudelios 439ffd13eb Android: Add support for folder dialogs 2026-05-14 11:50:52 -07:00
Cameron Cawley e50faf4e6a Support the full set of standard CSS cursors 2026-05-13 20:24:44 -07:00
Sam Lantinga c362f1341f Change controller sensor state on the main UI thread on Android
Fixes https://github.com/libsdl-org/SDL/issues/15565
2026-05-13 07:39:02 -07:00
Sam Lantinga 7222c04fbf Synchronize controller access on the Java side on Android 2026-05-13 07:39:02 -07:00
Rachel Blackman 418960bb4e Handle the Amazon Fire TV's weird Bluetooth behavior 2026-05-12 17:40:37 -07:00
Rachel Blackman e4a327709d Correctly support OG Steam Controller when connected via USB on Android (#15561) 2026-05-11 15:19:57 -07:00
Anthony c94b1435c7 Add joystickSetSensorsEnabled to proguard-rules.pro 2026-05-11 06:38:19 -07:00
Nintorch 3c1636a958 Fix JoyCon mappings on Android
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-05-04 11:49:25 -07:00
Nintorch c699512adc Add support for joystick motion sensors on Android
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-05-03 15:11:31 -07:00
Sam Lantinga 47d14491a6 Fixed keyboard being hidden while being shown on Android
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-04-25 17:10:54 -07:00
MAJigsaw77 7f12b975bb Use singleTop launchMode for SDLActivity on Android
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-04-11 20:04:46 +02:00
Sylvain ccf688c921 Android: fix lint warning "unneed cast to Activity"
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
2026-04-10 07:08:07 -07:00
Sam Lantinga fc2f4fcc22 Send SDL_EVENT_SCREEN_KEYBOARD_HIDDEN when the keyboard is hidden on Android 2026-04-04 10:07:58 -07:00
Sam Lantinga 815fd4bf45 Removed spurious whitespace 2026-03-28 22:22:39 -07:00
Tobiasz Laskowski 01bd8b3780 Fix backspace on android with api 30+ 2026-03-03 17:12:01 -08:00