src/main/android/SDL_android_main.c
author Gabriel Jacobo <gabomdq@gmail.com>
Wed, 21 Aug 2013 09:43:09 -0300
changeset 7677 871d43c6968a
parent 7663 53fe1b64eb2d
child 7678 286c42d7c5ed
permissions -rw-r--r--
OCD fixes: Adds a space before */
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
     1
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
     2
#include "SDL_config.h"
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
     3
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
     4
#ifdef __ANDROID__
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
/* Include the SDL main definition header */
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
#include "SDL_main.h"
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
/*******************************************************************************
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
                 Functions called by JNI
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
*******************************************************************************/
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
#include <jni.h>
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7501
diff changeset
    14
/* Called before SDL_main() to initialize JNI bindings in SDL library */
7501
b27825bb5879 Android: Removed all unnecessary dependencies on C++.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 7467
diff changeset
    15
extern void SDL_Android_Init(JNIEnv* env, jclass cls);
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7501
diff changeset
    17
/* Start up the SDL app */
7501
b27825bb5879 Android: Removed all unnecessary dependencies on C++.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 7467
diff changeset
    18
void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject obj)
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
{
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    /* This interface could expand with ABI negotiation, calbacks, etc. */
4998
a514bfe6952a The window is changed to reflect the actual screen dimensions, for now.
Sam Lantinga <slouken@libsdl.org>
parents: 4964
diff changeset
    21
    SDL_Android_Init(env, cls);
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
7281
cd5516b9263d Added some extra protection to notify the developer if they haven't initialized the application properly.
Sam Lantinga <slouken@libsdl.org>
parents: 6354
diff changeset
    23
    SDL_SetMainReady();
cd5516b9263d Added some extra protection to notify the developer if they haven't initialized the application properly.
Sam Lantinga <slouken@libsdl.org>
parents: 6354
diff changeset
    24
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
    /* Run the application code! */
4999
55fccf89b340 Make sure we shut down the app if SDL_main() returns instead of exiting.
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    26
    int status;
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
    char *argv[2];
7467
998579383ced Changed strdup() to SDL_strdup().
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7281
diff changeset
    28
    argv[0] = SDL_strdup("SDL_app");
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
    argv[1] = NULL;
4999
55fccf89b340 Make sure we shut down the app if SDL_main() returns instead of exiting.
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    30
    status = SDL_main(1, argv);
55fccf89b340 Make sure we shut down the app if SDL_main() returns instead of exiting.
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    31
6186
e565ac981de6 Fixed bug 1293 - [Android] Support Pause/Resume
Sam Lantinga <slouken@libsdl.org>
parents: 6044
diff changeset
    32
    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
7677
871d43c6968a OCD fixes: Adds a space before */
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
    33
    /*exit(status); */
4964
6c645018741e Build the SDL library as a shared object on Android, so it will work correctly with SDL_image and SDL_ttf.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
}
4999
55fccf89b340 Make sure we shut down the app if SDL_main() returns instead of exiting.
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    35
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
    36
#endif /* __ANDROID__ */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 4999
diff changeset
    37
4999
55fccf89b340 Make sure we shut down the app if SDL_main() returns instead of exiting.
Sam Lantinga <slouken@libsdl.org>
parents: 4998
diff changeset
    38
/* vi: set ts=4 sw=4 expandtab: */