Commit Graph

273 Commits

Author SHA1 Message Date
Philipp Wiesemann
c518619898 Android: Fixed a comment. 2016-01-12 22:22:24 +01:00
Philipp Wiesemann
70ee80c035 Android: Added missing import statement.
It did not compile without.
2015-10-15 22:26:00 +02:00
Ryan C. Gordon
b3e68cdba0 Fix some Android keyboards that didn't work properly.
This conversation came from Joshua Granick on Twitter, starting here:

https://twitter.com/singmajesty/status/653640543675641857

"We found an issue where certain Android keyboards (like the S6 with
predictive text) wouldn't work ... Certain keyboards use a predictive text
mode that does not dispatch a traditional onKey events, which is troublesome
... but telling the OS to use a "visible password" keyboard helps deal with
this problem ... perhaps there's some other way (onKeyPreIme?) to do
"textediting" events, but for now, this should be a fast fix ...
I hear it affects the Galaxy Tab A 8.0", Galaxy S6, Asus ZenPhone 2, maybe
others"
2015-10-15 12:52:00 -04:00
Philipp Wiesemann
f313feca74 Android: Added a new method in SDLSurface. 2015-10-07 21:16:40 +02:00
Philipp Wiesemann
cb9dbdc0b6 Android: Removed three internal functions not used by SDL.
They were not needed internally since the switch to the common EGL backend.

Thanks to the SDL mailing list for pointing out that the functions seem unused.
2015-09-27 20:12:47 +02:00
Philipp Wiesemann
f4eb7eac1c Android: Improved last error message for failed APK expansion file use. 2015-09-18 21:26:28 +02:00
Philipp Wiesemann
ddba08b7b2 Android: Added additional error messages for APK expansion file use. 2015-09-17 22:36:11 +02:00
Philipp Wiesemann
bdaf9012cb Android: Fixed trying to read from APK expansion files without version hint set.
This also fixed overwriting the asset error message which is more useful if no
APK expansion files are available and the requested file was not found.
2015-09-17 22:30:24 +02:00
Philipp Wiesemann
0caa59e76b Android: Renamed SDLActivity's Java method used for APK expansion files.
The name was not correct.
2015-09-17 22:24:54 +02:00
Philipp Wiesemann
5e66b35e84 Android: Removed empty onDraw() override method from SDLActivity.
It was redundant because SDLActivity already inherits an empty method from the
base class SurfaceView (which does not implement it but inherits it from View).
Visibility of onDraw() in SDLActivity is now protected again instead of public.
2015-09-17 22:14:37 +02:00
Philipp Wiesemann
2e96b9d137 Android: Fixed unused variable warning. 2015-09-05 20:21:35 +02:00
Philipp Wiesemann
bb625edb1b Android: Fixed missing break warning. 2015-09-05 20:21:06 +02:00
Sam Lantinga
19f7bccc32 Fixed bug 2949 - [Android] Virtual DPAD remote not registered
Sylvain

I have an android device to which I try to connect the google virtual remote application.
https://play.google.com/store/apps/details?id=com.google.android.tv.remote

The java method "pollInputDevices()" detects it as an input source 0x701 which is (SOURCE_KEYBOARD | SOURCE_GAMEPAD | SOURCE_DPAD).

It it not added because it does not AND-bitwise with "SOURCE_CLASS_JOYSTICK".
It's only a virtual DPAD and it works when checking also with SOURCE_CLASS_BUTTON
2015-06-16 23:58:09 -07:00
Sam Lantinga
c3f6296f6f Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground
Sylvain

With a Landscape application.
Going to background with Home Key, then foreground.
The screen is distorted.

This has been reported by Samsung. It happens on S5 and Samsung Alpha, see the video attached.

I have captured the following logcat:

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
I/SDL     (20549): SDL_Android_Init()
I/SDL     (20549): SDL_Android_Init() finished!
V/SDL     (20549): SDL audio: opening device
V/SDL     (20549): SDL audio: wanted stereo 16-bit 22.05kHz, 256 frames buffer
V/SDL     (20549): SDL audio: got stereo 16-bit 22.05kHz, 1764 frames buffer
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): onWindowFocusChanged(): false
V/SDL     (20549): onPause()
V/SDL     (20549): nativePause()
V/SDL     (20549): surfaceDestroyed()

Background / Foreground

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1080x1920
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): nativeResume()



This seems to be related to the fact that I have in "AndroidManifest.xml":
android:configChanges="..."
Because of the fields: "orientation" and also "screenSize".


I have looked for another way to solve the issue. Discarding the "surfaceChanged" call, based on the "requestedOrientation" and the new Orientation. It seems to be better.


On my failing test case, the first "surfaceChanged()" is discarded. Sometimes the "focusChanged()" might appear between the two "surfaceChanged()", while the surface is not yet ready. Thus, discarding also the "nativeResume()".

So, for robustness, a call to "nativeResume()" is added at the end of "surfaceChanged()".

Some update:

