diff --git a/bugs.txt b/bugs.txt
index c2b476e7c..0f077772b 100644
--- a/bugs.txt
+++ b/bugs.txt
@@ -1,5 +1,5 @@
-Known bugs
-==========
+Known bugs (see also todo.txt)
+==============================
- With 4:3 screen aspect ratio the on-screen buttons are not shown on the inactive part of screen.
@@ -14,25 +14,3 @@ Known bugs
- 32-bpp color mode does not work with SW video surface, 24-bpp and 32-bpp mode does not work with SDL_HWSURFACE.
- Option SdlVideoResizeKeepAspect has no effect
-
-Requested features
-==================
-
-- Perform a check for free space available on SD card before writing there, and write to the internal storage if SD card is unplugged.
-
-- Split Settings.java into several files
-
-- Show/hide screen controls with longpress on Text Edit button.
-
-- Support of libjnigraphics (it will disable on-screen keyboard, only SW SDL screen surface supported)
-
-- Floating on-screen joystick - initially invisible, it appears when you touch the screen,
- centered on your finger, then it slides with your finger if you bump the joystick edge.
-
-- Export phone vibrator to SDL - interface is available in SDL 1.3
-
-- Control screen brightness with SDL_SetGamma()
-
-- Zoom in-out whole screen in SW mode with some SDL key -
- much like the "On-screen magnifying glass" feature (lazy porter's golden hammer)
-
diff --git a/changeAppSettings.sh b/changeAppSettings.sh
index fb52f35fe..bd4ff3c8d 100755
--- a/changeAppSettings.sh
+++ b/changeAppSettings.sh
@@ -182,6 +182,17 @@ if [ -n "$var" ] ; then
fi
fi
+if [ -z "$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState" -o -z "$AUTO" ]; then
+echo
+echo "Touchscreen keyboard will save and restore OpenGL state before drawing itself -"
+echo -n "this works reliably only on Android 4.X devices, many Andorid 2.X devices do not support glGet() (y)/(n) ($CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState): "
+read var
+if [ -n "$var" ] ; then
+ CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState="$var"
+ CHANGED=1
+fi
+fi
+
fi
if [ -z "$SdlVideoResize" -o -z "$AUTO" ]; then
@@ -295,6 +306,17 @@ if [ -n "$var" ] ; then
fi
fi
+if [ -z "$CompatibilityHacksSlowCompatibleEventQueue" -o -z "$AUTO" ]; then
+echo
+echo "Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -"
+echo -n "do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) ($CompatibilityHacksSlowCompatibleEventQueue): "
+read var
+if [ -n "$var" ] ; then
+ CompatibilityHacksSlowCompatibleEventQueue="$var"
+ CHANGED=1
+fi
+fi
+
if [ -z "$AppUsesJoystick" -o -z "$AUTO" ]; then
echo
echo "Application uses joystick (y) or (n), the on-screen DPAD will be used"
@@ -308,7 +330,7 @@ fi
if [ -z "$AppUsesAccelerometer" -o -z "$AUTO" ]; then
echo
-echo -n "Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 0 axes 2-3 ($AppUsesAccelerometer): "
+echo -n "Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 ($AppUsesAccelerometer): "
read var
if [ -n "$var" ] ; then
AppUsesAccelerometer="$var"
@@ -316,6 +338,16 @@ if [ -n "$var" ] ; then
fi
fi
+if [ -z "$AppUsesGyroscope" -o -z "$AUTO" ]; then
+echo
+echo -n "Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4 ($AppUsesGyroscope): "
+read var
+if [ -n "$var" ] ; then
+ AppUsesGyroscope="$var"
+ CHANGED=1
+fi
+fi
+
if [ -z "$AppUsesMultitouch" -o -z "$AUTO" ]; then
echo
echo "Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBUTTONDOWN/SDL_JOYBALLMOTION events"
@@ -425,7 +457,7 @@ if [ -n "$var" ] ; then
fi
fi
-FirstStartMenuOptionsDefault='(AppUsesMouse \&\& \! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true)'
+FirstStartMenuOptionsDefault='(AppUsesMouse \&\& \! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true), new Settings.GyroscopeCalibration()'
if [ -z "$AUTO" ]; then
echo
echo "Menu items to show at startup - this is Java code snippet, leave empty for default"
@@ -663,6 +695,8 @@ echo CompatibilityHacksTextInputEmulatesHwKeyboard=$CompatibilityHacksTextInputE
echo CompatibilityHacksPreventAudioChopping=$CompatibilityHacksPreventAudioChopping >> AndroidAppSettings.cfg
echo CompatibilityHacksAppIgnoresAudioBufferSize=$CompatibilityHacksAppIgnoresAudioBufferSize >> AndroidAppSettings.cfg
echo CompatibilityHacksAdditionalPreloadedSharedLibraries=\"$CompatibilityHacksAdditionalPreloadedSharedLibraries\" >> AndroidAppSettings.cfg
+echo CompatibilityHacksSlowCompatibleEventQueue=$CompatibilityHacksSlowCompatibleEventQueue >> AndroidAppSettings.cfg
+echo CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState >> AndroidAppSettings.cfg
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
echo AppNeedsTwoButtonMouse=$AppNeedsTwoButtonMouse >> AndroidAppSettings.cfg
echo ShowMouseCursor=$ShowMouseCursor >> AndroidAppSettings.cfg
@@ -671,6 +705,7 @@ echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AndroidAppSettings.cfg
echo AppNeedsTextInput=$AppNeedsTextInput >> AndroidAppSettings.cfg
echo AppUsesJoystick=$AppUsesJoystick >> AndroidAppSettings.cfg
echo AppUsesAccelerometer=$AppUsesAccelerometer >> AndroidAppSettings.cfg
+echo AppUsesGyroscope=$AppUsesGyroscope >> AndroidAppSettings.cfg
echo AppUsesMultitouch=$AppUsesMultitouch >> AndroidAppSettings.cfg
echo NonBlockingSwapBuffers=$NonBlockingSwapBuffers >> AndroidAppSettings.cfg
echo RedefinedKeys=\"$RedefinedKeys\" >> AndroidAppSettings.cfg
@@ -690,7 +725,9 @@ echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
+echo AppOverlapsSystemHeaders=$AppOverlapsSystemHeaders >> AndroidAppSettings.cfg
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
+echo AppBuildExclude=\'$AppBuildExclude\' >> AndroidAppSettings.cfg
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
@@ -725,9 +762,9 @@ else
fi
if [ "$SdlVideoResizeKeepAspect" = "y" ] ; then
- SdlVideoResizeKeepAspect=1
+ SdlVideoResizeKeepAspect=true
else
- SdlVideoResizeKeepAspect=0
+ SdlVideoResizeKeepAspect=false
fi
if [ "$InhibitSuspend" = "y" ] ; then
@@ -790,6 +827,18 @@ else
CompatibilityHacksAppIgnoresAudioBufferSize=
fi
+if [ "$CompatibilityHacksSlowCompatibleEventQueue" = "y" ]; then
+ CompatibilityHacksSlowCompatibleEventQueue=-DSDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE=1
+else
+ CompatibilityHacksSlowCompatibleEventQueue=
+fi
+
+if [ "$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState" = "y" ]; then
+ CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=-DSDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE=1
+else
+ CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
+fi
+
if [ "$AppUsesMouse" = "y" ] ; then
AppUsesMouse=true
else
@@ -838,6 +887,12 @@ else
AppUsesAccelerometer=false
fi
+if [ "$AppUsesGyroscope" = "y" ] ; then
+ AppUsesGyroscope=true
+else
+ AppUsesGyroscope=false
+fi
+
if [ "$AppUsesMultitouch" = "y" ] ; then
AppUsesMultitouch=true
else
@@ -910,8 +965,8 @@ mkdir -p project/src
cd project/java
for F in *.java; do
echo Patching $F
- echo '// DO NOT EDIT THIS FILE - it is automatically generated, edit file under project/java dir' > ../src/$F
- cat $F | sed "s/package .*;/package $AppFullName;/" >> ../src/$F
+ echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under project/java dir' > ../src/$F
+ cat $F | sed "s/package .*;/package $AppFullName;/" >> ../src/$F # | sed 's@$@ // THIS FILE IS AUTO-GENERATED@' >>
done
cd ../..
@@ -961,6 +1016,7 @@ cat project/src/Globals.java | \
sed "s/public static boolean CompatibilityHacksStaticInit = .*;/public static boolean CompatibilityHacksStaticInit = $CompatibilityHacksStaticInit;/" | \
sed "s/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = .*;/public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = $CompatibilityHacksTextInputEmulatesHwKeyboard;/" | \
sed "s/public static boolean HorizontalOrientation = .*;/public static boolean HorizontalOrientation = $HorizontalOrientation;/" | \
+ sed "s^public static boolean KeepAspectRatioDefaultSetting = .*^public static boolean KeepAspectRatioDefaultSetting = $SdlVideoResizeKeepAspect;^" | \
sed "s/public static boolean InhibitSuspend = .*;/public static boolean InhibitSuspend = $InhibitSuspend;/" | \
sed "s/public static boolean AppUsesMouse = .*;/public static boolean AppUsesMouse = $AppUsesMouse;/" | \
sed "s/public static boolean AppNeedsTwoButtonMouse = .*;/public static boolean AppNeedsTwoButtonMouse = $AppNeedsTwoButtonMouse;/" | \
@@ -970,6 +1026,7 @@ cat project/src/Globals.java | \
sed "s/public static boolean AppNeedsTextInput = .*;/public static boolean AppNeedsTextInput = $AppNeedsTextInput;/" | \
sed "s/public static boolean AppUsesJoystick = .*;/public static boolean AppUsesJoystick = $AppUsesJoystick;/" | \
sed "s/public static boolean AppUsesAccelerometer = .*;/public static boolean AppUsesAccelerometer = $AppUsesAccelerometer;/" | \
+ sed "s/public static boolean AppUsesGyroscope = .*;/public static boolean AppUsesGyroscope = $AppUsesGyroscope;/" | \
sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \
sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \
sed "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \
@@ -997,12 +1054,13 @@ cat project/jni/SettingsTemplate.mk | \
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
sed "s^SDL_VIDEO_RENDER_RESIZE := .*^SDL_VIDEO_RENDER_RESIZE := $SdlVideoResize^" | \
- sed "s^SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := .*^SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := $SdlVideoResizeKeepAspect^" | \
sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" | \
sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \
- sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $CompatibilityHacksPreventAudioChopping $CompatibilityHacksAppIgnoresAudioBufferSize^" | \
+ sed "s^APPLICATION_OVERLAPS_SYSTEM_HEADERS :=.*^APPLICATION_OVERLAPS_SYSTEM_HEADERS := $AppOverlapsSystemHeaders^" | \
+ sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $CompatibilityHacksPreventAudioChopping $CompatibilityHacksAppIgnoresAudioBufferSize $CompatibilityHacksSlowCompatibleEventQueue $CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState^" | \
sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \
+ sed "s^APPLICATION_BUILD_EXCLUDE :=.*^APPLICATION_BUILD_EXCLUDE := $AppBuildExclude^" | \
sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \
sed "s^SDL_VERSION :=.*^SDL_VERSION := $LibSdlVersion^" >> \
project/jni/Settings.mk
@@ -1040,6 +1098,12 @@ done
rm -rf project/bin/classes
rm -rf project/bin/res
+if which convert > /dev/null; then
+ convert project/res/drawable/ouya_icon.png -resize '732x412!' project/res/drawable-xhdpi/ouya_icon.png
+else
+ echo "Install ImageMagick to auto-resize Ouya icon from icon.png"
+fi
+
./copyAssets.sh || exit 1
echo Done
diff --git a/project/AndroidManifestTemplate.xml b/project/AndroidManifestTemplate.xml
index e276a013b..594a9a789 100644
--- a/project/AndroidManifestTemplate.xml
+++ b/project/AndroidManifestTemplate.xml
@@ -20,6 +20,7 @@
+
diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java
index f930661a9..0e054aecf 100644
--- a/project/java/Accelerometer.java
+++ b/project/java/Accelerometer.java
@@ -41,57 +41,89 @@ class AccelerometerReader implements SensorEventListener
{
private SensorManager _manager = null;
+ public boolean openedBySDL = false;
+ public static final GyroscopeListener gyro = new GyroscopeListener();
public AccelerometerReader(Activity context)
{
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
- start();
}
public synchronized void stop()
{
if( _manager != null )
{
+ System.out.println("libSDL: stopping accelerometer/gyroscope");
_manager.unregisterListener(this);
+ _manager.unregisterListener(gyro);
}
}
public synchronized void start()
{
- if( Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer )
+ if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
+ _manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
{
- if( _manager != null )
- {
- System.out.println("libSDL: starting accelerometer");
- // TODO: orientation allows for 3rd axis - azimuth, but it will be way too hard to the user
- // if( ! _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME) )
- _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
- }
+ System.out.println("libSDL: starting accelerometer");
+ _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
+ }
+ if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
+ {
+ System.out.println("libSDL: starting gyroscope");
+ _manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
}
}
- public synchronized void onSensorChanged(SensorEvent event) {
-
- if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
- {
- if( Globals.HorizontalOrientation )
- nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
- else
- nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
- }
+ public void onSensorChanged(SensorEvent event)
+ {
+ if( Globals.HorizontalOrientation )
+ nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
else
+ nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
+ }
+ public void onAccuracyChanged(Sensor s, int a)
+ {
+ }
+
+ static class GyroscopeListener implements SensorEventListener
+ {
+ public float x1, x2, xc, y1, y2, yc, z1, z2, zc;
+ public GyroscopeListener()
{
- if( Globals.HorizontalOrientation )
- nativeOrientation(event.values[1], -event.values[2], event.values[0]);
- else
- nativeOrientation(event.values[2], event.values[1], event.values[0]);
}
-
+ public void onSensorChanged(SensorEvent event)
+ {
+ // TODO: vertical orientation
+ //if( Globals.HorizontalOrientation )
+ if( event.values[0] < x1 || event.values[0] > x2 ||
+ event.values[1] < y1 || event.values[1] > y2 ||
+ event.values[2] < z1 || event.values[2] > z2 )
+ nativeGyroscope(event.values[0] - xc, event.values[1] - yc, event.values[2] - zc);
+ }
+ public void onAccuracyChanged(Sensor s, int a)
+ {
+ }
+ public boolean available(Activity context)
+ {
+ SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
+ }
+ public void registerListener(Activity context, SensorEventListener l)
+ {
+ SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
+ return;
+ manager.registerListener(l, manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
+ }
+ public void unregisterListener(Activity context,SensorEventListener l)
+ {
+ SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ if ( manager == null )
+ return;
+ manager.unregisterListener(l);
+ }
}
- public synchronized void onAccuracyChanged(Sensor s, int a) {
- }
-
- private native void nativeAccelerometer(float accX, float accY, float accZ);
- private native void nativeOrientation(float accX, float accY, float accZ);
+ private static native void nativeAccelerometer(float accX, float accY, float accZ);
+ private static native void nativeGyroscope(float X, float Y, float Z);
}
diff --git a/project/java/Globals.java b/project/java/Globals.java
index 3e4cbea87..0f455ff2b 100644
--- a/project/java/Globals.java
+++ b/project/java/Globals.java
@@ -42,6 +42,7 @@ class Globals
public static boolean CompatibilityHacksStaticInit = false;
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
public static boolean HorizontalOrientation = true;
+ public static boolean KeepAspectRatioDefaultSetting = false;
public static boolean InhibitSuspend = false;
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
public static String CommandLine = "";
@@ -53,6 +54,7 @@ class Globals
public static boolean AppNeedsTextInput = true;
public static boolean AppUsesJoystick = false;
public static boolean AppUsesAccelerometer = false;
+ public static boolean AppUsesGyroscope = false;
public static boolean AppUsesMultitouch = false;
public static boolean NonBlockingSwapBuffers = false;
public static boolean ResetSdlConfigForThisVersion = false;
@@ -62,7 +64,7 @@ class Globals
public static int StartupMenuButtonTimeout = 3000;
public static int AppMinimumRAM = 0;
public static Settings.Menu HiddenMenuOptions [] = {};
- public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true) };
+ public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true), new Settings.GyroscopeCalibration() };
public static String AdmobPublisherId = "";
public static String AdmobTestDeviceId = "";
public static String AdmobBannerSize = "";
@@ -96,7 +98,7 @@ class Globals
public static int RelativeMouseMovementSpeed = 2;
public static int RelativeMouseMovementAccel = 0;
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
- public static boolean KeepAspectRatio = false;
+ public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
public static int ClickScreenPressure = 0;
public static int ClickScreenTouchspotSize = 0;
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
@@ -111,4 +113,6 @@ class Globals
public static boolean VideoLinearFilter = true;
public static boolean MultiThreadedVideo = false;
public static boolean BrokenLibCMessageShown = false;
+ // Gyroscope calibration
+ public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
}
diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java
index 90b26f20e..482fea363 100644
--- a/project/java/MainActivity.java
+++ b/project/java/MainActivity.java
@@ -60,6 +60,7 @@ import java.io.FileInputStream;
import java.util.zip.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import java.util.Set;
import android.text.SpannedString;
import java.io.BufferedReader;
import java.io.BufferedInputStream;
diff --git a/project/java/Settings.java b/project/java/Settings.java
index b0301669c..e0f9658b4 100644
--- a/project/java/Settings.java
+++ b/project/java/Settings.java
@@ -66,6 +66,10 @@ import android.app.AlarmManager;
import android.util.DisplayMetrics;
import android.net.Uri;
import java.util.concurrent.Semaphore;
+import android.graphics.Color;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorEvent;
+import android.hardware.Sensor;
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
@@ -153,6 +157,15 @@ class Settings
out.writeBoolean(Globals.BrokenLibCMessageShown);
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
out.writeInt(p.getApplicationVersion());
+ out.writeFloat(Globals.gyro_x1);
+ out.writeFloat(Globals.gyro_x2);
+ out.writeFloat(Globals.gyro_xc);
+ out.writeFloat(Globals.gyro_y1);
+ out.writeFloat(Globals.gyro_y2);
+ out.writeFloat(Globals.gyro_yc);
+ out.writeFloat(Globals.gyro_z1);
+ out.writeFloat(Globals.gyro_z2);
+ out.writeFloat(Globals.gyro_zc);
out.close();
settingsLoaded = true;
@@ -299,6 +312,15 @@ class Settings
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
int cfgVersion = settingsFile.readInt();
+ Globals.gyro_x1 = settingsFile.readFloat();
+ Globals.gyro_x2 = settingsFile.readFloat();
+ Globals.gyro_xc = settingsFile.readFloat();
+ Globals.gyro_y1 = settingsFile.readFloat();
+ Globals.gyro_y2 = settingsFile.readFloat();
+ Globals.gyro_yc = settingsFile.readFloat();
+ Globals.gyro_z1 = settingsFile.readFloat();
+ Globals.gyro_z2 = settingsFile.readFloat();
+ Globals.gyro_zc = settingsFile.readFloat();
settingsLoaded = true;
@@ -530,6 +552,7 @@ class Settings
new MouseConfigMainMenu(),
new ArrowKeysConfig(),
new AccelerometerConfig(),
+ new GyroscopeCalibration(),
new AudioConfig(),
new RemapHwKeysConfig(),
new ScreenGesturesConfig(),
@@ -2194,8 +2217,10 @@ class Settings
{
MainActivity p;
FrameLayout layout = null;
- ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
+ ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
+ ImageView boundary = null;
+ Bitmap boundaryBmp = null;
int currentButton = 0;
int buttons[] = {
R.drawable.dpad,
@@ -2213,7 +2238,27 @@ class Settings
p = _p;
layout = new FrameLayout(p);
p.getVideoLayout().addView(layout);
+ boundary = new ImageView(p);
+ boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+ boundary.setScaleType(ImageView.ScaleType.MATRIX);
+ boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
+ boundary.setImageBitmap(boundaryBmp);
+ layout.addView(boundary);
currentButton = 0;
+ if( Globals.TouchscreenKeyboardTheme == 2 )
+ {
+ int buttons2[] = {
+ R.drawable.sun_dpad,
+ R.drawable.sun_keyboard,
+ R.drawable.sun_b1,
+ R.drawable.sun_b2,
+ R.drawable.sun_b3,
+ R.drawable.sun_b4,
+ R.drawable.sun_b5,
+ R.drawable.sun_b6
+ };
+ buttons = buttons2;
+ }
setupButton(true);
}
@@ -2240,11 +2285,28 @@ class Settings
if( imgs[currentButton] == null )
{
imgs[currentButton] = new ImageView(p);
- imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+ imgs[currentButton].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
imgs[currentButton].setScaleType(ImageView.ScaleType.MATRIX);
bmps[currentButton] = BitmapFactory.decodeResource( p.getResources(), buttons[currentButton] );
imgs[currentButton].setImageBitmap(bmps[currentButton]);
layout.addView(imgs[currentButton]);
+ boundary.bringToFront();
+ }
+ if( Globals.ScreenKbControlsLayout[currentButton][0] == Globals.ScreenKbControlsLayout[currentButton][2] ||
+ Globals.ScreenKbControlsLayout[currentButton][1] == Globals.ScreenKbControlsLayout[currentButton][3] )
+ {
+ int displayX = 800;
+ int displayY = 480;
+ try {
+ DisplayMetrics dm = new DisplayMetrics();
+ p.getWindowManager().getDefaultDisplay().getMetrics(dm);
+ displayX = dm.widthPixels;
+ displayY = dm.heightPixels;
+ } catch (Exception eeeee) {}
+ Globals.ScreenKbControlsLayout[currentButton][0] = displayX / 2 - displayX / 6;
+ Globals.ScreenKbControlsLayout[currentButton][2] = displayX / 2 + displayX / 6;
+ Globals.ScreenKbControlsLayout[currentButton][1] = displayY / 2 - displayY / 4;
+ Globals.ScreenKbControlsLayout[currentButton][3] = displayY / 2 + displayY / 4;
}
Matrix m = new Matrix();
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
@@ -2252,6 +2314,10 @@ class Settings
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
imgs[currentButton].setImageMatrix(m);
+ m = new Matrix();
+ src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
+ m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
+ boundary.setImageMatrix(m);
}
public void onTouchEvent(final MotionEvent ev)
@@ -2286,6 +2352,10 @@ class Settings
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
imgs[currentButton].setImageMatrix(m);
+ m = new Matrix();
+ src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
+ m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
+ boundary.setImageMatrix(m);
if( ev.getAction() == MotionEvent.ACTION_UP )
setupButton(false);
@@ -2438,6 +2508,149 @@ class Settings
}
}
+ static class GyroscopeCalibration extends Menu implements SensorEventListener
+ {
+ String title(final MainActivity p)
+ {
+ return p.getResources().getString(R.string.calibrate_gyroscope);
+ }
+ boolean enabled()
+ {
+ return Globals.AppUsesGyroscope;
+ }
+ void run (final MainActivity p)
+ {
+ if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
+ {
+ goBack(p);
+ return;
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(p);
+ builder.setTitle(p.getResources().getString(R.string.calibrate_gyroscope));
+ builder.setMessage(p.getResources().getString(R.string.calibrate_gyroscope_text));
+ builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int item)
+ {
+ dialog.dismiss();
+ startCalibration(p);
+ }
+ });
+ builder.setOnCancelListener(new DialogInterface.OnCancelListener()
+ {
+ public void onCancel(DialogInterface dialog)
+ {
+ goBack(p);
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.setOwnerActivity(p);
+ alert.show();
+ }
+
+ ImageView img;
+ Bitmap bmp;
+ int numEvents;
+ MainActivity p;
+
+ void startCalibration(final MainActivity _p)
+ {
+ p = _p;
+ img = new ImageView(p);
+ img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+ img.setScaleType(ImageView.ScaleType.MATRIX);
+ bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
+ img.setImageBitmap(bmp);
+ Matrix m = new Matrix();
+ RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
+ RectF dst = new RectF( p.getVideoLayout().getWidth()/2 - 50, p.getVideoLayout().getHeight()/2 - 50,
+ p.getVideoLayout().getWidth()/2 + 50, p.getVideoLayout().getHeight()/2 + 50);
+ m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
+ img.setImageMatrix(m);
+ p.getVideoLayout().addView(img);
+ numEvents = 0;
+ AccelerometerReader.gyro.x1 = 100;
+ AccelerometerReader.gyro.x2 = -100;
+ AccelerometerReader.gyro.xc = 0;
+ AccelerometerReader.gyro.y1 = 100;
+ AccelerometerReader.gyro.y2 = -100;
+ AccelerometerReader.gyro.yc = 0;
+ AccelerometerReader.gyro.z1 = 100;
+ AccelerometerReader.gyro.z2 = -100;
+ AccelerometerReader.gyro.zc = 0;
+ AccelerometerReader.gyro.registerListener(p, this);
+ (new Thread(new Runnable()
+ {
+ public void run()
+ {
+ for(int count = 1; count < 10; count++)
+ {
+ p.setText("" + count + "0% ...");
+ try {
+ Thread.sleep(500);
+ } catch( Exception e ) {}
+ }
+ finishCalibration(p);
+ }
+ }
+ )).start();
+ }
+
+ public void onSensorChanged(SensorEvent event)
+ {
+ gyroscopeEvent(event.values[0], event.values[1], event.values[2]);
+ }
+ public void onAccuracyChanged(Sensor s, int a)
+ {
+ }
+ void gyroscopeEvent(float x, float y, float z)
+ {
+ numEvents++;
+ AccelerometerReader.gyro.xc += x;
+ AccelerometerReader.gyro.yc += y;
+ AccelerometerReader.gyro.zc += z;
+ AccelerometerReader.gyro.x1 = Math.min(AccelerometerReader.gyro.x1, x * 1.1f); // Small safety bound coefficient
+ AccelerometerReader.gyro.x2 = Math.max(AccelerometerReader.gyro.x2, x * 1.1f);
+ AccelerometerReader.gyro.y1 = Math.min(AccelerometerReader.gyro.y1, y * 1.1f);
+ AccelerometerReader.gyro.y2 = Math.max(AccelerometerReader.gyro.y2, y * 1.1f);
+ AccelerometerReader.gyro.z1 = Math.min(AccelerometerReader.gyro.z1, z * 1.1f);
+ AccelerometerReader.gyro.z2 = Math.max(AccelerometerReader.gyro.z2, z * 1.1f);
+ final Matrix m = new Matrix();
+ RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
+ RectF dst = new RectF( x * 5000 + p.getVideoLayout().getWidth()/2 - 50, y * 5000 + p.getVideoLayout().getHeight()/2 - 50,
+ x * 5000 + p.getVideoLayout().getWidth()/2 + 50, y * 5000 + p.getVideoLayout().getHeight()/2 + 50);
+ m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
+ p.runOnUiThread(new Runnable()
+ {
+ public void run()
+ {
+ img.setImageMatrix(m);
+ }
+ });
+ }
+ void finishCalibration(final MainActivity p)
+ {
+ AccelerometerReader.gyro.unregisterListener(p, this);
+ try {
+ Thread.sleep(200); // Just in case we have pending events
+ } catch( Exception e ) {}
+ if( numEvents > 5 )
+ {
+ AccelerometerReader.gyro.xc /= (float)numEvents;
+ AccelerometerReader.gyro.yc /= (float)numEvents;
+ AccelerometerReader.gyro.zc /= (float)numEvents;
+ }
+ p.runOnUiThread(new Runnable()
+ {
+ public void run()
+ {
+ p.getVideoLayout().removeView(img);
+ goBack(p);
+ }
+ });
+ }
+ }
+
// ===============================================================================================
public static boolean deleteRecursively(File dir)
diff --git a/project/java/Video.java b/project/java/Video.java
index 1468a3b10..c63100f22 100644
--- a/project/java/Video.java
+++ b/project/java/Video.java
@@ -108,14 +108,13 @@ abstract class DifferentTouchInput
multiTouchAvailable2 = true;
}
try {
+ System.out.println("Device model: " + android.os.Build.MODEL);
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
{
- if(android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717"))
- return GalaxyNoteIcsTouchInput.Holder.sInstance;
return IcsTouchInput.Holder.sInstance;
}
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
- return XperiaPlayTouchpadTouchInput.Holder.sInstance;
+ return GingerbreadTouchInput.Holder.sInstance;
if (multiTouchAvailable1 && multiTouchAvailable2)
return MultiTouchInput.Holder.sInstance;
else
@@ -296,57 +295,21 @@ abstract class DifferentTouchInput
}
}
}
- private static class XperiaPlayTouchpadTouchInput extends MultiTouchInput
+ private static class GingerbreadTouchInput extends MultiTouchInput
{
private static class Holder
{
- private static final XperiaPlayTouchpadTouchInput sInstance = new XperiaPlayTouchpadTouchInput();
+ private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
}
- float xmin = 0.0f;
- float xmax = 1.0f;
- float ymin = 0.0f;
- float ymax = 1.0f;
- float minRange = 1.0f;
- float xshift = 0.0f;
-
- XperiaPlayTouchpadTouchInput()
+ GingerbreadTouchInput()
{
super();
- int[] devIds = InputDevice.getDeviceIds();
- for( int id : devIds )
- {
- InputDevice device = InputDevice.getDevice(id);
- if( device == null )
- continue;
- System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
- if( (device.getSources() & InputDevice.SOURCE_TOUCHPAD) != InputDevice.SOURCE_TOUCHPAD )
- continue;
- System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() + " is a touchpad" );
- InputDevice.MotionRange range = device.getMotionRange(MotionEvent.AXIS_X /*, InputDevice.SOURCE_TOUCHPAD*/);
- if(range != null)
- {
- xmin = range.getMin();
- xmax = range.getMax() - range.getMin();
- System.out.println("libSDL: touch pad X range " + xmin + ":" + xmax );
- }
- range = device.getMotionRange(MotionEvent.AXIS_Y /*, InputDevice.SOURCE_TOUCHPAD*/);
- if(range != null)
- {
- ymin = range.getMin();
- ymax = range.getMax() - range.getMin();
- System.out.println("libSDL: touch pad Y range " + ymin + ":" + ymax );
- }
- // Xperia Play has long wide touchpad with joystick-like embossing on the sides, so we'll leave only a left joystick to function
- // I don't know how to use the second joystick, so I'll just ignore it for now
- minRange = Math.min( Math.abs(ymax - ymin), Math.abs(xmax - xmin) );
- xshift = xmax - minRange;
- }
}
public void process(final MotionEvent event)
{
- boolean hwMouseEvent = ( event.getSource() == InputDevice.SOURCE_MOUSE ||
- event.getSource() == InputDevice.SOURCE_STYLUS ||
+ boolean hwMouseEvent = ( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ||
+ (event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS ||
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
if( ExternalMouseDetected != hwMouseEvent )
{
@@ -357,37 +320,10 @@ abstract class DifferentTouchInput
}
public void processGenericEvent(final MotionEvent event)
{
- if( event.getSource() != InputDevice.SOURCE_TOUCHPAD )
- {
- process(event);
- return;
- }
- /*
- int x = (int)((event.getX() - xmin) / xmax * 65535.0f);
- int y = (int)((event.getY() - ymin) / ymax * 65535.0f);
- */
- // Use only right square part of a touch surface - I've heard reports that it breaks functionality, feel free to uncomment and test it.
- int x = (int)((event.getX() - xshift) / minRange * 65535.0f);
- int y = (int)((event.getY() - ymin) / minRange * 65535.0f);
- if( x > 65535 )
- x = 65535;
- if( x < 0 )
- x = 0;
- if( y > 65535 )
- y = 65535;
- if( y < 0 )
- y = 0;
- int down = 1;
- int multitouch = event.getPointerCount() - 1;
- if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
- (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
- down = 0;
- // TODO: we're processing only one touch pointer, touchpad will most probably support multitouch
- //System.out.println("libSDL: touch pad event: " + x + ":" + y + " action " + event.getAction() + " down " + down + " multitouch " + multitouch );
- DemoGLSurfaceView.nativeTouchpad( x, 65535 - y, down, multitouch ); // Y axis is inverted, as you may have guessed
+ process(event);
}
}
- private static class IcsTouchInput extends XperiaPlayTouchpadTouchInput
+ private static class IcsTouchInput extends GingerbreadTouchInput
{
private static class Holder
{
@@ -411,6 +347,16 @@ abstract class DifferentTouchInput
}
public void processGenericEvent(final MotionEvent event)
{
+ // Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
+ if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
+ {
+ // event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
+ DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
+ event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
+ event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
+ event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) );
+ return;
+ }
// Process mousewheel
if( event.getAction() == MotionEvent.ACTION_SCROLL )
{
@@ -422,20 +368,6 @@ abstract class DifferentTouchInput
super.processGenericEvent(event);
}
}
- private static class GalaxyNoteIcsTouchInput extends IcsTouchInput
- {
- private static class Holder
- {
- private static final GalaxyNoteIcsTouchInput sInstance = new GalaxyNoteIcsTouchInput();
- }
- public void process(final MotionEvent event)
- {
- // HACK for Galaxy Note stylus, which pushes the cursor to the lower-right part of the screen, when you lift the stylus.
- // Also it reports the stylus as the mouse
- if(! (event.getSource() == InputDevice.SOURCE_MOUSE && (int)event.getX() == 0 && (int)event.getY() == 799))
- super.process(event);
- }
- }
}
@@ -585,6 +517,15 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
return context.isScreenKeyboardShown() ? 1 : 0;
}
+ public void startAccelerometerGyroscope(int started)
+ {
+ accelerometer.openedBySDL = (started != 0);
+ if( accelerometer.openedBySDL && !mPaused )
+ accelerometer.start();
+ else
+ accelerometer.stop();
+ }
+
public void exitApp()
{
nativeDone();
@@ -774,7 +715,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
System.out.println("libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
mRenderer.nativeGlContextRecreated();
- if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
+ if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
mRenderer.accelerometer.start();
};
@@ -805,8 +746,8 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
public static native void initJavaCallbacks();
public static native void nativeHardwareMouseDetected( int detected );
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
- public static native void nativeMouseWheel(int scrollX, int scrollY);
-
+ public static native void nativeMouseWheel( int scrollX, int scrollY );
+ public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger );
}
diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml
index 1fc80518a..9d06e3506 100644
--- a/project/java/translations/values/strings.xml
+++ b/project/java/translations/values/strings.xml
@@ -165,4 +165,7 @@
This app needs %1$d Mb RAM, your device has %2$d Mb
Ignore
+ Calibrate gyroscope
+ Put your phone on a flat surface
+
diff --git a/project/jni/SettingsTemplate.mk b/project/jni/SettingsTemplate.mk
index 7606ec220..bcb8d2a4a 100644
--- a/project/jni/SettingsTemplate.mk
+++ b/project/jni/SettingsTemplate.mk
@@ -28,16 +28,18 @@ SDL_TRACKBALL_KEYUP_DELAY := 1
# resized in HW-accelerated way, however it eats a tiny bit of CPU
SDL_VIDEO_RENDER_RESIZE := 1
-SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT := 0
-
COMPILED_LIBRARIES := tremor ogg
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -Werror=strict-aliasing -Werror=cast-align -Werror=pointer-arith -Werror=address
APPLICATION_ADDITIONAL_LDFLAGS := -ltremor
+APPLICATION_OVERLAPS_SYSTEM_HEADERS := n
+
APPLICATION_SUBDIRS_BUILD := src/*
+APPLICATION_BUILD_EXCLUDE :=
+
APPLICATION_CUSTOM_BUILD_SCRIPT :=
SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=SPACE -DSDL_ANDROID_KEYCODE_3=RETURN -DSDL_ANDROID_KEYCODE_4=RETURN
diff --git a/project/jni/application/Android.mk b/project/jni/application/Android.mk
index bbb73bad7..ecc4f0a7e 100644
--- a/project/jni/application/Android.mk
+++ b/project/jni/application/Android.mk
@@ -18,17 +18,22 @@ LOCAL_SRC_FILES := $(filter %.c %.cpp, $(APP_SUBDIRS))
APP_SUBDIRS := $(filter-out %.c %.cpp, $(APP_SUBDIRS))
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
+LOCAL_SRC_FILES := $(filter-out $(addprefix $(APPDIR)/, $(APPLICATION_BUILD_EXCLUDE)), $(LOCAL_SRC_FILES))
# Disabled because they give slight overhead, add "-frtti -fexceptions" to the AppCflags inside AndroidAppSettings.cfg if you need them
# If you use setEnvironment.sh you may write "env CXXFLAGS='-frtti -fexceptions' ../setEnvironment.sh ./configure".
#LOCAL_CPP_FEATURES := exceptions rtti
LOCAL_CFLAGS :=
-LOCAL_C_INCLUDES :=
+LOCAL_C_INCLUDES := $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D))
-LOCAL_C_INCLUDES += $(foreach D, $(APP_SUBDIRS), $(LOCAL_PATH)/$(D)) \
- $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include \
- $(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include) \
+ifeq ($(APPLICATION_OVERLAPS_SYSTEM_HEADERS),y)
+LOCAL_CFLAGS += $(foreach D, $(LOCAL_C_INCLUDES), -iquote$(D))
+LOCAL_C_INCLUDES :=
+endif
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include
+LOCAL_C_INCLUDES += $(foreach L, $(COMPILED_LIBRARIES), $(LOCAL_PATH)/../$(L)/include)
LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS)
diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg
index c09e6df42..d91f173ad 100644
--- a/project/jni/application/ballfield/AndroidAppSettings.cfg
+++ b/project/jni/application/ballfield/AndroidAppSettings.cfg
@@ -18,6 +18,7 @@ CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
+CompatibilityHacksAdditionalPreloadedSharedLibraries=""
AppUsesMouse=y
AppNeedsTwoButtonMouse=y
ShowMouseCursor=n
@@ -26,6 +27,7 @@ AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppUsesAccelerometer=y
+AppUsesGyroscope=y
AppUsesMultitouch=y
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
@@ -45,7 +47,9 @@ CompiledLibraries="sdl_mixer sdl_image"
CustomBuildScript=n
AppCflags='-O2 -finline-functions'
AppLdflags=''
+AppOverlapsSystemHeaders=
AppSubdirsBuild=''
+AppBuildExclude=''
AppCmdline=''
ReadmeText='^Readme text'
MinimumScreenSize=s
diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp
index 2c78f8011..abfc94c00 100644
--- a/project/jni/application/ballfield/ballfield.cpp
+++ b/project/jni/application/ballfield/ballfield.cpp
@@ -25,7 +25,7 @@
Definitions...
----------------------------------------------------------*/
-#define SCREEN_W 640
+#define SCREEN_W 800
#define SCREEN_H 480
@@ -437,13 +437,16 @@ int main(int argc, char* argv[])
// some random colors
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
- int accel[2], screenjoy[2];
+ int accel[5], screenjoy[4], gamepads[4][8];
SDL_Surface *mouse[4];
int screenKeyboardShown = 0;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
SDL_EnableUNICODE(1);
+ SDL_Joystick * joysticks[6];
+ for( i = 0; i < 6; i++ )
+ joysticks[i] = SDL_JoystickOpen(i);
atexit(SDL_Quit);
@@ -548,7 +551,7 @@ int main(int argc, char* argv[])
memset(touchPointers, 0, sizeof(touchPointers));
memset(accel, 0, sizeof(accel));
memset(screenjoy, 0, sizeof(screenjoy));
- SDL_Joystick * joystick = SDL_JoystickOpen(0);
+ memset(gamepads, 0, sizeof(gamepads));
while(1)
{
@@ -596,22 +599,33 @@ int main(int argc, char* argv[])
r.y -= r.h/2;
SDL_FillRect(screen, &r, colors[i]);
}
- r.x = SCREEN_W/2 + accel[0] * SCREEN_H / 65536;
- r.y = SCREEN_H/2 + accel[1] * SCREEN_H / 65536;
- //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Accel: %d %d screen %d %d", accel[0], accel[1], r.x, r.y);
- r.w = 10;
- r.h = 10;
- r.x -= r.w/2;
- r.y -= r.h/2;
- SDL_FillRect(screen, &r, 0xffffff);
- r.x = SCREEN_W/2 + screenjoy[0] * SCREEN_H / 65536;
- r.y = SCREEN_H/2 + screenjoy[1] * SCREEN_H / 65536;
- //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen joystick: %d %d screen %d %d", screenjoy[0], screenjoy[1], r.x, r.y);
- r.w = 10;
- r.h = 10;
- r.x -= r.w/2;
- r.y -= r.h/2;
- SDL_FillRect(screen, &r, 0x000000);
+ int joyInput[][3] = {
+ {accel[0], accel[1], 10},
+ {accel[2], accel[3], 10 + abs(accel[4]) * 100 / 32767},
+ {screenjoy[0], screenjoy[1], 10},
+ {screenjoy[2], screenjoy[3], 10},
+ {gamepads[0][0], gamepads[0][1], 10 + gamepads[0][4] * 100 / 32767},
+ {gamepads[0][2], gamepads[0][3], 10 + gamepads[0][5] * 100 / 32767},
+ {gamepads[0][6], gamepads[0][7], 10},
+ {gamepads[1][0], gamepads[1][1], 10 + gamepads[1][4] * 100 / 32767},
+ {gamepads[1][2], gamepads[1][3], 10 + gamepads[1][5] * 100 / 32767},
+ {gamepads[1][6], gamepads[1][7], 10},
+ {gamepads[2][0], gamepads[2][1], 10 + gamepads[2][4] * 100 / 32767},
+ {gamepads[2][2], gamepads[2][3], 10 + gamepads[2][5] * 100 / 32767},
+ {gamepads[2][6], gamepads[2][7], 10},
+ {gamepads[3][0], gamepads[3][1], 10 + gamepads[3][4] * 100 / 32767},
+ {gamepads[3][2], gamepads[3][3], 10 + gamepads[3][5] * 100 / 32767},
+ {gamepads[3][6], gamepads[3][7], 10},
+ };
+ for( i = 0; i < 15; i++ )
+ {
+ r.w = joyInput[i][2];
+ r.h = joyInput[i][2];
+ r.x = SCREEN_W/2 + joyInput[i][0] * SCREEN_H / 65536 - r.w/2;
+ r.y = SCREEN_H/2 + joyInput[i][1] * SCREEN_H / 65536 - r.w/2;
+ //__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Joy input %d: %d %d %d", i, joyInput[i][0], joyInput[i][1], joyInput[i][2] );
+ SDL_FillRect(screen, &r, i * 123);
+ }
int mx, my;
int b = SDL_GetMouseState(&mx, &my);
@@ -652,26 +666,35 @@ int main(int argc, char* argv[])
// Android-specific events - accelerometer, multitoush, and on-screen joystick
if( evt.type == SDL_JOYAXISMOTION )
{
- if(evt.jaxis.axis < 4)
+ if(evt.jaxis.which == 0) // Multitouch and on-screen joysticks
{
- if(evt.jaxis.axis < 2)
+ if(evt.jaxis.axis < 4)
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
else
- accel[evt.jaxis.axis - 2] = evt.jaxis.value;
+ touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
}
- else
+ if(evt.jaxis.which == 1)
{
- touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
+ accel[evt.jaxis.axis] = evt.jaxis.value; // accelerometer and gyroscope
+ }
+ if(evt.jaxis.which >= 2)
+ {
+ // Each gamepad has 8 axes - two joystick hats, two triggers, and Ouya touchpad
+ gamepads[evt.jaxis.which - 2][evt.jaxis.axis] = evt.jaxis.value;
}
}
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
{
- touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
+ if(evt.jbutton.which == 0) // Multitouch and on-screen joystick
+ touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
}
if( evt.type == SDL_JOYBALLMOTION )
{
- touchPointers[evt.jball.ball].x = evt.jball.xrel;
- touchPointers[evt.jball.ball].y = evt.jball.yrel;
+ if(evt.jball.which == 0) // Multitouch and on-screen joystick
+ {
+ touchPointers[evt.jball.ball].x = evt.jball.xrel;
+ touchPointers[evt.jball.ball].y = evt.jball.yrel;
+ }
}
}
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL))
diff --git a/project/jni/application/commandergenius/AndroidAppSettings.cfg b/project/jni/application/commandergenius/AndroidAppSettings.cfg
index ad97f1cf6..1b64257bb 100644
--- a/project/jni/application/commandergenius/AndroidAppSettings.cfg
+++ b/project/jni/application/commandergenius/AndroidAppSettings.cfg
@@ -5,7 +5,7 @@ AppName="Commander Genius"
AppFullName=net.sourceforge.clonekeenplus
ScreenOrientation=h
InhibitSuspend=n
-AppDataDownloadUrl="!Keen 1|keen1.zip^Keen 4|keen4.zip^Keen 7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqp19.zip/download"
+AppDataDownloadUrl="!Keen1|keen1.zip^!Keen4|keen4.zip^!Keen7|keen7.zip^High-quality GFX and music - 50 Mb|http://sourceforge.net/projects/clonekeenplus/files/High%20Quality%20Packs/Version%201.x/hqpv19.zip/download"
VideoDepthBpp=24
NeedDepthBuffer=n
NeedStencilBuffer=n
diff --git a/project/jni/application/commandergenius/AndroidData/keen1.zip b/project/jni/application/commandergenius/AndroidData/keen1.zip
deleted file mode 100644
index 21badd3b7..000000000
Binary files a/project/jni/application/commandergenius/AndroidData/keen1.zip and /dev/null differ
diff --git a/project/jni/application/commandergenius/AndroidData/keen4.zip b/project/jni/application/commandergenius/AndroidData/keen4.zip
deleted file mode 100644
index 4fb07e15e..000000000
Binary files a/project/jni/application/commandergenius/AndroidData/keen4.zip and /dev/null differ
diff --git a/project/jni/application/commandergenius/AndroidData/keen7.zip b/project/jni/application/commandergenius/AndroidData/keen7.zip
deleted file mode 100644
index f596ee376..000000000
Binary files a/project/jni/application/commandergenius/AndroidData/keen7.zip and /dev/null differ
diff --git a/project/jni/application/openarena/AndroidAppSettings.cfg b/project/jni/application/openarena/AndroidAppSettings.cfg
index eee9e555b..90feaff5e 100644
--- a/project/jni/application/openarena/AndroidAppSettings.cfg
+++ b/project/jni/application/openarena/AndroidAppSettings.cfg
@@ -18,6 +18,9 @@ CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
+CompatibilityHacksAdditionalPreloadedSharedLibraries=""
+CompatibilityHacksSlowCompatibleEventQueue=n
+CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n
@@ -26,9 +29,10 @@ AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppUsesAccelerometer=n
+AppUsesGyroscope=y
AppUsesMultitouch=y
NonBlockingSwapBuffers=n
-RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
+RedefinedKeys="SPACE SPACE NO_REMAP NO_REMAP RETURN ESCAPE LCTRL"
AppTouchscreenKeyboardKeysAmount=5
AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="SLASH BACKSPACE TAB END LCTRL SPACE UNKNOWN UNKNOWN UNKNOWN UNKNOWN"
@@ -37,15 +41,17 @@ HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
FirstStartMenuOptions=''
MultiABI=y
AppMinimumRAM=300
-AppVersionCode=08817
-AppVersionName="0.8.8.17"
-ResetSdlConfigForThisVersion=y
-DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag .openarena/baseoa/q3config.cfg"
+AppVersionCode=08819
+AppVersionName="0.8.8.19"
+ResetSdlConfigForThisVersion=n
+DeleteFilesOnUpgrade="libsdl-DownloadFinished-10.flag"
CompiledLibraries="sdl_mixer sdl_image freetype curl vorbis ogg"
CustomBuildScript=y
AppCflags='-O2 -finline-functions'
AppLdflags=''
+AppOverlapsSystemHeaders=
AppSubdirsBuild=''
+AppBuildExclude=''
AppCmdline=''
ReadmeText='^Readme text'
MinimumScreenSize=n
diff --git a/project/jni/application/openarena/engine b/project/jni/application/openarena/engine
index 9104eb974..1cef5a1e5 160000
--- a/project/jni/application/openarena/engine
+++ b/project/jni/application/openarena/engine
@@ -1 +1 @@
-Subproject commit 9104eb9749bd9ef21805cc1ac0d5a1840adf46d8
+Subproject commit 1cef5a1e56ef196c60dd44efab924d6134a0c4f3
diff --git a/project/jni/application/openarena/oa-reupload-vm.sh b/project/jni/application/openarena/oa-reupload-vm.sh
index 58e4829ae..78d85a8ea 100755
--- a/project/jni/application/openarena/oa-reupload-vm.sh
+++ b/project/jni/application/openarena/oa-reupload-vm.sh
@@ -1,3 +1,3 @@
#!/bin/sh
adb shell rm /sdcard/Android/data/ws.openarena.sdl/files/libsdl-DownloadFinished-10.flag
-adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena
+[ -n "$1" ] && adb shell rm -r /sdcard/Android/data/ws.openarena.sdl/files/.openarena
diff --git a/project/jni/application/openarena/vm b/project/jni/application/openarena/vm
index 26cafdcda..e6ae35e50 160000
--- a/project/jni/application/openarena/vm
+++ b/project/jni/application/openarena/vm
@@ -1 +1 @@
-Subproject commit 26cafdcdab7099d4992e747649f98ac42a3a8be8
+Subproject commit e6ae35e503252aea1073cdf57958fee4c8c89bbb
diff --git a/project/jni/application/openttd/AndroidAppSettings.cfg b/project/jni/application/openttd/AndroidAppSettings.cfg
index 7bf0af636..9ebf24a23 100644
--- a/project/jni/application/openttd/AndroidAppSettings.cfg
+++ b/project/jni/application/openttd/AndroidAppSettings.cfg
@@ -37,9 +37,9 @@ HiddenMenuOptions='OptionalDownloadConfig'
FirstStartMenuOptions=''
MultiABI=n
AppMinimumRAM=0
-AppVersionCode=12324
-AppVersionName="1.2.3.24"
-ResetSdlConfigForThisVersion=y
+AppVersionCode=12325
+AppVersionName="1.2.3.25"
+ResetSdlConfigForThisVersion=n
DeleteFilesOnUpgrade="%"
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
CustomBuildScript=y
diff --git a/project/jni/application/openttd/readme.txt b/project/jni/application/openttd/readme.txt
index 870b3e77a..21fc3ccc0 100644
--- a/project/jni/application/openttd/readme.txt
+++ b/project/jni/application/openttd/readme.txt
@@ -1,5 +1,7 @@
Quick compilation guide:
-Download my GIT repo from https://github.com/pelya/commandergenius,
+Install liblzma-dev, it's needed for configure script
+sudo apt-get install liblzma-dev
+Download my Git repo from https://github.com/pelya/commandergenius,
then install Android SDK, Android NDK, and "ant" tool, then launch commands
rm project/jni/application/src
ln -s openttd project/jni/application/src
diff --git a/project/jni/application/sc2/.gitignore b/project/jni/application/sc2/.gitignore
new file mode 100644
index 000000000..85de9cf93
--- /dev/null
+++ b/project/jni/application/sc2/.gitignore
@@ -0,0 +1 @@
+src
diff --git a/project/jni/application/sc2/AndroidAppSettings.cfg b/project/jni/application/sc2/AndroidAppSettings.cfg
index 0957232c5..f4068a369 100644
--- a/project/jni/application/sc2/AndroidAppSettings.cfg
+++ b/project/jni/application/sc2/AndroidAppSettings.cfg
@@ -5,7 +5,7 @@ AppName="Ur-Quan Masters"
AppFullName=com.sourceforge.sc2
ScreenOrientation=h
InhibitSuspend=n
-AppDataDownloadUrl="!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
+AppDataDownloadUrl="!!Game data (15 Mb)|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/sc2-data-5.zip/download^3DO remixed music (19 Mb) - enable it in Setup->Sound Options->3DO Remixes|:addons/3domusic/3domusic.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3domusic.zip/download^UQM music remix pack (150 Mb) - enable it in Setup->Sound Options->UQM Remixes|:addons/remix/remix.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/remix.zip/download^3DO voice (115 Mb) - go to Setup->Sound Options and increase Voice volume from zero|:addons/3dovoice/3dovoice.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovoice.zip/download^Russian translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/russian.zip/download^Deutsch translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/deutsch.zip/download^Spanish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/spanish.zip/download^Slovak translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/slovak.zip/download^Finnish translation|:addons/lang/shadow-content/lang.zip:http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/translations/2/finnish.zip/download^3DO video support - after installing this pack copy all files from|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^your 3DO Star Control II game CD from 'duckart' dir to the SD card to dir|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'app-data/com.sourceforge.sc2/addons/3dovideo', to extract files from 3DO disk use|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^'3DO Commander' or 'uncd-rom' apps from http://madroms.free.fr/3do/|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download^Then from the game change 'Setup->PC/3DO compat->Cutscenes' to Movies, and restart game|http://sourceforge.net/projects/libsdl-android/files/Ur-Quan%20Masters/3dovideo.zip/download"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
@@ -15,6 +15,10 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=n
CompatibilityHacksStaticInit=n
+CompatibilityHacksTextInputEmulatesHwKeyboard=n
+CompatibilityHacksPreventAudioChopping=n
+CompatibilityHacksAppIgnoresAudioBufferSize=n
+CompatibilityHacksAdditionalPreloadedSharedLibraries=""
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n
@@ -22,7 +26,7 @@ ForceRelativeMouseMode=n
AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
-AppHandlesJoystickSensitivity=n
+AppUsesAccelerometer=n
AppUsesMultitouch=n
NonBlockingSwapBuffers=n
RedefinedKeys="RETURN RSHIFT NO_REMAP NO_REMAP RCTRL F10"
@@ -33,14 +37,21 @@ StartupMenuButtonTimeout=3000
HiddenMenuOptions=''
FirstStartMenuOptions=''
MultiABI=n
-AppVersionCode=07022
-AppVersionName="0.7.0.22"
+AppMinimumRAM=0
+AppVersionCode=07023
+AppVersionName="0.7.0.23"
ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="%"
CompiledLibraries="sdl_image tremor ogg"
CustomBuildScript=n
-AppCflags='-O3 -DTHREADLIB_SDL=1 -DTIMELIB=SDL -DOVCODEC_TREMOR=1 -DNETPLAY=1 -DHAVE_GETOPT_LONG=1 -DHAVE_ZIP=1 -DHAVE_JOYSTICK=1'
+AppCflags='-O3 -DGFXMODULE_SDL -DOVCODEC_TREMOR -DNETPLAY=NETPLAY_FULL -DHAVE_JOYSTICK -DHAVE_ZIP=1 -DTHREADLIB_SDL -DUSE_INTERNAL_MIKMOD'
AppLdflags=''
-AppSubdirsBuild='src src/regex src/libs/* src/uqm/*'
+AppOverlapsSystemHeaders=y
+AppSubdirsBuild='src src/libs/* src/uqm/*'
+AppBuildExclude='src/libs/uio/hashtable.c src/libs/uio/memdebug.c'
AppCmdline='uqm --addon lang'
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
+MinimumScreenSize=s
+AdmobPublisherId=n
+AdmobTestDeviceId=
+AdmobBannerSize=
diff --git a/project/jni/application/sc2/AndroidData/logo.png b/project/jni/application/sc2/AndroidData/logo.png
new file mode 100644
index 000000000..b6df3d25f
Binary files /dev/null and b/project/jni/application/sc2/AndroidData/logo.png differ
diff --git a/project/jni/application/sc2/AndroidPreBuild.sh b/project/jni/application/sc2/AndroidPreBuild.sh
new file mode 100755
index 000000000..1be1c3e2e
--- /dev/null
+++ b/project/jni/application/sc2/AndroidPreBuild.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+LOCAL_PATH=`dirname $0`
+LOCAL_PATH=`cd $LOCAL_PATH && pwd`
+
+if [ -e src/patched.successfully ]; then
+ exit 0
+else
+ svn co https://sc2.svn.sourceforge.net/svnroot/sc2/trunk/sc2/src && patch -p0 -d src < android.diff && touch src/patched.successfully || exit 1
+fi
diff --git a/project/jni/application/sc2/android.diff b/project/jni/application/sc2/android.diff
index 1bf840c76..487b065a8 100644
--- a/project/jni/application/sc2/android.diff
+++ b/project/jni/application/sc2/android.diff
@@ -1,369 +1,411 @@
-Index: options.h
+Index: libs/md5/md5.c
===================================================================
---- options.h (revision 3778)
-+++ options.h (working copy)
-@@ -41,6 +41,7 @@
- extern int optWhichShield;
- extern int optSmoothScroll;
- extern int optMeleeScale;
-+extern int optDirectionalJoystick;
+--- libs/md5/md5.c (revision 3779)
++++ libs/md5/md5.c (working copy)
+@@ -21,7 +21,7 @@
- extern BOOLEAN opt3doMusic;
- extern BOOLEAN optRemixMusic;
-Index: uqm.c
+ /* Written by Ulrich Drepper , 1995. */
+
+-#include
++#include "config.h"
+
+ #include "md5.h"
+
+Index: libs/resource/filecntl.c
===================================================================
---- uqm.c (revision 3778)
-+++ uqm.c (working copy)
-@@ -55,8 +55,10 @@
- #endif
- #include "uqm/setup.h"
- #include "uqm/starcon.h"
-+#ifdef ANDROID
-+#include
-+#endif
+--- libs/resource/filecntl.c (revision 3779)
++++ libs/resource/filecntl.c (working copy)
+@@ -26,6 +26,7 @@
+ #include "port.h"
+ #include "resintrn.h"
+ #include "libs/uio.h"
++#include "libs/log.h"
+
+ uio_Stream *
+ res_OpenResFile (uio_DirHandle *dir, const char *filename, const char *mode)
+@@ -34,7 +35,10 @@
+ struct stat sb;
+
+ if (uio_stat (dir, filename, &sb) == 0 && S_ISDIR(sb.st_mode))
++ {
++ log_add (log_Debug, "res_OpenResFile('%s', '%s') - cannot open dir as file", filename, mode);
+ return ((uio_Stream *) ~0);
++ }
+
+ fp = uio_fopen (dir, filename, mode);
+
+Index: libs/sound/decoders/oggaud.c
+===================================================================
+--- libs/sound/decoders/oggaud.c (revision 3779)
++++ libs/sound/decoders/oggaud.c (working copy)
+@@ -270,7 +270,7 @@
+ // this is the closest to a frame there is in ogg vorbis stream
+ // doesn't seem to be a func to retrive it
+ #ifdef OVCODEC_TREMOR
+- return ova->vf.os->pageno;
++ return ova->vf.os.pageno;
+ #else
+ return ova->vf.os.pageno;
+ #endif /* OVCODEC_TREMOR */
+Index: libs/network/netmanager/netmanager_win.c
+===================================================================
+--- libs/network/netmanager/netmanager_win.c (revision 3779)
++++ libs/network/netmanager/netmanager_win.c (working copy)
+@@ -16,6 +16,8 @@
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
++#ifdef WIN32
++
+ #define PORT_WANT_ERRNO
+ #include "port.h"
+ #include "../netport.h"
+@@ -461,4 +463,4 @@
+ return 0;
+ }
-
- #if defined (GFXMODULE_SDL)
- # include SDL_INCLUDE(SDL.h)
- // Including this is actually necessary on OSX.
-@@ -129,6 +131,7 @@
- DECL_CONFIG_OPTION(float, sfxVolumeScale);
- DECL_CONFIG_OPTION(float, speechVolumeScale);
- DECL_CONFIG_OPTION(bool, safeMode);
-+ DECL_CONFIG_OPTION(bool, directionalJoystick);
++#endif
+Index: libs/network/network_win.c
+===================================================================
+--- libs/network/network_win.c (revision 3779)
++++ libs/network/network_win.c (working copy)
+@@ -16,6 +16,8 @@
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
- #define INIT_CONFIG_OPTION(name, val) \
- { val, false }
-@@ -263,6 +266,7 @@
- INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ),
- INIT_CONFIG_OPTION( speechVolumeScale, 1.0f ),
- INIT_CONFIG_OPTION( safeMode, false ),
-+ INIT_CONFIG_OPTION( directionalJoystick, true ),
- };
- struct options_struct defaults = options;
- int optionsResult;
-@@ -270,6 +274,20 @@
- int gfxFlags;
- int i;
++#ifdef WIN32
++
+ #include "netport.h"
+
+ #include "network.h"
+@@ -72,4 +74,4 @@
+ }
+ }
+
+-
++#endif
+Index: libs/network/socket/socket_win.c
+===================================================================
+--- libs/network/socket/socket_win.c (revision 3779)
++++ libs/network/socket/socket_win.c (working copy)
+@@ -18,6 +18,8 @@
+
+ // Socket functions for Winsock sockets.
+
++#ifdef WIN32
++
+ #define PORT_WANT_ERRNO
+ #include "port.h"
+ #include "../netport.h"
+@@ -311,4 +313,4 @@
+ return 0;
+ }
+
+-
++#endif
+Index: libs/graphics/sdl/pure.c
+===================================================================
+--- libs/graphics/sdl/pure.c (revision 3779)
++++ libs/graphics/sdl/pure.c (working copy)
+@@ -20,6 +20,10 @@
+ #include "scalers.h"
+ #include "libs/log.h"
+#ifdef ANDROID
-+ // Remove save and config files from my previous Andorid releases, where I've messed up save paths, so users will be able to overwrite saves
-+ unlink("melee.cfg");
-+ unlink("uqm.cfg");
-+ unlink("flight.cfg");
-+
-+ for(i = 0; i < 50; i++)
-+ {
-+ char buf[64];
-+ sprintf(buf, "save/starcon2.%02d", i);
-+ unlink(buf);
-+ };
++#include
+#endif
+
- // NOTE: we cannot use the logging facility yet because we may have to
- // log to a file, and we'll only get the log file name after parsing
- // the options.
-@@ -390,6 +408,7 @@
- sfxVolumeScale = options.sfxVolumeScale.value;
- speechVolumeScale = options.speechVolumeScale.value;
- optAddons = options.addons;
-+ optDirectionalJoystick = options.directionalJoystick.value;
+ static SDL_Surface *fade_color_surface = NULL;
+ static SDL_Surface *fade_temp = NULL;
+ static SDL_Surface *scaled_display = NULL;
+@@ -104,6 +108,7 @@
+ {
+ int i, videomode_flags;
+ SDL_PixelFormat conv_fmt;
++ int BPP = 32;
+
+ GraphicsDriver = driver;
- prepareContentDir (options.contentDir, options.addonDir, argv[0]);
- prepareMeleeDir ();
-@@ -637,6 +656,7 @@
- getBoolConfigValue (&options->fullscreen, "config.fullscreen");
- getBoolConfigValue (&options->scanlines, "config.scanlines");
- getBoolConfigValue (&options->showFps, "config.showfps");
-+ getBoolConfigValue (&options->directionalJoystick, "config.directionaljoystick");
- getBoolConfigValue (&options->keepAspectRatio, "config.keepaspectratio");
- getGammaConfigValue (&options->gamma, "config.gamma");
+@@ -128,6 +133,20 @@
+ "under pure SDL, using 640x480", width, height);
+ }
-Index: libs/uio/zip/zip.c
-===================================================================
---- libs/uio/zip/zip.c (revision 3778)
-+++ libs/uio/zip/zip.c (working copy)
-@@ -1366,6 +1366,10 @@
- gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]);
- break;
- }
-+ case 0x7875: // 'Unix string UID/GID'
-+ // Just skip it
-+ break;
++#ifdef ANDROID
++ videomode_flags = SDL_SWSURFACE;
++ ScreenWidthActual = 320;
++ ScreenHeightActual = 240;
++ graphics_backend = &pure_unscaled_backend;
++ BPP = 16;
++ /* Make the on-screen buttons slightly overlap, so we can hit them with one finger */
++ SDL_Rect b0;
++ SDL_ANDROID_GetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &b0);
++ b0.x -= b0.w * 0.2;
++ b0.w += b0.w * 0.2;
++ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &b0);
++#endif
+
- default:
- #ifdef DEBUG
- fprintf(stderr, "Debug: Extra field 0x%04x unsupported, "
-Index: libs/uio/hashtable.c
+ videomode_flags |= SDL_ANYFORMAT;
+ if (flags & TFB_GFXFLAGS_FULLSCREEN)
+ videomode_flags |= SDL_FULLSCREEN;
+@@ -135,7 +154,7 @@
+ /* We'll ask for a 32bpp frame, but it doesn't really matter, because we've set
+ SDL_ANYFORMAT */
+ SDL_Video = SDL_SetVideoMode (ScreenWidthActual, ScreenHeightActual,
+- 32, videomode_flags);
++ BPP, videomode_flags);
+
+ if (SDL_Video == NULL)
+ {
+Index: libs/cdp/cdpapi.c
===================================================================
---- libs/uio/hashtable.c (revision 3778)
-+++ libs/uio/hashtable.c (working copy)
-@@ -371,4 +371,3 @@
- HASHTABLE_(freeHashEntry)(HASHTABLE_(HashEntry) *entry) {
- uio_free(entry);
+--- libs/cdp/cdpapi.c (revision 3779)
++++ libs/cdp/cdpapi.c (working copy)
+@@ -20,6 +20,8 @@
+ * the API is used by both the engine and modules
+ */
+
++#ifndef ANDROID
++
+ #include "cdp.h"
+ #include "port.h"
+ #include "cdpint.h"
+@@ -862,3 +864,5 @@
+ }
+ return ret;
+ }
++
++#endif
+Index: libs/cdp/cdp.c
+===================================================================
+--- libs/cdp/cdp.c (revision 3779)
++++ libs/cdp/cdp.c (working copy)
+@@ -19,6 +19,8 @@
+ * CDP library definitions
+ */
+
++#ifndef ANDROID
++
+ #include
+ #include
+ #include "cdp.h"
+@@ -435,3 +437,5 @@
+ cdp_FreeModule (cdp);
+ }
+ }
++
++#endif
+Index: libs/cdp/windl.c
+===================================================================
+--- libs/cdp/windl.c (revision 3779)
++++ libs/cdp/windl.c (working copy)
+@@ -19,6 +19,8 @@
+ * CDP dlopen() & Co. WIN32 implementation
+ */
+
++#ifdef WIN32
++
+ #include "windl.h"
+ #include "port.h"
+ #define WIN32_LEAN_AND_MEAN
+@@ -74,3 +76,5 @@
+ else
+ return NULL;
+ }
++
++#endif
+Index: libs/input/sdl/input.c
+===================================================================
+--- libs/input/sdl/input.c (revision 3779)
++++ libs/input/sdl/input.c (working copy)
+@@ -186,6 +186,13 @@
+ directory. */
+ LoadResourceIndex (contentDir, "uqm.key", "keys.");
+ }
++
++#ifdef ANDROID // TODO: hacky
++ res_PutString("keys.1.up.2", "joystick 0 axis 1 negative");
++ res_PutString("keys.1.down.2", "joystick 0 axis 1 positive");
++ res_PutString("keys.1.left.2", "joystick 0 axis 0 negative");
++ res_PutString("keys.1.right.2", "joystick 0 axis 0 positive");
++#endif
+
+ register_flight_controls ();
+
+Index: libs/input/sdl/vcontrol.c
+===================================================================
+--- libs/input/sdl/vcontrol.c (revision 3779)
++++ libs/input/sdl/vcontrol.c (working copy)
+@@ -46,6 +46,7 @@
+ typedef struct vcontrol_joystick_axis {
+ keybinding *neg, *pos;
+ int polarity;
++ int value;
+ } axis_type;
+
+ typedef struct vcontrol_joystick_hat {
+@@ -66,7 +67,7 @@
+
+ #endif /* HAVE_JOYSTICK */
+
+-static unsigned int joycount;
++static unsigned int joycount = 0;
+ static unsigned int num_sdl_keys = 0;
+ static keybinding **bindings = NULL;
+
+@@ -818,6 +819,7 @@
+ int t;
+ if (!joysticks[port].stick)
+ return;
++ joysticks[port].axes[axis].value = value;
+ t = joysticks[port].threshold;
+ if (value > t)
+ {
+@@ -894,6 +896,25 @@
+ #endif /* HAVE_JOYSTICK */
+ }
+
++int
++VControl_GetJoyAxis(int port, int axis)
++{
++#ifdef HAVE_JOYSTICK
++ if( joycount <= port )
++ return 0;
++ if (!joysticks[port].stick || joysticks[port].numaxes <= axis )
++ return 0;
++ return joysticks[port].axes[axis].value;
++#else
++ return 0;
++#endif /* HAVE_JOYSTICK */
++};
++
++int VControl_GetJoysticksAmount()
++{
++ return joycount;
++};
++
+ void
+ VControl_ResetInput (void)
+ {
+Index: libs/input/sdl/vcontrol.h
+===================================================================
+--- libs/input/sdl/vcontrol.h (revision 3779)
++++ libs/input/sdl/vcontrol.h (working copy)
+@@ -76,6 +76,9 @@
+ void VControl_ProcessJoyAxis (int port, int axis, int value);
+ void VControl_ProcessJoyHat (int port, int which, Uint8 value);
+
++int VControl_GetJoyAxis(int port, int axis);
++int VControl_GetJoysticksAmount();
++
+ /* Force the input into the blank state. For preventing "sticky" keys. */
+ void VControl_ResetInput (void);
+
+Index: libs/log/msgbox_stub.c
+===================================================================
+--- libs/log/msgbox_stub.c (revision 3779)
++++ libs/log/msgbox_stub.c (working copy)
+@@ -16,6 +16,9 @@
+
+ #include "msgbox.h"
+ #include "loginternal.h"
++#ifdef ANDROID
++#include
++#endif
+
+ void
+ log_displayBox (const /*UTF-8*/char *title, int isError,
+@@ -26,6 +29,9 @@
+ // So just inform the user of our predicament
+ fprintf (streamOut, "Do not know how to display %s box\n",
+ isError ? "an error" : "a");
++#ifdef ANDROID
++ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg );
++#endif
+
+ // Suppress the compiler warnings in any case.
+ (void)title;
+Index: libs/log/uqmlog.c
+===================================================================
+--- libs/log/uqmlog.c (revision 3779)
++++ libs/log/uqmlog.c (working copy)
+@@ -23,6 +23,9 @@
+ #include
+ #include
+ #include
++#ifdef ANDROID
++#include
++#endif
+ #include "libs/threadlib.h"
+
+ #ifndef MAX_LOG_ENTRY_SIZE
+@@ -191,6 +194,9 @@
+ if ((int)level <= maxStreamLevel)
+ {
+ fprintf (streamOut, "%s\n", full_msg);
++#ifdef ANDROID
++ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg );
++#endif
+ }
+
+ if ((int)level <= maxLevel)
+@@ -227,6 +233,9 @@
+ if ((int)level <= maxStreamLevel)
+ {
+ fprintf (streamOut, "%s\n", full_msg);
++#ifdef ANDROID
++ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg );
++#endif
+ }
+
+ if ((int)level <= maxLevel)
+Index: libs/log/msgbox_win.c
+===================================================================
+--- libs/log/msgbox_win.c (revision 3779)
++++ libs/log/msgbox_win.c (working copy)
+@@ -14,6 +14,7 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
++#ifndef ANDROID
+ #include "msgbox.h"
+ #define WIN32_LEAN_AND_MEAN
+ #include
+@@ -64,4 +65,4 @@
+ free (swTitle);
+ free (swMsg);
}
-
-Index: libs/uio/hashtable.h
++#endif
+Index: libs/uio/match.c
===================================================================
---- libs/uio/hashtable.h (revision 3778)
-+++ libs/uio/hashtable.h (working copy)
-@@ -54,7 +54,7 @@
- # define HashTable_FREEKEY(hashTable, hashKey) \
- (hashTable)->freeKeyFunction(hashKey)
- # define HashTable_FREEVALUE(hashTable, hashValue) \
-- (hashTable)->freeValueFunction(hashKey)
-+ (hashTable)->freeValueFunction(hashValue)
+--- libs/uio/match.c (revision 3779)
++++ libs/uio/match.c (working copy)
+@@ -506,7 +506,7 @@
+ return match_ENOTINIT;
+ }
+ if (context->errorString) {
+- uio_free(context->errorString);
++ uio_free(context->errorString); //TODO: why does it crash here on Android?
+ context->errorString = NULL;
+ }
+ retval = regexec(&context->native, string, 0, NULL, 0);
+Index: libs/uio/match.h
+===================================================================
+--- libs/uio/match.h (revision 3779)
++++ libs/uio/match.h (working copy)
+@@ -79,7 +79,7 @@
+
+ #include
+ #ifdef HAVE_REGEX
+-# include
++#include
#endif
-
-Index: libs/uio/stdio/stdio.c
-===================================================================
---- libs/uio/stdio/stdio.c (revision 3778)
-+++ libs/uio/stdio/stdio.c (working copy)
-@@ -25,7 +25,7 @@
- // For the POSIX variant of readdir_r()
- #endif
-
--#include "./stdio.h"
-+#include "uio_stdio.h"
-
- #ifdef WIN32
- # include
-Index: libs/uio/stdio/stdio.h
-===================================================================
---- libs/uio/stdio/stdio.h (revision 3778)
-+++ libs/uio/stdio/stdio.h (working copy)
-@@ -1,111 +0,0 @@
--/*
-- * Copyright (C) 2003 Serge van den Boom
-- *
-- * This program is free software; you can redistribute it and/or modify
-- * it under the terms of version 2 of the GNU General Public License as
-- * published by the Free Software Foundation.
-- * Nota bene: later versions of the GNU General Public License do not apply
-- * to this program.
-- *
-- * This program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with this program; if not, write to the Free Software
-- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-- *
-- */
--
--typedef struct stdio_Handle *uio_NativeHandle;
--typedef void *uio_GPRootExtra;
--typedef struct stdio_GPDirData *uio_GPDirExtra;
--typedef void *uio_GPFileExtra;
--typedef struct stdio_EntriesIterator stdio_EntriesIterator;
--typedef stdio_EntriesIterator *uio_NativeEntriesContext;
--
--
--#define uio_INTERNAL_PHYSICAL
--
--#include "../gphys.h"
--#include "../iointrn.h"
--#include "../uioport.h"
--#include "../fstypes.h"
--#include "../physical.h"
--
--#include
--#ifndef WIN32
--# include
--#endif
--
--
--typedef struct stdio_GPDirData {
-- // The reason that names are stored is that in the system filesystem
-- // you need names to refer to files and directories.
-- // (you could keep a file descriptor to each one, but that would
-- // mean a lot of open file descriptors, and for some it won't even
-- // be enough).
-- // This is not needed for all filesystems; therefor this info is not
-- // in uio_GPDir itself.
-- // The reasons for including upDir here are similar.
-- char *name;
-- char *cachedPath;
-- uio_GPDir *upDir;
--} stdio_GPDirData;
--
--typedef struct stdio_Handle {
-- int fd;
--} stdio_Handle;
--
--#ifdef WIN32
--struct stdio_EntriesIterator {
-- long dirHandle;
-- struct _finddata_t findData;
-- int status;
--};
--#endif
--
--#ifndef WIN32
--struct stdio_EntriesIterator {
-- DIR *dirHandle;
-- struct dirent *entry;
-- struct dirent *direntBuffer;
-- int status;
--};
--#endif
--
--
--uio_PRoot *stdio_mount(uio_Handle *handle, int flags);
--int stdio_umount(uio_PRoot *);
--uio_PDirHandle *stdio_mkdir(uio_PDirHandle *pDirHandle, const char *name,
-- mode_t mode);
--uio_Handle *stdio_open(uio_PDirHandle *pDirHandle, const char *file, int flags,
-- mode_t mode);
--void stdio_close(uio_Handle *handle);
--int zip_access(uio_PDirHandle *pDirHandle, const char *name, int mode);
--int stdio_access(uio_PDirHandle *pDirHandle, const char *name, int mode);
--int stdio_fstat(uio_Handle *handle, struct stat *statBuf);
--int stdio_stat(uio_PDirHandle *pDirHandle, const char *name,
-- struct stat *statBuf);
--ssize_t stdio_read(uio_Handle *handle, void *buf, size_t count);
--int stdio_rename(uio_PDirHandle *oldPDirHandle, const char *oldName,
-- uio_PDirHandle *newPDirHandle, const char *newName);
--int stdio_rmdir(uio_PDirHandle *pDirHandle, const char *name);
--off_t stdio_seek(uio_Handle *handle, off_t offset, int whence);
--ssize_t stdio_write(uio_Handle *handle, const void *buf, size_t count);
--int stdio_unlink(uio_PDirHandle *pDirHandle, const char *name);
--
--stdio_EntriesIterator *stdio_openEntries(uio_PDirHandle *pDirHandle);
--int stdio_readEntries(stdio_EntriesIterator **iterator,
-- char *buf, size_t len);
--void stdio_closeEntries(stdio_EntriesIterator *iterator);
--#ifdef WIN32
--stdio_EntriesIterator *stdio_EntriesIterator_new(long dirHandle);
--#else
--stdio_EntriesIterator *stdio_EntriesIterator_new(DIR *dirHandle);
--#endif
--void stdio_EntriesIterator_delete(stdio_EntriesIterator *iterator);
--uio_PDirEntryHandle *stdio_getPDirEntryHandle(
-- const uio_PDirHandle *pDirHandle, const char *name);
--
-Index: libs/uio/stdio/uio_stdio.h
-===================================================================
---- libs/uio/stdio/uio_stdio.h 2012-06-01 13:05:34.086871977 +0300
-+++ libs/uio/stdio/uio_stdio.h 2012-06-11 18:52:31.723038973 +0300
-@@ -0,0 +1,111 @@
-+/*
-+ * Copyright (C) 2003 Serge van den Boom
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of version 2 of the GNU General Public License as
-+ * published by the Free Software Foundation.
-+ * Nota bene: later versions of the GNU General Public License do not apply
-+ * to this program.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License
-+ * along with this program; if not, write to the Free Software
-+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ *
-+ */
-+
-+typedef struct stdio_Handle *uio_NativeHandle;
-+typedef void *uio_GPRootExtra;
-+typedef struct stdio_GPDirData *uio_GPDirExtra;
-+typedef void *uio_GPFileExtra;
-+typedef struct stdio_EntriesIterator stdio_EntriesIterator;
-+typedef stdio_EntriesIterator *uio_NativeEntriesContext;
-+
-+
-+#define uio_INTERNAL_PHYSICAL
-+
-+#include "../gphys.h"
-+#include "../iointrn.h"
-+#include "../uioport.h"
-+#include "../fstypes.h"
-+#include "../physical.h"
-+
-+#include
-+#ifndef WIN32
-+# include
-+#endif
-+
-+
-+typedef struct stdio_GPDirData {
-+ // The reason that names are stored is that in the system filesystem
-+ // you need names to refer to files and directories.
-+ // (you could keep a file descriptor to each one, but that would
-+ // mean a lot of open file descriptors, and for some it won't even
-+ // be enough).
-+ // This is not needed for all filesystems; therefor this info is not
-+ // in uio_GPDir itself.
-+ // The reasons for including upDir here are similar.
-+ char *name;
-+ char *cachedPath;
-+ uio_GPDir *upDir;
-+} stdio_GPDirData;
-+
-+typedef struct stdio_Handle {
-+ int fd;
-+} stdio_Handle;
-+
-+#ifdef WIN32
-+struct stdio_EntriesIterator {
-+ long dirHandle;
-+ struct _finddata_t findData;
-+ int status;
-+};
-+#endif
-+
-+#ifndef WIN32
-+struct stdio_EntriesIterator {
-+ DIR *dirHandle;
-+ struct dirent *entry;
-+ struct dirent *direntBuffer;
-+ int status;
-+};
-+#endif
-+
-+
-+uio_PRoot *stdio_mount(uio_Handle *handle, int flags);
-+int stdio_umount(uio_PRoot *);
-+uio_PDirHandle *stdio_mkdir(uio_PDirHandle *pDirHandle, const char *name,
-+ mode_t mode);
-+uio_Handle *stdio_open(uio_PDirHandle *pDirHandle, const char *file, int flags,
-+ mode_t mode);
-+void stdio_close(uio_Handle *handle);
-+int zip_access(uio_PDirHandle *pDirHandle, const char *name, int mode);
-+int stdio_access(uio_PDirHandle *pDirHandle, const char *name, int mode);
-+int stdio_fstat(uio_Handle *handle, struct stat *statBuf);
-+int stdio_stat(uio_PDirHandle *pDirHandle, const char *name,
-+ struct stat *statBuf);
-+ssize_t stdio_read(uio_Handle *handle, void *buf, size_t count);
-+int stdio_rename(uio_PDirHandle *oldPDirHandle, const char *oldName,
-+ uio_PDirHandle *newPDirHandle, const char *newName);
-+int stdio_rmdir(uio_PDirHandle *pDirHandle, const char *name);
-+off_t stdio_seek(uio_Handle *handle, off_t offset, int whence);
-+ssize_t stdio_write(uio_Handle *handle, const void *buf, size_t count);
-+int stdio_unlink(uio_PDirHandle *pDirHandle, const char *name);
-+
-+stdio_EntriesIterator *stdio_openEntries(uio_PDirHandle *pDirHandle);
-+int stdio_readEntries(stdio_EntriesIterator **iterator,
-+ char *buf, size_t len);
-+void stdio_closeEntries(stdio_EntriesIterator *iterator);
-+#ifdef WIN32
-+stdio_EntriesIterator *stdio_EntriesIterator_new(long dirHandle);
-+#else
-+stdio_EntriesIterator *stdio_EntriesIterator_new(DIR *dirHandle);
-+#endif
-+void stdio_EntriesIterator_delete(stdio_EntriesIterator *iterator);
-+uio_PDirEntryHandle *stdio_getPDirEntryHandle(
-+ const uio_PDirHandle *pDirHandle, const char *name);
-+
+ #include "uioport.h"
Index: libs/uio/io.c
===================================================================
---- libs/uio/io.c (revision 3778)
+--- libs/uio/io.c (revision 3779)
+++ libs/uio/io.c (working copy)
@@ -35,6 +35,7 @@
#include "mem.h"
@@ -428,434 +470,32 @@ Index: libs/uio/io.c
int savedErrno = errno;
uio_free(name);
uio_PDirHandle_unref(pDirHandle);
-Index: libs/uio/memdebug.c
+Index: libs/uio/zip/zip.c
===================================================================
---- libs/uio/memdebug.c (revision 3778)
-+++ libs/uio/memdebug.c (working copy)
-@@ -94,6 +94,7 @@
- uio_MemDebug_pointerCompare,
- uio_MemDebug_pointerCopy,
- uio_MemDebug_pointerFree,
-+ uio_MemDebug_pointerFree,
- 4, 0.85, 0.90);
- }
- }
-Index: libs/uio/match.c
-===================================================================
---- libs/uio/match.c (revision 3778)
-+++ libs/uio/match.c (working copy)
-@@ -506,7 +506,7 @@
- return match_ENOTINIT;
- }
- if (context->errorString) {
-- uio_free(context->errorString);
-+ uio_free(context->errorString); //TODO: why does it crash here on Android?
- context->errorString = NULL;
- }
- retval = regexec(&context->native, string, 0, NULL, 0);
-Index: libs/uio/match.h
-===================================================================
---- libs/uio/match.h (revision 3778)
-+++ libs/uio/match.h (working copy)
-@@ -79,8 +79,12 @@
-
- #include
- #ifdef HAVE_REGEX
--# include
-+#ifdef ANDROID
-+#include "uqm_regex.h"
-+#else
-+#include
- #endif
-+#endif
-
- #include "uioport.h"
-
-Index: libs/cdp/windl.c
-===================================================================
---- libs/cdp/windl.c (revision 3778)
-+++ libs/cdp/windl.c (working copy)
-@@ -19,6 +19,8 @@
- * CDP dlopen() & Co. WIN32 implementation
- */
-
-+#ifdef WIN32
+--- libs/uio/zip/zip.c (revision 3779)
++++ libs/uio/zip/zip.c (working copy)
+@@ -1366,6 +1366,10 @@
+ gPFileData->gid = (uid_t) makeUInt16(buf[12], buf[13]);
+ break;
+ }
++ case 0x7875: // 'Unix string UID/GID'
++ // Just skip it
++ break;
+
- #include "windl.h"
- #include "port.h"
- #define WIN32_LEAN_AND_MEAN
-@@ -74,3 +76,5 @@
- else
- return NULL;
- }
-+
-+#endif
-Index: libs/cdp/cdpapi.c
-===================================================================
---- libs/cdp/cdpapi.c (revision 3778)
-+++ libs/cdp/cdpapi.c (working copy)
-@@ -20,6 +20,8 @@
- * the API is used by both the engine and modules
- */
-
-+#ifndef ANDROID
-+
- #include "cdp.h"
- #include "port.h"
- #include "cdpint.h"
-@@ -862,3 +864,5 @@
- }
- return ret;
- }
-+
-+#endif
-Index: libs/cdp/cdp.c
-===================================================================
---- libs/cdp/cdp.c (revision 3778)
-+++ libs/cdp/cdp.c (working copy)
-@@ -19,6 +19,8 @@
- * CDP library definitions
- */
-
-+#ifndef ANDROID
-+
- #include
- #include
- #include "cdp.h"
-@@ -435,3 +437,5 @@
- cdp_FreeModule (cdp);
- }
- }
-+
-+#endif
-Index: libs/sound/decoders/oggaud.c
-===================================================================
---- libs/sound/decoders/oggaud.c (revision 3778)
-+++ libs/sound/decoders/oggaud.c (working copy)
-@@ -270,7 +270,7 @@
- // this is the closest to a frame there is in ogg vorbis stream
- // doesn't seem to be a func to retrive it
- #ifdef OVCODEC_TREMOR
-- return ova->vf.os->pageno;
-+ return ova->vf.os.pageno;
- #else
- return ova->vf.os.pageno;
- #endif /* OVCODEC_TREMOR */
-Index: libs/network/network_win.c
-===================================================================
---- libs/network/network_win.c (revision 3778)
-+++ libs/network/network_win.c (working copy)
-@@ -16,6 +16,8 @@
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-+#ifdef WIN32
-+
- #include "netport.h"
-
- #include "network.h"
-@@ -72,4 +74,4 @@
- }
- }
-
--
-+#endif
-Index: libs/network/socket/socket_win.c
-===================================================================
---- libs/network/socket/socket_win.c (revision 3778)
-+++ libs/network/socket/socket_win.c (working copy)
-@@ -18,6 +18,8 @@
-
- // Socket functions for Winsock sockets.
-
-+#ifdef WIN32
-+
- #define PORT_WANT_ERRNO
- #include "port.h"
- #include "../netport.h"
-@@ -311,4 +313,4 @@
- return 0;
- }
-
--
-+#endif
-Index: libs/network/netmanager/netmanager_win.c
-===================================================================
---- libs/network/netmanager/netmanager_win.c (revision 3778)
-+++ libs/network/netmanager/netmanager_win.c (working copy)
-@@ -16,6 +16,8 @@
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-+#ifdef WIN32
-+
- #define PORT_WANT_ERRNO
- #include "port.h"
- #include "../netport.h"
-@@ -461,4 +463,4 @@
- return 0;
- }
-
--
-+#endif
-Index: libs/input/sdl/input.c
-===================================================================
---- libs/input/sdl/input.c (revision 3778)
-+++ libs/input/sdl/input.c (working copy)
-@@ -186,6 +186,13 @@
- directory. */
- LoadResourceIndex (contentDir, "uqm.key", "keys.");
- }
-+
-+#ifdef ANDROID // TODO: hacky
-+ res_PutString("keys.1.up.2", "joystick 0 axis 1 negative");
-+ res_PutString("keys.1.down.2", "joystick 0 axis 1 positive");
-+ res_PutString("keys.1.left.2", "joystick 0 axis 0 negative");
-+ res_PutString("keys.1.right.2", "joystick 0 axis 0 positive");
-+#endif
-
- register_flight_controls ();
-
-Index: libs/input/sdl/vcontrol.c
-===================================================================
---- libs/input/sdl/vcontrol.c (revision 3778)
-+++ libs/input/sdl/vcontrol.c (working copy)
-@@ -46,6 +46,7 @@
- typedef struct vcontrol_joystick_axis {
- keybinding *neg, *pos;
- int polarity;
-+ int value;
- } axis_type;
-
- typedef struct vcontrol_joystick_hat {
-@@ -66,7 +67,7 @@
-
- #endif /* HAVE_JOYSTICK */
-
--static unsigned int joycount;
-+static unsigned int joycount = 0;
- static unsigned int num_sdl_keys = 0;
- static keybinding **bindings = NULL;
-
-@@ -818,6 +819,7 @@
- int t;
- if (!joysticks[port].stick)
- return;
-+ joysticks[port].axes[axis].value = value;
- t = joysticks[port].threshold;
- if (value > t)
- {
-@@ -894,6 +896,25 @@
- #endif /* HAVE_JOYSTICK */
- }
-
-+int
-+VControl_GetJoyAxis(int port, int axis)
-+{
-+#ifdef HAVE_JOYSTICK
-+ if( joycount <= port )
-+ return 0;
-+ if (!joysticks[port].stick || joysticks[port].numaxes <= axis )
-+ return 0;
-+ return joysticks[port].axes[axis].value;
-+#else
-+ return 0;
-+#endif /* HAVE_JOYSTICK */
-+};
-+
-+int VControl_GetJoysticksAmount()
-+{
-+ return joycount;
-+};
-+
- void
- VControl_ResetInput (void)
- {
-Index: libs/input/sdl/vcontrol.h
-===================================================================
---- libs/input/sdl/vcontrol.h (revision 3778)
-+++ libs/input/sdl/vcontrol.h (working copy)
-@@ -76,6 +76,9 @@
- void VControl_ProcessJoyAxis (int port, int axis, int value);
- void VControl_ProcessJoyHat (int port, int which, Uint8 value);
-
-+int VControl_GetJoyAxis(int port, int axis);
-+int VControl_GetJoysticksAmount();
-+
- /* Force the input into the blank state. For preventing "sticky" keys. */
- void VControl_ResetInput (void);
-
-Index: libs/graphics/sdl/pure.c
-===================================================================
---- libs/graphics/sdl/pure.c (revision 3778)
-+++ libs/graphics/sdl/pure.c (working copy)
-@@ -20,6 +20,10 @@
- #include "scalers.h"
- #include "libs/log.h"
-
-+#ifdef ANDROID
-+#include
-+#endif
-+
- static SDL_Surface *fade_color_surface = NULL;
- static SDL_Surface *fade_temp = NULL;
- static SDL_Surface *scaled_display = NULL;
-@@ -104,6 +108,7 @@
- {
- int i, videomode_flags;
- SDL_PixelFormat conv_fmt;
-+ int BPP = 32;
-
- GraphicsDriver = driver;
-
-@@ -128,6 +133,28 @@
- "under pure SDL, using 640x480", width, height);
- }
-
-+#ifdef ANDROID
-+ videomode_flags = SDL_SWSURFACE;
-+ ScreenWidthActual = 320;
-+ ScreenHeightActual = 240;
-+ graphics_backend = &pure_unscaled_backend;
-+ BPP = 16;
-+ /* Make the on-screen buttons slightly overlap, so we can hit them with one finger */
-+ SDL_Rect b0;
-+ SDL_ANDROID_GetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &b0);
-+ b0.x -= b0.w * 0.2;
-+ b0.y -= b0.w * 0.2;
-+ b0.h += b0.w * 0.2;
-+ b0.w += b0.w * 0.2;
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &b0);
-+ SDL_ANDROID_GetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &b0);
-+ b0.x -= b0.w * 0.2;
-+ b0.y -= b0.w * 0.2;
-+ b0.h += b0.w * 0.2;
-+ b0.w += b0.w * 0.2;
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &b0);
-+#endif
-+
- videomode_flags |= SDL_ANYFORMAT;
- if (flags & TFB_GFXFLAGS_FULLSCREEN)
- videomode_flags |= SDL_FULLSCREEN;
-@@ -135,7 +162,7 @@
- /* We'll ask for a 32bpp frame, but it doesn't really matter, because we've set
- SDL_ANYFORMAT */
- SDL_Video = SDL_SetVideoMode (ScreenWidthActual, ScreenHeightActual,
-- 32, videomode_flags);
-+ BPP, videomode_flags);
-
- if (SDL_Video == NULL)
- {
-Index: libs/log/msgbox_stub.c
-===================================================================
---- libs/log/msgbox_stub.c (revision 3778)
-+++ libs/log/msgbox_stub.c (working copy)
-@@ -16,6 +16,9 @@
-
- #include "msgbox.h"
- #include "loginternal.h"
-+#ifdef ANDROID
-+#include
-+#endif
-
- void
- log_displayBox (const /*UTF-8*/char *title, int isError,
-@@ -26,6 +29,9 @@
- // So just inform the user of our predicament
- fprintf (streamOut, "Do not know how to display %s box\n",
- isError ? "an error" : "a");
-+#ifdef ANDROID
-+ __android_log_print( isError ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO, "Ur-Quan Masters", "%s: %s", title, msg );
-+#endif
-
- // Suppress the compiler warnings in any case.
- (void)title;
-Index: libs/log/msgbox_win.c
-===================================================================
---- libs/log/msgbox_win.c (revision 3778)
-+++ libs/log/msgbox_win.c (working copy)
-@@ -14,6 +14,7 @@
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-+#ifndef ANDROID
- #include "msgbox.h"
- #define WIN32_LEAN_AND_MEAN
- #include
-@@ -64,4 +65,4 @@
- free (swTitle);
- free (swMsg);
- }
--
-+#endif
-Index: libs/log/uqmlog.c
-===================================================================
---- libs/log/uqmlog.c (revision 3778)
-+++ libs/log/uqmlog.c (working copy)
-@@ -23,6 +23,9 @@
- #include
- #include
- #include
-+#ifdef ANDROID
-+#include
-+#endif
- #include "libs/threadlib.h"
-
- #ifndef MAX_LOG_ENTRY_SIZE
-@@ -191,6 +194,9 @@
- if ((int)level <= maxStreamLevel)
- {
- fprintf (streamOut, "%s\n", full_msg);
-+#ifdef ANDROID
-+ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg );
-+#endif
- }
-
- if ((int)level <= maxLevel)
-@@ -227,6 +233,9 @@
- if ((int)level <= maxStreamLevel)
- {
- fprintf (streamOut, "%s\n", full_msg);
-+#ifdef ANDROID
-+ __android_log_print( ANDROID_LOG_INFO, "Ur-Quan Masters", "%s", full_msg );
-+#endif
- }
-
- if ((int)level <= maxLevel)
-Index: libs/resource/filecntl.c
-===================================================================
---- libs/resource/filecntl.c (revision 3778)
-+++ libs/resource/filecntl.c (working copy)
-@@ -26,6 +26,7 @@
- #include "port.h"
- #include "resintrn.h"
- #include "libs/uio.h"
-+#include "libs/log.h"
-
- uio_Stream *
- res_OpenResFile (uio_DirHandle *dir, const char *filename, const char *mode)
-@@ -34,7 +35,10 @@
- struct stat sb;
-
- if (uio_stat (dir, filename, &sb) == 0 && S_ISDIR(sb.st_mode))
-+ {
-+ log_add (log_Debug, "res_OpenResFile('%s', '%s') - cannot open dir as file", filename, mode);
- return ((uio_Stream *) ~0);
-+ }
-
- fp = uio_fopen (dir, filename, mode);
-
+ default:
+ #ifdef DEBUG
+ fprintf(stderr, "Debug: Extra field 0x%04x unsupported, "
Index: config_unix.h
===================================================================
--- config_unix.h (revision 0)
-+++ config_unix.h (revision 0)
-@@ -0,0 +1,67 @@
++++ config_unix.h (working copy)
+@@ -0,0 +1,63 @@
+/* This file contains some compile-time configuration options for *nix
+ * systems.
+ * config_unix.h is generated from config_unix.h.in by build.sh
+ * When building on MS Windows using build.sh (MinGW, Cygwin),
+ * config_win.h is generated from src/config_win.h.in.
-+ * When using MSVC on MS Windows, you'll have to edit src/msvc++/config.h
++ * When using MSVC on MS Windows, you'll have to edit src/config_vc6.h
+ * manually if you want anything else than the defaults.
+ */
+
@@ -878,403 +518,44 @@ Index: config_unix.h
+#define SAVEDIR "save/"
+
+/* Defined if words are stored with the most significant byte first */
-+#ifdef __ARMEL__
+#undef WORDS_BIGENDIAN
-+#endif
+
+/* Defined if your system has readdir_r of its own */
-+#define HAVE_READDIR_R 1
++#define HAVE_READDIR_R
+
+/* Defined if your system has setenv of its own */
-+#ifndef HAVE_SETENV
-+#define HAVE_SETENV 1
-+#endif
++#define HAVE_SETENV
+
+/* Defined if your system has strupr of its own */
+#undef HAVE_STRUPR
+
+/* Defined if your system has strcasecmp of its own */
-+#define HAVE_STRCASECMP_UQM 1
++#define HAVE_STRCASECMP_UQM
+ // Not using "HAVE_STRCASECMP" as that conflicts with SDL.
+
+/* Defined if your system has stricmp of its own */
+#undef HAVE_STRICMP
+
+/* Defined if your system has getopt_long */
-+#define HAVE_GETOPT_LONG 1
++#define HAVE_GETOPT_LONG
+
+/* Defined if your system has iswgraph of its own*/
-+#define HAVE_ISWGRAPH 1
++#define HAVE_ISWGRAPH
+
+/* Defined if your system has wchar_t of its own */
-+#define HAVE_WCHAR_T 1
++#define HAVE_WCHAR_T
+
+/* Defined if your system has wint_t of its own */
-+#define HAVE_WINT_T 1
++#define HAVE_WINT_T
+
+/* Defined if your system has _Bool of its own */
-+#define HAVE__BOOL 1
++#define HAVE__BOOL
+
+#endif /* _CONFIG_UNIX_H */
+
-Index: uqm/comm/spathi/spathic.c
-===================================================================
---- uqm/comm/spathi/spathic.c (revision 3778)
-+++ uqm/comm/spathi/spathic.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../spathi/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/pkunk/pkunkc.c
-===================================================================
---- uqm/comm/pkunk/pkunkc.c (revision 3778)
-+++ uqm/comm/pkunk/pkunkc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../pkunk/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/rebel/rebel.c
-===================================================================
---- uqm/comm/rebel/rebel.c (revision 3778)
-+++ uqm/comm/rebel/rebel.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "../yehat/resinst.h"
--#include "strings.h"
-+#include "../rebel/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/arilou/arilouc.c
-===================================================================
---- uqm/comm/arilou/arilouc.c (revision 3778)
-+++ uqm/comm/arilou/arilouc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../arilou/strings.h"
-
- #include "uqm/gameev.h"
-
-Index: uqm/comm/druuge/druugec.c
-===================================================================
---- uqm/comm/druuge/druugec.c (revision 3778)
-+++ uqm/comm/druuge/druugec.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../druuge/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/setup.h"
-Index: uqm/comm/spahome/spahome.c
-===================================================================
---- uqm/comm/spahome/spahome.c (revision 3778)
-+++ uqm/comm/spahome/spahome.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "../spathi/resinst.h"
--#include "strings.h"
-+#include "../spahome/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/starbas/starbas.c
-===================================================================
---- uqm/comm/starbas/starbas.c (revision 3778)
-+++ uqm/comm/starbas/starbas.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "../comandr/resinst.h"
--#include "strings.h"
-+#include "../starbas/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/setup.h"
-Index: uqm/comm/utwig/utwigc.c
-===================================================================
---- uqm/comm/utwig/utwigc.c (revision 3778)
-+++ uqm/comm/utwig/utwigc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../utwig/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/umgah/umgahc.c
-===================================================================
---- uqm/comm/umgah/umgahc.c (revision 3778)
-+++ uqm/comm/umgah/umgahc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../umgah/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/talkpet/talkpet.c
-===================================================================
---- uqm/comm/talkpet/talkpet.c (revision 3778)
-+++ uqm/comm/talkpet/talkpet.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../talkpet/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/syreen/syreenc.c
-===================================================================
---- uqm/comm/syreen/syreenc.c (revision 3778)
-+++ uqm/comm/syreen/syreenc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../syreen/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/setup.h"
-Index: uqm/comm/slyland/slyland.c
-===================================================================
---- uqm/comm/slyland/slyland.c (revision 3778)
-+++ uqm/comm/slyland/slyland.c (working copy)
-@@ -16,10 +16,10 @@
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-+#include "../slyland/strings.h"
-+#include
- #include "../commall.h"
--#include
- #include "resinst.h"
--#include "strings.h"
-
- #include "options.h"
- #include "uqm/battle.h"
-Index: uqm/comm/chmmr/chmmrc.c
-===================================================================
---- uqm/comm/chmmr/chmmrc.c (revision 3778)
-+++ uqm/comm/chmmr/chmmrc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../chmmr/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/hyper.h"
-Index: uqm/comm/thradd/thraddc.c
-===================================================================
---- uqm/comm/thradd/thraddc.c (revision 3778)
-+++ uqm/comm/thradd/thraddc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../thradd/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/melnorm/melnorm.c
-===================================================================
---- uqm/comm/melnorm/melnorm.c (revision 3778)
-+++ uqm/comm/melnorm/melnorm.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../melnorm/strings.h"
-
- #include "uqm/gameev.h"
- #include "uqm/shipcont.h"
-Index: uqm/comm/orz/orzc.c
-===================================================================
---- uqm/comm/orz/orzc.c (revision 3778)
-+++ uqm/comm/orz/orzc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../orz/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/ilwrath/ilwrathc.c
-===================================================================
---- uqm/comm/ilwrath/ilwrathc.c (revision 3778)
-+++ uqm/comm/ilwrath/ilwrathc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../ilwrath/strings.h"
-
- #include "uqm/gameev.h"
-
-Index: uqm/comm/yehat/yehatc.c
-===================================================================
---- uqm/comm/yehat/yehatc.c (revision 3778)
-+++ uqm/comm/yehat/yehatc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../yehat/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/urquan/urquanc.c
-===================================================================
---- uqm/comm/urquan/urquanc.c (revision 3778)
-+++ uqm/comm/urquan/urquanc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../urquan/strings.h"
-
- static LOCDATA urquan_desc =
- {
-Index: uqm/comm/supox/supoxc.c
-===================================================================
---- uqm/comm/supox/supoxc.c (revision 3778)
-+++ uqm/comm/supox/supoxc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../supox/strings.h"
-
- #include "uqm/build.h"
-
-Index: uqm/comm/slyhome/slyhome.c
-===================================================================
---- uqm/comm/slyhome/slyhome.c (revision 3778)
-+++ uqm/comm/slyhome/slyhome.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../slyhome/strings.h"
-
- #include "uqm/gameev.h"
-
-Index: uqm/comm/zoqfot/zoqfotc.c
-===================================================================
---- uqm/comm/zoqfot/zoqfotc.c (revision 3778)
-+++ uqm/comm/zoqfot/zoqfotc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../zoqfot/strings.h"
-
- #include "uqm/build.h"
- #include "uqm/gameev.h"
-Index: uqm/comm/vux/vuxc.c
-===================================================================
---- uqm/comm/vux/vuxc.c (revision 3778)
-+++ uqm/comm/vux/vuxc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../vux/strings.h"
-
- static LOCDATA vux_desc =
- {
-Index: uqm/comm/blackur/blackurc.c
-===================================================================
---- uqm/comm/blackur/blackurc.c (revision 3778)
-+++ uqm/comm/blackur/blackurc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../blackur/strings.h"
-
- static LOCDATA blackurq_desc =
- {
-Index: uqm/comm/comandr/comandr.c
-===================================================================
---- uqm/comm/comandr/comandr.c (revision 3778)
-+++ uqm/comm/comandr/comandr.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../comandr/strings.h"
-
- #include "uqm/setup.h"
- #include "uqm/sis.h"
-Index: uqm/comm/shofixt/shofixt.c
-===================================================================
---- uqm/comm/shofixt/shofixt.c (revision 3778)
-+++ uqm/comm/shofixt/shofixt.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../shofixt/strings.h"
-
- #include "uqm/gameev.h"
-
-Index: uqm/comm/mycon/myconc.c
-===================================================================
---- uqm/comm/mycon/myconc.c (revision 3778)
-+++ uqm/comm/mycon/myconc.c (working copy)
-@@ -18,7 +18,7 @@
-
- #include "../commall.h"
- #include "resinst.h"
--#include "strings.h"
-+#include "../mycon/strings.h"
-
- #include "uqm/gameev.h"
- #include "libs/mathlib.h"
Index: uqm/confirm.c
===================================================================
---- uqm/confirm.c (revision 3778)
+--- uqm/confirm.c (revision 3779)
+++ uqm/confirm.c (working copy)
@@ -36,22 +36,29 @@
#define CONFIRM_WIN_HEIGHT 22
@@ -1406,26 +687,9 @@ Index: uqm/confirm.c
ExitRequested = FALSE;
GamePaused = FALSE;
FlushInput ();
-Index: uqm/intel.c
-===================================================================
---- uqm/intel.c (revision 3778)
-+++ uqm/intel.c (working copy)
-@@ -45,10 +45,10 @@
- // Allow a player to warp-escape in cyborg mode
- if (StarShipPtr->playerNr == RPG_PLAYER_NUM)
- InputState |= CurrentInputToBattleInput (
-- context->playerNr) & BATTLE_ESCAPE;
-+ context->playerNr, -1) & BATTLE_ESCAPE;
- }
- else
-- InputState = CurrentInputToBattleInput (context->playerNr);
-+ InputState = CurrentInputToBattleInput (context->playerNr, -1);
- }
- else if (!(PlayerControl[context->playerNr] & PSYTRON_CONTROL))
- InputState = 0;
Index: uqm/battle.c
===================================================================
---- uqm/battle.c (revision 3778)
+--- uqm/battle.c (revision 3779)
+++ uqm/battle.c (working copy)
@@ -16,6 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -1470,9 +734,56 @@ Index: uqm/battle.c
}
}
+Index: uqm/intel.c
+===================================================================
+--- uqm/intel.c (revision 3779)
++++ uqm/intel.c (working copy)
+@@ -45,10 +45,10 @@
+ // Allow a player to warp-escape in cyborg mode
+ if (StarShipPtr->playerNr == RPG_PLAYER_NUM)
+ InputState |= CurrentInputToBattleInput (
+- context->playerNr) & BATTLE_ESCAPE;
++ context->playerNr, -1) & BATTLE_ESCAPE;
+ }
+ else
+- InputState = CurrentInputToBattleInput (context->playerNr);
++ InputState = CurrentInputToBattleInput (context->playerNr, -1);
+ }
+ else if (!(PlayerControl[context->playerNr] & PSYTRON_CONTROL))
+ InputState = 0;
+Index: uqm/controls.h
+===================================================================
+--- uqm/controls.h (revision 3779)
++++ uqm/controls.h (working copy)
+@@ -90,13 +90,14 @@
+ #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5))
+ #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6))
+
+-BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player);
++BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */);
+ BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player);
+
+ extern CONTROLLER_INPUT_STATE CurrentInputState;
+ extern CONTROLLER_INPUT_STATE PulsedInputState;
+ extern volatile CONTROLLER_INPUT_STATE ImmediateInputState;
+ extern CONTROL_TEMPLATE PlayerControls[];
++extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu;
+
+ void UpdateInputState (void);
+ extern void FlushInput (void);
+@@ -116,6 +117,9 @@
+ BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput);
+ BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput);
+
++/* TODO: only joystick #0 and player #0 supported currently */
++extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction);
++
+ void DoPopupWindow(const char *msg);
+
+ typedef void (InputFrameCallback) (void);
Index: uqm/planets/solarsys.c
===================================================================
---- uqm/planets/solarsys.c (revision 3778)
+--- uqm/planets/solarsys.c (revision 3779)
+++ uqm/planets/solarsys.c (working copy)
@@ -837,18 +837,19 @@
static void
@@ -1506,60 +817,9 @@ Index: uqm/planets/solarsys.c
if (pSolarSysState->turn_counter)
--pSolarSysState->turn_counter;
else if (delta_x)
-Index: uqm/planets/pstarmap.c
-===================================================================
---- uqm/planets/pstarmap.c (revision 3778)
-+++ uqm/planets/pstarmap.c (working copy)
-@@ -44,7 +44,12 @@
-
- #include
-
-+#ifdef ANDROID
-+#include
-+#include
-+#endif
-
-+
- static POINT cursorLoc;
- static POINT mapOrigin;
- static int zoomLevel;
-@@ -1572,6 +1577,18 @@
- RECT clip_r;
- CONTEXT OldContext;
-
-+#ifdef ANDROID
-+ /* Show zoom in/out buttons */
-+ SDL_Rect btn;
-+ // SDL_ListModes()[0]->w SDL_ListModes()[0]->h
-+ SDL_ANDROID_GetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &btn);
-+ btn.y -= btn.h;
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &btn);
-+ SDL_ANDROID_GetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &btn);
-+ btn.y -= btn.h;
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &btn);
-+#endif
-+
- memset (&MenuState, 0, sizeof (MenuState));
-
- zoomLevel = 0;
-@@ -1625,6 +1642,14 @@
- && GLOBAL (autopilot.y) == universe.y)
- GLOBAL (autopilot.x) = GLOBAL (autopilot.y) = ~0;
-
-+#ifdef ANDROID
-+ /* Hide zoom in/out buttons */
-+ btn.w = 0;
-+ btn.h = 0;
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &btn);
-+ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &btn);
-+#endif
-+
- return (GLOBAL (autopilot.x) != ~0
- && GLOBAL (autopilot.y) != ~0);
- }
Index: uqm/planets/lander.c
===================================================================
---- uqm/planets/lander.c (revision 3778)
+--- uqm/planets/lander.c (revision 3779)
+++ uqm/planets/lander.c (working copy)
@@ -1591,15 +1591,15 @@
if (crew_left)
@@ -1591,7 +851,7 @@ Index: uqm/planets/lander.c
dy = 0;
Index: uqm/setupmenu.c
===================================================================
---- uqm/setupmenu.c (revision 3778)
+--- uqm/setupmenu.c (revision 3779)
+++ uqm/setupmenu.c (working copy)
@@ -75,7 +75,7 @@
#endif
@@ -1661,7 +921,7 @@ Index: uqm/setupmenu.c
res_PutBoolean ("config.pulseshield", opts->shield == OPTVAL_3DO);
Index: uqm/setupmenu.h
===================================================================
---- uqm/setupmenu.h (revision 3778)
+--- uqm/setupmenu.h (revision 3779)
+++ uqm/setupmenu.h (working copy)
@@ -81,6 +81,7 @@
OPT_ENABLABLE fullscreen, subtitles, scanlines, fps, stereo;
@@ -1671,39 +931,9 @@ Index: uqm/setupmenu.h
OPT_CONSOLETYPE menu, text, cscan, scroll, intro, meleezoom, shield;
CONTROL_TEMPLATE player1, player2;
int speechvol, musicvol, sfxvol;
-Index: uqm/controls.h
-===================================================================
---- uqm/controls.h (revision 3778)
-+++ uqm/controls.h (working copy)
-@@ -90,13 +90,14 @@
- #define BATTLE_ESCAPE ((BATTLE_INPUT_STATE)(1 << 5))
- #define BATTLE_DOWN ((BATTLE_INPUT_STATE)(1 << 6))
-
--BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player);
-+BATTLE_INPUT_STATE CurrentInputToBattleInput (COUNT player, int direction /* = -1 for no directional input */);
- BATTLE_INPUT_STATE PulsedInputToBattleInput (COUNT player);
-
- extern CONTROLLER_INPUT_STATE CurrentInputState;
- extern CONTROLLER_INPUT_STATE PulsedInputState;
- extern volatile CONTROLLER_INPUT_STATE ImmediateInputState;
- extern CONTROL_TEMPLATE PlayerControls[];
-+extern BOOLEAN EmergencyEscapeWarpUnitActivatedFromMenu;
-
- void UpdateInputState (void);
- extern void FlushInput (void);
-@@ -116,6 +117,9 @@
- BOOLEAN WaitForNoInput (TimePeriod duration, BOOLEAN resetInput);
- BOOLEAN WaitForNoInputUntil (TimeCount timeOut, BOOLEAN resetInput);
-
-+/* TODO: only joystick #0 and player #0 supported currently */
-+extern BATTLE_INPUT_STATE GetDirectionalJoystickInput(int direction);
-+
- void DoPopupWindow(const char *msg);
-
- typedef void (InputFrameCallback) (void);
Index: uqm/gameinp.c
===================================================================
---- uqm/gameinp.c (revision 3778)
+--- uqm/gameinp.c (revision 3779)
+++ uqm/gameinp.c (working copy)
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -1864,50 +1094,364 @@ Index: uqm/gameinp.c
+ }
+ return InputState;
+}
-Index: regex/regex.c
+Index: uqm/comm/urquan/urquanc.c
===================================================================
---- regex/regex.c (revision 3778)
-+++ regex/regex.c (working copy)
-@@ -24,6 +24,7 @@
+--- uqm/comm/urquan/urquanc.c (revision 3779)
++++ uqm/comm/urquan/urquanc.c (working copy)
+@@ -18,7 +18,7 @@
- #include "port.h"
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../urquan/strings.h"
-+#ifndef ANDROID
- #ifdef _AIX
- #pragma alloca
- #else
-@@ -47,9 +48,11 @@
- # endif
- # endif
- #endif
-+#endif
+ static LOCDATA urquan_desc =
+ {
+Index: uqm/comm/supox/supoxc.c
+===================================================================
+--- uqm/comm/supox/supoxc.c (revision 3779)
++++ uqm/comm/supox/supoxc.c (working copy)
+@@ -18,7 +18,7 @@
- #ifdef _LIBC
- /* We have to keep the namespace clean. */
-+/*
- # define regfree(preg) __regfree (preg)
- # define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
- # define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
-@@ -69,6 +72,7 @@
- # define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
- __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
- # define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
-+*/
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../supox/strings.h"
- # include "../locale/localeinfo.h"
- #endif
-@@ -82,7 +86,7 @@
- #undefs RE_DUP_MAX and sets it to the right value. */
- #include
+ #include "uqm/build.h"
--#include
-+#include "uqm_regex.h"
- #include "regex_internal.h"
+Index: uqm/comm/vux/vuxc.c
+===================================================================
+--- uqm/comm/vux/vuxc.c (revision 3779)
++++ uqm/comm/vux/vuxc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../vux/strings.h"
+
+ static LOCDATA vux_desc =
+ {
+Index: uqm/comm/shofixt/shofixt.c
+===================================================================
+--- uqm/comm/shofixt/shofixt.c (revision 3779)
++++ uqm/comm/shofixt/shofixt.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../shofixt/strings.h"
+
+ #include "uqm/gameev.h"
+
+Index: uqm/comm/pkunk/pkunkc.c
+===================================================================
+--- uqm/comm/pkunk/pkunkc.c (revision 3779)
++++ uqm/comm/pkunk/pkunkc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../pkunk/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/spathi/spathic.c
+===================================================================
+--- uqm/comm/spathi/spathic.c (revision 3779)
++++ uqm/comm/spathi/spathic.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../spathi/strings.h"
+
+ #include "uqm/build.h"
+
+Index: uqm/comm/rebel/rebel.c
+===================================================================
+--- uqm/comm/rebel/rebel.c (revision 3779)
++++ uqm/comm/rebel/rebel.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "../yehat/resinst.h"
+-#include "strings.h"
++#include "../rebel/strings.h"
+
+ #include "uqm/build.h"
+
+Index: uqm/comm/druuge/druugec.c
+===================================================================
+--- uqm/comm/druuge/druugec.c (revision 3779)
++++ uqm/comm/druuge/druugec.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../druuge/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/setup.h"
+Index: uqm/comm/spahome/spahome.c
+===================================================================
+--- uqm/comm/spahome/spahome.c (revision 3779)
++++ uqm/comm/spahome/spahome.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "../spathi/resinst.h"
+-#include "strings.h"
++#include "../spahome/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/starbas/starbas.c
+===================================================================
+--- uqm/comm/starbas/starbas.c (revision 3779)
++++ uqm/comm/starbas/starbas.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "../comandr/resinst.h"
+-#include "strings.h"
++#include "../starbas/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/setup.h"
+Index: uqm/comm/utwig/utwigc.c
+===================================================================
+--- uqm/comm/utwig/utwigc.c (revision 3779)
++++ uqm/comm/utwig/utwigc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../utwig/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/umgah/umgahc.c
+===================================================================
+--- uqm/comm/umgah/umgahc.c (revision 3779)
++++ uqm/comm/umgah/umgahc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../umgah/strings.h"
+
+ #include "uqm/build.h"
+
+Index: uqm/comm/talkpet/talkpet.c
+===================================================================
+--- uqm/comm/talkpet/talkpet.c (revision 3779)
++++ uqm/comm/talkpet/talkpet.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../talkpet/strings.h"
+
+ #include "uqm/build.h"
+
+Index: uqm/comm/syreen/syreenc.c
+===================================================================
+--- uqm/comm/syreen/syreenc.c (revision 3779)
++++ uqm/comm/syreen/syreenc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../syreen/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/setup.h"
+Index: uqm/comm/melnorm/melnorm.c
+===================================================================
+--- uqm/comm/melnorm/melnorm.c (revision 3779)
++++ uqm/comm/melnorm/melnorm.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../melnorm/strings.h"
+
+ #include "uqm/gameev.h"
+ #include "uqm/shipcont.h"
+Index: uqm/comm/yehat/yehatc.c
+===================================================================
+--- uqm/comm/yehat/yehatc.c (revision 3779)
++++ uqm/comm/yehat/yehatc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../yehat/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/orz/orzc.c
+===================================================================
+--- uqm/comm/orz/orzc.c (revision 3779)
++++ uqm/comm/orz/orzc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../orz/strings.h"
+
+ #include "uqm/build.h"
+
+Index: uqm/comm/slyhome/slyhome.c
+===================================================================
+--- uqm/comm/slyhome/slyhome.c (revision 3779)
++++ uqm/comm/slyhome/slyhome.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../slyhome/strings.h"
+
+ #include "uqm/gameev.h"
+
+Index: uqm/comm/zoqfot/zoqfotc.c
+===================================================================
+--- uqm/comm/zoqfot/zoqfotc.c (revision 3779)
++++ uqm/comm/zoqfot/zoqfotc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../zoqfot/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/blackur/blackurc.c
+===================================================================
+--- uqm/comm/blackur/blackurc.c (revision 3779)
++++ uqm/comm/blackur/blackurc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../blackur/strings.h"
+
+ static LOCDATA blackurq_desc =
+ {
+Index: uqm/comm/comandr/comandr.c
+===================================================================
+--- uqm/comm/comandr/comandr.c (revision 3779)
++++ uqm/comm/comandr/comandr.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../comandr/strings.h"
+
+ #include "uqm/setup.h"
+ #include "uqm/sis.h"
+Index: uqm/comm/mycon/myconc.c
+===================================================================
+--- uqm/comm/mycon/myconc.c (revision 3779)
++++ uqm/comm/mycon/myconc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../mycon/strings.h"
+
+ #include "uqm/gameev.h"
+ #include "libs/mathlib.h"
+Index: uqm/comm/arilou/arilouc.c
+===================================================================
+--- uqm/comm/arilou/arilouc.c (revision 3779)
++++ uqm/comm/arilou/arilouc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../arilou/strings.h"
+
+ #include "uqm/gameev.h"
+
+Index: uqm/comm/slyland/slyland.c
+===================================================================
+--- uqm/comm/slyland/slyland.c (revision 3779)
++++ uqm/comm/slyland/slyland.c (working copy)
+@@ -16,10 +16,10 @@
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
++#include "../slyland/strings.h"
++#include
+ #include "../commall.h"
+-#include
+ #include "resinst.h"
+-#include "strings.h"
+
+ #include "options.h"
+ #include "uqm/battle.h"
+Index: uqm/comm/thradd/thraddc.c
+===================================================================
+--- uqm/comm/thradd/thraddc.c (revision 3779)
++++ uqm/comm/thradd/thraddc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../thradd/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/gameev.h"
+Index: uqm/comm/chmmr/chmmrc.c
+===================================================================
+--- uqm/comm/chmmr/chmmrc.c (revision 3779)
++++ uqm/comm/chmmr/chmmrc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../chmmr/strings.h"
+
+ #include "uqm/build.h"
+ #include "uqm/hyper.h"
+Index: uqm/comm/ilwrath/ilwrathc.c
+===================================================================
+--- uqm/comm/ilwrath/ilwrathc.c (revision 3779)
++++ uqm/comm/ilwrath/ilwrathc.c (working copy)
+@@ -18,7 +18,7 @@
+
+ #include "../commall.h"
+ #include "resinst.h"
+-#include "strings.h"
++#include "../ilwrath/strings.h"
+
+ #include "uqm/gameev.h"
- #include "regex_internal.ci"
Index: options.c
===================================================================
---- options.c (revision 3778)
+--- options.c (revision 3779)
+++ options.c (working copy)
@@ -50,6 +50,7 @@
int optWhichShield;
@@ -1925,3 +1469,51 @@ Index: options.c
if (uio_mountDir (repository, mountPoint, uio_FSTYPE_ZIP,
dirHandle, dirList->names[i], "/", autoMount,
relativeFlags | uio_MOUNT_RDONLY,
+Index: options.h
+===================================================================
+--- options.h (revision 3779)
++++ options.h (working copy)
+@@ -41,6 +41,7 @@
+ extern int optWhichShield;
+ extern int optSmoothScroll;
+ extern int optMeleeScale;
++extern int optDirectionalJoystick;
+
+ extern BOOLEAN opt3doMusic;
+ extern BOOLEAN optRemixMusic;
+Index: uqm.c
+===================================================================
+--- uqm.c (revision 3779)
++++ uqm.c (working copy)
+@@ -129,6 +129,7 @@
+ DECL_CONFIG_OPTION(float, sfxVolumeScale);
+ DECL_CONFIG_OPTION(float, speechVolumeScale);
+ DECL_CONFIG_OPTION(bool, safeMode);
++ DECL_CONFIG_OPTION(bool, directionalJoystick);
+
+ #define INIT_CONFIG_OPTION(name, val) \
+ { val, false }
+@@ -263,6 +264,7 @@
+ INIT_CONFIG_OPTION( sfxVolumeScale, 1.0f ),
+ INIT_CONFIG_OPTION( speechVolumeScale, 1.0f ),
+ INIT_CONFIG_OPTION( safeMode, false ),
++ INIT_CONFIG_OPTION( directionalJoystick, true ),
+ };
+ struct options_struct defaults = options;
+ int optionsResult;
+@@ -390,6 +392,7 @@
+ sfxVolumeScale = options.sfxVolumeScale.value;
+ speechVolumeScale = options.speechVolumeScale.value;
+ optAddons = options.addons;
++ optDirectionalJoystick = options.directionalJoystick.value;
+
+ prepareContentDir (options.contentDir, options.addonDir, argv[0]);
+ prepareMeleeDir ();
+@@ -637,6 +640,7 @@
+ getBoolConfigValue (&options->fullscreen, "config.fullscreen");
+ getBoolConfigValue (&options->scanlines, "config.scanlines");
+ getBoolConfigValue (&options->showFps, "config.showfps");
++ getBoolConfigValue (&options->directionalJoystick, "config.directionaljoystick");
+ getBoolConfigValue (&options->keepAspectRatio, "config.keepaspectratio");
+ getGammaConfigValue (&options->gamma, "config.gamma");
+
diff --git a/project/jni/application/sc2/src b/project/jni/application/sc2/src
deleted file mode 120000
index fc5d6d0d1..000000000
--- a/project/jni/application/sc2/src
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../sc2/sc2/src/
\ No newline at end of file
diff --git a/project/jni/application/vcmi/Makefile b/project/jni/application/vcmi/Makefile
index 85bc5a3e3..e353f6486 100644
--- a/project/jni/application/vcmi/Makefile
+++ b/project/jni/application/vcmi/Makefile
@@ -1,8 +1,15 @@
$(shell mkdir -p AI debug/AI Scripting debug/Scripting \
+<<<<<<< HEAD
out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/lib/Mapping \
out/vcmi/lib/RMG out/vcmi/server out/vcmi/AI/StupidAI \
out/vcmi/AI/GeniusAI out/vcmi/client out/vcmi/Scripting/ERM)
+=======
+ out/vcmi/lib out/vcmi/lib/Filesystem out/vcmi/server out/vcmi/AI/StupidAI \
+ out/vcmi/AI/BattleAI out/vcmi/AI/EmptyAI \
+ out/vcmi/AI/Fuzzylite out/vcmi/AI/VCAI \
+ out/vcmi/client out/vcmi/Scripting/ERM)
+>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
$(shell rm -f ../../../obj/local/armeabi/libvcmi.so)
LOCAL_PATH=$(shell dirname $0)
@@ -10,7 +17,7 @@ LOCAL_PATH=`cd $LOCAL_PATH && pwd`
GCC_PREFIX=$(if $(shell which ndk-build | grep 'android-ndk-r8'),arm-linux-androideabi,arm-eabi)
-SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
+SOURCES_LIB=$(wildcard vcmi/lib/*.cpp vcmi/lib/Filesystem/*.cpp vcmi/CConsoleHandler.cpp vcmi/CThreadHelper.cpp)
OBJS_LIB=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB))
SOURCES_LIB_FILESYSTEM=$(wildcard vcmi/lib/Filesystem/*.cpp)
@@ -25,11 +32,26 @@ OBJS_LIB_RMG=$(patsubst %.cpp, out/%.o, $(SOURCES_LIB_RMG))
SOURCES_SERVER=$(wildcard vcmi/server/*.cpp)
OBJS_SERVER=$(patsubst %.cpp, out/%.o, $(SOURCES_SERVER))
+SOURCES_CLIENT=$(wildcard vcmi/client/*.cpp vcmi/client/BattleInterface/*.cpp vcmi/client/UIFramework/*.cpp)
+OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
+
+#SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
+#OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
+
+SOURCES_BATTLEAI=$(wildcard vcmi/AI/BattleAI/*.cpp)
+OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_BATTLEAI))
+
+SOURCES_EMPTYAI=$(wildcard vcmi/AI/EmptyAI/*.cpp)
+OBJS_BATTLEAI=$(patsubst %.cpp, out/%.o, $(SOURCES_EMPTYAI))
+
+SOURCES_FUZZYLITE=$(wildcard vcmi/AI/FuzzyLite/*.cpp)
+OBJS_FUZZYLITE=$(patsubst %.cpp, out/%.o, $(SOURCES_FUZZYLITE))
+
SOURCES_STUPIDAI=$(wildcard vcmi/AI/StupidAI/*.cpp)
OBJS_STUPIDAI=$(patsubst %.cpp, out/%.o, $(SOURCES_STUPIDAI))
-SOURCES_GENIUSAI=$(filter-out %/ExpertSystem.cpp, $(wildcard vcmi/AI/GeniusAI/*.cpp))
-OBJS_GENIUSAI=$(patsubst %.cpp, out/%.o, $(SOURCES_GENIUSAI))
+SOURCES_VCAI=$(wildcard vcmi/AI/VCAI/*.cpp)
+OBJS_VCAI=$(patsubst %.cpp, out/%.o, $(SOURCES_VCAI))
SOURCES_ERM=$(wildcard vcmi/Scripting/ERM/*.cpp)
OBJS_ERM=$(patsubst %.cpp, out/%.o, $(SOURCES_ERM))
@@ -39,11 +61,15 @@ OBJS_CLIENT=$(patsubst %.cpp, out/%.o, $(SOURCES_CLIENT))
all: AndroidData/binaries.zip libapplication.so
-AndroidData/binaries.zip: vcmiserver AI/libGeniusAI.so AI/libStupidAI.so Scripting/libvcmiERM.so
+AndroidData/binaries.zip: vcmiserver AI/libAI.so Scripting/libvcmiERM.so
rm -f $@
zip -r $@ $^
+<<<<<<< HEAD
$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING) $(OBJS_LIB_RMG) $(OBJS_GENIUSAI) $(OBJS_STUPIDAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
+=======
+$(OBJS_SERVER) $(OBJS_LIB) $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) $(OBJS_CLIENT) $(OBJS_ERM): out/%.o: %.cpp
+>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
../setEnvironment.sh sh -c \
"$(GCC_PREFIX)-g++ \
-c \$$CXXFLAGS -Ivcmi -std=c++11 -Ivcmi/lib \
@@ -59,8 +85,13 @@ vcmiserver: $(OBJS_SERVER) $(OBJS_LIB) $(OBJS_LIB_FILESYSTEM) $(OBJS_LIB_MAPPING
env BUILD_EXECUTABLE=1 NO_SHARED_LIBS=1 ../setEnvironment.sh sh -c \
"$(GCC_PREFIX)-g++ \
$^ -o $@ \
+<<<<<<< HEAD
\$$LDFLAGS -L. -L../../boost/lib/arm-linux-androideabi-4.6 \
-lboost_filesystem -lboost_iostreams -lboost_system -lboost_thread -lgnustl_static" && \
+=======
+ \$$LDFLAGS -L. \
+ -lboost_system -lboost_filesystem -lboost_iostreams -lboost_thread" && \
+>>>>>>> 2986a60b94e08c9946f3b29f2598b4eb0a53a8b0
cp $@ debug/$@ && \
$(GCC_PREFIX)-strip $@
@@ -76,10 +107,7 @@ LINK_LIB= \
.PHONY: -lvcmi
-lvcmi: libvcmi.so
-AI/libGeniusAI.so: $(OBJS_GENIUSAI) -lvcmi
- $(LINK_LIB)
-
-AI/libStupidAI.so: $(OBJS_STUPIDAI) -lvcmi
+AI/libAI.so: $(OBJS_BATTLEAI) $(OBJS_EMPTYAI) $(OBJS_FUZZYLITE) $(OBJS_STUPIDAI) $(OBJS_VCAI) -lvcmi
$(LINK_LIB)
Scripting/libvcmiERM.so: $(OBJS_ERM) -lvcmi
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c
new file mode 100644
index 000000000..3e7a9f3c5
--- /dev/null
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c
@@ -0,0 +1,592 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2009 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include
+#include
+#include
+#include
+#include
+#include
+#include // for memset()
+
+#include "SDL_config.h"
+
+#include "SDL_version.h"
+#include "SDL_mutex.h"
+#include "SDL_events.h"
+#if SDL_VERSION_ATLEAST(1,3,0)
+#include "SDL_touch.h"
+#include "../../events/SDL_touch_c.h"
+#endif
+
+#include "../SDL_sysvideo.h"
+#include "SDL_androidvideo.h"
+#include "SDL_androidinput.h"
+#include "unicodestuff.h"
+#include "atan2i.h"
+
+
+#ifdef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
+
+// This code is left here to rot - it's bad, complicated and needed by only one applicaiton
+
+#if SDL_VERSION_ATLEAST(1,3,0)
+
+#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
+extern SDL_Window * ANDROID_CurrentWindow;
+
+#else
+
+#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
+#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
+#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
+
+#endif
+
+enum { MAX_BUFFERED_EVENTS = 64 };
+static SDL_Event BufferedEvents[MAX_BUFFERED_EVENTS];
+static int BufferedEventsStart = 0, BufferedEventsEnd = 0;
+static SDL_mutex * BufferedEventsMutex = NULL;
+
+/* We need our own event queue, because Free Heroes 2 game uses
+ * SDL_SetEventFilter(), and it calls SDL_Flip() from inside
+ * it's custom filter function, and SDL_Flip() does not work
+ * when it's not called from the main() thread.
+ * So we, like, push the events into our own queue,
+ * read each event from that queue inside SDL_ANDROID_PumpEvents(),
+ * unlock the mutex, and push the event to SDL queue,
+ * which is then immediately read by SDL from the same thread,
+ * and then SDL invokes event filter function from FHeroes2.
+ * FHeroes2 call SDL_Flip() from inside that event filter function,
+ * and it works, because it is called from the main() thread.
+ */
+extern void SDL_ANDROID_PumpEvents()
+{
+ static int oldMouseButtons = 0;
+ SDL_Event ev;
+ SDL_ANDROID_processAndroidTrackballDampening();
+ SDL_ANDROID_processMoveMouseWithKeyboard();
+#if SDL_VERSION_ATLEAST(1,3,0)
+ SDL_Window * window = SDL_GetFocusWindow();
+ if( !window )
+ return;
+#endif
+
+ if( !BufferedEventsMutex )
+ BufferedEventsMutex = SDL_CreateMutex();
+
+ SDL_mutexP(BufferedEventsMutex);
+ while( BufferedEventsStart != BufferedEventsEnd )
+ {
+ ev = BufferedEvents[BufferedEventsStart];
+ BufferedEvents[BufferedEventsStart].type = 0;
+ BufferedEventsStart++;
+ if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
+ BufferedEventsStart = 0;
+ SDL_mutexV(BufferedEventsMutex);
+
+ switch( ev.type )
+ {
+ case SDL_MOUSEMOTION:
+ SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y );
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
+ {
+ oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
+ SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button );
+ }
+ break;
+ case SDL_KEYDOWN:
+ //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
+ SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym );
+ break;
+ case SDL_JOYAXISMOTION:
+ if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] )
+ SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value );
+ break;
+ case SDL_JOYBUTTONDOWN:
+ if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
+ SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state );
+ break;
+ case SDL_JOYBALLMOTION:
+ if( ev.jball.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
+ SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[ev.jball.which], ev.jball.ball, ev.jball.xrel, ev.jball.yrel );
+ break;
+#if SDL_VERSION_ATLEAST(1,3,0)
+ //if( ANDROID_CurrentWindow )
+ // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+#else
+ case SDL_ACTIVEEVENT:
+ SDL_PrivateAppActive(ev.active.gain, ev.active.state);
+ break;
+#endif
+#if SDL_VERSION_ATLEAST(1,3,0)
+ case SDL_FINGERMOTION:
+ SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
+ break;
+ case SDL_FINGERDOWN:
+ SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
+ break;
+ case SDL_TEXTINPUT:
+ SDL_SendKeyboardText(ev.text.text);
+ break;
+ case SDL_MOUSEWHEEL:
+ SDL_SendMouseWheel( ANDROID_CurrentWindow, ev.wheel.x, ev.wheel.y );
+ break;
+#endif
+ }
+
+ SDL_mutexP(BufferedEventsMutex);
+ }
+ SDL_mutexV(BufferedEventsMutex);
+};
+// Queue events to main thread
+static int getNextEventAndLock()
+{
+ int nextEvent;
+ if( !BufferedEventsMutex )
+ return -1;
+ SDL_mutexP(BufferedEventsMutex);
+ nextEvent = BufferedEventsEnd;
+ nextEvent++;
+ if( nextEvent >= MAX_BUFFERED_EVENTS )
+ nextEvent = 0;
+ while( nextEvent == BufferedEventsStart )
+ {
+ SDL_mutexV(BufferedEventsMutex);
+ if( SDL_ANDROID_InsideVideoThread() )
+ SDL_ANDROID_PumpEvents();
+ else
+ SDL_Delay(100);
+ SDL_mutexP(BufferedEventsMutex);
+ nextEvent = BufferedEventsEnd;
+ nextEvent++;
+ if( nextEvent >= MAX_BUFFERED_EVENTS )
+ nextEvent = 0;
+ }
+ return nextEvent;
+}
+
+static int getPrevEventNoLock()
+{
+ int prevEvent;
+ if(BufferedEventsStart == BufferedEventsEnd)
+ return -1;
+ prevEvent = BufferedEventsEnd;
+ prevEvent--;
+ if( prevEvent < 0 )
+ prevEvent = MAX_BUFFERED_EVENTS - 1;
+ return prevEvent;
+}
+
+extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
+{
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ int prevEvent = getPrevEventNoLock();
+ if( prevEvent > 0 && BufferedEvents[prevEvent].type == SDL_MOUSEMOTION )
+ {
+ // Reuse previous mouse motion event, to prevent mouse movement lag
+ BufferedEvents[prevEvent].motion.x = x;
+ BufferedEvents[prevEvent].motion.y = y;
+ }
+ else
+ {
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+ ev->type = SDL_MOUSEMOTION;
+ ev->motion.x = x;
+ ev->motion.y = y;
+ }
+ SDL_ANDROID_currentMouseX = x;
+ SDL_ANDROID_currentMouseY = y;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
+{
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_MOUSEBUTTONDOWN;
+ ev->button.state = pressed;
+ ev->button.button = button;
+
+ if(pressed)
+ SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
+ else
+ SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+
+extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
+{
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ if( SDL_ANDROID_moveMouseWithArrowKeys && (
+ key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
+ key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbX < 0 )
+ {
+ SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
+ SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
+ }
+
+ if( pressed )
+ {
+ if( key == SDL_KEY(LEFT) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
+ }
+ else if( key == SDL_KEY(RIGHT) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
+ }
+
+ if( key == SDL_KEY(UP) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
+ }
+ else if( key == SDL_KEY(DOWN) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
+ }
+ }
+ else
+ {
+ if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
+ {
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbAccelX = 0;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
+ }
+ if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
+ {
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbAccelY = 0;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
+ }
+ }
+
+ SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
+ SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
+
+ SDL_mutexV(BufferedEventsMutex);
+
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
+ return;
+ }
+
+ ev->type = SDL_KEYDOWN;
+ ev->key.state = pressed;
+ ev->key.keysym.scancode = key;
+ ev->key.keysym.sym = key;
+ ev->key.keysym.mod = KMOD_NONE;
+ ev->key.keysym.unicode = 0;
+#if SDL_VERSION_ATLEAST(1,3,0)
+#else
+ if ( SDL_TranslateUNICODE )
+#endif
+ ev->key.keysym.unicode = key;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+
+extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_JOYAXISMOTION;
+ ev->jaxis.which = joy;
+ ev->jaxis.axis = axis;
+ ev->jaxis.value = MAX( -32768, MIN( 32767, value ) );
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_JOYBUTTONDOWN;
+ ev->jbutton.which = joy;
+ ev->jbutton.button = button;
+ ev->jbutton.state = pressed;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_JOYBALLMOTION;
+ ev->jball.which = joy;
+ ev->jball.ball = ball;
+ ev->jball.xrel = x;
+ ev->jball.yrel = y;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+}
+extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_FINGERDOWN;
+ ev->tfinger.fingerId = id;
+ ev->tfinger.state = pressed;
+ ev->tfinger.x = x;
+ ev->tfinger.y = y;
+ ev->tfinger.pressure = force;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+#endif
+};
+extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_FINGERMOTION;
+ ev->tfinger.fingerId = id;
+ ev->tfinger.x = x;
+ ev->tfinger.y = y;
+ ev->tfinger.pressure = force;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+#endif
+};
+
+extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_MOUSEWHEEL;
+ ev->wheel.x = x;
+ ev->wheel.y = y;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+#endif
+}
+
+extern void SDL_ANDROID_MainThreadPushAppActive(int active)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ //if( ANDROID_CurrentWindow )
+ // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+#else
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ ev->type = SDL_ACTIVEEVENT;
+ ev->active.gain = active;
+ ev->active.state = SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS;
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+#endif
+}
+
+enum { DEFERRED_TEXT_COUNT = 256 };
+static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
+static int deferredTextIdx1 = 0;
+static int deferredTextIdx2 = 0;
+static SDL_mutex * deferredTextMutex = NULL;
+
+void SDL_ANDROID_DeferredTextInput()
+{
+ if( !deferredTextMutex )
+ deferredTextMutex = SDL_CreateMutex();
+
+ SDL_mutexP(deferredTextMutex);
+
+ if( deferredTextIdx1 != deferredTextIdx2 )
+ {
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ {
+ SDL_mutexV(deferredTextMutex);
+ return;
+ }
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+ deferredTextIdx1++;
+ if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx1 = 0;
+
+ ev->type = SDL_KEYDOWN;
+ ev->key.state = deferredText[deferredTextIdx1].down;
+ ev->key.keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+ if( SDL_ANDROID_isMouseUsed )
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
+ }
+ else
+ {
+ if( SDL_ANDROID_TextInputFinished )
+ {
+ SDL_ANDROID_TextInputFinished = 0;
+ SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
+ }
+ }
+
+ SDL_mutexV(deferredTextMutex);
+};
+
+extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
+{
+ int shiftRequired;
+
+ int nextEvent = getNextEventAndLock();
+ if( nextEvent == -1 )
+ return;
+
+ SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
+
+#if SDL_VERSION_ATLEAST(1,3,0)
+
+ ev->type = SDL_TEXTINPUT;
+ UnicodeToUtf8(unicode, ev->text.text);
+
+#endif
+
+ if( !deferredTextMutex )
+ deferredTextMutex = SDL_CreateMutex();
+
+ SDL_mutexP(deferredTextMutex);
+
+ ev->type = 0;
+
+ shiftRequired = checkShiftRequired(&ascii);
+
+ if( shiftRequired )
+ {
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_PRESSED;
+ deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
+ deferredText[deferredTextIdx2].unicode = 0;
+ }
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_PRESSED;
+ deferredText[deferredTextIdx2].scancode = ascii;
+ deferredText[deferredTextIdx2].unicode = unicode;
+
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_RELEASED;
+ deferredText[deferredTextIdx2].scancode = ascii;
+ deferredText[deferredTextIdx2].unicode = 0;
+ if( shiftRequired )
+ {
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_RELEASED;
+ deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
+ deferredText[deferredTextIdx2].unicode = 0;
+ }
+
+ SDL_mutexV(deferredTextMutex);
+
+ BufferedEventsEnd = nextEvent;
+ SDL_mutexV(BufferedEventsMutex);
+};
+
+#endif
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c
new file mode 100644
index 000000000..3cd01444b
--- /dev/null
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c
@@ -0,0 +1,342 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2009 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include
+#include
+#include
+#include
+#include
+#include
+#include // for memset()
+
+#include "SDL_config.h"
+
+#include "SDL_version.h"
+#include "SDL_mutex.h"
+#include "SDL_events.h"
+#if SDL_VERSION_ATLEAST(1,3,0)
+#include "SDL_touch.h"
+#include "../../events/SDL_touch_c.h"
+#endif
+
+#include "../SDL_sysvideo.h"
+#include "SDL_androidvideo.h"
+#include "SDL_androidinput.h"
+#include "unicodestuff.h"
+#include "atan2i.h"
+
+#ifndef SDL_COMPATIBILITY_HACKS_SLOW_COMPATIBLE_EVENT_QUEUE
+
+#if SDL_VERSION_ATLEAST(1,3,0)
+
+#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
+extern SDL_Window * ANDROID_CurrentWindow;
+
+#else
+
+#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
+#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
+#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
+
+#endif
+
+static volatile int joystickEventsCount;
+static int oldMouseButtons = 0;
+
+extern void SDL_ANDROID_PumpEvents()
+{
+ joystickEventsCount = 0;
+
+ SDL_ANDROID_processAndroidTrackballDampening();
+ SDL_ANDROID_processMoveMouseWithKeyboard();
+};
+
+extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
+{
+ SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y );
+
+ SDL_ANDROID_currentMouseX = x;
+ SDL_ANDROID_currentMouseY = y;
+}
+
+extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
+{
+ if( ((oldMouseButtons & SDL_BUTTON(button)) != 0) != pressed )
+ {
+ oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(button)) | (pressed ? SDL_BUTTON(button) : 0);
+ SDL_SendMouseButton( ANDROID_CurrentWindow, pressed, button );
+ }
+
+ if(pressed)
+ SDL_ANDROID_currentMouseButtons |= SDL_BUTTON(button);
+ else
+ SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button));
+}
+
+extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
+{
+ SDL_keysym keysym;
+
+ if( SDL_ANDROID_moveMouseWithArrowKeys && (
+ key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
+ key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbX < 0 )
+ {
+ SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
+ SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
+ }
+
+ if( pressed )
+ {
+ if( key == SDL_KEY(LEFT) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedX > 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedX -= SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelX = -SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
+ }
+ else if( key == SDL_KEY(RIGHT) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedX < 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelX = SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 1;
+ }
+
+ if( key == SDL_KEY(UP) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedY > 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY -= SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelY = -SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
+ }
+ else if( key == SDL_KEY(DOWN) )
+ {
+ if( SDL_ANDROID_moveMouseWithKbSpeedY < 0 )
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbSpeed;
+ SDL_ANDROID_moveMouseWithKbAccelY = SDL_ANDROID_moveMouseWithKbAccel;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded |= 2;
+ }
+ }
+ else
+ {
+ if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
+ {
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbAccelX = 0;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~1;
+ }
+ if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
+ {
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbAccelY = 0;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded &= ~2;
+ }
+ }
+
+ SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
+ SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
+
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
+ return;
+ }
+
+ keysym.scancode = key;
+ keysym.sym = key;
+ keysym.mod = KMOD_NONE;
+ keysym.unicode = 0;
+#if SDL_VERSION_ATLEAST(1,3,0)
+#else
+ if ( SDL_TranslateUNICODE )
+#endif
+ keysym.unicode = key;
+
+ if( pressed == SDL_RELEASED )
+ keysym.unicode = 0;
+
+ SDL_SendKeyboardKey( pressed, &keysym );
+}
+
+extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ if( joystickEventsCount > 64 )
+ {
+ //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Too many joystick events in the queue - dropping some events");
+ return;
+ }
+
+ joystickEventsCount++;
+
+ SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[joy], axis, MAX( -32768, MIN( 32767, value ) ) );
+}
+
+extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[joy], button, pressed );
+}
+
+extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
+{
+ if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
+ return;
+
+ SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[joy], ball, x, y );
+}
+
+extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ SDL_SendFingerDown(0, id, pressed ? 1 : 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
+#endif
+}
+
+extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ SDL_SendTouchMotion(0, id, 0, (float)x / (float)window->w, (float)y / (float)window->h, force);
+#endif
+}
+
+extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ SDL_SendMouseWheel( ANDROID_CurrentWindow, x, y );
+#endif
+}
+
+extern void SDL_ANDROID_MainThreadPushAppActive(int active)
+{
+#if SDL_VERSION_ATLEAST(1,3,0)
+ //if( ANDROID_CurrentWindow )
+ // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+#else
+ SDL_PrivateAppActive(active, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
+#endif
+}
+
+enum { DEFERRED_TEXT_COUNT = 256 };
+static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
+static int deferredTextIdx1 = 0;
+static int deferredTextIdx2 = 0;
+static SDL_mutex * deferredTextMutex = NULL;
+
+void SDL_ANDROID_DeferredTextInput()
+{
+ if( !deferredTextMutex )
+ deferredTextMutex = SDL_CreateMutex();
+
+ SDL_mutexP(deferredTextMutex);
+
+ if( deferredTextIdx1 != deferredTextIdx2 )
+ {
+ SDL_keysym keysym;
+
+ deferredTextIdx1++;
+ if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx1 = 0;
+
+ keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
+ if( deferredText[deferredTextIdx1].down == SDL_RELEASED )
+ keysym.unicode = 0;
+
+ SDL_SendKeyboardKey( deferredText[deferredTextIdx1].down, &keysym );
+
+ if( SDL_ANDROID_isMouseUsed )
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + (SDL_ANDROID_currentMouseX % 2 ? -1 : 1), SDL_ANDROID_currentMouseY); // Force screen redraw
+ }
+ else
+ {
+ if( SDL_ANDROID_TextInputFinished )
+ {
+ SDL_ANDROID_TextInputFinished = 0;
+ SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
+ }
+ }
+
+ SDL_mutexV(deferredTextMutex);
+}
+
+extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
+{
+ int shiftRequired;
+
+#if SDL_VERSION_ATLEAST(1,3,0)
+ {
+ char text[32];
+ UnicodeToUtf8(unicode, text);
+ SDL_SendKeyboardText(text);
+ }
+#endif
+
+ if( !deferredTextMutex )
+ deferredTextMutex = SDL_CreateMutex();
+
+ SDL_mutexP(deferredTextMutex);
+
+ shiftRequired = checkShiftRequired(&ascii);
+
+ if( shiftRequired )
+ {
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_PRESSED;
+ deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
+ deferredText[deferredTextIdx2].unicode = 0;
+ }
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_PRESSED;
+ deferredText[deferredTextIdx2].scancode = ascii;
+ deferredText[deferredTextIdx2].unicode = unicode;
+
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_RELEASED;
+ deferredText[deferredTextIdx2].scancode = ascii;
+ deferredText[deferredTextIdx2].unicode = 0;
+ if( shiftRequired )
+ {
+ deferredTextIdx2++;
+ if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
+ deferredTextIdx2 = 0;
+ deferredText[deferredTextIdx2].down = SDL_RELEASED;
+ deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
+ deferredText[deferredTextIdx2].unicode = 0;
+ }
+
+ SDL_mutexV(deferredTextMutex);
+}
+
+#endif
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c
index 149a09c1e..fcc42842e 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c
@@ -42,12 +42,10 @@
#include "SDL_androidinput.h"
#include "SDL_screenkeyboard.h"
#include "jniwrapperstuff.h"
+#include "unicodestuff.h"
#include "atan2i.h"
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
-
-static SDLKey SDL_android_keymap[KEYCODE_LAST+1];
+SDLKey SDL_android_keymap[KEYCODE_LAST+1];
static inline SDL_scancode TranslateKey(int scancode)
{
@@ -57,32 +55,35 @@ static inline SDL_scancode TranslateKey(int scancode)
}
static int isTrackballUsed = 0;
-static int isMouseUsed = 0;
+int SDL_ANDROID_isMouseUsed = 0;
+
+#define NORMALIZE_FLOAT_32767(X) (fminf(32767.0f, fmax(-32767.0f, (X) * 32767.0f)))
enum { RIGHT_CLICK_NONE = 0, RIGHT_CLICK_WITH_MULTITOUCH = 1, RIGHT_CLICK_WITH_PRESSURE = 2,
RIGHT_CLICK_WITH_KEY = 3, RIGHT_CLICK_WITH_TIMEOUT = 4 };
enum { LEFT_CLICK_NORMAL = 0, LEFT_CLICK_NEAR_CURSOR = 1, LEFT_CLICK_WITH_MULTITOUCH = 2, LEFT_CLICK_WITH_PRESSURE = 3,
LEFT_CLICK_WITH_KEY = 4, LEFT_CLICK_WITH_TIMEOUT = 5, LEFT_CLICK_WITH_TAP = 6, LEFT_CLICK_WITH_TAP_OR_TIMEOUT = 7 };
+enum { JOY_TOUCHSCREEN = 0, JOY_ACCELGYRO = 1, JOY_GAMEPAD1 = 2, JOY_GAMEPAD2 = 3, JOY_GAMEPAD3 = 4, JOY_GAMEPAD4 = 5 };
static int leftClickMethod = LEFT_CLICK_NORMAL;
static int rightClickMethod = RIGHT_CLICK_NONE;
static int leftClickKey = KEYCODE_DPAD_CENTER;
static int rightClickKey = KEYCODE_MENU;
int SDL_ANDROID_ShowScreenUnderFinger = ZOOM_NONE;
SDL_Rect SDL_ANDROID_ShowScreenUnderFingerRect = {0, 0, 0, 0}, SDL_ANDROID_ShowScreenUnderFingerRectSrc = {0, 0, 0, 0};
-static int moveMouseWithArrowKeys = 0;
static int clickMouseWithDpadCenter = 0;
-static int moveMouseWithKbSpeed = 0;
-static int moveMouseWithKbAccel = 0;
-static int moveMouseWithKbX = -1, moveMouseWithKbY = -1;
-static int moveMouseWithKbSpeedX = 0, moveMouseWithKbSpeedY = 0;
-static int moveMouseWithKbAccelX = 0, moveMouseWithKbAccelY = 0;
-static int moveMouseWithKbAccelUpdateNeeded = 0;
+int SDL_ANDROID_moveMouseWithArrowKeys = 0;
+int SDL_ANDROID_moveMouseWithKbSpeed = 0;
+int SDL_ANDROID_moveMouseWithKbAccel = 0;
+int SDL_ANDROID_moveMouseWithKbX = -1, SDL_ANDROID_moveMouseWithKbY = -1;
+int SDL_ANDROID_moveMouseWithKbSpeedX = 0, SDL_ANDROID_moveMouseWithKbSpeedY = 0;
+int SDL_ANDROID_moveMouseWithKbAccelX = 0, SDL_ANDROID_moveMouseWithKbAccelY = 0;
+int SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded = 0;
static int maxForce = 0;
static int maxRadius = 0;
int SDL_ANDROID_isJoystickUsed = 0;
static int SDL_ANDROID_isAccelerometerUsed = 0;
static int isMultitouchUsed = 0;
-SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1] = {NULL};
+SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1];
static int TrackballDampening = 0; // in milliseconds
static Uint32 lastTrackballAction = 0;
enum { TOUCH_PTR_UP = 0, TOUCH_PTR_MOUSE = 1, TOUCH_PTR_SCREENKB = 2 };
@@ -117,45 +118,13 @@ static int relativeMovementAccel = 0;
static int relativeMovementX = 0;
static int relativeMovementY = 0;
static unsigned int relativeMovementTime = 0;
-static int currentMouseX = 0;
-static int currentMouseY = 0;
-static int currentMouseButtons = 0;
+int SDL_ANDROID_currentMouseX = 0;
+int SDL_ANDROID_currentMouseY = 0;
+int SDL_ANDROID_currentMouseButtons = 0;
static int hardwareMouseDetected = 0;
enum { MOUSE_HW_BUTTON_LEFT = 1, MOUSE_HW_BUTTON_RIGHT = 2, MOUSE_HW_BUTTON_MIDDLE = 4, MOUSE_HW_BUTTON_BACK = 8, MOUSE_HW_BUTTON_FORWARD = 16, MOUSE_HW_BUTTON_MAX = MOUSE_HW_BUTTON_FORWARD };
-static int UnicodeToUtf8(int src, char * dest)
-{
- int len = 0;
- if ( src <= 0x007f) {
- *dest++ = (char)src;
- len = 1;
- } else if (src <= 0x07ff) {
- *dest++ = (char)0xc0 | (src >> 6);
- *dest++ = (char)0x80 | (src & 0x003f);
- len = 2;
- } else if (src == 0xFEFF) {
- // nop -- zap the BOM
- } else if (src >= 0xD800 && src <= 0xDFFF) {
- // surrogates not supported
- } else if (src <= 0xffff) {
- *dest++ = (char)0xe0 | (src >> 12);
- *dest++ = (char)0x80 | ((src >> 6) & 0x003f);
- *dest++ = (char)0x80 | (src & 0x003f);
- len = 3;
- } else if (src <= 0xffff) {
- *dest++ = (char)0xf0 | (src >> 18);
- *dest++ = (char)0x80 | ((src >> 12) & 0x3f);
- *dest++ = (char)0x80 | ((src >> 6) & 0x3f);
- *dest++ = (char)0x80 | (src & 0x3f);
- len = 4;
- } else {
- // out of Unicode range
- }
- *dest = 0;
- return len;
-}
-
static inline int InsideRect(const SDL_Rect * r, int x, int y)
{
return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h );
@@ -394,7 +363,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
if( multitouchGestureDist - dist > distMaxDiff )
{
multitouchGestureKeyPressed[1] = 1;
- SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[1] );
+ SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[1] );
}
else
if( multitouchGestureKeyPressed[1] )
@@ -447,13 +416,13 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
#endif
if( action == MOUSE_DOWN )
- SDL_ANDROID_MainThreadPushJoystickButton(0, pointerId, SDL_PRESSED);
- SDL_ANDROID_MainThreadPushJoystickBall(0, pointerId, x, y);
- SDL_ANDROID_MainThreadPushJoystickAxis(0, pointerId+4, force + radius); // Radius is more sensitive usually
+ SDL_ANDROID_MainThreadPushJoystickButton(JOY_TOUCHSCREEN, pointerId, SDL_PRESSED);
+ SDL_ANDROID_MainThreadPushJoystickBall(JOY_TOUCHSCREEN, pointerId, x, y);
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_TOUCHSCREEN, pointerId+4, force + radius); // Radius is more sensitive usually
if( action == MOUSE_UP )
- SDL_ANDROID_MainThreadPushJoystickButton(0, pointerId, SDL_RELEASED);
+ SDL_ANDROID_MainThreadPushJoystickButton(JOY_TOUCHSCREEN, pointerId, SDL_RELEASED);
}
- if( !isMouseUsed && !SDL_ANDROID_isTouchscreenKeyboardUsed )
+ if( !SDL_ANDROID_isMouseUsed && !SDL_ANDROID_isTouchscreenKeyboardUsed )
{
SDL_keysym keysym;
if( action != MOUSE_MOVE )
@@ -461,7 +430,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
return;
}
- if( !isMouseUsed )
+ if( !SDL_ANDROID_isMouseUsed )
return;
if( pointerId == firstMousePointerId )
@@ -470,14 +439,14 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
{
if( action == MOUSE_DOWN )
{
- relativeMovementX = currentMouseX - x;
- relativeMovementY = currentMouseY - y;
+ relativeMovementX = SDL_ANDROID_currentMouseX - x;
+ relativeMovementY = SDL_ANDROID_currentMouseY - y;
}
x += relativeMovementX;
y += relativeMovementY;
- int diffX = x - currentMouseX;
- int diffY = y - currentMouseY;
+ int diffX = x - SDL_ANDROID_currentMouseX;
+ int diffY = y - SDL_ANDROID_currentMouseY;
int coeff = relativeMovementSpeed + 2;
if( relativeMovementSpeed > 2 )
coeff += relativeMovementSpeed - 2;
@@ -493,8 +462,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
}
relativeMovementTime = newTime;
}
- diffX -= x - currentMouseX;
- diffY -= y - currentMouseY;
+ diffX -= x - SDL_ANDROID_currentMouseX;
+ diffY -= y - SDL_ANDROID_currentMouseY;
x += diffX;
y += diffY;
relativeMovementX += diffX;
@@ -541,33 +510,33 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_MAGNIFIER )
{
// Move mouse by 1 pixel so it will force screen update and mouse-under-finger window will be removed
- if( moveMouseWithKbX >= 0 )
- SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX > 0 ? moveMouseWithKbX-1 : 0, moveMouseWithKbY);
+ if( SDL_ANDROID_moveMouseWithKbX >= 0 )
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX > 0 ? SDL_ANDROID_moveMouseWithKbX-1 : 0, SDL_ANDROID_moveMouseWithKbY);
else
SDL_ANDROID_MainThreadPushMouseMotion(x > 0 ? x-1 : 0, y);
}
- moveMouseWithKbX = -1;
- moveMouseWithKbY = -1;
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbX = -1;
+ SDL_ANDROID_moveMouseWithKbY = -1;
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
}
if( action == MOUSE_DOWN )
{
- if( (moveMouseWithKbX >= 0 || leftClickMethod == LEFT_CLICK_NEAR_CURSOR) &&
- abs(currentMouseX - x) < SDL_ANDROID_sFakeWindowWidth / 10 && abs(currentMouseY - y) < SDL_ANDROID_sFakeWindowHeight / 10 )
+ if( (SDL_ANDROID_moveMouseWithKbX >= 0 || leftClickMethod == LEFT_CLICK_NEAR_CURSOR) &&
+ abs(SDL_ANDROID_currentMouseX - x) < SDL_ANDROID_sFakeWindowWidth / 10 && abs(SDL_ANDROID_currentMouseY - y) < SDL_ANDROID_sFakeWindowHeight / 10 )
{
SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_LEFT );
- moveMouseWithKbX = currentMouseX;
- moveMouseWithKbY = currentMouseY;
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
+ SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
action = MOUSE_MOVE;
}
else
if( leftClickMethod == LEFT_CLICK_NORMAL )
{
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
- if( !hardwareMouseDetected || currentMouseButtons == 0 )
+ if( !hardwareMouseDetected || SDL_ANDROID_currentMouseButtons == 0 )
SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_LEFT );
}
else
@@ -582,7 +551,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
}
if( action == MOUSE_MOVE )
{
- if( moveMouseWithKbX >= 0 )
+ if( SDL_ANDROID_moveMouseWithKbX >= 0 )
{
// Mouse lazily follows magnifying glass, not very intuitive for drag&drop
/*
@@ -599,17 +568,17 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
moveMouseWithKbY += moveMouseWithKbSpeedY;
*/
// Mouse follows touch instantly, when it's out of the snapping distance from mouse cursor
- if( abs(moveMouseWithKbX - x) >= SDL_ANDROID_sFakeWindowWidth / 10 ||
- abs(moveMouseWithKbY - y) >= SDL_ANDROID_sFakeWindowHeight / 10 )
+ if( abs(SDL_ANDROID_moveMouseWithKbX - x) >= SDL_ANDROID_sFakeWindowWidth / 10 ||
+ abs(SDL_ANDROID_moveMouseWithKbY - y) >= SDL_ANDROID_sFakeWindowHeight / 10 )
{
- moveMouseWithKbX = -1;
- moveMouseWithKbY = -1;
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbSpeedY = 0;
+ SDL_ANDROID_moveMouseWithKbX = -1;
+ SDL_ANDROID_moveMouseWithKbY = -1;
+ SDL_ANDROID_moveMouseWithKbSpeedX = 0;
+ SDL_ANDROID_moveMouseWithKbSpeedY = 0;
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
}
else
- SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
}
else
{
@@ -711,42 +680,42 @@ void ProcessDeferredMouseTap()
#define SDL_ANDROID_sFakeWindowWidth window->w
#define SDL_ANDROID_sFakeWindowHeight window->h
#endif
- if( currentMouseX + 1 < SDL_ANDROID_sFakeWindowWidth )
- SDL_ANDROID_MainThreadPushMouseMotion(currentMouseX + 1, currentMouseY);
+ if( SDL_ANDROID_currentMouseX + 1 < SDL_ANDROID_sFakeWindowWidth )
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX + 1, SDL_ANDROID_currentMouseY);
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
}
- else if( currentMouseX > 0 ) // Force application to redraw, and call SDL_Flip()
- SDL_ANDROID_MainThreadPushMouseMotion(currentMouseX - 1, currentMouseY);
+ else if( SDL_ANDROID_currentMouseX > 0 ) // Force application to redraw, and call SDL_Flip()
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_currentMouseX - 1, SDL_ANDROID_currentMouseY);
}
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeTouchpad) ( JNIEnv* env, jobject thiz, jint x, jint y, jint down, jint multitouch)
{
- if( !isMouseUsed )
+ if( !SDL_ANDROID_isMouseUsed )
return;
if( ! down )
{
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_RIGHT );
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
- moveMouseWithKbX = -1;
- moveMouseWithKbY = -1;
- moveMouseWithKbAccelUpdateNeeded = 0;
+ SDL_ANDROID_moveMouseWithKbX = -1;
+ SDL_ANDROID_moveMouseWithKbY = -1;
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded = 0;
}
else
{
// x and y from 0 to 65535
- if( moveMouseWithKbX < 0 )
+ if( SDL_ANDROID_moveMouseWithKbX < 0 )
{
- moveMouseWithKbX = currentMouseX;
- moveMouseWithKbY = currentMouseY;
+ SDL_ANDROID_moveMouseWithKbX = SDL_ANDROID_currentMouseX;
+ SDL_ANDROID_moveMouseWithKbY = SDL_ANDROID_currentMouseY;
}
- moveMouseWithKbSpeedX = (x - 32767) / 8192;
- moveMouseWithKbSpeedY = (y - 32767) / 8192;
+ SDL_ANDROID_moveMouseWithKbSpeedX = (x - 32767) / 8192;
+ SDL_ANDROID_moveMouseWithKbSpeedY = (y - 32767) / 8192;
//moveMouseWithKbX += moveMouseWithKbSpeedX;
//moveMouseWithKbY += moveMouseWithKbSpeedY;
- SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
- moveMouseWithKbAccelUpdateNeeded = 1;
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
+ SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded = 1;
if( multitouch )
SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_RIGHT );
@@ -764,9 +733,9 @@ void SDL_ANDROID_WarpMouse(int x, int y)
}
else
{
- //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_WarpMouse(): %dx%d rel %dx%d old %dx%d", x, y, relativeMovementX, relativeMovementY, currentMouseX, currentMouseY);
- relativeMovementX -= currentMouseX-x;
- relativeMovementY -= currentMouseY-y;
+ //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_WarpMouse(): %dx%d rel %dx%d old %dx%d", x, y, relativeMovementX, relativeMovementY, SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY);
+ relativeMovementX -= SDL_ANDROID_currentMouseX-x;
+ relativeMovementY -= SDL_ANDROID_currentMouseY-y;
SDL_ANDROID_MainThreadPushMouseMotion(x, y);
}
};
@@ -861,14 +830,31 @@ JAVA_EXPORT_NAME(AccelerometerReader_nativeAccelerometer) ( JNIEnv* env, jobjec
JNIEXPORT void JNICALL
-JAVA_EXPORT_NAME(AccelerometerReader_nativeOrientation) ( JNIEnv* env, jobject thiz, jfloat accX, jfloat accY, jfloat accZ )
+JAVA_EXPORT_NAME(AccelerometerReader_nativeGyroscope) ( JNIEnv* env, jobject thiz, jfloat X, jfloat Y, jfloat Z )
{
#if SDL_VERSION_ATLEAST(1,3,0)
#else
if( !SDL_CurrentVideoSurface )
return;
#endif
- updateOrientation (accX, accY, accZ); // TODO: make values in range 0.0:1.0
+ X *= 0.25f;
+ Y *= 0.25f;
+ Z *= 0.25f;
+ while ( X != 0.0f || Y != 0.0f || Z != 0.0f )
+ {
+ float dx = ( X > 1.0f ? 1.0f : ( X < -1.0f ? -1.0f : X ) );
+ float dy = ( Y > 1.0f ? 1.0f : ( Y < -1.0f ? -1.0f : Y ) );
+ float dz = ( Z > 1.0f ? 1.0f : ( Z < -1.0f ? -1.0f : Z ) );
+
+ X -= dx;
+ Y -= dy;
+ Z -= dz;
+
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_ACCELGYRO, 2, NORMALIZE_FLOAT_32767(dx));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_ACCELGYRO, 3, NORMALIZE_FLOAT_32767(dy));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_ACCELGYRO, 4, NORMALIZE_FLOAT_32767(dz));
+ //if( fabs(dx) >= 1.0f || fabs(dy) >= 1.0f || fabs(dz) >= 1.0f ) __android_log_print(ANDROID_LOG_INFO, "libSDL", "nativeGyroscope(): sending several events, this eats CPU!");
+ }
}
JNIEXPORT void JNICALL
@@ -902,16 +888,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz,
jint RelativeMovement, jint RelativeMovementSpeed, jint RelativeMovementAccel,
jint ShowMouseCursor)
{
- isMouseUsed = 1;
+ SDL_ANDROID_isMouseUsed = 1;
rightClickMethod = RightClickMethod;
SDL_ANDROID_ShowScreenUnderFinger = ShowScreenUnderFinger;
- moveMouseWithArrowKeys = MoveMouseWithJoystick;
+ SDL_ANDROID_moveMouseWithArrowKeys = MoveMouseWithJoystick;
clickMouseWithDpadCenter = ClickMouseWithDpad;
leftClickMethod = LeftClickMethod;
maxForce = MaxForce;
maxRadius = MaxRadius;
- moveMouseWithKbSpeed = MoveMouseWithJoystickSpeed + 1;
- moveMouseWithKbAccel = MoveMouseWithJoystickAccel;
+ SDL_ANDROID_moveMouseWithKbSpeed = MoveMouseWithJoystickSpeed + 1;
+ SDL_ANDROID_moveMouseWithKbAccel = MoveMouseWithJoystickAccel;
leftClickKey = LeftClickKeycode;
rightClickKey = RightClickKeycode;
leftClickTimeout = getClickTimeout(LeftClickTimeout);
@@ -926,7 +912,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetMouseUsed) (JNIEnv* env, jobject thiz,
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeHardwareMouseDetected) (JNIEnv* env, jobject thiz, int detected)
{
- if( !isMouseUsed )
+ if( !SDL_ANDROID_isMouseUsed )
return;
static struct {
@@ -965,11 +951,11 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeHardwareMouseDetected) (JNIEnv* env, jo
}
}
-JNIEXPORT void JNICALL
+JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseButtonsPressed) (JNIEnv* env, jobject thiz, jint buttonId, jint pressedState)
{
int btn = SDL_BUTTON_LEFT;
- if( !isMouseUsed )
+ if( !SDL_ANDROID_isMouseUsed )
return;
switch(buttonId)
@@ -1012,7 +998,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz,
}
for( ; scrollY > 0; scrollY-- )
{
- if(!isMouseUsed)
+ if(!SDL_ANDROID_isMouseUsed)
{
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_UP) );
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) );
@@ -1025,7 +1011,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz,
}
for( ; scrollY < 0; scrollY++ )
{
- if(!isMouseUsed)
+ if(!SDL_ANDROID_isMouseUsed)
{
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_DOWN) );
SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) );
@@ -1062,7 +1048,7 @@ static float dx = 0.04, dy = 0.1, dz = 0.1, joystickSensitivity = 400.0f; // For
enum { ACCELEROMETER_CENTER_FLOATING, ACCELEROMETER_CENTER_FIXED_START, ACCELEROMETER_CENTER_FIXED_HORIZ };
static int accelerometerCenterPos = ACCELEROMETER_CENTER_FLOATING;
-JNIEXPORT void JNICALL
+JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetAccelerometerSettings) ( JNIEnv* env, jobject thiz, jint sensitivity, jint centerPos)
{
dx = 0.04; dy = 0.08; dz = 0.08; joystickSensitivity = 32767.0f * 3.0f; // Fast sensitivity
@@ -1077,7 +1063,7 @@ JAVA_EXPORT_NAME(Settings_nativeSetAccelerometerSettings) ( JNIEnv* env, jobjec
accelerometerCenterPos = centerPos;
}
-JNIEXPORT void JNICALL
+JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetTrackballDampening) ( JNIEnv* env, jobject thiz, jint value)
{
TrackballDampening = (value * 200);
@@ -1096,8 +1082,8 @@ void updateOrientation ( float accX, float accY, float accZ )
if( SDL_ANDROID_isAccelerometerUsed )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): sending joystick event");
- SDL_ANDROID_MainThreadPushJoystickAxis(0, 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accX) * 32767.0f))));
- SDL_ANDROID_MainThreadPushJoystickAxis(0, 3, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accY) * 32767.0f))));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_ACCELGYRO, 0, NORMALIZE_FLOAT_32767(accX));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_ACCELGYRO, 1, NORMALIZE_FLOAT_32767(-accY));
//SDL_ANDROID_MainThreadPushJoystickAxis(0, 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accZ) * 32767.0f))));
return;
}
@@ -1113,8 +1099,8 @@ void updateOrientation ( float accX, float accY, float accZ )
if( SDL_ANDROID_isJoystickUsed )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): sending joystick event");
- SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accX - midX) * joystickSensitivity))));
- SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accY - midY) * joystickSensitivity))));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_TOUCHSCREEN, 0, NORMALIZE_FLOAT_32767((accX - midX) * joystickSensitivity));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_TOUCHSCREEN, 1, NORMALIZE_FLOAT_32767(-(accY - midY) * joystickSensitivity));
//SDL_ANDROID_MainThreadPushJoystickAxis(0, 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accZ - midZ) * joystickSensitivity))));
if( accelerometerCenterPos == ACCELEROMETER_CENTER_FLOATING )
@@ -1255,6 +1241,18 @@ void updateOrientation ( float accX, float accY, float accZ )
}
+JNIEXPORT void JNICALL
+JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeGamepadAnalogJoystickInput) (JNIEnv* env, jobject thiz,
+ jfloat stick1x, jfloat stick1y, jfloat stick2x, jfloat stick2y, jfloat rtrigger, jfloat ltrigger)
+{
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 0, NORMALIZE_FLOAT_32767(stick1x));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 1, NORMALIZE_FLOAT_32767(stick1y));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 2, NORMALIZE_FLOAT_32767(stick2x));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 3, NORMALIZE_FLOAT_32767(stick2y));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 4, NORMALIZE_FLOAT_32767(ltrigger));
+ SDL_ANDROID_MainThreadPushJoystickAxis(JOY_GAMEPAD1, 5, NORMALIZE_FLOAT_32767(rtrigger));
+}
+
static int leftPressed = 0, rightPressed = 0, upPressed = 0, downPressed = 0;
int processAndroidTrackball(int key, int action)
@@ -1379,11 +1377,7 @@ void SDL_ANDROID_processAndroidTrackballDampening()
int SDL_SYS_JoystickInit(void)
{
- SDL_numjoysticks = 0;
- if( SDL_ANDROID_isJoystickUsed || isMultitouchUsed || SDL_ANDROID_isAccelerometerUsed )
- SDL_numjoysticks = 1;
- //if( isMultitouchUsed )
- // SDL_numjoysticks = MAX_MULTITOUCH_POINTERS+1;
+ SDL_numjoysticks = JOY_GAMEPAD4 + 1;
return(SDL_numjoysticks);
}
@@ -1391,7 +1385,19 @@ int SDL_SYS_JoystickInit(void)
/* Function to get the device-dependent name of a joystick */
const char *SDL_SYS_JoystickName(int index)
{
- return("Android accelerometer/multitouch sensor");
+ if( index == JOY_TOUCHSCREEN )
+ return "Multitouch and on-screen joystick";
+ if( index == JOY_ACCELGYRO )
+ return "Accelerometer/gyroscope";
+ if( index == JOY_GAMEPAD1 )
+ return "Gamepad 1";
+ if( index == JOY_GAMEPAD2 )
+ return "Gamepad 2";
+ if( index == JOY_GAMEPAD3 )
+ return "Gamepad 3";
+ if( index == JOY_GAMEPAD4 )
+ return "Gamepad 4";
+ return "This joystick does not exist, check your code";
}
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
@@ -1399,9 +1405,9 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
joystick->nbuttons = 0;
joystick->nhats = 0;
joystick->nballs = 0;
- if( joystick->index == 0 )
+ if( joystick->index == JOY_TOUCHSCREEN )
{
- joystick->naxes = 4; // Joystick plus accelerometer
+ joystick->naxes = 4; // Two on-screen joysticks (I'm planning to implement second joystick soon)
if(isMultitouchUsed)
{
joystick->naxes = 4 + MAX_MULTITOUCH_POINTERS; // Joystick plus accelerometer, plus touch pressure/size
@@ -1409,6 +1415,15 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
joystick->nballs = MAX_MULTITOUCH_POINTERS;
}
}
+ if( joystick->index == JOY_ACCELGYRO )
+ {
+ joystick->naxes = 5; // Accelerometer = axes 0-1, gyroscope = axes 2-4
+ SDL_ANDROID_CallJavaStartAccelerometerGyroscope(1);
+ }
+ if( joystick->index >= JOY_GAMEPAD1 || joystick->index <= JOY_GAMEPAD4 )
+ {
+ joystick->naxes = 8; // Two analog stick + two trigger buttons + Ouya touchpad
+ }
SDL_ANDROID_CurrentJoysticks[joystick->index] = joystick;
return(0);
}
@@ -1422,6 +1437,8 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
{
SDL_ANDROID_CurrentJoysticks[joystick->index] = NULL;
+ if( joystick->index == JOY_ACCELGYRO )
+ SDL_ANDROID_CallJavaStartAccelerometerGyroscope(0);
return;
}
@@ -1433,601 +1450,11 @@ void SDL_SYS_JoystickQuit(void)
return;
}
-
-enum { MAX_BUFFERED_EVENTS = 64 };
-static SDL_Event BufferedEvents[MAX_BUFFERED_EVENTS];
-static int BufferedEventsStart = 0, BufferedEventsEnd = 0;
-static SDL_mutex * BufferedEventsMutex = NULL;
-
-#if SDL_VERSION_ATLEAST(1,3,0)
-
-#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym)
-extern SDL_Window * ANDROID_CurrentWindow;
-
-#else
-
-#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y)
-#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 )
-#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym)
-
-#endif
-
-/* We need our own event queue, because Free Heroes 2 game uses
- * SDL_SetEventFilter(), and it calls SDL_Flip() from inside
- * it's custom filter function, and SDL_Flip() does not work
- * when it's not called from the main() thread.
- * So we, like, push the events into our own queue,
- * read each event from that queue inside SDL_ANDROID_PumpEvents(),
- * unlock the mutex, and push the event to SDL queue,
- * which is then immediately read by SDL from the same thread,
- * and then SDL invokes event filter function from FHeroes2.
- * FHeroes2 call SDL_Flip() from inside that event filter function,
- * and it works, because it is called from the main() thread.
- */
-extern void SDL_ANDROID_PumpEvents()
-{
- static int oldMouseButtons = 0;
- SDL_Event ev;
- SDL_ANDROID_processAndroidTrackballDampening();
- SDL_ANDROID_processMoveMouseWithKeyboard();
-#if SDL_VERSION_ATLEAST(1,3,0)
- SDL_Window * window = SDL_GetFocusWindow();
- if( !window )
- return;
-#endif
-
- if( !BufferedEventsMutex )
- BufferedEventsMutex = SDL_CreateMutex();
-
- SDL_mutexP(BufferedEventsMutex);
- while( BufferedEventsStart != BufferedEventsEnd )
- {
- ev = BufferedEvents[BufferedEventsStart];
- BufferedEvents[BufferedEventsStart].type = 0;
- BufferedEventsStart++;
- if( BufferedEventsStart >= MAX_BUFFERED_EVENTS )
- BufferedEventsStart = 0;
- SDL_mutexV(BufferedEventsMutex);
-
- switch( ev.type )
- {
- case SDL_MOUSEMOTION:
- SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y );
- break;
- case SDL_MOUSEBUTTONDOWN:
- if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state )
- {
- oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0);
- SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button );
- }
- break;
- case SDL_KEYDOWN:
- //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_KEYDOWN: %i %i", ev->key.keysym.sym, ev->key.state);
- SDL_SendKeyboardKey( ev.key.state, &ev.key.keysym );
- break;
- case SDL_JOYAXISMOTION:
- if( ev.jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jaxis.which] )
- SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev.jaxis.which], ev.jaxis.axis, ev.jaxis.value );
- break;
- case SDL_JOYBUTTONDOWN:
- if( ev.jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
- SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev.jbutton.which], ev.jbutton.button, ev.jbutton.state );
- break;
- case SDL_JOYBALLMOTION:
- if( ev.jball.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev.jbutton.which] )
- SDL_PrivateJoystickBall( SDL_ANDROID_CurrentJoysticks[ev.jball.which], ev.jball.ball, ev.jball.xrel, ev.jball.yrel );
- break;
-#if SDL_VERSION_ATLEAST(1,3,0)
- //if( ANDROID_CurrentWindow )
- // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
-#else
- case SDL_ACTIVEEVENT:
- SDL_PrivateAppActive(ev.active.gain, ev.active.state);
- break;
-#endif
-#if SDL_VERSION_ATLEAST(1,3,0)
- case SDL_FINGERMOTION:
- SDL_SendTouchMotion(0, ev.tfinger.fingerId, 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
- break;
- case SDL_FINGERDOWN:
- SDL_SendFingerDown(0, ev.tfinger.fingerId, ev.tfinger.state ? 1 : 0, (float)ev.tfinger.x / (float)window->w, (float)ev.tfinger.y / (float)window->h, ev.tfinger.pressure);
- break;
- case SDL_TEXTINPUT:
- SDL_SendKeyboardText(ev.text.text);
- break;
- case SDL_MOUSEWHEEL:
- SDL_SendMouseWheel( ANDROID_CurrentWindow, ev.wheel.x, ev.wheel.y );
- break;
-#endif
- }
-
- SDL_mutexP(BufferedEventsMutex);
- }
- SDL_mutexV(BufferedEventsMutex);
-};
-// Queue events to main thread
-static int getNextEventAndLock()
-{
- int nextEvent;
- if( !BufferedEventsMutex )
- return -1;
- SDL_mutexP(BufferedEventsMutex);
- nextEvent = BufferedEventsEnd;
- nextEvent++;
- if( nextEvent >= MAX_BUFFERED_EVENTS )
- nextEvent = 0;
- while( nextEvent == BufferedEventsStart )
- {
- SDL_mutexV(BufferedEventsMutex);
- if( SDL_ANDROID_InsideVideoThread() )
- SDL_ANDROID_PumpEvents();
- else
- SDL_Delay(100);
- SDL_mutexP(BufferedEventsMutex);
- nextEvent = BufferedEventsEnd;
- nextEvent++;
- if( nextEvent >= MAX_BUFFERED_EVENTS )
- nextEvent = 0;
- }
- return nextEvent;
-}
-
-static int getPrevEventNoLock()
-{
- int prevEvent;
- if(BufferedEventsStart == BufferedEventsEnd)
- return -1;
- prevEvent = BufferedEventsEnd;
- prevEvent--;
- if( prevEvent < 0 )
- prevEvent = MAX_BUFFERED_EVENTS - 1;
- return prevEvent;
-}
-
-extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
-{
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- int prevEvent = getPrevEventNoLock();
- if( prevEvent > 0 && BufferedEvents[prevEvent].type == SDL_MOUSEMOTION )
- {
- // Reuse previous mouse motion event, to prevent mouse movement lag
- BufferedEvents[prevEvent].motion.x = x;
- BufferedEvents[prevEvent].motion.y = y;
- }
- else
- {
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
- ev->type = SDL_MOUSEMOTION;
- ev->motion.x = x;
- ev->motion.y = y;
- }
- currentMouseX = x;
- currentMouseY = y;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button)
-{
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_MOUSEBUTTONDOWN;
- ev->button.state = pressed;
- ev->button.button = button;
-
- if(pressed)
- currentMouseButtons |= SDL_BUTTON(button);
- else
- currentMouseButtons &= ~(SDL_BUTTON(button));
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-
-extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key)
-{
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- if( moveMouseWithArrowKeys && (
- key == SDL_KEY(UP) || key == SDL_KEY(DOWN) ||
- key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) ) )
- {
- if( moveMouseWithKbX < 0 )
- {
- moveMouseWithKbX = currentMouseX;
- moveMouseWithKbY = currentMouseY;
- }
-
- if( pressed )
- {
- if( key == SDL_KEY(LEFT) )
- {
- if( moveMouseWithKbSpeedX > 0 )
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbSpeedX -= moveMouseWithKbSpeed;
- moveMouseWithKbAccelX = -moveMouseWithKbAccel;
- moveMouseWithKbAccelUpdateNeeded |= 1;
- }
- else if( key == SDL_KEY(RIGHT) )
- {
- if( moveMouseWithKbSpeedX < 0 )
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbSpeedX += moveMouseWithKbSpeed;
- moveMouseWithKbAccelX = moveMouseWithKbAccel;
- moveMouseWithKbAccelUpdateNeeded |= 1;
- }
-
- if( key == SDL_KEY(UP) )
- {
- if( moveMouseWithKbSpeedY > 0 )
- moveMouseWithKbSpeedY = 0;
- moveMouseWithKbSpeedY -= moveMouseWithKbSpeed;
- moveMouseWithKbAccelY = -moveMouseWithKbAccel;
- moveMouseWithKbAccelUpdateNeeded |= 2;
- }
- else if( key == SDL_KEY(DOWN) )
- {
- if( moveMouseWithKbSpeedY < 0 )
- moveMouseWithKbSpeedY = 0;
- moveMouseWithKbSpeedY += moveMouseWithKbSpeed;
- moveMouseWithKbAccelY = moveMouseWithKbAccel;
- moveMouseWithKbAccelUpdateNeeded |= 2;
- }
- }
- else
- {
- if( key == SDL_KEY(LEFT) || key == SDL_KEY(RIGHT) )
- {
- moveMouseWithKbSpeedX = 0;
- moveMouseWithKbAccelX = 0;
- moveMouseWithKbAccelUpdateNeeded &= ~1;
- }
- if( key == SDL_KEY(UP) || key == SDL_KEY(DOWN) )
- {
- moveMouseWithKbSpeedY = 0;
- moveMouseWithKbAccelY = 0;
- moveMouseWithKbAccelUpdateNeeded &= ~2;
- }
- }
-
- moveMouseWithKbX += moveMouseWithKbSpeedX;
- moveMouseWithKbY += moveMouseWithKbSpeedY;
-
- SDL_mutexV(BufferedEventsMutex);
-
- SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
- return;
- }
-
- ev->type = SDL_KEYDOWN;
- ev->key.state = pressed;
- ev->key.keysym.scancode = key;
- ev->key.keysym.sym = key;
- ev->key.keysym.mod = KMOD_NONE;
- ev->key.keysym.unicode = 0;
-#if SDL_VERSION_ATLEAST(1,3,0)
-#else
- if ( SDL_TranslateUNICODE )
-#endif
- ev->key.keysym.unicode = key;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-
-extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value)
-{
- if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
- return;
-
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_JOYAXISMOTION;
- ev->jaxis.which = joy;
- ev->jaxis.axis = axis;
- ev->jaxis.value = MAX( -32768, MIN( 32767, value ) );
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed)
-{
- if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
- return;
-
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_JOYBUTTONDOWN;
- ev->jbutton.which = joy;
- ev->jbutton.button = button;
- ev->jbutton.state = pressed;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-extern void SDL_ANDROID_MainThreadPushJoystickBall(int joy, int ball, int x, int y)
-{
- if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) )
- return;
-
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_JOYBALLMOTION;
- ev->jball.which = joy;
- ev->jball.ball = ball;
- ev->jball.xrel = x;
- ev->jball.yrel = y;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-}
-extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force)
-{
-#if SDL_VERSION_ATLEAST(1,3,0)
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_FINGERDOWN;
- ev->tfinger.fingerId = id;
- ev->tfinger.state = pressed;
- ev->tfinger.x = x;
- ev->tfinger.y = y;
- ev->tfinger.pressure = force;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-#endif
-};
-extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force)
-{
-#if SDL_VERSION_ATLEAST(1,3,0)
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_FINGERMOTION;
- ev->tfinger.fingerId = id;
- ev->tfinger.x = x;
- ev->tfinger.y = y;
- ev->tfinger.pressure = force;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-#endif
-};
-
-extern void SDL_ANDROID_MainThreadPushMouseWheel(int x, int y)
-{
-#if SDL_VERSION_ATLEAST(1,3,0)
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_MOUSEWHEEL;
- ev->wheel.x = x;
- ev->wheel.y = y;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-#endif
-}
-
-extern void SDL_ANDROID_MainThreadPushAppActive(int active)
-{
-#if SDL_VERSION_ATLEAST(1,3,0)
- //if( ANDROID_CurrentWindow )
- // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0);
-#else
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- ev->type = SDL_ACTIVEEVENT;
- ev->active.gain = active;
- ev->active.state = SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS;
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-#endif
-}
-
-
-enum { DEFERRED_TEXT_COUNT = 256 };
-static struct { int scancode; int unicode; int down; } deferredText[DEFERRED_TEXT_COUNT];
-static int deferredTextIdx1 = 0;
-static int deferredTextIdx2 = 0;
-static SDL_mutex * deferredTextMutex = NULL;
-
-static SDL_keysym asciiToKeysym(int ascii, int unicode)
-{
- SDL_keysym keysym;
- keysym.scancode = ascii;
- keysym.sym = ascii;
- keysym.mod = KMOD_NONE;
- keysym.unicode = 0;
-#if SDL_VERSION_ATLEAST(1,3,0)
- keysym.sym = SDL_GetScancodeFromKey(ascii);
-#else
- if ( SDL_TranslateUNICODE )
-#endif
- keysym.unicode = unicode;
- return keysym;
-}
-
-static int checkShiftRequired( int * sym )
-{
- switch( *sym )
- {
- case '!': *sym = '1'; return 1;
- case '@': *sym = '2'; return 1;
- case '#': *sym = '3'; return 1;
- case '$': *sym = '4'; return 1;
- case '%': *sym = '5'; return 1;
- case '^': *sym = '6'; return 1;
- case '&': *sym = '7'; return 1;
- case '*': *sym = '8'; return 1;
- case '(': *sym = '9'; return 1;
- case ')': *sym = '0'; return 1;
- case '_': *sym = '-'; return 1;
- case '+': *sym = '='; return 1;
- case '|': *sym = '\\';return 1;
- case '<': *sym = ','; return 1;
- case '>': *sym = '.'; return 1;
- case '?': *sym = '/'; return 1;
- case ':': *sym = ';'; return 1;
- case '"': *sym = '\'';return 1;
- case '{': *sym = '['; return 1;
- case '}': *sym = ']'; return 1;
- case '~': *sym = '`'; return 1;
- default: if( *sym >= 'A' && *sym <= 'Z' ) { *sym += 'a' - 'A'; return 1; };
- }
- return 0;
-}
-
-void SDL_ANDROID_DeferredTextInput()
-{
- if( !deferredTextMutex )
- deferredTextMutex = SDL_CreateMutex();
-
- SDL_mutexP(deferredTextMutex);
-
- if( deferredTextIdx1 != deferredTextIdx2 )
- {
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- {
- SDL_mutexV(deferredTextMutex);
- return;
- }
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
- deferredTextIdx1++;
- if( deferredTextIdx1 >= DEFERRED_TEXT_COUNT )
- deferredTextIdx1 = 0;
-
- ev->type = SDL_KEYDOWN;
- ev->key.state = deferredText[deferredTextIdx1].down;
- ev->key.keysym = asciiToKeysym( deferredText[deferredTextIdx1].scancode, deferredText[deferredTextIdx1].unicode );
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
- if( isMouseUsed )
- SDL_ANDROID_MainThreadPushMouseMotion(currentMouseX + (currentMouseX % 2 ? -1 : 1), currentMouseY); // Force screen redraw
- }
- else
- {
- if( SDL_ANDROID_TextInputFinished )
- {
- SDL_ANDROID_TextInputFinished = 0;
- SDL_ANDROID_IsScreenKeyboardShownFlag = 0;
- }
- }
-
- SDL_mutexV(deferredTextMutex);
-};
-
-extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode )
-{
- int shiftRequired;
-
- int nextEvent = getNextEventAndLock();
- if( nextEvent == -1 )
- return;
-
- SDL_Event * ev = &BufferedEvents[BufferedEventsEnd];
-
-#if SDL_VERSION_ATLEAST(1,3,0)
-
- ev->type = SDL_TEXTINPUT;
- UnicodeToUtf8(unicode, ev->text.text);
-
-#endif
-
- if( !deferredTextMutex )
- deferredTextMutex = SDL_CreateMutex();
-
- SDL_mutexP(deferredTextMutex);
-
- ev->type = 0;
-
- shiftRequired = checkShiftRequired(&ascii);
-
- if( shiftRequired )
- {
- deferredTextIdx2++;
- if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
- deferredTextIdx2 = 0;
- deferredText[deferredTextIdx2].down = SDL_PRESSED;
- deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
- deferredText[deferredTextIdx2].unicode = 0;
- }
- deferredTextIdx2++;
- if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
- deferredTextIdx2 = 0;
- deferredText[deferredTextIdx2].down = SDL_PRESSED;
- deferredText[deferredTextIdx2].scancode = ascii;
- deferredText[deferredTextIdx2].unicode = unicode;
-
- deferredTextIdx2++;
- if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
- deferredTextIdx2 = 0;
- deferredText[deferredTextIdx2].down = SDL_RELEASED;
- deferredText[deferredTextIdx2].scancode = ascii;
- deferredText[deferredTextIdx2].unicode = 0;
- if( shiftRequired )
- {
- deferredTextIdx2++;
- if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT )
- deferredTextIdx2 = 0;
- deferredText[deferredTextIdx2].down = SDL_RELEASED;
- deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT;
- deferredText[deferredTextIdx2].unicode = 0;
- }
-
- SDL_mutexV(deferredTextMutex);
-
- BufferedEventsEnd = nextEvent;
- SDL_mutexV(BufferedEventsMutex);
-};
-
-
Uint32 lastMoveMouseWithKeyboardUpdate = 0;
void SDL_ANDROID_processMoveMouseWithKeyboard()
{
- if( ! moveMouseWithKbAccelUpdateNeeded )
+ if( ! SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded )
return;
Uint32 ticks = SDL_GetTicks();
@@ -2037,12 +1464,12 @@ void SDL_ANDROID_processMoveMouseWithKeyboard()
lastMoveMouseWithKeyboardUpdate = ticks;
- moveMouseWithKbSpeedX += moveMouseWithKbAccelX;
- moveMouseWithKbSpeedY += moveMouseWithKbAccelY;
+ SDL_ANDROID_moveMouseWithKbSpeedX += SDL_ANDROID_moveMouseWithKbAccelX;
+ SDL_ANDROID_moveMouseWithKbSpeedY += SDL_ANDROID_moveMouseWithKbAccelY;
- moveMouseWithKbX += moveMouseWithKbSpeedX;
- moveMouseWithKbY += moveMouseWithKbSpeedY;
- SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY);
+ SDL_ANDROID_moveMouseWithKbX += SDL_ANDROID_moveMouseWithKbSpeedX;
+ SDL_ANDROID_moveMouseWithKbY += SDL_ANDROID_moveMouseWithKbSpeedY;
+ SDL_ANDROID_MainThreadPushMouseMotion(SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY);
};
extern void SDL_ANDROID_ProcessDeferredEvents()
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h
index 59caac53a..a04f0399c 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h
@@ -203,4 +203,18 @@ extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode );
extern void SDL_android_init_keymap(SDLKey *SDL_android_keymap);
extern void SDL_ANDROID_MainThreadPushMouseWheel( int x, int y ); // SDL 1.3 only
extern void SDL_ANDROID_MainThreadPushAppActive(int active);
+
+// Internal input queue stuff
+extern SDLKey SDL_android_keymap[];
+extern SDL_Joystick *SDL_ANDROID_CurrentJoysticks[];
+extern int SDL_ANDROID_isMouseUsed;
+extern int SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY, SDL_ANDROID_currentMouseButtons;
+extern int SDL_ANDROID_moveMouseWithArrowKeys;
+extern int SDL_ANDROID_moveMouseWithKbSpeed;
+extern int SDL_ANDROID_moveMouseWithKbAccel;
+extern int SDL_ANDROID_moveMouseWithKbX, SDL_ANDROID_moveMouseWithKbY;
+extern int SDL_ANDROID_moveMouseWithKbSpeedX, SDL_ANDROID_moveMouseWithKbSpeedY;
+extern int SDL_ANDROID_moveMouseWithKbAccelX, SDL_ANDROID_moveMouseWithKbAccelY;
+extern int SDL_ANDROID_moveMouseWithKbAccelUpdateNeeded;
+
#endif
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
index ebf847df3..0c143aad3 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
@@ -910,10 +910,9 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
// Do it old-fashioned way with direct GL calls
glPushMatrix();
glLoadIdentity();
- glOrthox( 0, SDL_ANDROID_sFakeWindowWidth * 0x10000, SDL_ANDROID_sFakeWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
- glColor4x(0, 0, 0, 0x10000);
+ glOrthof( 0.0f, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight, 0.0f, 0.0f, 1.0f );
glEnableClientState(GL_VERTEX_ARRAY);
- glColor4x(0, 0, 0, 0x10000);
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
GLshort vertices[] = { frame.x, frame.y,
frame.x + frame.w, frame.y,
frame.x + frame.w, frame.y + frame.h,
@@ -991,7 +990,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
SDL_GetMouseState(&x, &y);
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
- SDL_ANDROID_DrawMouseCursor( x, y, 0, 255 );
+ SDL_ANDROID_DrawMouseCursor( x, y, 0, 1.0f );
}
if( SDL_ANDROID_ShowScreenUnderFinger != ZOOM_NONE )
{
@@ -1005,7 +1004,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
SDL_ANDROID_ShowScreenUnderFingerRect.h / SDL_ANDROID_ShowScreenUnderFingerRectSrc.h;
x = x * SDL_ANDROID_sRealWindowWidth / SDL_ANDROID_sFakeWindowWidth;
y = y * SDL_ANDROID_sRealWindowHeight / SDL_ANDROID_sFakeWindowHeight;
- SDL_ANDROID_DrawMouseCursor( x, y, 16, 255 );
+ SDL_ANDROID_DrawMouseCursor( x, y, 16, 1.0f );
}
}
}
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c
index ee67a7799..e5296585f 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.c
@@ -65,6 +65,7 @@ static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
static jmethodID JavaHideScreenKeyboard = NULL;
static jmethodID JavaIsScreenKeyboardShown = NULL;
+static jmethodID JavaStartAccelerometerGyroscope = NULL;
static jmethodID JavaGetAdvertisementParams = NULL;
static jmethodID JavaSetAdvertisementVisible = NULL;
static jmethodID JavaSetAdvertisementPosition = NULL;
@@ -110,8 +111,8 @@ int SDL_ANDROID_CallJavaSwapBuffers()
{
glPushMatrix();
glLoadIdentity();
- glOrthox( 0, (SDL_ANDROID_sRealWindowWidth) * 0x10000, SDL_ANDROID_sRealWindowHeight * 0x10000, 0, 0, 1 * 0x10000 );
- glColor4x(0, 0, 0, 0x10000);
+ glOrthof( 0.0f, SDL_ANDROID_sRealWindowWidth, SDL_ANDROID_sRealWindowHeight, 0.0f, 0.0f, 1.0f );
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
GLshort vertices[] = { SDL_ANDROID_ForceClearScreenRect.x, SDL_ANDROID_ForceClearScreenRect.y,
@@ -297,6 +298,11 @@ int SDL_ANDROID_IsScreenKeyboardShown()
return SDL_ANDROID_IsScreenKeyboardShownFlag;
}
+void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start)
+{
+ (*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaStartAccelerometerGyroscope, (jint) start );
+}
+
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject thiz )
{
@@ -309,7 +315,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
JavaHideScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "hideScreenKeyboard", "()V");
JavaIsScreenKeyboardShown = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "isScreenKeyboardShown", "()I");
- // TODO: implement it
+ JavaStartAccelerometerGyroscope = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "startAccelerometerGyroscope", "(I)V");
+
JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "getAdvertisementParams", "([I)V");
JavaSetAdvertisementVisible = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementVisible", "(I)V");
JavaSetAdvertisementPosition = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "setAdvertisementPosition", "(II)V");
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h
index bef803eb4..7cd24b83e 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h
+++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo.h
@@ -69,10 +69,10 @@ extern void SDL_ANDROID_initFakeStdout();
extern SDL_VideoDevice *ANDROID_CreateDevice_1_3(int devindex);
extern void SDL_ANDROID_ProcessDeferredEvents();
extern void SDL_ANDROID_WarpMouse(int x, int y);
-extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha);
+extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha);
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
-
+extern void SDL_ANDROID_CallJavaStartAccelerometerGyroscope(int start);
#if SDL_VERSION_ATLEAST(1,3,0)
extern SDL_Window * ANDROID_CurrentWindow;
diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c
index 864123689..141e35413 100644
--- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c
+++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c
@@ -40,14 +40,10 @@
#include "SDL_androidvideo.h"
#include "SDL_androidinput.h"
#include "jniwrapperstuff.h"
-
-// #include "touchscreentheme.h" // Not used yet
+#include "atan2i.h"
// TODO: this code is a HUGE MESS
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
-
enum { MAX_BUTTONS = SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM-1, MAX_BUTTONS_AUTOFIRE = 2, BUTTON_TEXT_INPUT = SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, BUTTON_ARROWS = MAX_BUTTONS } ; // Max amount of custom buttons
int SDL_ANDROID_isTouchscreenKeyboardUsed = 0;
@@ -56,7 +52,7 @@ static short touchscreenKeyboardShown = 1;
static short AutoFireButtonsNum = 0;
static short buttonsize = 1;
static short buttonDrawSize = 1;
-static short transparency = 128;
+static float transparency = 128.0f/255.0f;
static SDL_Rect arrows, arrowsExtended, buttons[MAX_BUTTONS], buttonsAutoFireRect[MAX_BUTTONS_AUTOFIRE];
static SDL_Rect arrowsDraw, buttonsDraw[MAX_BUTTONS];
@@ -118,16 +114,30 @@ oldGlState;
static inline void beginDrawingTex()
{
+#ifndef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
+ // Make the video somehow work on emulator
+ oldGlState.texture2d = GL_TRUE;
+ oldGlState.texunitId = GL_TEXTURE0;
+ oldGlState.clientTexunitId = GL_TEXTURE0;
+ oldGlState.textureId = 0;
+ oldGlState.texEnvMode = GL_MODULATE;
+ oldGlState.blend = GL_TRUE;
+ oldGlState.blend1 = GL_SRC_ALPHA;
+ oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
+ oldGlState.colorArray = GL_FALSE;
+#else
// Save OpenGL state
- glGetError(); // Clear error flag
// This code does not work on 1.6 emulator, and on some older devices
// However GLES 1.1 spec defines all theese values, so it's a device fault for not implementing them
oldGlState.texture2d = glIsEnabled(GL_TEXTURE_2D);
glGetIntegerv(GL_ACTIVE_TEXTURE, &oldGlState.texunitId);
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &oldGlState.clientTexunitId);
+#endif
+
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
+#ifdef SDL_TOUCHSCREEN_KEYBOARD_SAVE_RESTORE_OPENGL_STATE
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldGlState.textureId);
glGetFloatv(GL_CURRENT_COLOR, &(oldGlState.color[0]));
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &oldGlState.texEnvMode);
@@ -136,19 +146,7 @@ static inline void beginDrawingTex()
glGetIntegerv(GL_BLEND_DST, &oldGlState.blend2);
glGetBooleanv(GL_COLOR_ARRAY, &oldGlState.colorArray);
// It's very unlikely that some app will use GL_TEXTURE_CROP_RECT_OES, so just skip it
- if( glGetError() != GL_NO_ERROR )
- {
- // Make the video somehow work on emulator
- oldGlState.texture2d = GL_FALSE;
- oldGlState.texunitId = GL_TEXTURE0;
- oldGlState.clientTexunitId = GL_TEXTURE0;
- oldGlState.textureId = 0;
- oldGlState.texEnvMode = GL_MODULATE;
- oldGlState.blend = GL_FALSE;
- oldGlState.blend1 = GL_SRC_ALPHA;
- oldGlState.blend2 = GL_ONE_MINUS_SRC_ALPHA;
- oldGlState.colorArray = GL_FALSE;
- }
+#endif
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@@ -164,7 +162,7 @@ static inline void endDrawingTex()
glDisable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, oldGlState.textureId);
glColor4f(oldGlState.color[0], oldGlState.color[1], oldGlState.color[2], oldGlState.color[3]);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, oldGlState.texEnvMode);
if( oldGlState.blend == GL_FALSE )
glDisable(GL_BLEND);
glBlendFunc(oldGlState.blend1, oldGlState.blend2);
@@ -174,7 +172,7 @@ static inline void endDrawingTex()
glEnableClientState(GL_COLOR_ARRAY);
}
-static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, int flipX, int flipY, float r, float g, float b, float a)
{
GLint cropRect[4];
@@ -183,7 +181,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
glBindTexture(GL_TEXTURE_2D, tex->id);
- glColor4x(r * 0x100, g * 0x100, b * 0x100, a * 0x100 );
+ glColor4f(r, g, b, a);
if(src)
{
@@ -213,7 +211,7 @@ static inline void drawCharTexFlip(GLTexture_t * tex, SDL_Rect * src, SDL_Rect *
glDrawTexiOES(dest->x, SDL_ANDROID_sWindowHeight - dest->y - dest->h, 0, dest->w, dest->h);
}
-static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * dest, float r, float g, float b, float a)
{
drawCharTexFlip(tex, src, dest, 0, 0, r, g, b, a);
}
@@ -221,24 +219,24 @@ static inline void drawCharTex(GLTexture_t * tex, SDL_Rect * src, SDL_Rect * des
static void drawTouchscreenKeyboardLegacy()
{
int i;
- int blendFactor;
+ float blendFactor;
blendFactor = ( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ? 1 : 0 ) +
( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ? 1 : 0 );
if( blendFactor == 0 )
- drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
+ drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
else
{
if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] )
- drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
+ drawCharTex( &arrowImages[1], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] )
- drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
+ drawCharTex( &arrowImages[2], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] )
- drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
+ drawCharTex( &arrowImages[3], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] )
- drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 255, 255, 255, transparency / blendFactor );
+ drawCharTex( &arrowImages[4], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency / blendFactor );
}
for( i = 0; i < MAX_BUTTONS; i++ )
@@ -274,7 +272,7 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = pos1dst;
drawCharTex( &buttonImages[i*2+1],
- &autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
+ &autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
autoFireCrop.x = pos2src;
autoFireCrop.w = buttonImages[i*2+1].w - pos2src;
@@ -282,7 +280,7 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = buttonsDraw[i].w - pos2dst;
drawCharTex( &buttonImages[i*2+1],
- &autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
+ &autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
autoFireCrop.x = pos1src;
autoFireCrop.w = pos2src - pos1src;
@@ -290,13 +288,13 @@ static void drawTouchscreenKeyboardLegacy()
autoFireDest.w = pos2dst - pos1dst;
drawCharTex( &buttonAutoFireImages[i*2+1],
- &autoFireCrop, &autoFireDest, 255, 255, 255, transparency );
+ &autoFireCrop, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
}
else
{
drawCharTex( ( i < AutoFireButtonsNum && ButtonAutoFire[i] ) ? &buttonAutoFireImages[i*2] :
&buttonImages[ SDL_GetKeyboardState(NULL)[buttonKeysyms[i]] ? (i * 2 + 1) : (i * 2) ],
- NULL, &buttonsDraw[i], 255, 255, 255, transparency );
+ NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
}
}
}
@@ -305,7 +303,7 @@ static void drawTouchscreenKeyboardSun()
{
int i;
- drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 255, 255, 255, transparency );
+ drawCharTex( &arrowImages[0], NULL, &arrowsDraw, 1.0f, 1.0f, 1.0f, transparency );
if(pointerInButtonRect[BUTTON_ARROWS] != -1)
{
SDL_Rect touch = arrowsDraw;
@@ -313,7 +311,7 @@ static void drawTouchscreenKeyboardSun()
touch.h /= 2;
touch.x = joystickTouchPoints[0] - touch.w / 2;
touch.y = joystickTouchPoints[1] - touch.h / 2;
- drawCharTex( &arrowImages[0], NULL, &touch, 255, 255, 255, transparency );
+ drawCharTex( &arrowImages[0], NULL, &touch, 1.0f, 1.0f, 1.0f, transparency );
}
for( i = 0; i < MAX_BUTTONS; i++ )
@@ -339,10 +337,10 @@ static void drawTouchscreenKeyboardSun()
if( i < AutoFireButtonsNum && ButtonAutoFire[i] )
drawCharTex( &buttonAutoFireImages[i*2+1],
- NULL, &buttonsDraw[i], 255, 255, 255, transparency );
+ NULL, &buttonsDraw[i], 1.0f, 1.0f, 1.0f, transparency );
drawCharTexFlip( &buttonImages[ pressed ? (i * 2 + 1) : (i * 2) ],
- NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 255, 255, 255, transparency );
+ NULL, &buttonsDraw[i], (i >= 2 && pressed), 0, 1.0f, 1.0f, 1.0f, transparency );
if( i < AutoFireButtonsNum && ! ButtonAutoFire[i] &&
( ButtonAutoFireX[i*2] > 0 || ButtonAutoFireX[i*2+1] > 0 ) )
@@ -359,7 +357,7 @@ static void drawTouchscreenKeyboardSun()
autoFireDest.y = buttonsDraw[i].y + buttonsDraw[i].h/2 - autoFireDest.h/2;
drawCharTex( &buttonAutoFireImages[i*2],
- NULL, &autoFireDest, 255, 255, 255, transparency );
+ NULL, &autoFireDest, 1.0f, 1.0f, 1.0f, transparency );
}
}
}
@@ -700,12 +698,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetupScreenKeyboard) ( JNIEnv* env, jobject thi
buttonDrawSize = drawsize;
switch(_transparency)
{
- case 0: transparency = 32; break;
- case 1: transparency = 64; break;
- case 2: transparency = 128; break;
- case 3: transparency = 192; break;
- case 4: transparency = 255; break;
- default: transparency = 192; break;
+ case 0: transparency = 32.0f/255.0f; break;
+ case 1: transparency = 64.0f/255.0f; break;
+ case 2: transparency = 128.0f/255.0f; break;
+ case 3: transparency = 192.0f/255.0f; break;
+ case 4: transparency = 255.0f/255.0f; break;
+ default: transparency = 192.0f/255.0f; break;
}
// Arrows to the lower-left part of screen
@@ -778,16 +776,16 @@ JAVA_EXPORT_NAME(Settings_nativeSetTouchscreenKeyboardUsed) ( JNIEnv* env, jobj
SDL_ANDROID_isTouchscreenKeyboardUsed = 1;
}
-void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha)
+void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, float alpha)
{
SDL_Rect r;
- // I've failed with size calcualtions, so leaving it as-is
+ // I've failed with size calculations, so leaving it as-is
r.x = x - MOUSE_POINTER_X;
r.y = y - MOUSE_POINTER_Y;
r.w = MOUSE_POINTER_W;
r.h = MOUSE_POINTER_H;
beginDrawingTex();
- drawCharTex( &mousePointer, NULL, &r, 255, 255, 255, alpha );
+ drawCharTex( &mousePointer, NULL, &r, 1.0f, 1.0f, 1.0f, alpha );
endDrawingTex();
}
diff --git a/project/jni/sdl-1.2/src/video/android/atan2i.h b/project/jni/sdl-1.2/src/video/android/atan2i.h
index e7111a618..59efd9d72 100644
--- a/project/jni/sdl-1.2/src/video/android/atan2i.h
+++ b/project/jni/sdl-1.2/src/video/android/atan2i.h
@@ -30,4 +30,7 @@ static inline int atan2i(int y, int x)
return(angle);
};
+#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+
#endif
diff --git a/project/jni/sdl-1.2/src/video/android/keymap.c b/project/jni/sdl-1.2/src/video/android/keymap.c
index df88bd744..e846e4bf1 100644
--- a/project/jni/sdl-1.2/src/video/android/keymap.c
+++ b/project/jni/sdl-1.2/src/video/android/keymap.c
@@ -130,18 +130,18 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap)
keymap[KEYCODE_PAGE_DOWN] = SDL_KEY(PAGEDOWN);
keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT);
keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT);
- keymap[KEYCODE_BUTTON_A] = SDL_KEY(A);
- keymap[KEYCODE_BUTTON_B] = SDL_KEY(B);
+ keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
+ keymap[KEYCODE_BUTTON_B] = SDL_KEY(ESCAPE); // SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); // There's no Back key on Ouya
keymap[KEYCODE_BUTTON_C] = SDL_KEY(C);
keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0));
keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1));
keymap[KEYCODE_BUTTON_Z] = SDL_KEY(Z);
- keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2));
- keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3));
- keymap[KEYCODE_BUTTON_L2] = SDL_KEY(LCTRL);
- keymap[KEYCODE_BUTTON_R2] = SDL_KEY(RCTRL);
- keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(LALT);
- keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(RALT);
+ keymap[KEYCODE_BUTTON_L1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_5));
+ keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_4));
+ keymap[KEYCODE_BUTTON_L2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0));
+ keymap[KEYCODE_BUTTON_R2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_6));
+ keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
+ keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_4));
keymap[KEYCODE_BUTTON_START] = SDL_KEY(RETURN);
keymap[KEYCODE_BUTTON_SELECT] = SDL_KEY(ESCAPE);
keymap[KEYCODE_BUTTON_MODE] = SDL_KEY(SPACE);
diff --git a/project/jni/sdl-1.2/src/video/android/unicodestuff.h b/project/jni/sdl-1.2/src/video/android/unicodestuff.h
new file mode 100644
index 000000000..3ef7971e1
--- /dev/null
+++ b/project/jni/sdl-1.2/src/video/android/unicodestuff.h
@@ -0,0 +1,86 @@
+#ifndef _UNICODE_STUFF_H_
+#define _UNICODE_STUFF_H_
+
+#include "SDL_androidinput.h"
+
+// I'm too lazy to move code into .c file
+
+static inline int UnicodeToUtf8(int src, char * dest)
+{
+ int len = 0;
+ if ( src <= 0x007f) {
+ *dest++ = (char)src;
+ len = 1;
+ } else if (src <= 0x07ff) {
+ *dest++ = (char)0xc0 | (src >> 6);
+ *dest++ = (char)0x80 | (src & 0x003f);
+ len = 2;
+ } else if (src == 0xFEFF) {
+ // nop -- zap the BOM
+ } else if (src >= 0xD800 && src <= 0xDFFF) {
+ // surrogates not supported
+ } else if (src <= 0xffff) {
+ *dest++ = (char)0xe0 | (src >> 12);
+ *dest++ = (char)0x80 | ((src >> 6) & 0x003f);
+ *dest++ = (char)0x80 | (src & 0x003f);
+ len = 3;
+ } else if (src <= 0xffff) {
+ *dest++ = (char)0xf0 | (src >> 18);
+ *dest++ = (char)0x80 | ((src >> 12) & 0x3f);
+ *dest++ = (char)0x80 | ((src >> 6) & 0x3f);
+ *dest++ = (char)0x80 | (src & 0x3f);
+ len = 4;
+ } else {
+ // out of Unicode range
+ }
+ *dest = 0;
+ return len;
+}
+
+static inline SDL_keysym asciiToKeysym(int ascii, int unicode)
+{
+ SDL_keysym keysym;
+ keysym.scancode = ascii;
+ keysym.sym = ascii;
+ keysym.mod = KMOD_NONE;
+ keysym.unicode = 0;
+#if SDL_VERSION_ATLEAST(1,3,0)
+ keysym.sym = SDL_GetScancodeFromKey(ascii);
+#else
+ if ( SDL_TranslateUNICODE )
+#endif
+ keysym.unicode = unicode;
+ return keysym;
+}
+
+static inline int checkShiftRequired( int * sym )
+{
+ switch( *sym )
+ {
+ case '!': *sym = '1'; return 1;
+ case '@': *sym = '2'; return 1;
+ case '#': *sym = '3'; return 1;
+ case '$': *sym = '4'; return 1;
+ case '%': *sym = '5'; return 1;
+ case '^': *sym = '6'; return 1;
+ case '&': *sym = '7'; return 1;
+ case '*': *sym = '8'; return 1;
+ case '(': *sym = '9'; return 1;
+ case ')': *sym = '0'; return 1;
+ case '_': *sym = '-'; return 1;
+ case '+': *sym = '='; return 1;
+ case '|': *sym = '\\';return 1;
+ case '<': *sym = ','; return 1;
+ case '>': *sym = '.'; return 1;
+ case '?': *sym = '/'; return 1;
+ case ':': *sym = ';'; return 1;
+ case '"': *sym = '\'';return 1;
+ case '{': *sym = '['; return 1;
+ case '}': *sym = ']'; return 1;
+ case '~': *sym = '`'; return 1;
+ default: if( *sym >= 'A' && *sym <= 'Z' ) { *sym += 'a' - 'A'; return 1; };
+ }
+ return 0;
+}
+
+#endif
diff --git a/project/project.properties b/project/project.properties
index 0840b4a05..a3ee5ab64 100644
--- a/project/project.properties
+++ b/project/project.properties
@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-15
+target=android-17
diff --git a/project/res/drawable-xhdpi/.gitignore b/project/res/drawable-xhdpi/.gitignore
new file mode 100644
index 000000000..a7fa27a93
--- /dev/null
+++ b/project/res/drawable-xhdpi/.gitignore
@@ -0,0 +1 @@
+ouya_icon.png
diff --git a/project/res/drawable/ouya_icon.png b/project/res/drawable/ouya_icon.png
new file mode 120000
index 000000000..12585c964
--- /dev/null
+++ b/project/res/drawable/ouya_icon.png
@@ -0,0 +1 @@
+icon.png
\ No newline at end of file
diff --git a/project/res/drawable/rectangle.png b/project/res/drawable/rectangle.png
new file mode 100644
index 000000000..1cf77c79b
Binary files /dev/null and b/project/res/drawable/rectangle.png differ
diff --git a/project/res/drawable/sun_b1.png b/project/res/drawable/sun_b1.png
new file mode 100644
index 000000000..faa1f8b24
Binary files /dev/null and b/project/res/drawable/sun_b1.png differ
diff --git a/project/res/drawable/sun_b2.png b/project/res/drawable/sun_b2.png
new file mode 100644
index 000000000..b9f58e5dd
Binary files /dev/null and b/project/res/drawable/sun_b2.png differ
diff --git a/project/res/drawable/sun_b3.png b/project/res/drawable/sun_b3.png
new file mode 100644
index 000000000..6e5fbe515
Binary files /dev/null and b/project/res/drawable/sun_b3.png differ
diff --git a/project/res/drawable/sun_b4.png b/project/res/drawable/sun_b4.png
new file mode 100644
index 000000000..a92dd6af6
Binary files /dev/null and b/project/res/drawable/sun_b4.png differ
diff --git a/project/res/drawable/sun_b5.png b/project/res/drawable/sun_b5.png
new file mode 100644
index 000000000..d40c10820
Binary files /dev/null and b/project/res/drawable/sun_b5.png differ
diff --git a/project/res/drawable/sun_b6.png b/project/res/drawable/sun_b6.png
new file mode 100644
index 000000000..9b644d122
Binary files /dev/null and b/project/res/drawable/sun_b6.png differ
diff --git a/project/res/drawable/sun_dpad.png b/project/res/drawable/sun_dpad.png
new file mode 100644
index 000000000..f653f2550
Binary files /dev/null and b/project/res/drawable/sun_dpad.png differ
diff --git a/project/res/drawable/sun_keyboard.png b/project/res/drawable/sun_keyboard.png
new file mode 100644
index 000000000..10b740e92
Binary files /dev/null and b/project/res/drawable/sun_keyboard.png differ
diff --git a/readme.txt b/readme.txt
index 7bb85dbcd..c37381849 100644
--- a/readme.txt
+++ b/readme.txt
@@ -10,10 +10,10 @@ Also this port is developed very slowly, although the same is true for an offici
Installation
============
-This project should be compiled with Android 3.1 SDK (API level 15) and NDK r8, r7c, r6 or r5c,
+This project should be compiled with Android 4.2 SDK (API level 17) and NDK r8, r7c, r6 or r5c,
google for them and install them as described in their docs.
You'll need to install Java Ant too.
-The application will run on Android OS 1.6 and above, don't mind the 3.1 dependency.
+The application will run on Android OS 1.6 and above, but will use features from Android 4.2 if available.
Also it's compatible with NDK r4b and all versions of CrystaX NDK starting from r4b.
CrystaX NDK adds support for wide chars, and required if you want to use Boost libraries.
http://www.crystax.net/android/ndk.php
@@ -120,8 +120,21 @@ Also make sure that your HW textures are not wider than 1024 pixels, or it will
texture on HTC G1, and other low-end devices. Software surfaces may be of any size of course.
If you want HW acceleration - just use OpenGL, that's the easiest and most cross-platform way,
-however note that on-screen keyboard (even the text input button) is also drawn using OpenGL,
-so it might mess up your GL state (although it should not do that due to recent code changes).
+however if you'll use on-screen keyboard (even the text input button) the OpenGL state will get
+messed up after each frame - after each SDL_GL_SwapBuffers() you'll need to restore following GL state:
+
+glEnable(GL_TEXTURE_2D);
+glActiveTexture(GL_TEXTURE0);
+glClientActiveTexture(GL_TEXTURE0);
+glBindTexture(GL_TEXTURE_2D, your_texture_id);
+glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+glEnable(GL_BLEND);
+glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+glEnableClientState(GL_COLOR_ARRAY);
+
+Previously I've got the code to save/restore OpenGL state, but it doens't work on every device -
+you may wish to uncomment it inside file SDL_touchscreenkeyboard.c in functions beginDrawingTex() and endDrawingTex().
If you don't use on-screen keyboard you don't need to reinit OpenGL state - set following in AndroidAppSettings.cfg:
AppNeedsArrowKeys=n
diff --git a/todo.txt b/todo.txt
index a2976458c..274323d01 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,2 +1,24 @@
-I'm not planning any more games to port, or any development on this SDL port.
-See bugs.txt if you want to contribute.
\ No newline at end of file
+Requested features (see also bugs.txt)
+======================================
+
+- Option for default on-screen key theme in AndroidAppSettings.cfg.
+
+- Select between normal mouse input and magnifying glass/relative input automatically, based on screen size.
+
+- Split Settings.java into several files.
+
+- Show/hide screen controls with longpress on Text Edit button.
+
+- Floating on-screen joystick - initially invisible, it appears when you touch the screen,
+ centered on your finger, then it slides with your finger if you bump the joystick edge.
+
+- Export phone vibrator to SDL - interface is available in SDL 1.3.
+
+- Control screen brightness with SDL_SetGamma().
+
+- Zoom in-out whole screen in SW mode with some SDL key or gesture, as in AndroidVNC. -
+
+- Support of libjnigraphics (it will disable on-screen keyboard, only SW SDL screen surface supported).
+ This is not relevant already, as every device around is fast enough with GL.
+
+- Second joystick, to be used in TeeWorlds.
\ No newline at end of file