Commit graph

355 commits

Author SHA1 Message Date
Sam Lantinga
d5b3d8d150 Added some extra permissions and features likely to be used by SDL applications 2020-02-14 18:21:58 -08:00
Sam Lantinga
a430e13434 Fixed opening audio on Android from the Steam Link shell activity 2020-02-13 16:10:52 -08:00
Sam Lantinga
06433488e1 Implemented OpenSL-ES audio recording on Android 2020-02-11 16:14:02 -08:00
Sam Lantinga
b727f93948 Fixed NullPointerException 2020-02-07 20:20:37 -08:00
Sam Lantinga
443729e39d Miscellaneous pending fixes 2020-01-29 20:09:08 -08:00
Sam Lantinga
b3e4cf8e4f Fixed member order to make more sense 2020-01-28 21:41:13 -08:00
Sam Lantinga
a8f3dbf7be Fixed wired PS4 controller support on Android 2020-01-28 17:11:17 -08:00
Sam Lantinga
604d10b517 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
694ebfdff3 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
8cf14d6373 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
ed187bc102 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
4d689c2a25 The Amlogic TVB-906X is Android TV 2020-01-11 04:34:23 -08:00
Sylvain Becker
c4b62cfd9d 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
3092fedc53 Added support for wireless Xbox 360 controllers using the HIDAPI driver 2019-12-19 15:01:32 -08:00
Sylvain Becker
55181836c4 Fixed bug 4906 - Pressing Back button terminates app after SDL_StartTextInput 2019-12-19 13:54:03 +01:00
Sam Lantinga
f85f872ffa Added Android support for the Hyperkin X91 and the SteelSeries Stratus Duo 2019-12-17 12:03:57 -08:00
Sam Lantinga
5d869a7e59 Backed out changeset 6f0ec1079286, 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
8bd87ca117 Fixed bug 4775 - Japanese on Android, remove inputtype PASSWORD (Thanks Tamo!) 2019-10-23 11:25:16 +02:00
Sylvain Becker
a8b00e9d91 Fixed bug 3918 - HIDAPI, CMake support for android project 2019-08-27 11:38:43 +02:00
Sylvain Becker
7a36cc410d Android: remove tabs/indent 2019-08-15 20:38:25 +02:00
Sylvain Becker
d6637510b2 Android: SDL_image/SDL_mixer/SDL_ttf partially compiling with CMake (bug 3918) 2019-08-13 16:00:08 +02:00
Sylvain Becker
79da113ed7 Fixed bug 3918 - CMake support for android project 2019-08-11 15:23:37 +02:00
Sam Lantinga
7de41a80e1 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
f937c8e7b4 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
47c068debe Android: prevent ignoring surfaceChanged() in MultiWindow 2019-06-18 11:35:30 +02:00
Sylvain Becker
fcb3684025 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
3a4db15e17 Android: revert wrong fix typo calling onBackPressed() (Bug 4657) 2019-06-11 10:19:26 +02:00
Sylvain Becker
fa9722ea01 Android: add MinimizeWindow function (Bug 4580, 4657)
shouldMinimizeOnFocusLoss is un-activated (return false)
2019-06-10 21:58:03 +02:00
Sylvain Becker
608dc4f6ce Android: fix typo calling onBackPressed() (Bug 4657) 2019-06-10 21:41:22 +02:00
Sam Lantinga
a5f7e64dd3 Fixed hiding the Android virtual keyboard when the return key is pressed 2019-05-23 11:05:43 -07:00
Sylvain Becker
417eeb55b6 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
e1571a9923 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
1b77525040 Change my previous fix based on feedback from dev @saml 2019-04-23 14:08:14 -07:00
Sam Lantinga
597de77bf3 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
e117f3c8fa 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
3524165d24 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/8703488687ca/src/video/SDL_video.c#l2653
https://hg.libsdl.org/SDL/file/8703488687ca/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
10186659df 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
e20e39b3d9 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
6c6f081a3e Android: minor comment update 2019-03-13 14:08:21 +01:00
Sylvain Becker
e6cf4a7523 Android: remove duplicate code in SDLGenericMotionListener_API24
and use parent method
2019-01-17 16:30:19 +01:00
Sylvain Becker
b331b1db3e Android: remove another hard-coded constant for Samsung DeX (no op!) 2019-01-17 14:59:46 +01:00
Sylvain Becker
2e326cb656 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
d446c52322 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
39706e04b8 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
830f87f3c5 Android: also update APP_PLATFORM to android-16 in Application.mk
https://hg.libsdl.org/SDL/rev/8db358c7a09a
https://hg.libsdl.org/SDL/rev/787e86a461f5
2019-01-17 09:28:30 +01:00
Sylvain Becker
089bdbc56d Android: merge SDLJoystickHandler_API12 and SDLJoystickHandler_API16 2019-01-16 09:22:20 +01:00
Sylvain Becker
3b3d2b97ca Android: remove trailing spaces 2019-01-16 09:12:31 +01:00
Sylvain Becker
0c6417e562 Android: remove old code after Android-16 has been set as minimum requirement 2019-01-16 09:11:13 +01:00
Sylvain Becker
91f11c320e 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
4408f8a713 Android: minor, remove static attributes, move mIsSurfaceReady to SDLSurface 2019-01-14 21:34:12 +01:00