Commit Graph

196 Commits (952bac7c47302a472f6eb9782b412871c36edbfe)

Author SHA1 Message Date
Sylvain Becker ae41831e0d Android: minor, remove static attributes, move mIsSurfaceReady to SDLSurface 2019-01-14 21:34:12 +01:00
Sylvain Becker 42e18bd0c2 Android: fix bad merge from previous commit 2019-01-11 14:25:32 +01:00
Sylvain Becker 7a1d1baefc Android: add name for Touch devices and simplification, from bug 3958 2019-01-10 21:40:57 +01:00
Sylvain Becker d23c2f07e3 Fixed bug 3930 - Android, set thread priorities and names
SDLActivity thread priority is unchanged, by default -10 (THREAD_PRIORITY_VIDEO).

SDLAudio thread priority was -4 (SDL_SetThreadPriority was ignored) and is now -16 (THREAD_PRIORITY_AUDIO).

SDLThread thread priority was 0 (THREAD_PRIORITY_DEFAULT) and is -4 (THREAD_PRIORITY_DISPLAY).
2019-01-10 18:05:56 +01:00
Sylvain Becker 0e0e0272b8 Android: remove deprecated PixelFormat in surfaceChanged()
Can be check by adding in build.grable:

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
    }
}

SDLActivity.java:1691: warning: [deprecation] A_8 in PixelFormat has been deprecated
        case PixelFormat.A_8:
SDLActivity.java:1694: warning: [deprecation] LA_88 in PixelFormat has been deprecated
SDLActivity.java:1697: warning: [deprecation] L_8 in PixelFormat has been deprecated
SDLActivity.java:1700: warning: [deprecation] RGBA_4444 in PixelFormat has been deprecated
SDLActivity.java:1704: warning: [deprecation] RGBA_5551 in PixelFormat has been deprecated
SDLActivity.java:1716: warning: [deprecation] RGB_332 in PixelFormat has been deprecated
2019-01-10 16:04:52 +01:00
Sylvain Becker 5c11e5ef92 Android: some simplification, don't need mExitCalledFromJava 2019-01-10 15:48:43 +01:00
Sylvain Becker 66fbfe1d00 Android: nativeQuit for SDLActivity thread
- destroy Android_ActivityMutex
- display any SDL error message that may have occured in this thread,
  since SDL_GetError() is thread specific, and user has no access to it.
2019-01-10 15:43:07 +01:00
Sylvain Becker dad8161103 Android: only send Quit event to SDLThread if it's not already terminated
And it avoids reporting errors using Android_Pause/ResumeSem that are NULL.
2019-01-10 15:35:46 +01:00
Sylvain Becker 61d37de099 Android: un-needed transition to Pause state.
- Don't need to go into Pause state, since onPause() has been called before.
- Don't need to call nativePause is SDLThread is already ended
2019-01-10 15:29:37 +01:00
Sylvain Becker 8dd915507e Android: prevent a dummy error message sending SDL_DISPLAYEVENT_ORIENTATION
In the usual case, first call to onNativeOrientationChanged() is done before
SDL has been initialised and would just set an error message
"Video subsystem has not been initialized" without sending the event.
2019-01-09 23:19:26 +01:00
Sylvain Becker 68c0e69f0a Android: native_window validity is guaranteed between surfaceCreated and Destroyed
It's currently still available after surfaceDestroyed().
And available (but invalid) between surfaceCreated() and surfaceChanged().

Which means ANativewindow_getWidth/Height/Format() fail in those cases.

