diff --git a/project/jni/application/xserver/AndroidAppSettings.cfg b/project/jni/application/xserver/AndroidAppSettings.cfg index b220e69ad..17359b097 100644 --- a/project/jni/application/xserver/AndroidAppSettings.cfg +++ b/project/jni/application/xserver/AndroidAppSettings.cfg @@ -23,7 +23,7 @@ InhibitSuspend=n # If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir - # these files are put inside .apk package by build system # Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS -AppDataDownloadUrl="!!Data files - 20 Mb|http://sourceforge.net/projects/libsdl-android/files/OpenTTD/openttd-data-1.3.2.zip/download" +AppDataDownloadUrl="!!Data files|:data.tar.gz:data-1.tgz^!!Data files|:busybox:busybox" # Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only # with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32) @@ -106,7 +106,7 @@ AppUsesAccelerometer=n AppUsesGyroscope=n # Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0 -AppUsesMultitouch=n +AppUsesMultitouch=y # Application records audio (it will use any available source, such a s microphone) # API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void); diff --git a/project/jni/application/xserver/AndroidBuild.sh b/project/jni/application/xserver/AndroidBuild.sh index c0d29dc0c..284c4a145 100755 --- a/project/jni/application/xserver/AndroidBuild.sh +++ b/project/jni/application/xserver/AndroidBuild.sh @@ -15,7 +15,7 @@ cd xserver [ -e configure ] || autoreconf --force -v --install || exit 1 cd android -env PACKAGE_NAME=$PACKAGE_NAME \ +env TARGET_DIR=/data/data/$PACKAGE_NAME/files \ ./build.sh || exit 1 ../../../setEnvironment-armeabi-v7a.sh sh -c '\ diff --git a/project/jni/application/xserver/AndroidData/busybox b/project/jni/application/xserver/AndroidData/busybox new file mode 120000 index 000000000..f00036bfc --- /dev/null +++ b/project/jni/application/xserver/AndroidData/busybox @@ -0,0 +1 @@ +../xserver/data/busybox \ No newline at end of file diff --git a/project/jni/application/xserver/AndroidData/data-1.tgz b/project/jni/application/xserver/AndroidData/data-1.tgz new file mode 120000 index 000000000..2a2d243ac --- /dev/null +++ b/project/jni/application/xserver/AndroidData/data-1.tgz @@ -0,0 +1 @@ +../xserver/data/data-1.tgz \ No newline at end of file diff --git a/project/jni/application/xserver/main.c b/project/jni/application/xserver/main.c index cc1891f58..1fc2fa924 100644 --- a/project/jni/application/xserver/main.c +++ b/project/jni/application/xserver/main.c @@ -1,21 +1,90 @@ #include +#include +#include +#include #include +#include -extern int android_main(int argc, char *argv[], char *envp[]); +extern int android_main( int argc, char *argv[], char *envp[] ); +static int unpack_files(); -int main(int argc, char* argv[]) +int main( int argc, char* argv[] ) { char screenres[64] = "640x480x24"; char* args[] = { "XSDL", ":1111", - "-3button", + "-nolock", "-screen", screenres }; char * envp[] = { NULL }; - sprintf("%sx%sx%d", getenv("DISPLAY_RESOLUTION_WIDTH"), getenv("DISPLAY_RESOLUTION_HEIGHT"), 24); + sprintf( screenres, "%sx%sx%d", getenv("DISPLAY_RESOLUTION_WIDTH"), getenv("DISPLAY_RESOLUTION_HEIGHT"), 24 ); + + if( !unpack_files() ) + { + __android_log_print(ANDROID_LOG_INFO, "XSDL", "Error while unpacking files, try to reinstall the app"); + return 1; + } - return android_main(5, args, envp); + return android_main( 5, args, envp ); +} + +int unpack_files() +{ + char fname[PATH_MAX*2]; + strcpy( fname, getenv("SECURE_STORAGE_DIR") ); + strcat( fname, "/usr/bin/xkbcomp" ); + struct stat st; + if( stat( fname, &st ) == 0 ) + return 1; + + strcpy( fname, getenv("SECURE_STORAGE_DIR") ); + strcat( fname, "/busybox" ); + FILE * ff = fopen("busybox", "rb"); + FILE * fo = fopen(fname, "wb"); + if( !ff || !fo ) + return 0; + + for(;;) + { + char buf[2048]; + int cnt = fread( buf, 1, sizeof(buf), ff ); + if( cnt < 0 ) + return 1; + fwrite( buf, 1, cnt, fo ); + if( cnt < sizeof(buf) ) + break; + } + + fclose(ff); + fclose(fo); + + if( chmod(fname, 0755) != 0 ) + return 0; + + ff = fopen("data.tar.gz", "rb"); + strcat(fname, " tar xz -C "); + strcat(fname, getenv("SECURE_STORAGE_DIR")); + fo = popen(fname, "w"); + if( !ff || !fo ) + return 0; + + for(;;) + { + char buf[2048]; + int cnt = fread( buf, 1, sizeof(buf), ff ); + if( cnt < 0 ) + return 1; + fwrite( buf, 1, cnt, fo ); + if( cnt < sizeof(buf) ) + break; + } + + fclose(ff); + if( pclose(fo) != 0 ) + return 0; + + return 1; } diff --git a/project/jni/application/xserver/readme.txt b/project/jni/application/xserver/readme.txt index 1e942c8b9..c8a6dcf78 100644 --- a/project/jni/application/xserver/readme.txt +++ b/project/jni/application/xserver/readme.txt @@ -1,12 +1,12 @@ You will to install some packages to your Debian/Ubuntu first: -sudo apt-get install libpixman-1-dev libxfont-dev \ -libxkbfile-dev libpciaccess-dev xutils-dev xcb-proto \ -python-xcbgen xsltproc x11proto-bigreqs-dev \ -x11proto-composite-dev x11proto-core-dev \ -x11proto-damage-dev x11proto-dmx-dev \ -x11proto-dri2-dev x11proto-fixes-dev \ +sudo apt-get install bison libpixman-1-dev +libxfont-dev libxkbfile-dev libpciaccess-dev \ +xutils-dev xcb-proto python-xcbgen xsltproc \ +x11proto-bigreqs-dev x11proto-composite-dev \ +x11proto-core-dev x11proto-damage-dev \ +x11proto-dmx-dev x11proto-dri2-dev x11proto-fixes-dev \ x11proto-fonts-dev x11proto-gl-dev \ x11proto-input-dev x11proto-kb-dev \ x11proto-print-dev x11proto-randr-dev \ diff --git a/project/jni/application/xserver/xserver b/project/jni/application/xserver/xserver index eb6eaf433..5ae2822ed 160000 --- a/project/jni/application/xserver/xserver +++ b/project/jni/application/xserver/xserver @@ -1 +1 @@ -Subproject commit eb6eaf433b5ebb5bc31b23b8b1006653c9b4ceb4 +Subproject commit 5ae2822edd89880db1b456d3f61c39e14d6f4bb2 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 2af5ab3c3..5462d46a9 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 @@ -420,8 +420,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t if( action == MOUSE_DOWN ) 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 + SDL_ANDROID_MainThreadPushJoystickBall(JOY_TOUCHSCREEN, pointerId, x, y); if( action == MOUSE_UP ) SDL_ANDROID_MainThreadPushJoystickButton(JOY_TOUCHSCREEN, pointerId, SDL_RELEASED); }