Commit fe5870f0 authored by kenan's avatar kenan

#ifdef _IRR_ANDROID_PLATFORM_

parent 342dca22
......@@ -39,6 +39,15 @@ void Game::process(irr::SEvent &event) {
}
#ifdef _IRR_ANDROID_PLATFORM_
void onActivityLifeChanged(struct android_app* app, int32_t status){
//status ==
//ANDROID_ACTIVITY_RESUME 1
//ANDROID_ACTIVITY_STOP 2
// ANDROID_ACTIVITY_PAUSE 5
//ANDROID_ACTIVITY_DESTROY 3
//ANDROID_ACTIVITY_FOCUS 4
}
bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
this->appMain = app;
#endif
......@@ -72,6 +81,8 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
device->setProcessReceiver(this);
app->onInputEvent = android::handleInput;
((CIrrDeviceAndroid*)device)->onActivityLifeChanged = onActivityLifeChanged;
ILogger* logger = device->getLogger();
// logger->setLogLevel(ELL_WARNING);
isPSEnabled = options->isPendulumScaleEnabled();
......
......@@ -279,21 +279,36 @@ void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
case APP_CMD_LOST_FOCUS:
os::Printer::log("Android command APP_CMD_LOST_FOCUS", ELL_DEBUG);
device->Focused = false;
if(device->onActivityLifeChanged != nullptr){
device->onActivityLifeChanged(app, ANDROID_ACTIVITY_FOCUS);
}
break;
case APP_CMD_DESTROY:
os::Printer::log("Android command APP_CMD_DESTROY", ELL_DEBUG);
device->Initialized = false;
if(device->onActivityLifeChanged != nullptr){
device->onActivityLifeChanged(app, ANDROID_ACTIVITY_DESTROY);
}
break;
case APP_CMD_PAUSE:
os::Printer::log("Android command APP_CMD_PAUSE", ELL_DEBUG);
device->Paused = true;
if(device->onActivityLifeChanged != nullptr){
device->onActivityLifeChanged(app, ANDROID_ACTIVITY_PAUSE);
}
break;
case APP_CMD_STOP:
os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG);
if(device->onActivityLifeChanged != nullptr){
device->onActivityLifeChanged(app, ANDROID_ACTIVITY_STOP);
}
break;
case APP_CMD_RESUME:
os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG);
device->Paused = false;
if(device->onActivityLifeChanged != nullptr){
device->onActivityLifeChanged(app, ANDROID_ACTIVITY_RESUME);
}
break;
case APP_CMD_WINDOW_RESIZED:
os::Printer::log("Android command APP_CMD_WINDOW_RESIZED", ELL_DEBUG);
......
......@@ -17,6 +17,12 @@
#include <android/sensor.h>
#include <android_native_app_glue.h>
#define ANDROID_ACTIVITY_RESUME 1
#define ANDROID_ACTIVITY_STOP 2
#define ANDROID_ACTIVITY_PAUSE 5
#define ANDROID_ACTIVITY_DESTROY 3
#define ANDROID_ACTIVITY_FOCUS 4
namespace irr
{
class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter
......@@ -52,6 +58,8 @@ namespace irr
virtual void restoreWindow();
void (*onActivityLifeChanged)(struct android_app* app, int32_t status);
virtual core::position2di getWindowPosition();
virtual E_DEVICE_TYPE getType() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment