mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +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)
 | 
					if (ANDROID)
 | 
				
			||||||
 | 
					    set(GAME ${GAME} android_commandLine.cpp)
 | 
				
			||||||
    set(GAME ${GAME} android_main.c)
 | 
					    set(GAME ${GAME} android_main.c)
 | 
				
			||||||
endif()
 | 
					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,10 +1,8 @@
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../../SDL_internal.h"
 | 
					#include "../../SDL_internal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __ANDROID__
 | 
					#ifdef __ANDROID__
 | 
				
			||||||
#include "SDL_main.h"
 | 
					#include "SDL_main.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/*******************************************************************************
 | 
					/*******************************************************************************
 | 
				
			||||||
 Functions called by JNI
 | 
					 Functions called by JNI
 | 
				
			||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
| 
						 | 
					@ -12,26 +10,22 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called before  to initialize JNI bindings  */
 | 
					/* Called before  to initialize JNI bindings  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
 | 
					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,
 | 
				
			||||||
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
 | 
							jobject obj) {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SDL_Android_Init(env, cls);
 | 
						SDL_Android_Init(env, cls);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SDL_SetMainReady();
 | 
						SDL_SetMainReady();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     
 | 
					 | 
				
			||||||
	/* Run the application code! */
 | 
						/* Run the application code! */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int status;
 | 
						int status;
 | 
				
			||||||
    char *argv[2];
 | 
					
 | 
				
			||||||
    argv[0] = SDL_strdup("openmw");
 | 
						status = main(argcData+1, argvData);
 | 
				
			||||||
    argv[1] = NULL;
 | 
					 | 
				
			||||||
    status = main(1, argv);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
 | 
						/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
 | 
				
			||||||
	/* exit(status); */
 | 
						/* exit(status); */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue