예제 #1
0
static void print_cur_config (void *data)
{
   struct android_app *android_app = (struct android_app*)data;
   char lang[2], country[2];
   AConfiguration_getLanguage(android_app->config, lang);
   AConfiguration_getCountry(android_app->config, country);

   RARCH_LOG("Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d "
         "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d "
         "modetype=%d modenight=%d\n",
         AConfiguration_getMcc(android_app->config),
         AConfiguration_getMnc(android_app->config),
         lang[0], lang[1], country[0], country[1],
         AConfiguration_getOrientation(android_app->config),
         AConfiguration_getTouchscreen(android_app->config),
         AConfiguration_getDensity(android_app->config),
         AConfiguration_getKeyboard(android_app->config),
         AConfiguration_getNavigation(android_app->config),
         AConfiguration_getKeysHidden(android_app->config),
         AConfiguration_getNavHidden(android_app->config),
         AConfiguration_getSdkVersion(android_app->config),
         AConfiguration_getScreenSize(android_app->config),
         AConfiguration_getScreenLong(android_app->config),
         AConfiguration_getUiModeType(android_app->config),
         AConfiguration_getUiModeNight(android_app->config));
}
예제 #2
0
void AndroidConfiguration::reloadCacheForToString() {

  AConfiguration* config = mConfiguration.get();

  std::stringstream stream;

  char lang[2], country[2];
  AConfiguration_getLanguage(config, lang);
  AConfiguration_getCountry(config, country);

  stream << "Config: "
         << "mcc="       << AConfiguration_getMcc(config)         << " "
         << "mnc="       << AConfiguration_getMnc(config)         << " "
         << "lang="      << lang[0] << lang[1]                    << " "
         << "cnt="       << country[0] << country[1]              << " "
         << "orien="     << AConfiguration_getOrientation(config) << " "
         << "touch="     << AConfiguration_getTouchscreen(config) << " "
         << "dens="      << AConfiguration_getDensity(config)     << " "
         << "keys="      << AConfiguration_getKeyboard(config)    << " "
         << "nav="       << AConfiguration_getNavigation(config)  << " "
         << "keysHid="   << AConfiguration_getKeysHidden(config)  << " "
         << "navHid="    << AConfiguration_getNavHidden(config)   << " "
         << "sdk="       << AConfiguration_getSdkVersion(config)  << " "
         << "size="      << AConfiguration_getScreenSize(config)  << " "
         << "long="      << AConfiguration_getScreenLong(config)  << " "
         << "modetype="  << AConfiguration_getUiModeType(config)  << " "
         << "modenight=" << AConfiguration_getUiModeNight(config) << ""
         << "\n";
  mCacheForToString = stream.str();
}
예제 #3
0
static void onAppCmd(struct android_app* app, int32_t cmd)
{
	if (!app)
	{
		return;
	}

	switch(cmd)
	{
		case APP_CMD_INIT_WINDOW:
			{
				int32_t orientation = AConfiguration_getOrientation (g_app->config);

				int32_t width;
				int32_t height;

				if (orientation == ACONFIGURATION_ORIENTATION_PORT)
				{
					width = ANativeWindow_getWidth(g_app->window);
					height = ANativeWindow_getHeight(g_app->window);
				}
				else
				{
					height = ANativeWindow_getWidth(g_app->window);
					width = ANativeWindow_getHeight(g_app->window);
				}

				if (width != g_width || height != g_height)
				{
					g_width = width;
					g_height = height;
				}

				g_nativeWindow = app->window;
			}
	        break;

	    case APP_CMD_TERM_WINDOW:
	    case APP_CMD_DESTROY:

	    	if (g_nativeWindow)
	    	{
		    	_glusWindowInternalClose();

		    	g_nativeWindow = 0;
	    	}

			g_width = -1;
			g_height = -1;

	    	app->destroyRequested = 1;

	    	break;
	}
}
예제 #4
0
 void AndroidEGLWindow::_createInternalResources(NativeWindowType window, AConfiguration* config)
 {
     mWindow = window;
     
     int minAttribs[] = {
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
         EGL_BUFFER_SIZE, 16,
         EGL_DEPTH_SIZE, 16,
         EGL_NONE
     };
     
     int maxAttribs[] = {
         EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
         EGL_BUFFER_SIZE, mMaxBufferSize,
         EGL_DEPTH_SIZE, mMaxDepthSize,
         EGL_STENCIL_SIZE, mMaxStencilSize,
         EGL_NONE
     };
     
     mEglDisplay = mGLSupport->getGLDisplay();
     mEglConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs);
     
     EGLint format;
     eglGetConfigAttrib(mEglDisplay, mEglConfig, EGL_NATIVE_VISUAL_ID, &format);
     EGL_CHECK_ERROR
     
     ANativeWindow_setBuffersGeometry(mWindow, 0, 0, format);
     
     mEglSurface = createSurfaceFromWindow(mEglDisplay, mWindow);
     
     if(config)
     {
         bool isLandscape = (int)AConfiguration_getOrientation(config) == 2;
         mGLSupport->setConfigOption("Orientation", isLandscape ? "Landscape" : "Portrait");
     }
     
     eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, (EGLint*)&mWidth);
     eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, (EGLint*)&mHeight);
     EGL_CHECK_ERROR
     
     if(mContext)
     {
         mActive = true;
         mVisible = true;
         mClosed = false;
         
         mContext->_createInternalResources(mEglDisplay, mEglConfig, mEglSurface, NULL);
         mContext->setCurrent();
         
         windowMovedOrResized();
         static_cast<GLESRenderSystem*>(Ogre::Root::getSingletonPtr()->getRenderSystem())->resetRenderer(this);
     }
 }
예제 #5
0
GLUSvoid _glusOsPollEvents()
{
	int ident;
    int events;
    struct android_poll_source* androidPollSource;

    while ((ident = ALooper_pollAll( 0, NULL, &events, (void**)&androidPollSource)) >= 0)
    {
         if (androidPollSource != NULL)
         {
        	 androidPollSource->process(g_app, androidPollSource);
         }
    }

	int32_t orientation = AConfiguration_getOrientation (g_app->config);

	int32_t width;
	int32_t height;

	if (orientation == ACONFIGURATION_ORIENTATION_PORT)
	{
		width = ANativeWindow_getWidth(g_app->window);
		height = ANativeWindow_getHeight(g_app->window);
	}
	else
	{
		height = ANativeWindow_getWidth(g_app->window);
		width = ANativeWindow_getHeight(g_app->window);
	}

	if (width != g_width || height != g_height)
	{
		g_width = width;
		g_height = height;

		_glusWindowInternalReshape(g_width, g_height);
	}

    if (g_app->destroyRequested != 0 )
    {
    	_glusWindowInternalClose();
    }
}
예제 #6
0
void StAndroidGlue::printConfig() {
    char aLang[3], aCountry[3];
    AConfiguration_getLanguage(myConfig, aLang);
    AConfiguration_getCountry (myConfig, aCountry);
    aLang[2]    = '\0';
    aCountry[2] = '\0';
    ST_DEBUG_LOG("Config:"
               + " mcc="       + AConfiguration_getMcc(myConfig)
               + " mnc="       + AConfiguration_getMnc(myConfig)
               + " lang="      + aLang + " cnt=" + aCountry
               + " orien="     + AConfiguration_getOrientation(myConfig)
               + " touch="     + AConfiguration_getTouchscreen(myConfig)
               + " dens="      + AConfiguration_getDensity    (myConfig)
               + " keys="      + AConfiguration_getKeyboard   (myConfig)
               + " nav="       + AConfiguration_getNavigation (myConfig)
               + " keysHid="   + AConfiguration_getKeysHidden (myConfig)
               + " navHid="    + AConfiguration_getNavHidden  (myConfig)
               + " sdk="       + AConfiguration_getSdkVersion (myConfig)
               + " size="      + AConfiguration_getScreenSize (myConfig)
               + " long="      + AConfiguration_getScreenLong (myConfig)
               + " modetype="  + AConfiguration_getUiModeType (myConfig)
               + " modenight=" + AConfiguration_getUiModeNight(myConfig));
}
예제 #7
0
void StAndroidGlue::updateMonitors() {
    if(myConfig == NULL) {
        return;
    }

    const int32_t aWidthDp  = AConfiguration_getScreenWidthDp (myConfig);
    const int32_t aHeightDp = AConfiguration_getScreenHeightDp(myConfig);
    const int32_t aDpi      = AConfiguration_getDensity       (myConfig);

    StMonitor aMon;
    aMon.setId(0);
    if(myStereoApiId == "S3DV") {
        aMon.setPnPId("ST@S3DV");
    }
    aMon.changeVRect().top()    = 0;
    aMon.changeVRect().left()   = 0;
    aMon.changeVRect().right()  = (int )(0.5 + double(aWidthDp ) * (double(aDpi) / 160.0));
    aMon.changeVRect().bottom() = (int )(0.5 + double(aHeightDp) * (double(aDpi) / 160.0));

    aMon.setOrientation(AConfiguration_getOrientation(myConfig) == ACONFIGURATION_ORIENTATION_PORT
                      ? StMonitor::Orientation_Portrait : StMonitor::Orientation_Landscape);
    aMon.setScale(float(double(aDpi) / 160.0));
    StSearchMonitors::setupGlobalDisplay(aMon);
}
예제 #8
0
static void _onAppCmd(struct android_app* app, int32_t cmd)
{
    if (!app || app != g_app)
    {
        return;
    }

    switch (cmd)
    {
        case APP_CMD_INIT_WINDOW:
        {
            int32_t orientation = AConfiguration_getOrientation(g_app->config);

            g_width = ANativeWindow_getWidth(g_app->window);
            g_height = ANativeWindow_getHeight(g_app->window);

            if (orientation != ACONFIGURATION_ORIENTATION_PORT)
            {
                int32_t temp = g_width;

                g_width = g_height;
                g_height = temp;
            }

            g_nativeAndroidWindow = app->window;
        }
        break;

        case APP_CMD_TERM_WINDOW:
        case APP_CMD_DESTROY:

            g_app->destroyRequested = 1;

            break;
    }
}
예제 #9
0
    void AndroidEGLWindow::_createInternalResources(NativeWindowType window, AConfiguration* config)
    {
        mWindow = window;
        
        int minAttribs[] = {
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_BUFFER_SIZE, mMinBufferSize,
            EGL_DEPTH_SIZE, 16,
            EGL_NONE
        };
        
        int maxAttribs[] = {
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
			EGL_BUFFER_SIZE, mMaxBufferSize,
            EGL_DEPTH_SIZE, mMaxDepthSize,
            EGL_STENCIL_SIZE, mMaxStencilSize,
            EGL_NONE
        };

		bool bAASuccess = false;
		if (mCSAA)
		{
			try
			{
				int CSAAminAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMinBufferSize,
					EGL_DEPTH_SIZE, 16,
					EGL_COVERAGE_BUFFERS_NV, 1,
					EGL_COVERAGE_SAMPLES_NV, mCSAA,
					EGL_NONE
				};
				int CSAAmaxAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMaxBufferSize,
					EGL_DEPTH_SIZE, mMaxDepthSize,
					EGL_STENCIL_SIZE, mMaxStencilSize,
					EGL_COVERAGE_BUFFERS_NV, 1,
					EGL_COVERAGE_SAMPLES_NV, mCSAA,
					EGL_NONE
				};
				mEglConfig = mGLSupport->selectGLConfig(CSAAminAttribs, CSAAmaxAttribs);
				bAASuccess = true;
			}
			catch (Exception& e)
			{
				LogManager::getSingleton().logMessage("AndroidEGLWindow::_createInternalResources: setting CSAA failed");
			}
		}

		if (mMSAA && !bAASuccess)
		{
			try
			{
				int MSAAminAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMinBufferSize,
					EGL_DEPTH_SIZE, 16,
					EGL_SAMPLE_BUFFERS, 1,
					EGL_SAMPLES, mMSAA,
					EGL_NONE
				};
				int MSAAmaxAttribs[] = {
					EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
					EGL_BUFFER_SIZE, mMaxBufferSize,
					EGL_DEPTH_SIZE, mMaxDepthSize,
					EGL_STENCIL_SIZE, mMaxStencilSize,
					EGL_SAMPLE_BUFFERS, 1,
					EGL_SAMPLES, mMSAA,
					EGL_NONE
				};
				mEglConfig = mGLSupport->selectGLConfig(MSAAminAttribs, MSAAmaxAttribs);
				bAASuccess = true;
			}
			catch (Exception& e)
			{
				LogManager::getSingleton().logMessage("AndroidEGLWindow::_createInternalResources: setting MSAA failed");
			}
		}
        
        mEglDisplay = mGLSupport->getGLDisplay();
        if (!bAASuccess) mEglConfig = mGLSupport->selectGLConfig(minAttribs, maxAttribs);
        
        EGLint format;
        eglGetConfigAttrib(mEglDisplay, mEglConfig, EGL_NATIVE_VISUAL_ID, &format);
        EGL_CHECK_ERROR
        
        ANativeWindow_setBuffersGeometry(mWindow, 0, 0, format);
        
        mEglSurface = createSurfaceFromWindow(mEglDisplay, mWindow);
        
        if(config)
        {
            bool isLandscape = (int)AConfiguration_getOrientation(config) == 2;
            mGLSupport->setConfigOption("Orientation", isLandscape ? "Landscape" : "Portrait");
        }
        
        if(mContext)
        {
            mActive = true;
            mVisible = true;
            mClosed = false;
            
            mContext->_createInternalResources(mEglDisplay, mEglConfig, mEglSurface, NULL);

            static_cast<GLES2RenderSystem*>(Ogre::Root::getSingletonPtr()->getRenderSystem())->resetRenderer(this);
        }
    }
