mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-05 23:10:58 +00:00
Corrected header file documentation comment.
This commit is contained in:
commit
9c398852e6
1896 changed files with 489150 additions and 0 deletions
77
src/main/android/SDL_android_main.c
Normal file
77
src/main/android/SDL_android_main.c
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
SDL_android_main.c, placed in the public domain by Sam Lantinga 3/13/14
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
/* Include the SDL main definition header */
|
||||
#include "SDL_main.h"
|
||||
|
||||
/*******************************************************************************
|
||||
Functions called by JNI
|
||||
*******************************************************************************/
|
||||
#include <jni.h>
|
||||
|
||||
/* Called before SDL_main() to initialize JNI bindings in SDL library */
|
||||
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
|
||||
|
||||
/* Start up the SDL app */
|
||||
int Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject array)
|
||||
{
|
||||
int i;
|
||||
int argc;
|
||||
int status;
|
||||
|
||||
/* This interface could expand with ABI negotiation, callbacks, etc. */
|
||||
SDL_Android_Init(env, cls);
|
||||
|
||||
SDL_SetMainReady();
|
||||
|
||||
/* Prepare the arguments. */
|
||||
|
||||
int len = (*env)->GetArrayLength(env, array);
|
||||
char* argv[1 + len + 1];
|
||||
argc = 0;
|
||||
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
|
||||
https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
|
||||
*/
|
||||
argv[argc++] = SDL_strdup("app_process");
|
||||
for (i = 0; i < len; ++i) {
|
||||
const char* utf;
|
||||
char* arg = NULL;
|
||||
jstring string = (*env)->GetObjectArrayElement(env, array, i);
|
||||
if (string) {
|
||||
utf = (*env)->GetStringUTFChars(env, string, 0);
|
||||
if (utf) {
|
||||
arg = SDL_strdup(utf);
|
||||
(*env)->ReleaseStringUTFChars(env, string, utf);
|
||||
}
|
||||
}
|
||||
if (!arg) {
|
||||
arg = SDL_strdup("");
|
||||
}
|
||||
argv[argc++] = arg;
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
|
||||
/* Run the application. */
|
||||
|
||||
status = SDL_main(argc, argv);
|
||||
|
||||
/* Release the arguments. */
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
SDL_free(argv[i]);
|
||||
}
|
||||
|
||||
/* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
|
||||
/* exit(status); */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* __ANDROID__ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
Loading…
Add table
Add a link
Reference in a new issue