Commit Graph

24 Commits

Author SHA1 Message Date
Sam Lantinga
2bb344d6dc Don't crash when no WM is present.
CR: Sam Lantinga.
2013-11-27 10:29:27 -08:00
Gabriel Jacobo
1ad0d24828 [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
c933166401 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
fdfea4ad1f [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
04afd61cd9 [Android] Try to improve handling of some dpad+gamepad+keyboard corner cases 2013-11-11 11:12:43 -03:00
Gabriel Jacobo
6dbed827a7 [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
d37bad52b1 [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
45a88b6ade [Android] Fixes bug 2217, better joystick axes handling on Android. 2013-11-11 10:15:35 -03:00
Philipp Wiesemann
842a9898ce Fixed joystick crash on Android if joystick subsystem not initialized. 2013-11-10 17:50:40 +01:00
Philipp Wiesemann
305f64ba2e Replaced search loop with indexOf() in Java file. 2013-11-10 17:44:51 +01:00
Philipp Wiesemann
bbf0f62be9 Replaced implicit boxing with explicit boxing in Java file. 2013-11-10 17:42:01 +01:00
Philipp Wiesemann
2d67178149 Renamed a class in Java file for consistency. 2013-11-10 17:40:26 +01:00
Philipp Wiesemann
802f83ff99 Removed not needed imports from Java file. 2013-11-10 17:38:03 +01:00
Philipp Wiesemann
d6c1e3812e Added missing @Override annotations in Java file. 2013-11-10 17:35:07 +01:00
Philipp Wiesemann
26ce68e8c2 Changed motion listener implementation not to inherit from Activity class. 2013-11-10 15:04:58 +01:00
Philipp Wiesemann
fda8d93440 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
22770a8f40 [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
0b7c69fe12 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
5697089d98 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
7ae171d15e 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
Philipp Wiesemann
0db36f51aa 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
cc122ce520 Fixes #2036 and #2038, bypass camera zoom and shutter keypresses on Android. 2013-08-22 10:22:22 -03:00
Gabriel Jacobo
0eeb76d869 Fixes bug #2037, common EGL code for Android and X11 2013-08-19 16:29:46 -03:00
Gabriel Jacobo
dad420670f 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