1/ First I tried, to discard the surface using the current orientation (rather than width / heigh). -> that solve the issue sometimes, but not always.

2/ Samsung Certification now accepts my application that were previously failing.

3/ I personally now owns a Samsung S5, and was able to solve the issue on my side.

4/ I now use the patch and get no complaints from my users. (but I admit, nobody seemed to be complaining before neither...).

5/ I have added a v2 because of a new smart-phone called "Black Berry Passport" that has a square screen of 1440x1440. This screen has a "status bar" so the resolution is in fact : 1440x1308. (as reported by "surfaceChanged").

Problem is: the portrait resolution is in fact a Landscape!

So the "v1" patch is always discarding the "surface" of BlackBerry Passport. Which is terribly bad.


Hence, I added the "v2" patch not to discard the surface when aspect ratio is < 1.20. (BB 1440/1308 is : 1.1009). Which seems fair.
2015-06-16 22:16:35 -07:00
Philipp Wiesemann
2ff0535704 Android: Added deactivated intent filter for testing drop file support. 2015-06-05 19:40:50 +02:00
Philipp Wiesemann
1e002e220b Android: Added missing space in three log messages.
Also fixed a typo and changed tag string to constant.
2015-05-31 19:23:16 +02:00
Ryan C. Gordon
dcd8ca19be Android: Added basic drop file support (thanks, "noxalus"!).
This lets SDL-based apps respond to "Open With" commands properly, as they
can now obtain the requested path via a standard SDL dropfile event.

This is only checked on startup, so apps don't get drop events at any other
time, even if Android supports that, but this is still a definite
improvement.

Fixes Bugzilla #2762.
2015-05-26 20:36:45 -04:00
Philipp Wiesemann
3e0d9b02d6 Android: Fixed touch pressure being out of range.
According to the documentation of Android's MotionEvent, the getPressure() may
return values higher than 1 on some devices. To prevent passing such values into
SDL they are now corrected to 1 in Java before the JNI call (where it is assumed
to be correct).

Currently SDL only sends SDL_FINGERMOTION events if the touch state (position or
pressure) changed. By correcting pressure down to 1 some events may get dropped
in the rare case that only the pressure was changed but was out of range and the
position did not change.
2015-05-22 22:34:08 +02:00
Philipp Wiesemann
c239a3abee Android: Replaced logging tag strings with constant. 2015-05-16 21:15:59 +02:00
Reto Schneider
a81dd20654 Remove trailing spaces in Android source code. 2015-04-08 12:14:36 +02:00
Philipp Wiesemann
6d57df4eb0 Android: Fixed lint warning about order of elements in AndroidManifest.xml. 2015-04-13 20:52:38 +02:00
Philipp Wiesemann
98aaddbdde Android: Fixed calling a getter method twice. 2015-04-08 22:24:33 +02:00
Ryan C. Gordon
b0ad5c3e78 Log Android hardware at startup (thanks, rettichschnidi!).
Fixes Bugzilla #2653.
2015-04-08 01:37:17 -04:00
Joseba García Etxebarria
a00125c9be Cast the result of calling getButtonState to an Integer 2015-04-02 00:55:45 +02:00
Ryan C. Gordon
244550f0d7 Android: more separate-mouse-and-touch work.
This avoids a hint lookup for each mouse event we get by setting a static Java
variable from native code during our hint watcher callback.

Also attempts to do the right thing with mouse buttons if you happen to be
on an API14 (Ice Cream Sandwich, Android 4.0) or later device. We still
target API12 (Honeycomb MR1, Android 3.1) for SDL 2.0.4 though.

This isn't tested, so I'm pushing to see what the Android buildbot says. Stand
back, I'm a professional!
2015-04-01 12:14:56 -04:00
Joseba García Etxebarria
fe4155e517 Renamed SDLGenericMotionListener back to SDLGenericMotionListener_API12 2015-03-27 18:09:51 -04:00
Philipp Wiesemann
728db68685 Android: Removed outdated comment from source. 2015-03-25 22:47:22 +01:00
Joseba García Etxebarria
648ac3e582 * More Android patch work 2015-03-24 21:02:28 +01:00
Joseba García Etxebarria
b1c3794e4b * Improve mouse support in Android. These changes require Android API v12 to compile 2015-03-24 20:45:29 +01:00
Philipp Wiesemann
65ef074256 Fixed wrong comment in implementation for Android. 2015-01-31 10:32:45 +01:00
Philipp Wiesemann
0770f17f4f Fixed bug 2816 - [patch] Android: Expose screen refresh rate
Jonas Kulla

Display::getRefreshRate() is available on all API levels.
2015-01-23 20:29:08 +01:00
Philipp Wiesemann
7758e7c831 Added name for second Java Thread on Android. 2014-11-23 20:35:51 +01:00
Philipp Wiesemann
e97261d145 Fixed bug 2759 - Android findLibrary() returns NULL
Sylvain

