Commit graph

326 commits

Author SHA1 Message Date
Philipp Wiesemann
946ca79670 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
56f86cc81f 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
69487c41dd Fixed warning about implicit boxing to Java Object. 2014-08-12 23:33:16 +02:00
Philipp Wiesemann
36341cbc34 Added javadoc comment for consistency. 2014-08-11 23:16:47 +02:00
Sam Lantinga
f5054661e6 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
424dd9d921 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
9024566f68 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
822b690cac Added javadoc comments to document methods used by JNI. 2014-05-29 23:05:18 +02:00
Philipp Wiesemann
272e4b090a Added javadoc comments to prevent unused parameter warning. 2014-05-29 22:58:06 +02:00
Philipp Wiesemann
4efae3ae35 Fixed implicit boxing and unboxing of Java Objects warning. 2014-05-29 22:53:53 +02:00
stopiccot
c076c21acb added comment
--HG--
branch : apk
2014-04-30 23:05:05 +03:00
stopiccot
82ba2c2c8b access google apk library through reflection
--HG--
branch : apk
2014-04-30 22:51:29 +03:00
stopiccot
20623e3dad Fixing issues discovered by Philipp Wiesemann
--HG--
branch : apk
2014-04-23 03:42:32 +03:00
stopiccot
a41b3ce38b inital apk extension support
--HG--
branch : apk
2014-04-07 21:20:39 +03:00
Philipp Wiesemann
5e41b5887c Fixed unused local variable warning. 2014-04-05 23:24:33 +02:00
Gabriel Jacobo
bf6a7b1a2d 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
e2653cfbe5 fixed hat code validation. 2014-01-28 15:28:20 -08:00
Philipp Wiesemann
60e32d1ffc 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
037b44fc19 Bug 2358 - [Android] Sort joystick axes - Fix by David Brady 2014-01-24 09:54:04 -03:00
Philipp Wiesemann
d67b11b967 Fixed missing @Override annotation warning in source for Android. 2013-12-24 20:04:53 +01:00
Gabriel Jacobo
ae184f5e89 [Android] Hotplugging support for joysticks 2013-12-10 16:24:11 -03:00
Gabriel Jacobo
b3fa9a3e55 [Android] Handle native thread finishing when not commanded from the Java side 2013-12-05 10:51:38 -03:00
Sam Lantinga
aee889c1bd Don't crash when no WM is present.
CR: Sam Lantinga.
2013-11-27 10:29:27 -08:00
Gabriel Jacobo
fc300345e6 [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
2ca1d5c980 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
239ba53a4c [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
67b0e2ce38 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
c68f34799d [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
edcae582ac [Android] Try to improve handling of some dpad+gamepad+keyboard corner cases 2013-11-11 11:12:43 -03:00
Gabriel Jacobo
a5bc73516f [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
3940f9ca8e [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
a2cdc5c163 [Android] Fixes bug 2217, better joystick axes handling on Android. 2013-11-11 10:15:35 -03:00
Philipp Wiesemann
26038047c5 Fixed joystick crash on Android if joystick subsystem not initialized. 2013-11-10 17:50:40 +01:00
Philipp Wiesemann
8fc589c69b Replaced search loop with indexOf() in Java file. 2013-11-10 17:44:51 +01:00
Philipp Wiesemann
b081847e58 Replaced implicit boxing with explicit boxing in Java file. 2013-11-10 17:42:01 +01:00
Philipp Wiesemann
48e7bb9b10 Renamed a class in Java file for consistency. 2013-11-10 17:40:26 +01:00
Philipp Wiesemann
fa4a6001e7 Removed not needed imports from Java file. 2013-11-10 17:38:03 +01:00
Philipp Wiesemann
20dbab5d8d Added missing @Override annotations in Java file. 2013-11-10 17:35:07 +01:00
Philipp Wiesemann
aa059d0a18 Changed motion listener implementation not to inherit from Activity class. 2013-11-10 15:04:58 +01:00
Philipp Wiesemann
d01fdd5e48 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
dd726d96bf [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
7075ece4a5 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
e8d2a8b3b8 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
84d3120257 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
e7dba74084 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
20b394d072 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
cd9a7c392c Fixes #2036 and #2038, bypass camera zoom and shutter keypresses on Android. 2013-08-22 10:22:22 -03:00
Gabriel Jacobo
ef4a588d99 Fixes bug #2037, common EGL code for Android and X11 2013-08-19 16:29:46 -03:00
Gabriel Jacobo
a3982939c5 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
610264fb0b 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