예제 #10
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state) {

    // Make sure glue isn't stripped.
    app_dummy();

    memset(&engine, 0, sizeof(engine));
    state->userData = &engine;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    engine.app = state;

    // Prepare to monitor accelerometer
    engine.sensorManager = ASensorManager_getInstance();
    engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
            ASENSOR_TYPE_ACCELEROMETER);
    engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
            state->looper, LOOPER_ID_USER, NULL, NULL);

    if (state->savedState != NULL) {
        // We are starting with a previous saved state; restore from it.
        engine.state = *(struct saved_state*)state->savedState;
    }

    // loop waiting for stuff to do.

    while (1) {
        // Read all pending events.
        int ident;
        int events;
        struct android_poll_source* source;

        // If not animating, we will block forever waiting for events.
        // If animating, we loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events,
                (void**)&source)) >= 0) {

            // Process this event.
            if (source != NULL) {
                source->process(state, source);
            }

            // If a sensor has data, process it now.
            if (ident == LOOPER_ID_USER) {
                if (engine.accelerometerSensor != NULL) {
                    ASensorEvent event;
                    while (ASensorEventQueue_getEvents(engine.sensorEventQueue,
                            &event, 1) > 0) {

                        LOG_EVENTS_DEBUG("accelerometer: x=%f y=%f z=%f",
                                event.acceleration.x, event.acceleration.y,
                                event.acceleration.z);

                        AConfiguration* _currentconf = AConfiguration_new();
                        AConfiguration_fromAssetManager(_currentconf,
                                                        state->activity->assetManager);
                        static int32_t _orientation = AConfiguration_getOrientation(_currentconf);

                        if (ACONFIGURATION_ORIENTATION_LAND != _orientation) {
                            // ACONFIGURATION_ORIENTATION_ANY
                            // ACONFIGURATION_ORIENTATION_PORT
                            // ACONFIGURATION_ORIENTATION_SQUARE
                            cocos2d::Acceleration acc;
                            acc.x = -event.acceleration.x/10;
                            acc.y = -event.acceleration.y/10;
                            acc.z = event.acceleration.z/10;
                            acc.timestamp = 0;
                            cocos2d::EventAcceleration accEvent(acc);

                            cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
                        } else {
                            // ACONFIGURATION_ORIENTATION_LAND
                            // swap x and y parameters
                            cocos2d::Acceleration acc;
                            acc.x = event.acceleration.y/10;
                            acc.y = -event.acceleration.x/10;
                            acc.z = event.acceleration.z/10;
                            acc.timestamp = 0;
                            cocos2d::EventAcceleration accEvent(acc);

                            cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
                        }
                    }
                }
            }

            // Check if we are exiting.
            if (state->destroyRequested != 0) {
                engine_term_display(&engine);

                memset(&engine, 0, sizeof(engine));
                s_methodInitialized = false;
                return;
            }
        }

        if (engine.animating) {
            // Done with events; draw next animation frame.
            engine.state.angle += .01f;
            if (engine.state.angle > 1) {
                engine.state.angle = 0;
            }

            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            LOG_RENDER_DEBUG("android_main : engine.animating");
            engine_draw_frame(&engine);
        } else {
            LOG_RENDER_DEBUG("android_main : !engine.animating");
        }
    }
}
예제 #11
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state) {
   const char *data_path = engine.data_path;
	// Make sure glue isn't stripped.
	app_dummy();

	memset(&engine, 0, sizeof(engine));
   engine.data_path = data_path;
	state->userData = &engine;
	state->onAppCmd = engine_handle_cmd;
	state->onInputEvent = engine_handle_input;
	engine.app = state;

   LOGI( "BEGIN ANDROID_MAIN" );
	// Prepare to monitor accelerometer
 	//engine.sensorManager = ASensorManager_getInstance();
	//engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager,
	//			ASENSOR_TYPE_ACCELEROMETER);
	//engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager,
	//			state->looper, LOOPER_ID_USER, NULL, NULL);

	if (state->savedState != NULL) {
		// We are starting with a previous saved state; restore from it.
		engine.state = *(struct saved_state*)state->savedState;
		engine.state.closed = 0;
      engine.state.animating = 0; // won't be ready to animate until later...
		engine.state.restarting = 1;
		LOGI( "Recover prior saved state... %d %d", engine.state.closed, engine.state.restarting );
	}
	else
	{
      LOGI( "No prior state" );
		engine.state.orientation = AConfiguration_getOrientation(engine.app->config);
		BeginNativeProcess( &engine );
	}

	// loop waiting for stuff to do.
	while (1) {
		// Read all pending events.
		int ident;
		int events;
		struct android_poll_source* source;

		// If not animating, we will block forever waiting for events.
		// If animating, we loop until all events are read, then continue
		// to draw the next frame of animation.
		while ((ident=ALooper_pollAll(engine.state.animating ? 0 : -1, NULL, &events, (void**)&source)) >= 0)
		{
			// Process this event.
			if (source != NULL)
			{
				source->process(state, source);
			}

			// Check if we are exiting.
			if (state->destroyRequested != 0) {
				LOGI( "Destroy Requested... %d", engine.state.closed );
				//state->activity->vm->DetachCurrentThread();
				BagVidlibPureglCloseDisplay();
				engine.did_finish_once = 0;
				return;
			}

			// if not animating, this will get missed...
			if(engine.state.closed && !engine.did_finish_once )
			{
				engine.did_finish_once = 1;
				LOGI( "Do final activity" );
				ANativeActivity_finish(state->activity);
			}
		}

		if (engine.state.animating) {
				// Drawing is throttled to the screen update rate, so there
			// is no need to do timing here.
			// trigger want draw?
         //LOGI( "Animating..." );
			engine.state.rendering = 1;
			if( BagVidlibPureglRenderPass )
				engine.state.animating = BagVidlibPureglRenderPass();
			else
			{
				if( BagVidlibPureglFirstRender )
					BagVidlibPureglFirstRender();
				engine.state.animating = 0;
			}
         engine.state.rendering = 0;
		}
	}
}
예제 #12
0
/**
 * Process the next main command.
 */
