diff --git a/android/Android.mk b/android/Android.mk index 997c7be05..4c85471db 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -207,6 +207,7 @@ LOCAL_CFLAGS := -I../lib/angelscript/include \ -Iobj/openal/include \ -Iobj/openssl/include \ -DUSE_GLES2 \ + -DMOBILE_STK \ -DENABLE_SOUND \ -DENABLE_CRYPTO_OPENSSL \ -DNDEBUG \ diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h index 0ab5f17ab..d3b17160a 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h @@ -90,8 +90,10 @@ namespace irr } +#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ #ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_ -extern void irrlicht_main(); +extern int ios_main(int argc, char *argv[]); +extern void override_default_params_for_mobile(); #endif #endif diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm index f52beb733..cced3fbf3 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm @@ -56,7 +56,7 @@ namespace irr Active = true; Focus = false; - [self performSelectorOnMainThread:@selector(runIrrlicht) withObject:nil waitUntilDone:NO]; + [self performSelectorOnMainThread:@selector(runSTK) withObject:nil waitUntilDone:NO]; return YES; } @@ -143,9 +143,10 @@ namespace irr Focus = true; } -- (void)runIrrlicht +- (void)runSTK { - irrlicht_main(); + override_default_params_for_mobile(); + ios_main(0, {}); } - (void)setDevice:(irr::CIrrDeviceiOS*)device diff --git a/src/main.cpp b/src/main.cpp index 5791d0086..5ecc17a81 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1858,7 +1858,11 @@ void main_abort() #endif // ---------------------------------------------------------------------------- -int main(int argc, char *argv[] ) +#ifdef IOS_STK +int ios_main(int argc, char *argv[]) +#else +int main(int argc, char *argv[]) +#endif { CommandLine::init(argc, argv); diff --git a/src/main_android.cpp b/src/main_android.cpp index 8bced3d43..7d57727f7 100644 --- a/src/main_android.cpp +++ b/src/main_android.cpp @@ -15,19 +15,21 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#ifdef ANDROID +#ifdef MOBILE_STK #include "config/user_config.hpp" #include "graphics/irr_driver.hpp" #include "utils/log.hpp" +#ifdef ANDROID #include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h" +#endif extern int main(int argc, char *argv[]); struct android_app* global_android_app; -void override_default_params() +void override_default_params_for_mobile() { // It has an effect only on the first run, when config file is created. // So that we can still modify these params in STK options and user's @@ -42,7 +44,8 @@ void override_default_params() // Enable multitouch race GUI UserConfigParams::m_multitouch_draw_gui = true; - + +#ifdef ANDROID // Set multitouch device scale depending on actual screen size int32_t screen_size = AConfiguration_getScreenSize(global_android_app->config); @@ -67,7 +70,8 @@ void override_default_params() default: break; } - +#endif + // Enable screen keyboard UserConfigParams::m_screen_keyboard = 1; @@ -82,6 +86,7 @@ void override_default_params() UserConfigParams::m_enforce_current_player = true; } +#ifdef ANDROID void android_main(struct android_app* app) { Log::info("AndroidMain", "Loading application..."); @@ -92,7 +97,7 @@ void android_main(struct android_app* app) CIrrDeviceAndroid::onCreate(); app_dummy(); - override_default_params(); + override_default_params_for_mobile(); main(0, {}); @@ -106,5 +111,6 @@ void android_main(struct android_app* app) fflush(NULL); _exit(0); } +#endif #endif