7#if defined(__cplusplus) && !defined(SP_DISABLE_ABBREVIATION)
8#define SP_DISABLE_ABBREVIATION 1
9#define SP_ENABLE_ABBREVIATION_LATER 1
14#if defined(SP_ENABLE_ABBREVIATION_LATER)
15#undef SP_DISABLE_ABBREVIATION
16#undef SP_ENABLE_ABBREVIATION_LATER
26int spMain(
int argc,
char *argv[]);
29int main(
int argc,
char *argv[])
31#if !(defined(MACOSX64) || defined(IPHONE)) && !TARGET_API_MAC_CARBON
34 return spMain(argc, argv);
39#include <android_native_app_glue.h>
40#include <android/log.h>
42#define SP_LOG_TAG "spMain.h"
43#define SP_LOGI(...) __android_log_print(ANDROID_LOG_INFO,SP_LOG_TAG,__VA_ARGS__)
45extern void spUpdateDirectoryAndroid(JNIEnv *env, jobject clazzobj);
47int spMain(
int argc,
char *argv[]);
49static void spEngineHandleCmd(
struct android_app* app, int32_t cmd) {
52static int32_t spEngineHandleInput(
struct android_app* app, AInputEvent* event) {
53 if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY) {
54 SP_LOGI(
"Key event: action=%d keyCode=%d metaState=0x%x",
55 AKeyEvent_getAction(event),
56 AKeyEvent_getKeyCode(event),
57 AKeyEvent_getMetaState(event));
58 }
else if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
59 SP_LOGI(
"Motion event: (%f, %f)",
60 AMotionEvent_getX(event, 0), AMotionEvent_getY(event, 0));
65void android_main(
struct android_app* state) {
70 struct android_poll_source* source;
71 char *argv[1] = {
"main"};
74 state->onAppCmd = spEngineHandleCmd;
75 state->onInputEvent = spEngineHandleInput;
77 vm = state->activity->vm;
78 (*vm)->AttachCurrentThread(vm, &env, NULL);
79 spUpdateDirectoryAndroid(env, state->activity->clazz);
80 (*vm)->DetachCurrentThread(vm);
84 while ((ident = ALooper_pollAll(-1, NULL, &events, (
void**)&source)) >= 0) {
87 source->process(state, source);
91 if (state->destroyRequested != 0) {
92 SP_LOGI(
"Engine thread destroy requested!");
97#elif defined(_WIN32) && !defined(__CYGWIN32__)
98int spMain(
int argc,
char *argv[]);
100int main(
int argc,
char *argv[])
102#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
103 _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
105 spsetstdio(stdin, stdout, stderr);
106 return spMain(argc, argv);