extra patch with minor modifications:
- typo
- cancel-able set to false
- add the error message, so that the user can report it.
2014-10-24 11:53:34 +02:00
Philipp Wiesemann
d37316fe5d Added an option to define libraries to be loaded on Android in a derived class.
This way it is no more needed to modify SDLActivity.java to add own libraries.
2014-10-23 16:45:18 +02:00
Philipp Wiesemann
5a0a4d6f56 Fixed alert dialog for not loaded libraries on Android being cancelable.
If the alert dialog could be canceled the Activity would not be finished here.
Also setting the property to "true" would be redundant because that is default.
2014-10-23 16:41:01 +02:00
Philipp Wiesemann
fc4c480457 Fixed missing @Override annotation warning in source for Android. 2014-10-23 16:39:15 +02:00
Philipp Wiesemann
39d104f5f6 Fixed upper case button in alert dialog for not loaded libraries on Android.
This is more consistent with the buttons of other dialogs on Android.
2014-10-23 16:38:03 +02:00
Philipp Wiesemann
45abe97d21 Fixed typo in message of alert dialog for not loaded libraries on Android. 2014-10-23 16:34:48 +02:00
Philipp Wiesemann
402661665d Fixed writing new errors to standard output instead of error output on Android. 2014-10-23 16:33:27 +02:00
Philipp Wiesemann
28e6e9079b Fixed documentation in source for Android. 2014-10-23 16:31:02 +02:00
Gabriel Jacobo
ec40387505 [Android] #2759: Show a message on failure to load a .so library (by Sylvain) 2014-10-21 11:44:35 -03:00
Philipp Wiesemann
ab7bcfc0a3 Fixed setting of screen saver state crashing on some version of Android.
Setting Window flags seems to affect Views and must be handled on UI thread.
2014-10-20 22:19:09 +02:00
Gabriel Jacobo
32120029aa Bug 2739 - [Android] No support for SDL_DisableScreenSaver by Martin Gerhardy 2014-10-20 10:10:39 -03:00
Philipp Wiesemann
fa7abca4ec Fixed bug 2476 - Allow custom main() arguments
rettichschnidi

I would like to pass custom arguments from my Java code (subclass of SDLActivity) to the native SDL2 binary.
2014-10-17 23:36:45 +02:00
Philipp Wiesemann
a992769e0a Fixed broken layout for buttons with configured color in messagebox on Android. 2014-09-25 20:56:27 +02:00
Philipp Wiesemann
87dede4f00 Added setting configured color to button texts for messagebox on Android. 2014-09-24 23:46:46 +02:00
Gabriel Jacobo
c8bc78fd0f [Android] Fixes #2679 - Crash resuming from screen off
Before destroying the static Java-side data, wait for the SDL native thread,
*and* the listener thread that waits on it to trigger a clean up.
2014-09-17 08:59:43 -03:00
Philipp Wiesemann
e13a86c874 Fixed key down closing messagebox dialog instead of key up on Android.
This fixed sending key up event to SDL a dialog closed by down did not consume.
2014-09-14 19:44:53 +02:00
Sam Lantinga
f8f74bdd97 Fixed bug 2415 - Message Boxes aren't implemented on Android
Philipp Wiesemann

I attached a patch for an incomplete implementation of the messagebox parts.

It was not tested on lots of devices yet and features a very fragile workaround to block the calling SDL thread while the dialog is handled on Android's UI thread. Although it works for testmessage.c I assume there are lot of situations were it may fail (standby, device rotation and other changes). Also not all flags and colors are implemented.

On the other hand most uses of the messagebox are to show an error on start and fragility (or working at all) may not matter there.
2014-09-13 02:15:18 -07:00
Philipp Wiesemann
039f06d731 Fixed warning about implicit boxing to Java Object. 2014-08-12 23:33:16 +02:00
Philipp Wiesemann
50b5d62934 Added javadoc comment for consistency. 2014-08-11 23:16:47 +02:00
Sam Lantinga
b69ed39252 Merged changes from Alexey Petruchik to support Android obb files
http://developer.android.com/google/play/expansion-files.html
2014-06-21 20:35:36 -07:00
Sam Lantinga
d2163b6749 Fixed bug 2558 - Missing FINGERUP in Android
Sylvain

If you play with the TouchScreen with +3 fingers randomly / pressing simultaneously all fingers.

You triggers FINGER DOWN events, but not always all the associated FINGER UP events.

So, after a while SDL_GetNumFingers() can report a wrong number of fingers pressed !


The explanation is hidden there : http://developer.android.com/reference/android/view/MotionEvent.html

Each pointer has a unique id that is assigned when it first goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN).
A pointer id remains valid until the pointer eventually goes up (indicated by ACTION_UP or ACTION_POINTER_UP) or when the gesture is canceled (indicated by ACTION_CANCEL).

in ACTION_CANCEL :

The current gesture has been aborted. You will not receive any more points in it. You should treat this as an up event, but not perform any action that you normally would.
Constant Value: 3 (0x00000003)
2014-06-15 19:32:39 -07:00
Philipp Wiesemann
3674fe380b Changed two Java nested classes into static nested classes.
Both do not need an implicitly created reference to enclosing class.
2014-06-08 13:14:20 +02:00
Philipp Wiesemann
16a52c4987 Added javadoc comments to document methods used by JNI. 2014-05-29 23:05:18 +02:00
Philipp Wiesemann
98abcdc843 Added javadoc comments to prevent unused parameter warning. 2014-05-29 22:58:06 +02:00
Philipp Wiesemann
d9b9067e85 Fixed implicit boxing and unboxing of Java Objects warning. 2014-05-29 22:53:53 +02:00
stopiccot
09ed1dc424 added comment
--HG--
branch : apk
2014-04-30 23:05:05 +03:00
stopiccot
1e528e6976 access google apk library through reflection
--HG--
branch : apk
2014-04-30 22:51:29 +03:00
stopiccot
17b9ef82d9 Fixing issues discovered by Philipp Wiesemann
--HG--
branch : apk
2014-04-23 03:42:32 +03:00
stopiccot
df6159bfef inital apk extension support
--HG--
branch : apk
2014-04-07 21:20:39 +03:00
Philipp Wiesemann
bb9a20954a Fixed unused local variable warning. 2014-04-05 23:24:33 +02:00
Gabriel Jacobo
6438cb2372 Try to work around Android's handling of static variables in terminated apps
Android, we want to love you, but you don't make it easy for us...
2014-02-12 18:12:14 -03:00
dbrady
99745583e9 fixed hat code validation. 2014-01-28 15:28:20 -08:00
Philipp Wiesemann
b155b04c15 Removed unused variable from Java class for Android.
The audio thread was moved to native side and "protected" prevented a warning.
2014-01-26 23:50:35 +01:00
Gabriel Jacobo
61e75f2da8 Bug 2358 - [Android] Sort joystick axes - Fix by David Brady 2014-01-24 09:54:04 -03:00
Philipp Wiesemann
ffb9a7697b Fixed missing @Override annotation warning in source for Android. 2013-12-24 20:04:53 +01:00
Gabriel Jacobo
3bbcbd6cb5 [Android] Hotplugging support for joysticks 2013-12-10 16:24:11 -03:00
Gabriel Jacobo
d5a570b8bf [Android] Handle native thread finishing when not commanded from the Java side 2013-12-05 10:51:38 -03:00
Sam Lantinga
1bc76ccb74 Don't crash when no WM is present.
CR: Sam Lantinga.
2013-11-27 10:29:27 -08:00
Gabriel Jacobo
e0b4d63b5b [Android] Fixes #2228, reworked touch code
Lets Android take care of which is the primary pointer (the one acting as the
mouse in SDL), reorganized the Java side code as well to make it easier to
understand.
2013-11-25 12:28:09 -03:00
Philipp Wiesemann
068ec0d37d Fixed bug 2258 - Crash when using Android clipboard
chw

The Android clipboard manager methods must be called from the UI thread,
otherwise crashes of the dalvikvm happen.
2013-11-23 23:38:16 +01:00
Gabriel Jacobo
c99c529099 [Android] Fixes #2247, enable hardware acceleration by default.
Setting android:hardwareAccelerated="true" seems to fix some random behaviors
in certain devices like the XperiaE.

Ref: http://developer.android.com/guide/topics/graphics/hardware-accel.html
2013-11-22 10:26:28 -03:00
Gabriel Jacobo
fbda2dcacf Adds testgles2
Source code copied from: https://github.com/fantasydr/sdl-2.0-gles (thanks!)

Minor fixes, configure script changes done by me.
2013-11-19 10:56:38 -03:00
Gabriel Jacobo
50454ffe1f [Android] Try to improve handling of DPAD|GAMEPAD + KEYBOARD devices
It seems some devices report themselves as DPAD or GAMEPAD and KEYBOARD as well,
and we need to route different keycodes to different parts of SDL.
2013-11-19 10:00:05 -03:00
Gabriel Jacobo
e16f591102 [Android] Try to improve handling of some dpad+gamepad+keyboard corner cases 2013-11-11 11:12:43 -03:00
Gabriel Jacobo
258f349104 [Android] Fixes Bug 2031 - Backspace Not Sending Events From On-Screen Keyboard
Thanks Joe LeVeque!
2013-11-11 10:59:15 -03:00
Gabriel Jacobo
7ed94cd043 [Android] Improve handling of keyboard, dpad and gamepad events
Thanks Dimitris Zenios for the report!
2013-11-11 10:49:48 -03:00
Gabriel Jacobo
36a24d1c0b [Android] Fixes bug 2217, better joystick axes handling on Android. 2013-11-11 10:15:35 -03:00
Philipp Wiesemann
15c259e7ba Fixed joystick crash on Android if joystick subsystem not initialized. 2013-11-10 17:50:40 +01:00
Philipp Wiesemann
3e318670be Replaced search loop with indexOf() in Java file. 2013-11-10 17:44:51 +01:00
Philipp Wiesemann
05ce5d124c Replaced implicit boxing with explicit boxing in Java file. 2013-11-10 17:42:01 +01:00
Philipp Wiesemann
33f48a6ddb Renamed a class in Java file for consistency. 2013-11-10 17:40:26 +01:00
Philipp Wiesemann
7b12da4100 Removed not needed imports from Java file. 2013-11-10 17:38:03 +01:00
Philipp Wiesemann
8c3a433919 Added missing @Override annotations in Java file. 2013-11-10 17:35:07 +01:00
Philipp Wiesemann
b2c9b7a871 Changed motion listener implementation not to inherit from Activity class. 2013-11-10 15:04:58 +01:00
Philipp Wiesemann
7888ae8351 Moved two function calls so they are only called if needed.
If the MotionEvent is not from joystick the return values are not needed.
2013-11-10 14:58:48 +01:00
Gabriel Jacobo
becbba3801 [Android] Fixes Bug 2041 - can't get SDL_QUIT event...
Thanks to Denis Bernard!

Also, changed the Android manifest so the app doesn't quit with orientation
changes, and made testgles.c exit properly on Android.
2013-11-06 11:23:24 -03:00
Gabriel Jacobo
515ee991e4 Adds Joystick support for Android
This bumps the build SDK level to 12 (up from 10). Runtime requirements remain
the same (at API level < 12 joystick support is disabled).

Also enables building SDL for armv7 and x86.
2013-11-05 20:07:39 -03:00
Sam Lantinga
ba407b9ae8 Fixed bug 2156 - Android: Accelerometer values fed to joystick driver are inverted for the X axis and wrong for Z
Denis Bernard

Background information: http://developer.android.com/reference/android/hardware/SensorEvent.html#values

Steps to reproduce: compile testjoystick.c as an android app (change screen size according to your device). While running the app, also run:

adb logcat -c; adb logcat -s 'SDL:*' 'SDL/APP:*'

When tilting the device left/right, the joystick moves in the opposite direction of what one would expect. Or at least, the behaviour is not consistent with the Y axis.

Also when the device sits on a table (obviously not moving), the Z axis value oscillates between -32000 and +32000 (by overflow):

I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32511
I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32575
I/SDL/APP ( 1994): Joystick 0 axis 2 value: 32383
I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32386
I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32450
I/SDL/APP ( 1994): Joystick 0 axis 2 value: -32578

This is caused by the accelerometer yielding a constant value around 9.81 for Z and feeding something like 0.9 to 1.1 to the joystick driver, resulting in the overflow.

Proposed fix in SDLActivity.java (swap X and subtract G from Z reading)
2013-10-20 23:52:02 -07:00
Sam Lantinga
0fe40360a5 Fixed bug 2155 - automatically remap accelerometer coordinates according to screen orientation on Android
Denis Bernard

Background information: http://android-developers.blogspot.fr/2010/09/one-screen-turn-deserves-another.html and http://developer.android.com/reference/android/hardware/SensorEvent.html

Right now, the Android accelerometer event handler feeds raw accelerometer data  to the SDL Joystick driver. The result is that for landscape-only applications, the axis need to be swapped if running on a portrait device (like a phone), and vice-versa: running a portrait only app on a landscape device like a tablet.

The purpose of this patch is to perform coordinate remapping of the accelerometer data before feeding it to the SDL joystick driver so that the X axis of the joystick is always aligned with the X axis of the display, same for the Y axis.

This has been tested on applications that support screen orientation changes as well as applications with fixed screen orientations, both on phones and tablets.
2013-10-17 23:44:30 -07:00
Sam Lantinga
fc1340575e Fixed bug 2146 - Enable static linking of libSDL on Android
Denis Bernard

This patch to Android.mk adds support for static linking of libSDL for Android applications. A patched readme with static build instructions is also provided.

It does not break existing build environments setup according to the README-android.txt since the static library version will not be built in not required.

The static build uses the Android NDK module system (see docs/IMPORT-MODULE.html in the NDK folder and step 5 in the instructions below).

Instructions:
1. Copy the android-project directory wherever you want to keep your projects
   and rename it to the name of your project.
2. Create a symlink to SDL/src/main/android/SDL_android_main.c as
   <project>/jni/src/SDL_android_main.c
3. Rename <project>/jni/src/Android_static.mk to <project>/jni/src/Android.mk
   (overwrite the existing one)
4. Edit <project>/jni/src/Android.mk to include your source files
5. create and export an environment variable named NDK_MODULE_PATH that points
   to the parent directory of this SDL directory. e.g.:

   export NDK_MODULE_PATH="$PWD"/..

6. Edit <project>/src/org/libsdl/app/SDLActivity.java and remove the call to
   System.loadLibrary("SDL2") line 42.
7. Run 'ndk-build' (a script provided by the NDK). This compiles the C source