https://developer.android.com/reference/android/view/SurfaceHolder.html#getSurface()
2019-01-09 22:41:52 +01:00
Sylvain Becker 59df6d6b13 Android: don't allow multiple instance of SDLActivity
Default launch mode (standard) allows multiple instances of the SDLActivity.
( https://developer.android.com/guide/topics/manifest/activity-element#lmode )

Not sure this is intended in SDL as this doesn't work. There are static
 variables in Java, in C code which make this impossible (allow one android_window) and
 also Audio print errors.

There is also some code added in onDestroy as if it would be able to
re-initialize: https://hg.libsdl.org/SDL/rev/27686adb08c3

Bug Android activity life-cycle seems to show there is not transition to get out
of onDestroy()
https://developer.android.com/reference/android/app/Activity#ActivityLifecycle

( can be tested with "adb shell am start  my.package.org/.MainActivity"
  and "adb shell am start -n  my.package.org/.MainActivity" )

Send me a message if there are real use-case for this !
2019-01-07 17:06:50 +01:00
Sylvain Becker 911f1d3e67 Android: remove SURFACE_TYPE_GPU, deprecated in API level 5.
https://developer.android.com/reference/android/view/SurfaceHolder

This constant was deprecated in API level 5. this is ignored, this value is set automatically when needed.
2019-01-05 22:49:50 +01:00
Sylvain Becker a95f91bcea Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565
Use the egl format to reconfigure java SurfaceView holder format.
If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
2019-01-02 18:06:33 +01:00
Sylvain Becker a02998a292 Android: make sure surfaceChanged try to enter into 'resumed' state. 2019-01-02 17:41:33 +01:00
Sylvain Becker 4d2b5c791e Fixed bug 4424 - Android windowed mode is broken (Thanks Jonas Thiem!) 2019-01-02 17:08:01 +01:00
Sam Lantinga cc39c7a0cb Fixed bug 4320 - Android remove reflection for HIDDeviceBLESteamController
Sylvain

Uneeded use of reflection to access connectGatt method in HIDDeviceBLESteamController.java

The method is API 23

https://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#connectGatt(android.content.Context,%20boolean,%20android.bluetooth.BluetoothGattCallback,%20int)
2018-11-02 17:25:00 -07:00
Sam Lantinga 67a94893c0 Fixed bug 4319 - Android remove reflection for PointerIcon
Sylvain

Since SDL2 min requirement is Android SDK 26, and PointerIcon is 24. We don't need reflection to access it.
2018-11-02 17:22:15 -07:00
Sam Lantinga e381a1599d Updated Android project files and documentation 2018-10-28 10:31:06 -07:00
Sam Lantinga b699ddc0a9 Fixed reinitializing the SDL joystick subsystem on Android 2018-10-23 12:40:25 -07:00
Sam Lantinga d7fa11204f Change our fullscreen wait logic to only wait if we need to. (thanks Rachel!) 2018-10-22 14:55:47 -07:00
Sam Lantinga e6068b5b15 Handle failure to load hidapi gracefully 2018-10-22 14:55:45 -07:00
Sam Lantinga 3e3ce6e95c Fixed bug 4318 - Android move Haptic code to API26 class
Sylvain

- Create SDLHapticHandler_API26
- No need of reflection since SDL2 compile with Android 26 as a min requirement.
- remove spaces
2018-10-16 15:00:43 -07:00
Sam Lantinga b0c48dd9dd Support vibration magnitude on Android 8.0 (thanks Rachel!) 2018-10-16 08:29:27 -07:00
Sam Lantinga f5a21ebf0c Added support for surround sound and float audio on Android 2018-10-09 20:12:43 -07:00
Sam Lantinga 4679f6826d Removed unneeded variable qualifiers 2018-10-09 20:12:40 -07:00
Sam Lantinga 337cea4411 Fixed life-cycle issues with two activities sharing HIDDeviceManager 2018-10-08 12:49:30 -07:00
Sam Lantinga 1e728f5075 Close on shutdown, for consistency 2018-10-08 12:49:28 -07:00
Sam Lantinga e4c9806f4f Trying to track down NullPointerException in USB input thread 2018-10-08 12:49:26 -07:00
Sam Lantinga a0c53668e6 Allow SDL to use ReLinker if present.
This fixes issues for applications that have a large number of shared libraries
For more information, see https://github.com/KeepSafe/ReLinker for ReLinker's repository.
2018-10-04 16:29:17 -07:00
Sam Lantinga ae5317e844 The Amlogic X96 is a set-top box 2018-10-02 13:17:31 -07:00
Sam Lantinga 679d355317 Fixed UnsatisfiedLinkError when initializing the HIDDeviceManager in some cases 2018-10-01 14:52:28 -07:00
Sam Lantinga e77ec88969 Fixed tablet detection on Android 2018-09-29 02:14:46 -07:00
Sam Lantinga 74638ea3c5 Ensure we wait on the surface resize before returning from setting fullscreen mode. 2018-09-28 20:39:57 -07:00
Sam Lantinga d40657bfc9 Fixed bug 4270 - Android HIDDeviceManager function needs to be public
Sylvain

Can't run an android app without declaring the JNI interface function as public.
2018-09-25 20:11:52 -07:00
Sam Lantinga da89b81c3c Fixed rare null pointer dereference 2018-09-24 20:31:24 -07:00
Sam Lantinga e0fe8f3cb3 Support relative mouse for Samsung DeX on Samsung Experience 9.5 or later (Android 8.1 or later) 2018-09-24 11:53:04 -07:00
Sam Lantinga c179d3948a Fixed NullPointerException if there's no singleton 2018-09-17 12:08:05 -07:00
Sam Lantinga 66294d31df Guard against Steam Controller input when we're shutting down. 2018-09-14 18:31:03 -07:00
Sam Lantinga a0b3dcc26a Fixed bug 4002 - Android, nativeRunMain() fails on some phone with arm64-v8a
Sylvain

The issue is totally reproducible on P8 Lite.

"The dlopen() call doesn't include the app's native library directory. The behavior of  dlopen() by Android is not guaranteed".

Workaround in getMainSharedObject()

Just replace
    return library;
with
    return getContext().getApplicationInfo().nativeLibraryDir + "/" + library;
2018-09-05 15:54:46 -07:00
Sam Lantinga 09ab752aa3 Implement SDL_HapticStopEffect on Android (thanks Rachel!) 2018-08-24 10:41:57 -07:00
Sam Lantinga a003fa0a05 Implemented SDL_GetDisplayOrientation() on Android (thanks Rachel!) 2018-08-23 14:05:25 -07:00
Sam Lantinga 38ae49880f Updated required Android SDK to API 26, to match Google's new App Store requirements 2018-08-21 20:46:25 -07:00
Sam Lantinga c2791fc60d Don't crash if the app doesn't have Bluetooth permissions 2018-08-21 11:59:13 -07:00
Sam Lantinga 2a4999b4bb By default just build for 32-bit ARM and x86 2018-08-21 11:44:08 -07:00
Sam Lantinga 109544ca04 Add SDL_IsTablet() to Android and iOS SDL. 2018-08-21 11:23:47 -07:00
Sam Lantinga b09b25f6e4 Don't crash if the app doesn't have Bluetooth permissions 2018-08-21 11:07:56 -07:00
Sam Lantinga ad1e3c2a4c Fixed Android build error 2018-08-21 10:37:26 -07:00
Sam Lantinga cf823094a2 The MINIX NEO-U1 is now being reported as Android TV 2018-08-09 16:04:25 -07:00
Sam Lantinga d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Sam Lantinga fd8e8f9f20 Clean up captured pointer code to avoid logcat clutter on pre-8.0 systems (thanks Rachel!) 2018-07-13 12:55:50 -07:00
Sam Lantinga ff8c9538bc Allow trapping the back button so right mouse click can work on some Android systems (thanks Rachel!)
Also, added a function SDL_AndroidBackButton() so applications can respond to the back button directly
2018-07-12 13:28:13 -07:00
Sam Lantinga a515853569 Added support for external mouse in Samsung DeX mode
relative mode doesn't work, but absolute coordinates are functional
2018-06-18 13:14:02 -07:00
Sam Lantinga f1d8f5f7fd Make certain we only hide system UI when we're fullscreen for real. (thanks Rachel!) 2018-06-18 13:14:00 -07:00
Sam Lantinga 8b574dc43c Deal with situations where the system UI is shown when the keyboard pops up (thanks Rachel!) 2018-06-18 13:13:58 -07:00
Sam Lantinga 12ff19c035 SDL Android fullscreen code extensively tested on Steam Link with no issues reported 2018-06-13 14:24:30 -07:00
Sam Lantinga 63317dfb17 Don't crash on exit from SDLActivity if we don't have a singleton for some reason. (Thanks Rachel!) 2018-06-07 17:07:05 -07:00
Sam Lantinga fe196db774 Track android device panel width & height as well as window surface & height.
Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails.

Add Android_DeviceWidth/Android_DeviceHeight globals to native code.
Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight
Use device width/height for all display mode settings.
2018-06-07 17:07:03 -07:00
Sam Lantinga 77709aecc7 Added Android hardware feature support to the default manifest 2018-06-06 09:42:12 -07:00
Sam Lantinga 7c5f3cf3cb Added improved mouse pointer capture under API 26. (Thanks Rachel!) 2018-06-05 14:08:39 -07:00
Sam Lantinga 113801b790 Added SDL_IsChromebook() to determine if we're running on a Chromebook. 2018-06-05 12:46:13 -07:00
Sam Lantinga 03ff7dcf6b Added support for Android relative mouse mode on API 24 and above 2018-05-29 11:18:01 -07:00
Sam Lantinga 5d1d035705 Better fix for axis sorting with some Android controllers 2018-05-23 17:15:35 -07:00
Sam Lantinga f536fbea71 Reimplemented Android cursor API support using reflection so it builds with older SDKs 2018-03-16 11:08:53 -07:00
Sam Lantinga e20d4173bf Added Android custom cursor implementation
This is commented out in SDLActivity.java, with the note #CURSORIMPLEENTATION because it requires API 24, which is higher than the minimum required SDK
2018-03-15 18:22:48 -07:00
Sam Lantinga 9e651b6915 Try to dynamically create a default Android game controller mapping based on the buttons and axes on the controller.
Include the controller USB VID/PID in the GUID where possible, as we do on other platforms.
2018-03-06 14:51:50 -08:00
Sam Lantinga 0df7fe8404 Temporarily disabled fullscreen switching code on Android, until we can resolve bug 4096 - Enabling fullscreen on Android causes the app to toggle fullscreen mode continuously in a loop 2018-03-01 08:22:56 -08:00
Sam Lantinga 6e01fbb763 On Android show the system UI when an SDL window is windowed, hide the system UI when it's fullscreen, like we do on iOS.
We're increasing the Android SDK minimum version to API 19, this doesn't increase the minimum target API, which is API 14.
2018-02-11 18:23:37 -08:00
Sam Lantinga 54340ab9de Fixed bug 4021 - Android, hard-coded Keycode value
Sylvain

There is an hard-coded keycode value in SDLActivity.java
2018-02-07 15:10:50 -08:00
Cole Campbell b401cfd915 Allow Android Java shim to be built as an AAR 2018-01-09 19:11:34 -05:00
Sam Lantinga 6ed184ec69 Added SDL_IsAndroidTV() 2018-02-06 15:03:35 -08:00
Sam Lantinga fab2e2463f Removed armeabi from the SDL build API list, since it's not supported by the latest Android SDK 2018-01-27 12:07:05 -08:00
Sam Lantinga 616827ae64 Fixed bug 4001 - Android, prevent error message box to crash
Sylvain

Prevent the error message box to crash after being clicked.
Because of "SDLActivity.mSingleton.finish();"
2017-12-19 11:19:10 -08:00
Sam Lantinga b92e2f027a Fixed bug 4004 - iOS: don't hide keyboard on RETURN
Dominik Reichardt

As discussed in 2012 the iOS onscreen keyboard hides when you hit RETURN (see https://discourse.libsdl.org/t/on-screen-keyboard-change/19216).
IMO this is a bad idea to not be able to influence this behavior and just recently this was fixed for Android by adding the hint SDL_HINT_ANDROID_RETURN_HIDES_IME in changeset 11768	6ce3bb5e38a5.
2017-12-19 10:57:21 -08:00
Sam Lantinga 2afc0b7fa5 Add the ability to set SDL to handle Return as 'hide IME' on Android softkeyboard. (thanks Rachel!) 2017-12-12 12:52:23 -08:00
Sam Lantinga c317ab978f Fixed Android build error on older SDK 2017-11-12 10:59:05 -08:00
Sam Lantinga 50e422adfe Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
Sylvain

What about getting some return code instead of creating another native function.
2017-11-04 22:03:28 -07:00
Sam Lantinga 758156a765 Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
We're going to push the manifest environment variables from the Java side instead of continually querying for them from the native side.
2017-11-04 09:37:29 -07:00
Sam Lantinga bb8c3a9cc2 Make SDL fullscreen windows on Android actually fullscreen 2017-11-02 10:41:55 -07:00
Sam Lantinga 522901b88d Fixed bug 3933 - Android, no need of the listener thread
Sylvain

A listener thread has been added to know when the native thread would end.
But now, it is more easy to only check that after the main function has returned. It's one thread less.
2017-11-02 08:46:14 -07:00
Sam Lantinga 8c46580231 Allow the activity to persist through connecting or disconnecting a keyboard 2017-11-01 18:41:11 -07:00
Sam Lantinga 62c3acaf9f Moved the meta-data into the right section 2017-11-01 18:40:11 -07:00
Sam Lantinga a90be440e8 Added controller mapping for Android TV remotes
Also fixed the back button on the remote exiting the application
2017-11-01 10:06:58 -07:00
Sam Lantinga 4478707b0a Add SDL_GetDisplayDPI implementation on Android. (thanks Rachel!) 2017-10-31 13:49:59 -07:00
Sam Lantinga 6d23ea4bf0 Fixed Java string comparison with "" 2017-10-29 21:09:09 -07:00
Sam Lantinga 8e37bed3b6 android: Fix softkeyboard issue in SDL on Android. 2017-10-26 10:41:38 -07:00
Sam Lantinga 8fd0c22adc Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
2017-10-24 00:17:07 -07:00
Sam Lantinga 45536710f3 Fixed crash if mSurface isn't set up when we pause the application 2017-10-24 00:04:40 -07:00
Sam Lantinga 81f7e0c1f7 Removed unneeded file automatically generated by Android Studio 2017-10-23 23:35:04 -07:00
Sam Lantinga b8d8a1f122 Updated the minimum and target SDK versions in AndroidManifest.xml 2017-10-23 23:26:40 -07:00
Sam Lantinga edf0fae139 Updated Android build tools version, which bumped minimum deployment target to API 14
Also added native code to the Android gradle project, which allows using gradle or Android Studio to build the entire SDL application without a separate ndk-build step.
2017-10-23 23:23:47 -07:00
Sam Lantinga 76cdce440c Fixed build with older Android SDK 2017-10-23 23:23:34 -07:00
Sam Lantinga f08480af78 Switched to new style gradle Android application build process 2017-10-23 15:23:43 -07:00
Sam Lantinga c339d9ed6d Reverted changes 6acdea394736 and 1448a2ac30fe
I don't want to introduce any regressions with Android TV remote support
2017-10-20 10:29:22 -07:00
Sam Lantinga 2001898dce Fixed Android joystick detection 2017-10-19 15:37:52 -07:00
Sam Lantinga 9d9be45682 Don't use DPAD devices as joystick input on Android 2017-10-19 13:54:56 -07:00
Sam Lantinga dff56c3497 Android Studio code analyzer fixes 2017-10-13 19:55:07 -07:00
Sam Lantinga 14ed0d24c8 Fixed bug 3843 - Android missing some code in SDLHapticHandler
Sylvain

Some check for android SDK version are missing from https://hg.libsdl.org/SDL/rev/3d7a29a369a0
here's a patch
2017-09-23 12:37:09 -07:00
Sam Lantinga 82557750b0 Separated out SDL Android java code so audio, controller, and filesystem APIs can be used independently of the SDL activity, in Qt apps for example. 2017-09-22 08:31:56 -07:00
Sam Lantinga 53b2c91d26 Separated out SDL Android java code so audio, controller, and filesystem APIs can be used independently of the SDL activity, in Qt apps for example. 2017-09-22 08:30:46 -07:00