Xserver almost runs

This commit is contained in:
pelya
2013-11-03 18:32:06 +02:00
parent df6afa23aa
commit 331b74d01c
8 changed files with 87 additions and 16 deletions

View File

@@ -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);

View File

@@ -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 '\

View File

@@ -0,0 +1 @@
../xserver/data/busybox

View File

@@ -0,0 +1 @@
../xserver/data/data-1.tgz

View File

@@ -1,21 +1,90 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <SDL/SDL.h>
#include <android/log.h>
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;
}

View File

@@ -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 \