Although this requires an environment variable to be setup, it can be added once and for all to the main Android.mk of the project.
2013-10-10 21:51:39 -07:00
Philipp Wiesemann
f50e84c7c2 Added detection of touch devices before first touch events happen on Android.
On Android available touch devices are now added with video initialization (like
the keyboard). This fixes SDL_GetNumTouchDevices() returning 0 before any touch
events happened although there is a touch screen available. The adding of touch
devices after a touch event was received is still active to allow connecting
devices later (if this is possible) and to provide a fallback if the new init
did not work somehow. For the implementation JNI was used and API level 9 is
required. There seems to be nothing in the Android NDK's input header (input.h)
to implement everything on C side without communication with Java side.
2013-10-05 17:08:19 +02:00
Gabriel Jacobo
86025d2275 Fixes #2036 and #2038, bypass camera zoom and shutter keypresses on Android. 2013-08-22 10:22:22 -03:00
Gabriel Jacobo
84f07d804a Fixes bug #2037, common EGL code for Android and X11 2013-08-19 16:29:46 -03:00
Gabriel Jacobo
4c2136d6d2 Fixes #2022, do not resume on Android when surfaceChanged
If the app is in landscape mode and the user presses the power button, a pause
is followed immediately by a surfaceChanged event because the lock screen
is shown in portrait mode. This triggers a "false" resume.
So, we just pause and resume following the onWindowFocusChanged events.

Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before
blocking the event pump.
2013-08-12 11:13:50 -03:00
Gabriel Jacobo
d0ac9f02aa Start Android Audio Thread after audio buffer and AudioTrack are ready.
Also, it starts the Audio Thread from the native side, putting the code in line
with other backends.
2013-08-08 21:25:09 -03:00
Gabriel Jacobo
7da63a0c08 Add some protection against double init of the Android audio backend 2013-08-08 09:47:42 -03:00
Philipp Wiesemann
c14d87dec4 Fixed volume keys not being handled by Android if screen keyboard is visible.
See bug #1569.
2013-08-04 23:28:34 +02:00
Gabriel Jacobo
8d20160ad0 Fixes bug #1889, allows for GL Context deletion/recreation on Android
Thanks ny00!
2013-08-03 12:54:39 -03:00
Gabriel Jacobo
4b9c3c0664 Temporary fix for bug #1639 SDL does not message back closing of screen keyboard
See FIXME notes on patch for details.
2013-08-02 12:38:39 -03:00
Sam Lantinga
c7dfdbb52f Fixed bug 1569 - Android volume keys not honoured inside SDL
Joseba García Echebarria

The current version of SDL HG in Android doesn't do anything when volume keys are pressed.
The change makes SDL ignore volume keys so that they're handled by the OS and the sound volume can be changed within an app.
2013-07-31 21:08:22 -07:00
Gabriel Jacobo
53cf4bf3c6 Set mAudioTrack to null when AudioTrack initialization fails
Prevents potential problems when stopping the app.
2013-07-31 16:25:50 -03:00
Gabriel Jacobo
b5b67aacf8 Fix for bug 2001, verify that the AudioTrack is properly initialized
...and fail to initialize the audio backend if it's not!
2013-07-31 10:04:59 -03:00
Gabriel Jacobo
8ebc49587f Consider the case where an attribute is set to EGL_DONT_CARE in eglChooseConfig
SDL doesn't currently use EGL_DONT_CARE, but it doesn' hurt to future proof.
2013-07-26 12:37:36 -03:00
Gabriel Jacobo
77cacb8357 [Android] Bug 1827, select the best matching config provided by eglChooseConfig 2013-07-26 12:22:40 -03:00
Eric Wing
03cc44af03 Android: Removed all unnecessary dependencies on C++.
C++ is a bit of a minefield on Android. Much functionality still doesn't work, and Android can't decide on which C++ standard library to use, so it provides 3 different ones, all of which are incompatible with each other. (It looks like clang is coming too which will add a new compiler and a 4th standard library.)

