Editable data download path/application curdir, editable app commandline, updated teadme

This commit is contained in:
pelya
2010-12-29 12:55:44 +00:00
parent 3fdcecc38c
commit 154e2e3eda
12 changed files with 123 additions and 58 deletions

View File

@@ -2,7 +2,7 @@
KEYSTORE=~/.ssh/android.keystore KEYSTORE=~/.ssh/android.keystore
ALIAS=pelya ALIAS=pelya
APPS_SKIP="src jooleem_0.1.4 lbreakout2 glxgears atari800 scummvm" APPS_SKIP="src scummvm"
mkdir -p apk mkdir -p apk

View File

@@ -148,9 +148,7 @@ class DataDownloader extends Thread
Parent = _Parent; Parent = _Parent;
Status = new StatusWriter( _Status, _Parent ); Status = new StatusWriter( _Status, _Parent );
//Status.setText( "Connecting to " + Globals.DataDownloadUrl ); //Status.setText( "Connecting to " + Globals.DataDownloadUrl );
outFilesDir = Parent.getFilesDir().getAbsolutePath(); outFilesDir = Globals.DataDir;
if( Globals.DownloadToSdcard )
outFilesDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName();
DownloadComplete = false; DownloadComplete = false;
this.start(); this.start();
} }
@@ -217,18 +215,15 @@ class DataDownloader extends Thread
checkFile = null; checkFile = null;
// Create output directory (not necessary for phone storage) // Create output directory (not necessary for phone storage)
if( Globals.DownloadToSdcard ) try {
{ (new File( outFilesDir )).mkdirs();
try { OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
(new File( outFilesDir )).mkdirs(); out.flush();
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") ); out.close();
out.flush();
out.close();
}
catch( SecurityException e ) {}
catch( FileNotFoundException e ) {}
catch( IOException e ) {};
} }
catch( SecurityException e ) {}
catch( FileNotFoundException e ) {}
catch( IOException e ) {};
HttpResponse response = null; HttpResponse response = null;
HttpGet request; HttpGet request;

View File