static void engine_handle_cmd(struct android_app* app, int32_t cmd) {
	struct engine* engine = (struct engine*)app->userData;
	switch (cmd)
	{
	default:
		LOGI( "Other Command: %d", cmd );
		break;
	case APP_CMD_WAKE:
      break;
	case APP_CMD_DESTROY:
		// need to end normal process here
		// unload everything....
      //
      break;
	case APP_CMD_START:
		{
			if( !engine->state.restarting )
			{
            LOGI( "No; start is just a new display...." );
			}
			else
				LOGI( "App already started... just going to get a new display..." );
		}
		break;
	case APP_CMD_SAVE_STATE:
      LOGI( "*** Save my isntance data... do things change?" );
		// The system has asked us to save our current state.  Do so.
		engine->app->savedState = malloc(sizeof(struct saved_state));
		*((struct saved_state*)engine->app->savedState) = engine->state;
		engine->app->savedStateSize = sizeof(struct saved_state);
		break;
	case APP_CMD_INIT_WINDOW:
		// don't realy want to do anything, this is legal to bind to the egl context, but the size is invalid.
		// after init will get a changed anyway
		//break;
	//case APP_CMD_WINDOW_RESIZED:
		// LOGI( "Resized received..." );
		// The window is being shown, get it ready.
		while( engine->wait_for_startup )
		{
			LOGI( "wait for deadstart to finish (load interfaces)" );
			sched_yield();
		}
		if( BagVidlibPureglSetNativeWindowHandle )
		{
			BagVidlibPureglSetNativeWindowHandle( engine->app->pendingWindow );
			// reopen cameras...  (wait for animate to trigger that)
			// BagVidlibPureglOpenCameras();
		engine->state.animating = 1;

			LOGI( "Clear wait for display init..." );
		}
		if( engine->have_focus )
			engine->state.animating = 1;

		//engine->wait_for_display_init = 0;
      engine->state.opened = 1;
		//sched_yield();
		break;
	case APP_CMD_CONFIG_CHANGED:
		{
			int new_orient = AConfiguration_getOrientation(engine->app->config);
			if( engine->state.orientation != new_orient )
			{
            engine->state.orientation = new_orient;
				if( BagVidlibPureglPauseDisplay )
					BagVidlibPureglPauseDisplay();
			}
		}
      break;
	case APP_CMD_TERM_WINDOW:
		// The window is being hidden or closed, clean it up.
      engine->state.opened = 0;
		engine->state.animating = 0;
		engine->app->pendingWindow = NULL;
      if( BagVidlibPureglCloseDisplay )
			BagVidlibPureglCloseDisplay();
		break;
	case APP_CMD_GAINED_FOCUS:
		// first resume is not valid until gained focus (else resume during lock screen)
		//case APP_CMD_RESUME:
		// resume physics from now
		LOGI( "Gain focus" );
      engine->have_focus = 1;
      if( engine->state.opened )
			engine->state.animating = 1;
		else
         LOGI( "but we don't have a window?!" );

		// When our app gains focus, we start monitoring the accelerometer.
		//if (engine->accelerometerSensor != NULL) {
		//	ASensorEventQueue_enableSensor(engine->sensorEventQueue,
		//						engine->accelerometerSensor);
			// We'd like to get 60 events per second (in us).
		 //  ASensorEventQueue_setEventRate(engine->sensorEventQueue,
		 //  										engine->accelerometerSensor, (1000L/60)*1000);
		//}
		break;
	case APP_CMD_PAUSE:
      engine->have_focus = 0;
		engine->state.animating = 0;
		while( engine->state.rendering )
         sched_yield();
		if( BagVidlibPureglPauseDisplay )
			BagVidlibPureglPauseDisplay();
      engine->resumed = 0;
		break;
	case APP_CMD_RESUME:
		lprintf( "Resume..." );
		if( BagVidlibPureglResumeDisplay )
			BagVidlibPureglResumeDisplay();
      engine->resumed = 1;
		break;
	case APP_CMD_LOST_FOCUS:
		// need to suspend physics at this point; aka next move is time 0, until the next-next

		// Also stop animating.
		engine->state.animating = 0;
		break;
	}
}
예제 #13
0
파일: main.c 프로젝트: hongwd75/NDKBook_2nd
// Configurationを表示する
void displayConfiguration(struct engine* engine) {
    int idx = 0;
    // 画面の向き
    const char orientation_list[][32] = {
        "ORIENTATION_ANY",   // 未定義
        "ORIENTATION_PORT",  // Portrait
        "ORIENTATION_LAND",  // Landcape
        "ORIENTATION_SQUARE" // Square
    };
    // タッチスクリーン
    const char touchscreen_list[][32] = {
        "TOUCHSCREEN_ANY",    // 未定義
        "TOUCHSCREEN_NOTOUCH",// タッチスクリーンではない
        "TOUCHSCREEN_STYLUS", // (廃止)
        "TOUCHSCREEN_FINGER"  // タッチスクリーン
    };
    // キーボード
    const char keyboard_list[][32] = {
        "KEYBOARD_ANY",    // 未定義
        "KEYBOARD_NOKEYS", // キーはない
        "KEYBOARD_QWERTY", // QWERTY配列
        "KEYBOARD_12KEY"   // 12キー
    };
    // ナビゲーション
    const char navigation_list[][32] = {
        "NAVIGATION_ANY",   // 未定義
        "NAVIGATION_NONAV", // なし
        "NAVIGATION_DPAD",  // DPAD
        "NAVIGATION_TRACKBALL", // トラックボール
        "NAVIGATION_WHEEL"  // ホイール
    };
    // ソフトウェアキーボード
    const char keyshidden_list[][32] = {
        "KEYSHIDDEN_ANY", // 未定義
        "KEYSHIDDEN_NO",  // キーボードを隠すことができない
        "KEYSHIDDEN_YES", // キーボードを隠すことができる
        "KEYSHIDDEN_SOFT" // ソフト制御
    };
    // ナビゲーションキーの隠し方
    const char navhidden_list[][32] = {
        "NAVHIDDEN_ANY", // 未定義
        "NAVHIDDEN_NO",  // ナビゲーションキーを隠すことができる
        "NAVHIDDEN_YES"  // ナビゲーションキーを隠すことができない
    };
    // 画面サイズ
    const char screensize_list[][32] = {
        "SCREENSIZE_ANY",    // 未定義
        "SCREENSIZE_SMALL",  // 小さい
        "SCREENSIZE_NORMAL", // 標準
        "SCREENSIZE_LARGE",  // 大きい
        "SCREENSIZE_XLARGE"  // 特大
    };
    // ワイドスクリーンか
    const char screenlong_list[][32] = {
        "SCREENLONG_ANY",  // 未定義
        "SCREENLONG_NO",   // ワイドではない(QVGA,HVGA,VGAなど)
        "SCREENLONG_YES",  // ワイドである(WQVGA,WVGA,FWVGAなど)
    };
    // 接続状態
    const char uimodetype_list[][32] = {
        "UI_MODE_TYPE_ANY",    // 未定義
        "UI_MODE_TYPE_NORMAL", // 標準
        "UI_MODE_TYPE_DESK",   // DeskDocに接続中
        "UI_MODE_TYPE_CAR"     // CarDocに接続中
    };
    // UIモード(夜)タイプ
    const char uimodenight_list[][32] = {
        "UI_MODE_NIGHT_ANY", // 未定義
        "UI_MODE_NIGHT_NO",  // 昼モード
        "UI_MODE_NIGHT_YES"  // 夜モード
    };

    // 言語を取得(2文字が返る)
    char language[3] = { 0 };
    AConfiguration_getLanguage(engine->app->config, language);
    LOGI("Language:%s", language);
    // 国を取得(2文字が返る)
    char country[3] = { 0 };
    AConfiguration_getCountry(engine->app->config, country);
    LOGI("Country:%s", country);
    // 画面の向き
    idx = AConfiguration_getOrientation(engine->app->config);
    LOGI("Orientation:%s", orientation_list[idx]);
    // タッチスクリーン
    idx = AConfiguration_getTouchscreen(engine->app->config);
    LOGI("Touchscreen:%s", touchscreen_list[idx]);
    // 解像度
    int density = AConfiguration_getDensity(engine->app->config);
    LOGI("Density:%d", density);
    // キーボード
    idx = AConfiguration_getKeyboard(engine->app->config);
    LOGI("Keyboard:%s", keyboard_list[idx]);
    // ナビゲーション
    idx = AConfiguration_getNavigation(engine->app->config);
    LOGI("Navigation:%s", keyboard_list[idx]);
    // キーの隠し方
    idx = AConfiguration_getKeysHidden(engine->app->config);
    LOGI("KeysHidden:%s", keyshidden_list[idx]);
    // ナビゲーションキーの隠し方
    idx = AConfiguration_getNavHidden(engine->app->config);
    LOGI("NaviHidden:%s", navhidden_list[idx]);
    // SDK(API)バージョン
    int ver = AConfiguration_getSdkVersion(engine->app->config);
    LOGI("SdkVersion:%d", ver);
    // スクリーンサイズ
    idx = AConfiguration_getScreenSize(engine->app->config);
    LOGI("ScreenSize:%s", screensize_list[idx]);
    // ワイドスクリーンか
    idx = AConfiguration_getScreenLong(engine->app->config);
    LOGI("ScreenLong:%s", screenlong_list[idx]);
    // UIモードタイプ
    idx = AConfiguration_getUiModeType(engine->app->config);
    LOGI("UiModeType:%s", uimodetype_list[idx]);
    // UIモード(夜)タイプ
    idx = AConfiguration_getUiModeNight(engine->app->config);
    LOGI("UiModeNight:%s", uimodenight_list[idx]);
}
예제 #14
0
파일: Activity.cpp 프로젝트: acavelan/tigre
 int Activity::getOrientation() const
 {
     return AConfiguration_getOrientation(_app->config);
 }