Commit Graph

369 Commits

Author SHA1 Message Date
Sam Lantinga
5291e5cb76 Added version checking to SDLActivity.java
Make sure the SDL java and C code match when updating SDL in a game.
Right now we're assuming that we only have to make sure release versions match. We can extend the version string with an interface version if we need more fine grained sanity checking.

Fixes https://github.com/libsdl-org/SDL/issues/1540
2022-10-03 17:36:17 -07:00
Sam Lantinga
6acc7a5622 Mark the editbox as multi-line so the return key is always visible
Fixes https://github.com/libsdl-org/SDL/issues/6170
2022-09-30 17:45:08 -07:00
Sam Lantinga
257cacab18 Android text input now works like iOS, where you get text in progress and then backspaces and new text if autocomplete changes it or the IME commits it. 2022-09-30 17:25:58 -07:00
Sam Lantinga
82e341bc9e Android: use real editable text and mimic the edit operations to generate key events
This fixes issues where the IME and the output would get out of sync
2022-09-30 11:40:29 -07:00
yurii levchenko
3ce3594e38 Split SDLSurface to public class
Add SDLActivity method createSDLSurface
2022-08-22 14:57:15 -07:00
Sam Lantinga
be3a945a8b Added support for the 8BitDo Ultimate Wired Controller for Xbox 2022-07-20 11:05:55 -07:00
Sam Lantinga
986818143d Fixed missing imports in SDLActivity (thanks @guusw!) 2022-07-18 07:20:58 -07:00
Sam Lantinga
27d8cbf026 Added PowerA and Qanba vendors for Android USB device support 2022-07-12 18:18:00 -07:00
Sam Lantinga
209f457ea4 Generate backspaces for the text we're going to replace when committing text 2022-07-01 10:13:19 -07:00
Sam Lantinga
7ac5d616f3 Fixed backspace being delivered after committed text on Android 12
Testing:
Enter "hello ", followed by "?" - the events generated are:
: commitText hello
: Key pressed :  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key released:  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key pressed :  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key released:  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key released:  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key pressed :  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: Key released:  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: INPUT Text (\x68\x65\x6c\x6c\x6f\x20): "hello "
: finishComposingText
: deleteSurroundingText 1 / 0
: Key pressed :  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: Key released:  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: commitText ?
: Key pressed :  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: LSHIFT
: Key pressed :  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: (none)
: INPUT Text (\x3f): "?"
: setComposingText , at 1
: EDIT Text (): ""

Previously, the backspace would be delivered after the "?"
2022-07-01 08:58:08 -07:00
Sam Lantinga
37a517dc36 Re-enable IME text input on Android
In my testing, this results in text edit events followed by text input events. Any ASCII characters will generate scancode events based on a hypothetical US keyboard layout.

Fixes https://github.com/libsdl-org/SDL/issues/3377
2022-07-01 08:33:31 -07:00
Wohlstand
68beedde92 SDLActivity.java: Compatibility fix for debugSource
I did these fixes a while ago while debuggin my application, however, forgot to send them back.
2022-06-16 12:45:15 -07:00
staphen
123b9aaa41 Adjust gradle dependencies to enable the build to position assets for the APK 2022-03-15 21:57:25 -07:00
Sylvain
5b41844c75
Fixed bug #5322 - register virtual input devices as SDL_Touch device, fix compilation 2022-02-09 09:50:41 +01:00
Sylvain
3a9bbf604e
Fixed bug #5322 - register virtual input devices as SDL_Touch device because
they can send SOURCE_TOUCHSCREEN events even if getSources() doesn't declare them.
2022-02-09 09:37:36 +01:00
Sylvain
59f1e2875a
Android: add debug function to display class/sources 2022-02-08 21:50:19 +01:00
Sylvain
2df2da11f6
Android: handleMotionEvent() is checking for SOURCE_JOYSTICK. So don't handle DPAD GAMEPAD (see #5322, #2718) 2022-02-08 17:51:40 +01:00
Sylvain
1fc5dba3d5
Android: test for SOURCE_KEYBOARD / SOURCE_MOUSE. Don't compare to 0, since there are several bits (see #5322, #2718) 2022-02-08 17:41:17 +01:00
Sylvain
f185711203
Fixed bug #5310: Android, Undefined reference to AAssetManager_fromJava 2022-02-08 16:18:01 +01:00
Sylvain
68dd84f1de
Android: TouchDevice -1 is reserved for SDL synthetic devce (See #5322) 2022-02-08 11:42:24 +01:00
Sylvain
14bc3bf4ec
Android: fix typo to register TOUCHSCREEN device (see #5322, #2718) 2022-02-07 22:20:05 +01:00
Temdog007
b59e75c259 Handle menu button press from controller 2022-02-02 21:21:44 -08:00
Sam Lantinga
2363ddc330 Fixed crash on Windows Subsystem for Android, which doesn't have a USB manager.
Fixes https://github.com/libsdl-org/SDL/issues/5133
2021-12-28 17:30:36 -08:00
Sylvain
a1e992b110
Fixed bug #5118 - [Android] PointerIcon leak in Cursor API 2021-12-21 22:07:17 +01:00
Sylvain
cd86e269e4
Fixed bug #4982 - Failed to open audio_device. Android 5.1 should be ok. 2021-11-20 19:40:26 +01:00
Sylvain
b6d365677b
Fixed bug #4982 - Failed to open audio_device on Android 5.x with freq 96khz+ 2021-11-20 15:28:36 +01:00
Sam Lantinga
7ad64357ee Updated Android build environment for examples 2021-11-15 17:04:50 -08:00
Sam Lantinga
66058bbbd5 Fixed exception accessing Bluetooth devices on Android 12
Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()

Fixes https://github.com/libsdl-org/SDL/issues/4952
2021-11-15 16:52:56 -08:00
Sam Lantinga
be5b4d980d Added nativeGetHintBoolean for Java code 2021-11-15 16:52:54 -08:00
Sam Lantinga
2f591fb0a0 Added android:exported="true" to the example Android manifest
This is needed for targeting Android 12 (API 31)
2021-11-15 12:50:02 -08:00
Anders Jenbo
93556e67e0 Update AndroidManifest.xml 2021-11-14 20:19:54 -08:00
Anders Jenbo
b9c619017d [Android] Limit WRITE_EXTERNAL_STORAGE to SDK 22-
Direct access to the external storage is no longer allowed as of SDK 30. But on older version of Android you will still need WRITE_EXTERNAL_STORAGE in order to request the Download Manager to download files to your external file folder.
2021-11-14 20:19:54 -08:00
Sam Lantinga
c2dd50a9a0 Fixed whitespace 2021-11-12 08:28:02 -08:00
Sam Lantinga
97c71371f2 If Android version >= API 31 PendingIntent.FLAG_MUTABLE
"If your app targets Android 12, you must specify the mutability of each PendingIntent object that your app creates. This additional requirement improves your app's security."

Thanks @FormularSumo and @cgutman
2021-11-12 01:21:29 -08:00
Sam Lantinga
544d2e6aa0 Don't try to load hidapi at startup on Android 2021-11-11 20:47:19 -08:00
Sam Lantinga
ed05a0e9e7 Fixed exception trying to get USB permission
You can't set the intent to be immutable, otherwise the USB system can't set the device and permission in the response. This works fine on Android 12 without an immutable intent.
2021-11-11 20:33:02 -08:00
Sam Lantinga
c877dd93c5 The hidapi code is now built into SDL, we don't need to load a shared library for it 2021-11-11 19:29:42 -08:00
Sam Lantinga
dd85cc0195 Fixed whitespace 2021-11-07 13:17:54 -08:00
FormularSumo
80d19282f7 If Android version >= API 23 PendingIntent.FLAGIMMUTABLE
"If your app targets Android 12, you must specify the mutability of each PendingIntent object that your app creates. This additional requirement improves your app's security."

FLAG_IMMUTABLE was added in API 23 so that's why I'm using "> API 23". Using API 30 would also fix the Android 12 issue. Alternatively if PendingIntents should be mutable you could change it to "FLAG_MUTABLE".
2021-11-07 13:16:13 -08:00
Sylvain
8b1a2fe860
backout SDL_AndroidSetInputType() 2021-10-17 23:47:59 +02:00
Sylvain
ccb12457f9
Fixed bug #4843 - Can not get the ime candidatelist like chinese/japaness input method 2021-10-17 23:17:54 +02:00
Sylvain
325ae5c35d
Android: getCurrentOrientation uses getContext() to retrieve the activity (see bug #4825) 2021-10-13 08:35:56 +02:00
Sylvain
723f5cea43
Fixed bug #4825 - NullPointerException on SDLActivity.getCurrentOrientation() (Thanks Benau!) 2021-10-12 20:58:58 +02:00
Sam Lantinga
3172615074 Let Android know that we can handle USB devices
This is important on Android 29 and above if you don't want to be prompted for each device that you open
2021-08-04 13:13:22 -07:00
Sam Lantinga
107db2d899 Enable TV game mode by default on Android 2021-05-07 12:43:35 -07:00
Sylvain
13472cec67
Fixed bug #4228: move from jcenter() to mavenCentral()
SDL can use relinker. If it's enabled on your project, you need to update to version 1.4.3
2021-04-30 09:48:29 +02:00
Sylvain
98a966d1c2
Android: don't need to set the SurfaceHolder format from java code
It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface.
 - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken:
   calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen.
 - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
2021-04-22 18:06:17 +02:00
Sam Lantinga
6d9c4f6c6c Added support for the wired Amazon Luna gamepad on Android 2021-03-26 15:07:10 -07:00
Sam Lantinga
f5e9c5b7e0 Chromebooks support relative mouse motion now 2021-02-21 11:03:25 -08:00
Amir
1a924bc0bb add SDL_AndroidShowToast for https://developer.android.com/reference/android/widget/Toast 2021-02-20 23:05:09 -08:00
Jordan Christiansen
7032539785 Disabled Bluetooth if BLE is not supported
BluetoothManager is supported for Android API 18+. On older versions, skip
Bluetooth instead of crashing.
2021-01-07 19:33:12 -06:00
Sam Lantinga
cdd397118f Fixed the Xbox Series X controller showing up twice on Android 2020-12-15 14:57:49 -08:00
Sylvain Becker
311ae829c7 Android: keep compatibility with older JDK 2020-10-28 14:03:05 +01:00
Sylvain Becker
97cf314526 Android: apply code simplications found with lint / Android Studio 2020-10-27 21:14:49 +01:00
Sylvain Becker
0360987f45 Android: fix deprecated onCreateDialog() methods 2020-10-24 20:31:04 +02:00
Sylvain Becker
967041681b Android: fix Clipboard deprecated methods 2020-10-24 15:36:05 +02:00
Sylvain Becker
b7b8ef59a3 Fixed bug 5307 - Crash when joysticks hats number is odd (Thanks Sockmonsters!) 2020-10-07 17:32:07 +02:00
Sylvain Becker
bffbc7e316 Android: better readibility for pollHapticDevices() 2020-10-07 14:55:23 +02:00
Sylvain Becker
20c070d869 Android: better readibility for pollInputDevices()
and move isDeviceSDLJoystick() test at first since there are
always non-joystick devices present.
2020-10-07 14:41:37 +02:00
Sylvain Becker
a70bb58d4b Android: fix joystick allocation that can be never used 2020-10-05 14:09:31 +02:00
Sylvain Becker
2e38c94950 Fix bug 5303 - Touch/Mouse events simulation doesn't work on Android 11 2020-10-05 09:56:03 +02:00
Sylvain Becker
0467e332af Android: small change to access to device diagonal value 2020-10-01 15:11:28 +02:00
Sylvain Becker
62b029f33b Android: missing import class Uri 2020-10-01 14:43:59 +02:00
Sylvain Becker
dd55bfe89c Android: add helper function to open an URL/URI (see bug 2783) 2020-10-01 14:41:09 +02:00
Sylvain Becker
7ad71563ce Android: be sure shared libraries are loaded in onConfigurationChanged()
This could fix a rare crash if:
- onConfigurationChanged is called before onCreate();
or
 shared libraries failed to load and onConfigurationChanged() is called
2020-09-25 10:42:07 +02:00
Sylvain Becker
96d555e25a Android: remove un-needed java import (bug 4297) 2020-08-17 20:09:01 +02:00
Sylvain Becker
965b466ee8 Fixed bug 4297 - Android StrictMode policy. Remove APK expansion support
"In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play"
(see https://developer.android.com/guide/app-bundle)
And "Android App Bundles don't support APK expansion (*.obb) files".
2020-08-17 19:50:20 +02:00
Sam Lantinga
d0947c1483 Fixed exception if getManifestEnvironmentVariables() is called without a current SDL activity 2020-06-04 12:30:25 -07:00
Sam Lantinga
68e1731e02 Don't bother logging security exception getting the device serial number
This can happen anytime we haven't opened the device yet
2020-05-29 15:40:17 -07:00
Sockmonsters
eea450bc99 - Added exception handler for the new SecurityException in USBDevice getSerialNumber 2020-05-29 15:37:03 -07:00
Sylvain Becker
33642b47b2 Android: robustness if locale failed to be detected at start 2020-05-08 21:50:23 +02:00
Sylvain Becker
2491f16f85 Android: send SDL_LOCALECHANGED when locale changes 2020-05-08 21:40:28 +02:00
Sam Lantinga
beab15b09e Added additional logging to track down why the NVIDIA controller doesn't send the back button 2020-04-27 19:12:02 -07:00
Sam Lantinga
37faac0d81 Fixed java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.WindowManager android.app.Activity.getWindowManager()' on a null object reference 2020-03-05 08:43:16 -08:00
Sam Lantinga
dc54add5e0 Added some extra permissions and features likely to be used by SDL applications 2020-02-14 18:21:58 -08:00
Sam Lantinga
14bf532df3 Fixed opening audio on Android from the Steam Link shell activity 2020-02-13 16:10:52 -08:00
Sam Lantinga
4bb95e8403 Implemented OpenSL-ES audio recording on Android 2020-02-11 16:14:02 -08:00
Sam Lantinga
64c58b9f19 Fixed NullPointerException 2020-02-07 20:20:37 -08:00
Sam Lantinga
c9c89783cb Miscellaneous pending fixes 2020-01-29 20:09:08 -08:00
Sam Lantinga
598cf69475 Fixed member order to make more sense 2020-01-28 21:41:13 -08:00
Sam Lantinga
43b377b077 Fixed wired PS4 controller support on Android 2020-01-28 17:11:17 -08:00
Sam Lantinga
ce7c51a9cc Always release devices in onPause in case we're going to be force stopped, and for consistency with interacting with other activities that might use the controller 2020-01-26 00:37:48 -08:00
Sam Lantinga
43aa1fa9e7 Added support for detecting previously unknown Xbox 360 and Xbox One controllers using the HIDAPI driver with libusb and Android 2020-01-18 11:21:14 -08:00
Sylvain Becker
d52ba78b29 Fixed bug 4246 - Android: orientation between portrait<->landscape doesn't work
Improve handling of landscape/portrait orientation. Promote to SCREEN_ORIENTATION_SENSOR_* when needed.
Android window can be somehow resizable.
If SDL_WINDOW_RESIZABLE is set, window size change is allowed, for instance when orientation changes (provided the hint allows it).
2020-01-17 12:04:18 +01:00
Sam Lantinga
1d321850b6 Added support for claiming individiual interfaces on USB devices on Android
This is needed for supporting multiple wireless Xbox 360 controllers
2020-01-13 15:35:52 -08:00
Sam Lantinga
a7bf6af8c4 The Amlogic TVB-906X is Android TV 2020-01-11 04:34:23 -08:00
Sylvain Becker
f050309ee9 Android: fix IllegalStateException in onBackPressed()
Rare exception, not catch-able, which appears when the activity gets in a broken
state.

java.lang.IllegalStateException:
  at android.app.FragmentManagerImpl.checkStateLoss (FragmentManagerImpl.java:1323)
  at android.app.FragmentManagerImpl.popBackStackImmediate (FragmentManagerImpl.java:493)
  at android.app.Activity.onBackPressed (Activity.java:2215)
  at org.libsdl.app.SDLActivity.onBackPressed (SDLActivity.java)
  at android.app.Activity.onKeyUp (Activity.java:2193)
  at android.view.KeyEvent.dispatch (KeyEvent.java:2685)
  at android.app.Activity.dispatchKeyEvent (Activity.java:2423)
  at org.libsdl.app.SDLActivity.dispatchKeyEvent (SDLActivity.java)
2019-12-20 15:58:59 +01:00
Sam Lantinga
15d30298cf Added support for wireless Xbox 360 controllers using the HIDAPI driver 2019-12-19 15:01:32 -08:00
Sylvain Becker
5d5a56717f Fixed bug 4906 - Pressing Back button terminates app after SDL_StartTextInput 2019-12-19 13:54:03 +01:00
Sam Lantinga
7b2826f6c2 Added Android support for the Hyperkin X91 and the SteelSeries Stratus Duo 2019-12-17 12:03:57 -08:00
Sam Lantinga
d4e1c79720 Backed out changeset 36b79874a9c8, which fixed bug 4775
This change broke individual key events, so I'm reverting the change until we can investigate a better fix.
2019-11-27 17:17:03 -08:00
Sylvain Becker
59352cea8b Fixed bug 4775 - Japanese on Android, remove inputtype PASSWORD (Thanks Tamo!) 2019-10-23 11:25:16 +02:00
Sylvain Becker
0a9c74aa9a Fixed bug 3918 - HIDAPI, CMake support for android project 2019-08-27 11:38:43 +02:00
Sylvain Becker
7f9016f265 Android: remove tabs/indent 2019-08-15 20:38:25 +02:00
Sylvain Becker
412775f5a8 Android: SDL_image/SDL_mixer/SDL_ttf partially compiling with CMake (bug 3918) 2019-08-13 16:00:08 +02:00
Sylvain Becker
155087d106 Fixed bug 3918 - CMake support for android project 2019-08-11 15:23:37 +02:00
Sam Lantinga
e92fe23c83 Fix nullptr crash on android
nullcheck the device coming back from InputDevice.getDevice(deviceId) in new code added to sdlactivity.onkey.


java.lang.NullPointerException:
  at org.libsdl.app.SDLSurface.onKey (SDLActivity.java:1793)
  at android.view.View.dispatchKeyEvent (View.java:13321)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at com.android.internal.policy.DecorView.superDispatchKeyEvent (DecorView.java:685)
  at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent (PhoneWindow.java:1869)
  at android.app.Activity.dispatchKeyEvent (Activity.java:3447)
  at org.libsdl.app.SDLActivity.dispatchKeyEvent (SDLActivity.java:496)

@dang @saml @dave
2019-08-02 17:20:00 -07:00
Sylvain Becker
f994da0ef0 Fixed bug 4702 - Android back button does not send SDL_KEYDOWN event
fallback when event.getSource() is SOURCE_UNKNOWN
2019-07-03 13:37:54 +02:00
Sylvain Becker
5418d41626 Android: prevent ignoring surfaceChanged() in MultiWindow 2019-06-18 11:35:30 +02:00
Sylvain Becker
4392c6ff14 Android: fix coordinates for Surface.ROTATION_180
https://discourse.libsdl.org/t/android-screen-orientation-issues-2-0-9/26262
2019-06-11 11:01:15 +02:00
Sylvain Becker
45a3dd171d Android: revert wrong fix typo calling onBackPressed() (Bug 4657) 2019-06-11 10:19:26 +02:00
Sylvain Becker
f9a9193e2c Android: add MinimizeWindow function (Bug 4580, 4657)
shouldMinimizeOnFocusLoss is un-activated (return false)
2019-06-10 21:58:03 +02:00
Sylvain Becker
3f4e189b27 Android: fix typo calling onBackPressed() (Bug 4657) 2019-06-10 21:41:22 +02:00
Sam Lantinga
8b57331e71 Fixed hiding the Android virtual keyboard when the return key is pressed 2019-05-23 11:05:43 -07:00
Sylvain Becker
f91b87859c Android: minimum size for IME, so that it takes focus
In API 28, 0 width views can't take focus, so if someone tries to position the IME without setting a width, they'll stop getting text events.

Tested on Android 9: with a 0 size, it would send correctly letters a, b, c, etc. but not numbers.
2019-05-23 09:08:40 +02:00
Sam Lantinga
1a38853e02 Fixed bug 4566 - Hot-plugging Bluetooth controller causes force-quit on Android
Anthony @ POW Games

I tried adding different configChanges and sure enough, "navigation" worked! Now bluetooth controllers hot-plug nicely. So shall we add it as a default to the AndroidManifest.xml?

Funny that this is how this activity is described:

	"navigation" The navigation type (trackball/dpad) has changed. (This should never normally happen.)

I think the reason behind this is because the bluetooth game controller I was testing doubles-up as a keyboard, which probably comes with a DPAD? It's a MOCUTE-032X_B63-88CE
2019-04-24 12:53:15 -07:00
Sam Lantinga
f5252530d2 Change my previous fix based on feedback from dev @saml 2019-04-23 14:08:14 -07:00
Sam Lantinga
ecce803d54 Fix compile errors I hit when building org.libsdl in source2 (part 2 of 2) @saml 2019-04-23 12:59:28 -07:00
Sam Lantinga
45b5453b16 Fix compile errors I hit when building org.libsdl in source2 (part 1 of 2) 2019-04-23 12:59:20 -07:00
Sam Lantinga
9950271bb6 Fixed bug 4580 - Android 8: immersive fullscreen notification causes flickering between fullscreen and non-fullscreen and app is unresponsive
Sylvain 2019-04-18 21:22:59 UTC

Changes:
- SDL_WINDOWEVENT_FOCUS_GAINED and SDL_WINDOWEVENT_FOCUS_LOST are sent when the java method onWindowFocusChanged() is called.

- If we have support for MultiWindow (eg API >= 24), SDL event loop is blocked/un-blocked (or simply egl-backed-up or not), when java onStart()/onStop() are called.

- If not, this behaves like now, SDL event loop is blocked/un-blocked when onPause()/onResume() are called.

So if we have two app on screen and switch from one to the other, only FOCUS events are sent (and onPause()/onResume() are called but empty. onStart()/onStop() are not called).
The SDL app, un-focused, would still continue to run and display frames (currently the App would be displayed, but paused).
Like a video player app or a chronometer that would still be refreshed, even if the window hasn't the focus.
It should work also on ChromeBooks (not tested), with two apps opened at the same time.


I am not sure this fix Dan's issue. Because focus lost event triggers Minimize function (which BTW is not provided on android).
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/bb41b3635c34/src/video/SDL_video.c#l2634

So, in addition, it would need to add by default SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to 0.
So that the lost focus event doesn't try to minimize the window. And this should fix also the issue.
2019-04-22 16:19:52 -07:00
Sam Lantinga
cf87d5764d Explicitly load hidapi as a dependency of the SDL library
This fixes loading on Android 4.2
2019-04-16 20:00:14 -07:00
Sylvain Becker
bfdd0b228a Android: remove SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH
java layer runs as if separate mouse and touch was 1,
Use SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS
for generating synthetic touch/mouse events
2019-04-04 17:01:02 +02:00
Sylvain Becker
3bc1a8b619 Android: minor comment update 2019-03-13 14:08:21 +01:00
Sylvain Becker
9d10c73853 Android: remove duplicate code in SDLGenericMotionListener_API24
and use parent method
2019-01-17 16:30:19 +01:00
Sylvain Becker
55838d8bd6 Android: remove another hard-coded constant for Samsung DeX (no op!) 2019-01-17 14:59:46 +01:00
Sylvain Becker
56f4a711e3 Android: minor change in the evaluation of SOURCE_CLASS_JOYSTICK (no op!)
InputDevice.SOURCE_CLASS_* are one bit
More readable to check that the source has this class_joystick set,
compared to the other statements, where the source is gamepad or dpad.
(Clean-up from bug 3958)
2019-01-17 13:42:13 +01:00
Sylvain Becker
8f828a8e1b Android: remove hard-coded constant for Samsung DeX (no op!)
12290 = 0x3002 = SOURCE_MOUSE | SOURCE_TOUCHSCREEN

SOURCE_MOUSE            Constant Value: 8194 (0x00002002)
SOURCE_TOUCHSCREEN      Constant Value: 4098 (0x00001002)
SOURCE_CLASS_POINTER    Constant Value: 2    (0x00000002)

https://developer.android.com/reference/android/view/InputDevice.html
2019-01-17 12:25:19 +01:00
Sylvain Becker
e5f8801f55 Android: prevent concurrency in Android_SetScreenResolution() when exiting
by checking Android_Window validity

- SDLThread: user application is exiting:
    SDL_VideoQuit() and clearing SDL_GetVideoDevice()

- ActivityThread is changing orientation/size
    surfaceChanged() > Android_SetScreenResolution() > SDL_GetVideoDevice()

- Separate function into Android_SetScreenResolution() and Android_SendResize(),
    formating, and mark Android_DeviceWidth/Heigh as static
2019-01-17 11:05:05 +01:00
Sylvain Becker
6690a46941 Android: also update APP_PLATFORM to android-16 in Application.mk
https://hg.libsdl.org/SDL/rev/701c83eeb6e7
https://hg.libsdl.org/SDL/rev/0a69e71b715a
2019-01-17 09:28:30 +01:00
Sylvain Becker
291f6006a1 Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16 2019-01-16 09:22:20 +01:00
Sylvain Becker
a86754167c Android: remove trailing spaces 2019-01-16 09:12:31 +01:00
Sylvain Becker
d86de288d4 Android: remove old code after Android-16 has been set as minimum requirement 2019-01-16 09:11:13 +01:00
Sylvain Becker
dc263450ff Android: create Pause/ResumeSem semaphore at higher level than CreateWindow()
- If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background.

- If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids.

SDLActivity.java: the first resume() starts the SDLThread, don't call
nativeResume() as it would post ResumeSem. And the first pause would
automatically be resumed.
2019-01-14 23:33:48 +01:00
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