Merge remote-tracking branch 'sandstranger/command-line-support-for-Android'

celladd
Marc Zinnschlag 10 years ago
commit e6e02714a0

@ -7,6 +7,7 @@ set(GAME
)
if (ANDROID)
set(GAME ${GAME} android_commandLine.cpp)
set(GAME ${GAME} android_main.c)
endif()

@ -0,0 +1,18 @@
#include "android_commandLine.h"
#include "string.h"
const char *argvData[15];
int argcData;
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env,
jobject obj, jint argc, jobjectArray stringArray) {
jboolean iscopy;
argcData = (int) argc;
argvData[0]="openmw";
for (int i = 0; i < argcData; i++) {
jstring string = (jstring) (*env).GetObjectArrayElement(stringArray, i);
argvData[i+1] = (env)->GetStringUTFChars(string, &iscopy);
}
}

@ -0,0 +1,16 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#ifndef _Included_ui_activity_GameActivity_commandLine
#define _Included_ui_activity_GameActivity_commandLine
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_ui_activity_GameActivity_commandLine(JNIEnv *env, jobject obj,jint argcData, jobjectArray stringArray);
#ifdef __cplusplus
}
#endif
#endif

@ -1,42 +1,36 @@
#include "../../SDL_internal.h"
#ifdef __ANDROID__
#include "SDL_main.h"
/*******************************************************************************
Functions called by JNI
*******************************************************************************/
Functions called by JNI
*******************************************************************************/
#include <jni.h>
/* Called before to initialize JNI bindings */
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
extern int argcData;
extern const char *argvData[15];
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls,
jobject obj) {
SDL_Android_Init(env, cls);
SDL_SetMainReady();
/* Run the application code! */
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
{
SDL_Android_Init(env, cls);
SDL_SetMainReady();
int status;
/* Run the application code! */
int status;
char *argv[2];
argv[0] = SDL_strdup("openmw");
argv[1] = NULL;
status = main(1, argv);
status = main(argcData+1, argvData);
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
/* exit(status); */
return status;
return status;
}
#endif /* __ANDROID__ */

Loading…
Cancel
Save