Skip to content

Commit 8c00a1e

Browse files
committed
Share the override default params with android
1 parent b9d00db commit 8c00a1e

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

android/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ LOCAL_CFLAGS := -I../lib/angelscript/include \
207207
-Iobj/openal/include \
208208
-Iobj/openssl/include \
209209
-DUSE_GLES2 \
210+
-DMOBILE_STK \
210211
-DENABLE_SOUND \
211212
-DENABLE_CRYPTO_OPENSSL \
212213
-DNDEBUG \

lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ namespace irr
9090

9191
}
9292

93+
#define _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
9394
#ifdef _IRR_COMPILE_WITH_IOS_BUILTIN_MAIN_
94-
extern void irrlicht_main();
95+
extern int ios_main(int argc, char *argv[]);
96+
extern void override_default_params_for_mobile();
9597
#endif
9698

9799
#endif

lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
5656
Active = true;
5757
Focus = false;
5858

59-
[self performSelectorOnMainThread:@selector(runIrrlicht) withObject:nil waitUntilDone:NO];
59+
[self performSelectorOnMainThread:@selector(runSTK) withObject:nil waitUntilDone:NO];
6060

6161
return YES;
6262
}
@@ -143,9 +143,10 @@ - (void)applicationDidBecomeActive:(UIApplication*)application
143143
Focus = true;
144144
}
145145

146-
- (void)runIrrlicht
146+
- (void)runSTK
147147
{
148-
irrlicht_main();
148+
override_default_params_for_mobile();
149+
ios_main(0, {});
149150
}
150151

151152
- (void)setDevice:(irr::CIrrDeviceiOS*)device

src/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,11 @@ void main_abort()
18581858
#endif
18591859

18601860
// ----------------------------------------------------------------------------
1861-
int main(int argc, char *argv[] )
1861+
#ifdef IOS_STK
1862+
int ios_main(int argc, char *argv[])
1863+
#else
1864+
int main(int argc, char *argv[])
1865+
#endif
18621866
{
18631867
CommandLine::init(argc, argv);
18641868

src/main_android.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@
1515
// along with this program; if not, write to the Free Software
1616
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717

18-
#ifdef ANDROID
18+
#ifdef MOBILE_STK
1919

2020
#include "config/user_config.hpp"
2121
#include "graphics/irr_driver.hpp"
2222
#include "utils/log.hpp"
2323

24+
#ifdef ANDROID
2425
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
26+
#endif
2527

2628
extern int main(int argc, char *argv[]);
2729

2830
struct android_app* global_android_app;
2931

30-
void override_default_params()
32+
void override_default_params_for_mobile()
3133
{
3234
// It has an effect only on the first run, when config file is created.
3335
// So that we can still modify these params in STK options and user's
@@ -42,7 +44,8 @@ void override_default_params()
4244

4345
// Enable multitouch race GUI
4446
UserConfigParams::m_multitouch_draw_gui = true;
45-
47+
48+
#ifdef ANDROID
4649
// Set multitouch device scale depending on actual screen size
4750
int32_t screen_size = AConfiguration_getScreenSize(global_android_app->config);
4851

@@ -67,7 +70,8 @@ void override_default_params()
6770
default:
6871
break;
6972
}
70-
73+
#endif
74+
7175
// Enable screen keyboard
7276
UserConfigParams::m_screen_keyboard = 1;
7377

@@ -82,6 +86,7 @@ void override_default_params()
8286
UserConfigParams::m_enforce_current_player = true;
8387
}
8488

89+
#ifdef ANDROID
8590
void android_main(struct android_app* app)
8691
{
8792
Log::info("AndroidMain", "Loading application...");
@@ -92,7 +97,7 @@ void android_main(struct android_app* app)
9297
CIrrDeviceAndroid::onCreate();
9398

9499
app_dummy();
95-
override_default_params();
100+
override_default_params_for_mobile();
96101

97102
main(0, {});
98103

@@ -106,5 +111,6 @@ void android_main(struct android_app* app)
106111
fflush(NULL);
107112
_exit(0);
108113
}
114+
#endif
109115

110116
#endif

0 commit comments

Comments
 (0)