mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
command line support for Android
This commit is contained in:
parent
cf077dcf5d
commit
a418b70937
4 changed files with 52 additions and 23 deletions
|
@ -7,6 +7,7 @@ set(GAME
|
|||
)
|
||||
|
||||
if (ANDROID)
|
||||
set(GAME ${GAME} android_commandLine.cpp)
|
||||
set(GAME ${GAME} android_main.c)
|
||||
endif()
|
||||
|
||||
|
|
18
apps/openmw/android_commandLine.cpp
Normal file
18
apps/openmw/android_commandLine.cpp
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
16
apps/openmw/android_commandLine.h
Normal file
16
apps/openmw/android_commandLine.h
Normal file
|
@ -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) {
|
||||
|
||||
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
|
||||
{
|
||||
|
||||
SDL_Android_Init(env, cls);
|
||||
|
||||
SDL_SetMainReady();
|
||||
SDL_Android_Init(env, cls);
|
||||
|
||||
|
||||
/* Run the application code! */
|
||||
|
||||
int status;
|
||||
char *argv[2];
|
||||
argv[0] = SDL_strdup("openmw");
|
||||
argv[1] = NULL;
|
||||
status = main(1, argv);
|
||||
SDL_SetMainReady();
|
||||
|
||||
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
||||
/* exit(status); */
|
||||
/* Run the application code! */
|
||||
|
||||
return status;
|
||||
int status;
|
||||
|
||||
status = main(argcData+1, argvData);
|
||||
|
||||
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
||||
/* exit(status); */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* __ANDROID__ */
|
||||
|
|
Loading…
Reference in a new issue