@@ -83,10 +83,12 @@ class Globals {
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST]; public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
public static int RemapScreenKbKeycode[] = new int[6]; public static int RemapScreenKbKeycode[] = new int[6];
public static boolean ScreenKbControlsShown[] = new boolean[8]; /* Also joystick and text input button added */ public static boolean ScreenKbControlsShown[] = new boolean[8]; /* Also joystick and text input button added */
public static int ScreenKbControlsLayout[][] = new int[8][4];
public static int RemapMultitouchGestureKeycode[] = new int[4]; public static int RemapMultitouchGestureKeycode[] = new int[4];
public static boolean MultitouchGesturesUsed[] = new boolean[4]; public static boolean MultitouchGesturesUsed[] = new boolean[4];
public static int MultitouchGestureSensitivity = 1; public static int MultitouchGestureSensitivity = 1;
public static int TouchscreenCalibration[] = new int[4]; public static int TouchscreenCalibration[] = new int[4];
public static String DataDir = new String("");
} }
class LoadLibrary { class LoadLibrary {

View File

@@ -31,6 +31,9 @@ import android.widget.FrameLayout;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.widget.TextView;
import android.widget.EditText;
import android.text.Editable;
@@ -95,6 +98,12 @@ class Settings
out.writeInt(Globals.MultitouchGestureSensitivity); out.writeInt(Globals.MultitouchGestureSensitivity);
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ ) for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
out.writeInt(Globals.TouchscreenCalibration[i]); out.writeInt(Globals.TouchscreenCalibration[i]);
out.writeInt(Globals.DataDir.length());
for( int i = 0; i < Globals.DataDir.length(); i++ )
out.writeChar(Globals.DataDir.charAt(i));
out.writeInt(Globals.CommandLine.length());
for( int i = 0; i < Globals.CommandLine.length(); i++ )
out.writeChar(Globals.CommandLine.charAt(i));
out.close(); out.close();
settingsLoaded = true; settingsLoaded = true;
@@ -200,6 +209,17 @@ class Settings
Globals.MultitouchGestureSensitivity = settingsFile.readInt(); Globals.MultitouchGestureSensitivity = settingsFile.readInt();
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ ) for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
Globals.TouchscreenCalibration[i] = settingsFile.readInt(); Globals.TouchscreenCalibration[i] = settingsFile.readInt();
StringBuilder b = new StringBuilder();
int len = settingsFile.readInt();
for( int i = 0; i < len; i++ )
b.append( settingsFile.readChar() );
Globals.DataDir = b.toString();
b = new StringBuilder();
len = settingsFile.readInt();
for( int i = 0; i < len; i++ )
b.append( settingsFile.readChar() );
Globals.CommandLine = b.toString();
settingsLoaded = true; settingsLoaded = true;
@@ -211,6 +231,11 @@ class Settings
} catch( SecurityException e ) { } catch( SecurityException e ) {
} catch ( IOException e ) {}; } catch ( IOException e ) {};
if( Globals.DataDir.length() == 0 )
Globals.DataDir = Globals.DownloadToSdcard ?
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
p.getFilesDir().getAbsolutePath();
// This code fails for both of my phones! // This code fails for both of my phones!
/* /*
Configuration c = new Configuration(); Configuration c = new Configuration();
@@ -494,7 +519,8 @@ class Settings
}catch(Exception e) {} }catch(Exception e) {}
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone), final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
p.getResources().getString(R.string.storage_sd, freeSdcard) }; p.getResources().getString(R.string.storage_sd, freeSdcard),
p.getResources().getString(R.string.storage_custom) };
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^"); String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
builder.setTitle(downloadFiles[0].split("[|]")[0]); builder.setTitle(downloadFiles[0].split("[|]")[0]);
@@ -502,9 +528,66 @@ class Settings
{ {
public void onClick(DialogInterface dialog, int item) public void onClick(DialogInterface dialog, int item)
{ {
Globals.DownloadToSdcard = (item == 1); Globals.DownloadToSdcard = (item != 0);
Globals.DataDir = Globals.DownloadToSdcard ?
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
p.getFilesDir().getAbsolutePath();
dialog.dismiss(); dialog.dismiss();
if( item == 2 )
showCustomDownloadDirConfig(p);
else
showConfigMainMenu(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
};
static void showCustomDownloadDirConfig(final MainActivity p) {
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.storage_custom));
final EditText edit = new EditText(p);
edit.setFocusableInTouchMode(true);
edit.setFocusable(true);
edit.setText(Globals.DataDir);
builder.setView(edit);
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.DataDir = edit.getText().toString();
dialog.dismiss();
showCommandLineConfig(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
};
static void showCommandLineConfig(final MainActivity p) {
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
final EditText edit = new EditText(p);
edit.setFocusableInTouchMode(true);
edit.setFocusable(true);
edit.setText(Globals.CommandLine);
builder.setView(edit);
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.CommandLine = edit.getText().toString();
dialog.dismiss();
showConfigMainMenu(p); showConfigMainMenu(p);
} }
}); });
@@ -1369,8 +1452,6 @@ class Settings
static void Apply(Activity p) static void Apply(Activity p)
{ {
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
if( Globals.PhoneHasTrackball ) if( Globals.PhoneHasTrackball )
nativeSetTrackballUsed(); nativeSetTrackballUsed();
if( Globals.AppUsesMouse ) if( Globals.AppUsesMouse )
@@ -1452,7 +1533,6 @@ class Settings
} }
} }
private static native void nativeIsSdcardUsed(int flag);
private static native void nativeSetTrackballUsed(); private static native void nativeSetTrackballUsed();
private static native void nativeSetTrackballDampening(int value); private static native void nativeSetTrackballDampening(int value);
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos); private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);

View File

@@ -212,9 +212,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
// Tweak video thread priority, if user selected big audio buffer // Tweak video thread priority, if user selected big audio buffer
if(Globals.AudioBufferConfig >= 2) if(Globals.AudioBufferConfig >= 2)
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
nativeInit( Globals.DownloadToSdcard ? nativeInit( Globals.DataDir,
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
context.getFilesDir().getAbsolutePath(),
Globals.CommandLine); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code Globals.CommandLine); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
} }

View File

@@ -21,6 +21,8 @@
<string name="storage_phone">Internal storage - %d MB free</string> <string name="storage_phone">Internal storage - %d MB free</string>
<string name="storage_sd">SD card storage - %d MB free</string> <string name="storage_sd">SD card storage - %d MB free</string>
<string name="storage_custom">Specify directory</string>
<string name="storage_commandline">Specify command line parameters</string>
<string name="storage_question">Where to download application data</string> <string name="storage_question">Where to download application data</string>
<string name="optional_downloads">Optional downloads</string> <string name="optional_downloads">Optional downloads</string>
<string name="ok">OK</string> <string name="ok">OK</string>

View File

@@ -1,5 +1,5 @@
# The application settings for Android libSDL port # The application settings for Android libSDL port
AppSettingVersion=15 AppSettingVersion=16
LibSdlVersion=1.2 LibSdlVersion=1.2
AppName="REminiscence" AppName="REminiscence"
AppFullName=fr.freecyxdown.sdl AppFullName=fr.freecyxdown.sdl
@@ -20,6 +20,7 @@ NonBlockingSwapBuffers=n
RedefinedKeys="RSHIFT RETURN BACKSPACE RETURN SPACE" RedefinedKeys="RSHIFT RETURN BACKSPACE RETURN SPACE"
AppTouchscreenKeyboardKeysAmount=3 AppTouchscreenKeyboardKeysAmount=3
AppTouchscreenKeyboardKeysAmountAutoFire=0 AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="RSHIFT RETURN BACKSPACE RETURN SPACE"
MultiABI=n MultiABI=n
AppVersionCode=01901 AppVersionCode=01901
AppVersionName="0.1.9" AppVersionName="0.1.9"

View File

@@ -1,5 +1,5 @@
# The application settings for Android libSDL port # The application settings for Android libSDL port
AppSettingVersion=15 AppSettingVersion=16
LibSdlVersion=1.3 LibSdlVersion=1.3
AppName="Alien Blaster" AppName="Alien Blaster"
AppFullName=de.schwardtnet.alienblaster AppFullName=de.schwardtnet.alienblaster
@@ -20,6 +20,7 @@ NonBlockingSwapBuffers=n
RedefinedKeys="RETURN LCTRL PAGEUP PAGEDOWN LCTRL" RedefinedKeys="RETURN LCTRL PAGEUP PAGEDOWN LCTRL"
AppTouchscreenKeyboardKeysAmount=4 AppTouchscreenKeyboardKeysAmount=4
AppTouchscreenKeyboardKeysAmountAutoFire=1 AppTouchscreenKeyboardKeysAmountAutoFire=1
RedefinedKeysScreenKb="RETURN LCTRL PAGEUP PAGEDOWN LCTRL"
MultiABI=n MultiABI=n
AppVersionCode=110013 AppVersionCode=110013
AppVersionName="1.1.0.13 - fixed crashes for some devices" AppVersionName="1.1.0.13 - fixed crashes for some devices"

View File

@@ -22,8 +22,8 @@ AppTouchscreenKeyboardKeysAmount=0
AppTouchscreenKeyboardKeysAmountAutoFire=0 AppTouchscreenKeyboardKeysAmountAutoFire=0
RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2" RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2"
MultiABI=n MultiABI=n
AppVersionCode=10508 AppVersionCode=10509
AppVersionName="1.0.5.08" AppVersionName="1.0.5.09"
CompiledLibraries="jpeg png freetype timidity lzma lzo2" CompiledLibraries="jpeg png freetype timidity lzma lzo2"
CustomBuildScript=y CustomBuildScript=y
AppCflags='' AppCflags=''

View File

@@ -1 +1 @@
fheroes2 ballfield

View File

@@ -25,40 +25,27 @@
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH) #define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
static int isSdcardUsed = 0;
extern C_LINKAGE void extern C_LINKAGE void
JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline ) JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline )
{ {
int i = 0; int i = 0;
char curdir[PATH_MAX] = ""; char curdir[PATH_MAX] = "";
char realcurdir[PATH_MAX] = "";
const jbyte *jstr; const jbyte *jstr;
const char * str = "sdl"; const char * str = "sdl";
int argc = 0; int argc = 0;
char ** argv = NULL; char ** argv = NULL;
if( isSdcardUsed ) strcpy(curdir, "/sdcard/app-data/");
{ strcat(curdir, SDL_CURDIR_PATH);
strcpy(curdir, "/sdcard/app-data/");
strcat(curdir, SDL_CURDIR_PATH);
}
else
{
strcpy(curdir, "/data/data/");
strcat(curdir, SDL_CURDIR_PATH);
strcat(curdir, "/files");
}
jstr = (*env)->GetStringUTFChars(env, jcurdir, NULL); jstr = (*env)->GetStringUTFChars(env, jcurdir, NULL);
if (jstr != NULL && strlen(jstr) > 0) if (jstr != NULL && strlen(jstr) > 0)
strcpy(curdir, jstr); strcpy(curdir, jstr);
(*env)->ReleaseStringUTFChars(env, jcurdir, jstr); (*env)->ReleaseStringUTFChars(env, jcurdir, jstr);
if( realpath(curdir, realcurdir) == NULL ) chdir(curdir);
strcpy(realcurdir, curdir); setenv("HOME", curdir, 1);
chdir(realcurdir); __android_log_print(ANDROID_LOG_INFO, "libSDL", "Changing curdir to \"%s\"", curdir);
setenv("HOME", realcurdir, 1);
jstr = (*env)->GetStringUTFChars(env, cmdline, NULL); jstr = (*env)->GetStringUTFChars(env, cmdline, NULL);
@@ -104,12 +91,6 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
}; };
extern C_LINKAGE void
JAVA_EXPORT_NAME(Settings_nativeIsSdcardUsed) ( JNIEnv* env, jobject thiz, jint flag )
{
isSdcardUsed = flag;
}
extern C_LINKAGE void extern C_LINKAGE void
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value ) JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
{ {

View File

@@ -16,28 +16,33 @@ http://www.pocketmagic.net/?p=1332 - guide how to set up environment in Cygwin.
Please don't use NDK r5, it is buggy, wait for NDK r5b: Please don't use NDK r5, it is buggy, wait for NDK r5b:
http://groups.google.com/group/android-ndk/browse_thread/thread/6b35728eec7ef52f/b57f52776842041d http://groups.google.com/group/android-ndk/browse_thread/thread/6b35728eec7ef52f/b57f52776842041d
How to compile Alien Blaster demo application How to compile demo application
============================================= ===============================
Go to "project" directory and launch command Go to "project" directory and launch command
android update project -p . android update project -p .
rm project/jni/application/src
ln -s ballfield project/jni/application/src
Then go back, edit file build.sh if needed to add NDK dir to your PATH, then launch it. Then go back, edit file build.sh if needed to add NDK dir to your PATH, then launch it.
It will compile a bunch of libs under project/libs/armeabi, It will compile a bunch of libs under project/libs/armeabi,
create file project/bin/DemoActivity-debug.apk and install it on your device or emulator. create file project/bin/DemoActivity-debug.apk and install it on your device or emulator.
Then you can test it by launching Alien Blaster icon from Android applications menu. Then you can test it by launching Ballfield icon from Android applications menu.
It's designed for 640x480, so if you have smaller screen it will be resized. It's designed for 320x240, so if you have smaller screen it will be resized.
Note: The game enforces horizontal screen orientation, you may open your keyboard and use it for Note: The game enforces horizontal screen orientation, you may open your keyboard and use it for
additional keys - the phone will just keep current screen orientation. additional keys - the phone will just keep current screen orientation.
Recent Android phone models like HTC Evo have no keyboard at all, on-screen keyboard built into libSDL Recent Android phone models like HTC Evo have no keyboard at all, on-screen keyboard built into libSDL
is available for such devices - it has joystick (which can be configured as arrow buttons or analog joystick), is available for such devices - it has joystick (which can be configured as arrow buttons or analog joystick),
and 6 configurable keys, full text input is toggled with 7-th key. Application may redefine button layout and 6 configurable keys, full text input is toggled with 7-th key. Both user and application may redefine
and returned keycodes, and also toggle full text input - see SDL_screenkeyboard.h. button layout and returned keycodes, and also toggle full text input - see SDL_screenkeyboard.h.
This port also supports GL ES + SDL combo - there is GLXGears demo app in project/jni/application/glxgears, This port also supports GL ES + SDL combo - there is GLXGears demo app in project/jni/application/glxgears,
remove project/jni/application/src symlink and make new one pointing to glxgears, then run build.sh remove project/jni/application/src symlink and make new one pointing to glxgears, then run build.sh
Note that GL ES is NOT pure OpenGL - there are no glBegin() and glEnd() call and other widely used functions, Note that GL ES is NOT pure OpenGL - there are no glBegin() and glEnd() call and other widely used functions,
and generally it will take a lot of effort to port pure OpenGL application to GL ES. and generally it will take a lot of effort to port pure OpenGL application to GL ES.
Previously The Alien Blaster was the default demo application, however it uses SDL 1.3 and I'm breaking
the compilation too often, so if something does not compile please try to use some older revision.
How to compile your own application How to compile your own application
=================================== ===================================