More fixes for global_android_app
This commit is contained in:
parent
a2af7127e7
commit
80fd62c7d8
@ -58,68 +58,82 @@ CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
|
||||
#ifdef _DEBUG
|
||||
setDebugName("CIrrDeviceAndroid");
|
||||
#endif
|
||||
|
||||
Android = (android_app *)(param.PrivateData);
|
||||
assert(Android != NULL);
|
||||
|
||||
Android->userData = this;
|
||||
Android->onAppCmd = handleAndroidCommand;
|
||||
Android->onAppCmdDirect = handleAndroidCommandDirect;
|
||||
Android->onInputEvent = handleInput;
|
||||
|
||||
printConfig();
|
||||
createKeyMap();
|
||||
|
||||
CursorControl = new CCursorControl();
|
||||
|
||||
Android = (android_app*)(param.PrivateData);
|
||||
|
||||
Close = Android->destroyRequested;
|
||||
|
||||
// It typically shouldn't happen, but just in case...
|
||||
if (Close)
|
||||
return;
|
||||
|
||||
SensorManager = ASensorManager_getInstance();
|
||||
SensorEventQueue = ASensorManager_createEventQueue(SensorManager,
|
||||
Android->looper, LOOPER_ID_USER, NULL, NULL);
|
||||
|
||||
ANativeActivity_setWindowFlags(Android->activity,
|
||||
AWINDOW_FLAG_KEEP_SCREEN_ON |
|
||||
AWINDOW_FLAG_FULLSCREEN, 0);
|
||||
|
||||
os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG);
|
||||
|
||||
while (!IsStarted || !IsFocused || IsPaused)
|
||||
if (Android == NULL && CreationParams.DriverType != video::EDT_NULL)
|
||||
{
|
||||
s32 events = 0;
|
||||
android_poll_source* source = 0;
|
||||
|
||||
s32 id = ALooper_pollAll(-1, NULL, &events, (void**)&source);
|
||||
|
||||
if (id >=0 && source != NULL)
|
||||
{
|
||||
source->process(Android, source);
|
||||
}
|
||||
os::Printer::log("Irrlicht device can run only with NULL driver without android_app.", ELL_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(Android->window);
|
||||
os::Printer::log("Done", ELL_DEBUG);
|
||||
|
||||
ExposedVideoData.OGLESAndroid.Window = Android->window;
|
||||
|
||||
createVideoModeList();
|
||||
if (Android != NULL)
|
||||
{
|
||||
Android->userData = this;
|
||||
Android->onAppCmd = handleAndroidCommand;
|
||||
Android->onAppCmdDirect = handleAndroidCommandDirect;
|
||||
Android->onInputEvent = handleInput;
|
||||
|
||||
printConfig();
|
||||
|
||||
Close = Android->destroyRequested;
|
||||
|
||||
// It typically shouldn't happen, but just in case...
|
||||
if (Close)
|
||||
return;
|
||||
|
||||
SensorManager = ASensorManager_getInstance();
|
||||
SensorEventQueue = ASensorManager_createEventQueue(SensorManager,
|
||||
Android->looper, LOOPER_ID_USER, NULL, NULL);
|
||||
|
||||
ANativeActivity_setWindowFlags(Android->activity,
|
||||
AWINDOW_FLAG_KEEP_SCREEN_ON |
|
||||
AWINDOW_FLAG_FULLSCREEN, 0);
|
||||
|
||||
os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG);
|
||||
|
||||
while (!IsStarted || !IsFocused || IsPaused)
|
||||
{
|
||||
s32 events = 0;
|
||||
android_poll_source* source = 0;
|
||||
|
||||
s32 id = ALooper_pollAll(-1, NULL, &events, (void**)&source);
|
||||
|
||||
if (id >=0 && source != NULL)
|
||||
{
|
||||
source->process(Android, source);
|
||||
}
|
||||
}
|
||||
|
||||
assert(Android->window);
|
||||
os::Printer::log("Done", ELL_DEBUG);
|
||||
|
||||
ExposedVideoData.OGLESAndroid.Window = Android->window;
|
||||
|
||||
createVideoModeList();
|
||||
}
|
||||
|
||||
createDriver();
|
||||
|
||||
if (VideoDriver)
|
||||
{
|
||||
createGUIAndScene();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CIrrDeviceAndroid::~CIrrDeviceAndroid()
|
||||
{
|
||||
Android->userData = NULL;
|
||||
Android->onAppCmd = NULL;
|
||||
Android->onInputEvent = NULL;
|
||||
if (Android)
|
||||
{
|
||||
Android->userData = NULL;
|
||||
Android->onAppCmd = NULL;
|
||||
Android->onInputEvent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CIrrDeviceAndroid::printConfig()
|
||||
@ -211,6 +225,9 @@ bool CIrrDeviceAndroid::run()
|
||||
{
|
||||
os::Timer::tick();
|
||||
|
||||
if (Android == NULL)
|
||||
return !Close;
|
||||
|
||||
while (!Close)
|
||||
{
|
||||
s32 Events = 0;
|
||||
@ -372,8 +389,8 @@ void CIrrDeviceAndroid::handleAndroidCommandDirect(ANativeActivity* activity,
|
||||
switch (cmd)
|
||||
{
|
||||
case APP_CMD_RESUME:
|
||||
os::Printer::log("Android command direct APP_CMD_RESUME", ELL_DEBUG);
|
||||
hideNavBar(activity);
|
||||
os::Printer::log("Android command direct APP_CMD_RESUME", ELL_DEBUG);
|
||||
hideNavBar(activity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -49,6 +49,9 @@ void AssetsAndroid::init()
|
||||
#ifdef ANDROID
|
||||
if (m_file_manager == NULL)
|
||||
return;
|
||||
|
||||
if (!global_android_app)
|
||||
return;
|
||||
|
||||
bool needs_extract_data = false;
|
||||
const std::string version = std::string("supertuxkart.") + STK_VERSION;
|
||||
@ -339,6 +342,9 @@ void AssetsAndroid::extractData()
|
||||
bool AssetsAndroid::extractDir(std::string dir_name)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
if (!global_android_app)
|
||||
return false;
|
||||
|
||||
AAssetManager* amgr = global_android_app->activity->assetManager;
|
||||
|
||||
Log::info("AssetsAndroid", "Extracting %s directory",
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -756,11 +756,6 @@ int handleCmdLinePreliminary()
|
||||
if(CommandLine::has("--kartdir", &s))
|
||||
KartPropertiesManager::addKartSearchDir(s);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
if(CommandLine::has("--no-graphics") || CommandLine::has("-l"))
|
||||
#endif
|
||||
ProfileWorld::disableGraphics();
|
||||
|
||||
if (CommandLine::has("--sp-shader-debug"))
|
||||
SP::SPShader::m_sp_shader_debug = true;
|
||||
|
||||
@ -1843,6 +1838,11 @@ int main(int argc, char *argv[] )
|
||||
FileManager::setStdoutName(s);
|
||||
if (CommandLine::has("--stdout-dir", &s))
|
||||
FileManager::setStdoutDir(s);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
if(CommandLine::has("--no-graphics") || CommandLine::has("-l"))
|
||||
#endif
|
||||
ProfileWorld::disableGraphics();
|
||||
|
||||
// Init the minimum managers so that user config exists, then
|
||||
// handle all command line options that do not need (or must
|
||||
|
@ -312,20 +312,25 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
|
||||
} // if c[0]
|
||||
|
||||
#elif defined(ANDROID)
|
||||
char p_language[3] = {};
|
||||
AConfiguration_getLanguage(global_android_app->config, p_language);
|
||||
|
||||
if (p_language != NULL)
|
||||
if (global_android_app)
|
||||
{
|
||||
language += p_language;
|
||||
char p_language[3] = {};
|
||||
AConfiguration_getLanguage(global_android_app->config,
|
||||
p_language);
|
||||
|
||||
char p_country[3] = {};
|
||||
AConfiguration_getCountry(global_android_app->config, p_country);
|
||||
|
||||
if (p_country)
|
||||
if (p_language != NULL)
|
||||
{
|
||||
language += "_";
|
||||
language += p_country;
|
||||
language += p_language;
|
||||
|
||||
char p_country[3] = {};
|
||||
AConfiguration_getCountry(global_android_app->config,
|
||||
p_country);
|
||||
|
||||
if (p_country)
|
||||
{
|
||||
language += "_";
|
||||
language += p_country;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user