Search
lxdream.org :: lxdream :: r1241:74f8e11ab4b8
lxdream 0.9.1
released Jun 29
Download Now
changeset1241:74f8e11ab4b8
parent1240:190df8a791ca
child1243:7f28eb5b815a
authornkeynes
dateTue Feb 28 17:27:39 2012 +1000 (12 years ago)
Pass the application home dir through to the native code, so we can use it
as the default data directory
android/src/org/lxdream/Dreamcast.java
android/src/org/lxdream/LxdreamActivity.java
android/src/org/lxdream/LxdreamView.java
src/gui_jni.c
src/lxpaths.h
src/paths_unix.c
1.1 --- a/android/src/org/lxdream/Dreamcast.java Tue Feb 28 17:25:26 2012 +1000
1.2 +++ b/android/src/org/lxdream/Dreamcast.java Tue Feb 28 17:27:39 2012 +1000
1.3 @@ -25,7 +25,7 @@
1.4 }
1.5
1.6 /* Core emulation */
1.7 - public static native void init();
1.8 + public static native void init( String appHome );
1.9 public static native void setViewSize(int width, int height);
1.10 public static native void run();
1.11 public static native void stop();
2.1 --- a/android/src/org/lxdream/LxdreamActivity.java Tue Feb 28 17:25:26 2012 +1000
2.2 +++ b/android/src/org/lxdream/LxdreamActivity.java Tue Feb 28 17:27:39 2012 +1000
2.3 @@ -19,6 +19,7 @@
2.4 package org.lxdream;
2.5
2.6 import android.app.Activity;
2.7 +import android.content.Context;
2.8 import android.os.Bundle;
2.9 import android.util.Log;
2.10 import android.view.WindowManager;
2.11 @@ -32,7 +33,9 @@
2.12 @Override
2.13 protected void onCreate(Bundle bundle) {
2.14 super.onCreate(bundle);
2.15 - view = new LxdreamView(getApplication());
2.16 + Context ctx = getApplication();
2.17 + Dreamcast.init( ctx.getFilesDir().toString() );
2.18 + view = new LxdreamView(ctx);
2.19 setContentView(view);
2.20 }
2.21
3.1 --- a/android/src/org/lxdream/LxdreamView.java Tue Feb 28 17:25:26 2012 +1000
3.2 +++ b/android/src/org/lxdream/LxdreamView.java Tue Feb 28 17:27:39 2012 +1000
3.3 @@ -139,7 +139,6 @@
3.4 }
3.5
3.6 public void onSurfaceChanged(GL10 gl, int width, int height) {
3.7 - Dreamcast.init();
3.8 Dreamcast.setViewSize(width,height);
3.9 }
3.10
4.1 --- a/src/gui_jni.c Tue Feb 28 17:25:26 2012 +1000
4.2 +++ b/src/gui_jni.c Tue Feb 28 17:27:39 2012 +1000
4.3 @@ -22,16 +22,33 @@
4.4 #include "dreamcast.h"
4.5 #include "gui.h"
4.6 #include "config.h"
4.7 +#include "lxpaths.h"
4.8 #include "display.h"
4.9 #include "gdlist.h"
4.10 #include "hotkeys.h"
4.11 #include "serial.h"
4.12 #include "aica/audio.h"
4.13 +#include "drivers/video_gl.h"
4.14 #include "maple/maple.h"
4.15 #include "vmu/vmulist.h"
4.16
4.17 -JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_init(JNIEnv * env, jobject obj, jint width, jint height)
4.18 +static char *getStringChars( JNIEnv *env, jstring str )
4.19 {
4.20 + jboolean iscopy;
4.21 + const char *p = (*env)->GetStringUTFChars(env, str, &iscopy);
4.22 + char *result = strdup(p);
4.23 + (*env)->ReleaseStringUTFChars(env,str,p);
4.24 + return result;
4.25 +}
4.26 +
4.27 +static const char *appHome = NULL;
4.28 +
4.29 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_init(JNIEnv * env, jclass obj, jstring homeDir )
4.30 +{
4.31 + appHome = getStringChars(env, homeDir);
4.32 + const char *confFile = g_strdup_printf("%s/lxdreamrc", appHome);
4.33 + set_user_data_path(appHome);
4.34 + lxdream_set_config_filename( confFile );
4.35 lxdream_make_config_dir( );
4.36 lxdream_load_config( );
4.37 iso_init();
4.38 @@ -49,17 +66,17 @@
4.39 INFO( "%s! ready...", APP_NAME );
4.40 }
4.41
4.42 -JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_setViewSize(JNIEnv * env, jobject obj, jint width, jint height)
4.43 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_setViewSize(JNIEnv * env, jclass obj, jint width, jint height)
4.44 {
4.45 -
4.46 + gl_set_video_size(width, height);
4.47 }
4.48
4.49 -JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_run(JNIEnv * env, jobject obj)
4.50 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_run(JNIEnv * env, jclass obj)
4.51 {
4.52 dreamcast_run();
4.53 }
4.54
4.55 -JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_stop(JNIEnv * env, jobject obj)
4.56 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_stop(JNIEnv * env, jclass obj)
4.57 {
4.58 dreamcast_stop();
4.59 }
5.1 --- a/src/lxpaths.h Tue Feb 28 17:25:26 2012 +1000
5.2 +++ b/src/lxpaths.h Tue Feb 28 17:27:39 2012 +1000
5.3 @@ -42,6 +42,11 @@
5.4 */
5.5 const char *get_user_data_path();
5.6
5.7 +/**
5.8 + * Set the user data path
5.9 + */
5.10 +void set_user_data_path( const char *p );
5.11 +
5.12 /******************** Path helpers *****************/
5.13
5.14 /**
6.1 --- a/src/paths_unix.c Tue Feb 28 17:25:26 2012 +1000
6.2 +++ b/src/paths_unix.c Tue Feb 28 17:27:39 2012 +1000
6.3 @@ -47,4 +47,15 @@
6.4 user_data_path = g_strdup_printf( "%s/.lxdream", home );
6.5 }
6.6 return user_data_path;
6.7 +}
6.8 +
6.9 +void set_user_data_path( const char *p )
6.10 +{
6.11 + g_free(user_data_path);
6.12 + user_data_path = g_strdup(p);
6.13 +}
6.14 +
6.15 +const char *get_user_home_path()
6.16 +{
6.17 + return getenv("HOME");
6.18 }
6.19 \ No newline at end of file
.