As middleware, SDL might be distributed as a binary and intermixed with other projects already using C++. If C++ is intermixed in a bad way, bad things will happen. Removing dependencies on C++ will avoid this problem and downstream users won't have to worry/care.
2013-07-22 02:51:45 -07:00
Gabriel Jacobo
93274d6d53 Adds Input Focus handling on Android to improve pausing/resuming behavior
Ref: http://android-developers.blogspot.com/2011/11/making-android-games-that-play-nice.html
2013-07-09 10:25:16 -03:00
Gabriel Jacobo
fe40941788 Fixes Bug 1896 - Android app is running while the screen is locked
Original patch by ny00@outlook.com
2013-07-06 15:22:49 -03:00
Philipp Wiesemann
1e57fbb3ea Updated names of README files in source comments. 2013-06-09 11:58:31 +02:00
Philipp Wiesemann
ace9a18a3d Fixed Android Lint warning in AndroidManifest.xml.
If targetSdkVersion not set it becomes same as minSdkVersion and causes warning.
2013-06-09 11:51:59 +02:00
Philipp Wiesemann
0122ce66f8 Added deactivated loading of SDL2_net to Java file. 2013-05-30 12:23:36 +02:00
Sam Lantinga
3beb70c4bc Added mobile application events, with implementations for iOS and Android 2013-05-18 12:48:50 -07:00
Philipp Wiesemann
23dad5b9c7 Corrected comment in Java file. 2013-05-18 14:04:37 +02:00
Philipp Wiesemann
1cdf7f6988 Changed import statements in Java file. 2013-05-18 14:03:45 +02:00
Sam Lantinga
f14452ed24 There's no need to keep these private. If you extend SDLActivity, you should know what you're doing. 2013-05-15 23:18:29 -07:00
Philipp Wiesemann
f67a75ebbb Fixed Android Lint warning in AndroidManifest.xml. 2013-05-10 21:19:40 +02:00
Philipp Wiesemann
2cba589334 Removed not needed block from Java file. 2013-05-05 16:01:19 +02:00
Philipp Wiesemann
b6c14af95e Changed signatures of methods in Java file to return boolean, adapted C++ file.
This way more checking for errors is possible which is currently not done here.
2013-05-05 15:54:56 +02:00
Philipp Wiesemann
1773e82524 Changed signature of method recently added in Java file. 2013-05-05 15:50:21 +02:00
Philipp Wiesemann
6bf81bca0b Added a method in Java file which may be overridden for custom messages. 2013-05-05 12:53:57 +02:00
Philipp Wiesemann
daf329ee15 Fixed possible leak and its Android Lint warning in Java file. 2013-05-05 12:50:34 +02:00
Philipp Wiesemann
1f697948fd Removed not needed casts from Java file. 2013-04-27 17:23:20 +02:00
Philipp Wiesemann
b281192487 Removed not needed import statements from Java file. 2013-04-27 17:17:37 +02:00
Philipp Wiesemann
7edda57b2d Removed dead store from Java file because value never used. 2013-04-27 17:15:40 +02:00
Philipp Wiesemann
0ef57149cc Renamed inner class in Java file to avoid confusion with an unrelated class. 2013-04-27 17:10:14 +02:00
Philipp Wiesemann
881b76836e Changed Java source file to use constant from API instead of just a String. 2013-04-27 14:26:15 +02:00
Philipp Wiesemann
420b355303 Added missing @Override annotations in Java source file to reduce warnings. 2013-04-27 14:13:30 +02:00
Philipp Wiesemann
a94cf44b93 Corrected a comment in Java source file. 2013-04-27 13:33:05 +02:00
Gabriel Jacobo
4881297e05 Fix for bug #1776 by Jonathan Dearborn 2013-04-19 14:40:39 -03:00
Sam Lantinga
d7e7bfe9ad Fixed bug 1779 - SDL's Android project template has old default icons from Android.
Philipp Wiesemann

SDL's Android project template has old default icons from Android while iOS project template has custom icons with SDL's logo.

There is a Wizard in the Android Developer Tools to create "Android Icon Sets". As an example I created icons from the iOS loading screen and attached them in a ZIP archive. They are named "ic_launcher.png" instead of "icon.png" because that is the new name used in Android projects. To use them the AndroidManifest.xml needs to be changed to have "@drawable/ic_launcher" instead of "@drawable/icon". I do not know why there was no icon created for ldpi. Maybe it is deprecated.
2013-04-02 07:55:25 -07:00
Gabriel Jacobo
b19f55242a Backed out changeset: 9cef1005df5f 2013-04-01 13:20:22 -03:00
Sam Lantinga
91094c910e Fixed bug 1700 - Joysticks not supported in Android 2013-03-19 23:03:57 -07:00
Gabriel Jacobo
639d80667e Fixes AndroidManifest comment, Android API level 10 = Android 2.3.3 2013-03-04 10:39:21 -03:00
Sam Lantinga
ab93f37976 Fixed bug 1740 - Android pixel format constants out of sync
wjp

In SDL HG (2.0) the pixel format constants in
android-project/src/org/libsdl/app/SDLActivity.java seem to have gone out of
sync with include/SDL_pixels.h in HG rev b1124b32b07d.

E.g., at a glance it seems like 0x85151002 should have become 0x15151002.
2013-03-03 21:52:51 -08:00
Sam Lantinga
a65e5a3850 Removed local.properties from android-project folder
Alexey Petruchik

Please remove local.properties from android-project folder and add it to hgignore
According to the local.properties:
# This file must *NOT* be checked in Version Control Systems,
2013-02-23 02:25:34 -08:00
Sam Lantinga
9da7324da4 Fixed bug 1711 - Comment in "manifest" element within android-project/AndroidManifest.xml is the source of troubles
ny00@outlook.com

Let me quote the following opening tag from
android-project/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    <!-- Replace org.libsdl.app with the identifier of your game, e.g.
         com.gamemaker.game
     -->
      package="org.libsdl.app"
      android:versionCode="1"
      android:versionName="1.0"
      android:installLocation="auto">

The comment (with the text "Replace org.libsdl.app with...") seems to be a
cause of troubles. Here are a few examples I've spotted:

1) While using nkd-build from android-ndk-r8d, I receive the following error:

Invalid attribute name: <!-- replace org.libsdl.app with the identifier of your
game, e.g.
         com.gamemaker.game
     --
/home/ny00123/util/android-ndk-r8d/build/gmsl/__gmsl:512: *** non-numeric
second argument to `wordlist' function: ''.  Stop.

2) Repeating this but with android-ndk-r6b (an earlier revision), it reduces to
a warning and actual complication is not halted.

3) Following the instructions in README.android and using Eclipse (from a
recently downloaded ADT Bundle), I cannot seem to be able to create an Android
project from existing sources (one of the SDL test apps for now).
* On a side note, I can't find where I may choose the "Build Target" before
clicking "Finish", but it does not seem to be related to this bug report.
Anyway, following the choice of the project path and a click on "Finish",
nothing seems to occur.
If I rather do so after removing the above comment from AndroidManifest.xml,
though, the project appears on Eclipse as expected once I click on "Finish".
2013-02-08 01:12:48 -08:00
Gabriel Jacobo
11e188634e #1702,Android soft keyboard fails to pass all input, by Jonathan Dearborn 2013-01-26 12:31:55 -03:00
Gabriel Jacobo
06cac2693e Fixed SDLActivity::audioInit return type, thanks Andreas! 2013-01-08 08:28:39 -03:00
Gabriel Jacobo
69acbe58d2 Fix Audio Buffer allocation on Android >= 4.2 2013-01-07 12:22:26 -03:00
Sam Lantinga
94ec418971 Fixed bug 1616 - SDL does not use values set with SDL_GL_SetAttribute on Android
Philipp Wiesemann 2012-10-06 07:19:57 PDT

SDL does not use values set with SDL_GL_SetAttribute on Android.

I attached a patch which adds this functionality and makes it possible to set
(for example) depth buffer size or anti-aliasing in the actual application
instead of modifying the Java source (which seems currently the only way).
2012-12-31 14:57:36 -08:00
Sam Lantinga
9e89faaf15 Synchronized the on-screen keyboard state with whether we are accepting text input.
The functions to show/hide/toggle the on-screen keyboard have been folded into the text input state.
Calling SDL_StartTextInput() will automatically show the on-screen keyboard if it's available.
Calling SDL_StopTextInput() will automatically hide the on-screen keyboard if it's available.
There is a new API function SDL_IsTextInputActive() which will return whether text input is currently active.
Text input is disabled by default, you must call SDL_StartTextInput() when you are ready to accept text input.
SDL_HasScreenKeyboardSupport() no longer needs to be passed a window.
The iPhone-specific on-screen keyboard functions have been removed.
2012-11-04 21:53:28 -08:00
Sam Lantinga
48fe3e9f09 Cleaned up OpenGL initialization a bit so we fail if we can't create a surface. 2012-11-04 08:51:43 -08:00
Sam Lantinga
f7f237c125 Simplified the manifest a little - we don't need a Java class in there. :) 2012-11-02 03:03:55 -07:00
Sam Lantinga
94ca45bd69 Updated the Android project template and README.android
Added information on how to customize your application name and icon.
Added information on using STL with an Android application
Increased the minimum API level to 10, because that's the lowest API
that currently has an emulator image for testing.
2012-11-02 02:37:49 -07:00
Sam Lantinga
38732d0a49 Fixed bug 1614 - SDL for Android does not implement TextInput API
Andrey Isakov 2012-10-03 08:30:25 PDT

I've found out in the process of porting one OS project to Android/SDL2 that
there is no support for TextInput events/APIs on Android.
So I implemented some kind of initial support of that feature, and at the very
least it seems to work fine with latin chars input with soft and hardware
keyboards on my Moto Milestone2. I've also tried playing around with more
complex IMEs, like japanese, logging the process and it seemed to work too. I'm
not sure since the app itself I am working on does not have support for
non-latin input.

The main point of the patch is to place a fake input view in the region
specified by SDL_SetTextInputRect and create a custom InputConnection for it.
The reason to make it a separate view is to support Android's pan&scan on input
feature properly. For details please refer to
http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
Even though the manual states that SetTextInputRect is used to determine the
IME variants position, I thought this would be a proper use for this too.
2012-10-03 20:49:16 -07:00
Gabriel Jacobo
f5b7a7d7db Fixes bug #1506, Changing orientation on the Android device throws off touch scaling 2012-08-24 13:10:29 -03:00
Sam Lantinga
e6d37e6522 Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.
Philipp Wiesemann implemented a general on-screen keyboard API for SDL, and I switched iOS code over to use it.
2012-08-11 10:15:59 -07:00
Ryan C. Gordon
d20ba4537e Make Android port compatible with older API versions again.
Fixes Bugzilla #1563.

Thanks to Philipp Wiesemann for the patch!
2012-08-03 23:59:05 -04:00
Gabriel Jacobo
95b70995ba Fix Android's SDLActivity for devices that may send more than one surfaceChanged
event in a row (ie, the Kindle Fire)
2012-06-24 21:10:17 -03:00