• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ALooper_pollAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ALooper_pollAll函数的典型用法代码示例。如果您正苦于以下问题:C++ ALooper_pollAll函数的具体用法?C++ ALooper_pollAll怎么用?C++ ALooper_pollAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ALooper_pollAll函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: android_main

void android_main( struct android_app *app )
{
	int ident, events;
	struct android_poll_source *source;
	unsigned int oldtime, newtime, time;

	app_dummy();

	sys_android_app = app;
	app->inputPollSource.process = Sys_Android_ProcessInput;
	ANativeActivity_setWindowFlags( app->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0 ); // flags must be set before window creation

	app->onAppCmd = Sys_Android_WaitOnAppCmd;
	while( !sys_android_initialized )
	{
		Sys_Sleep( 0 );
		while( ( ident = ALooper_pollAll( 0, NULL, &events, ( void ** )( &source ) ) ) >= 0 )
		{
			if ( source )
				source->process( app, source );
		}
	}

	Sys_Android_Init();
	Qcommon_Init( 0, NULL );

	oldtime = Sys_Milliseconds();
	for( ;; )
	{
		if( dedicated && dedicated->integer )
			Sys_Sleep( 1 );

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

		for( ;; )
		{
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
			if( time > 0 )
				break;
			Sys_Sleep( 0 );
		}
		oldtime = newtime;

		Sys_Android_ExecuteIntent();
		Qcommon_Frame( time );
	}
}
开发者ID:MGXRace,项目名称:racesow,代码行数:52,代码来源:android_sys.c


示例2: SkDebugf

void* SkiaAndroidApp::pthread_main(void* arg) {
    SkDebugf("pthread_main begins");

    auto skiaAndroidApp = (SkiaAndroidApp*)arg;

    // Because JNIEnv is thread sensitive, we need AttachCurrentThread to set our fPThreadEnv
    skiaAndroidApp->fJavaVM->AttachCurrentThread(&(skiaAndroidApp->fPThreadEnv), nullptr);

    ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    pipe(skiaAndroidApp->fPipes);
    ALooper_addFd(looper, skiaAndroidApp->fPipes[0], LOOPER_ID_MESSAGEPIPE, ALOOPER_EVENT_INPUT,
                  message_callback, skiaAndroidApp);

    skiaAndroidApp->fApp = Application::Create(0, nullptr, skiaAndroidApp);

    double currentTime = 0.0;
    double previousTime = 0.0;
    while (true) {
        const int ident = ALooper_pollAll(0, nullptr, nullptr, nullptr);

        if (ident >= 0) {
            SkDebugf("Unhandled ALooper_pollAll ident=%d !", ident);
        } else {
            previousTime = currentTime;
            currentTime = now_ms();
            skiaAndroidApp->fApp->onIdle(currentTime - previousTime);
        }
    }

    SkDebugf("pthread_main ends");

    return nullptr;
}
开发者ID:VarcoDevs,项目名称:skia,代码行数:33,代码来源:surface_glue_android.cpp


示例3: while

void CEventLoop::run(IActivityHandler &activityHandler, IInputHandler &inputHandler)
{
  int ident;
  int events;
  struct android_poll_source* source;

  m_activityHandler = &activityHandler;
  m_inputHandler = &inputHandler;

  CXBMCApp::android_printf("CEventLoop: starting event loop");
  while (1)
  {
    // We will block forever waiting for events.
    while ((ident = ALooper_pollAll(-1, NULL, &events, (void**)&source)) >= 0)
    {
      // Process this event.
      if (source != NULL)
        source->process(m_application, source);

      // Check if we are exiting.
      if (m_application->destroyRequested)
      {
        CXBMCApp::android_printf("CEventLoop: we are being destroyed");
        return;
      }
    }
  }
}
开发者ID:OV3RDOSE,项目名称:xbmc,代码行数:28,代码来源:EventLoop.cpp


示例4: SkDebugf

void* SkiaAndroidApp::pthread_main(void* arg) {
    SkDebugf("pthread_main begins");

    auto skiaAndroidApp = (SkiaAndroidApp*)arg;

    // Because JNIEnv is thread sensitive, we need AttachCurrentThread to set our fPThreadEnv
    skiaAndroidApp->fJavaVM->AttachCurrentThread(&(skiaAndroidApp->fPThreadEnv), nullptr);

    ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    pipe(skiaAndroidApp->fPipes);
    ALooper_addFd(looper, skiaAndroidApp->fPipes[0], LOOPER_ID_MESSAGEPIPE, ALOOPER_EVENT_INPUT,
                  message_callback, skiaAndroidApp);

    int ident;
    int events;
    struct android_poll_source* source;

    skiaAndroidApp->fApp = Application::Create(0, nullptr, skiaAndroidApp);

    while ((ident = ALooper_pollAll(-1, nullptr, &events, (void**)&source)) >= 0) {
        SkDebugf("ALooper_pollAll ident=%d", ident);
    }

    return nullptr;
}
开发者ID:jszwedko,项目名称:skia,代码行数:25,代码来源:surface_glue_android.cpp


示例5: fprintf

inline bool CSensorAndroidBuiltIn::read_xyz(float& x1, float& y1, float& z1)
{
    if (qcn_main::g_iStop) return false;

    if (! m_pSensor || ! m_pLooper | ! m_pSensorEventQueue) {
        fprintf(stderr, "read_xyz error: no sensor %x or looper %x or event queue %x setup!\n", m_pSensor, m_pLooper, m_pSensorEventQueue);
        return false;  // no open file descriptor
    }

    int ident, events;
    float fCtr = 0.0;

    // should probably be while loop but taking too long on some devices
    // set the member vars m_xyz so can be reused if it has a timeout (so x1 etc aren't 0, ie carries over)
    if ((ident = ALooper_pollAll(m_minDelayMsec/2, NULL, &events, NULL)) >= 0) {
        if (ident == LOOPER_ID_QCN) {
            ASensorEvent event;
            if (ASensorEventQueue_getEvents(m_pSensorEventQueue, &event, 1) > 0) {
                m_xyz[0] = event.acceleration.x;
                m_xyz[1] = event.acceleration.y;
                m_xyz[2] = event.acceleration.z;
            }
        }
    }

    // m_xyz (ie android accelerometer return values) are in G's already, so just multiply by earth g 9.8
    x1 = m_xyz[0] * EARTH_G;
    y1 = m_xyz[1] * EARTH_G;
    z1 = m_xyz[2] * EARTH_G;

    //fprintf(stdout, "read_xyz:  %f %f %f\n", x1, y1, z1);

    return true;
}
开发者ID:happyj,项目名称:qcn,代码行数:34,代码来源:csensor_android_built_in.cpp


示例6: gtk_android_exit

void gtk_android_exit(struct android_app *state)
{
    int ident;
    int events;
    struct android_poll_source* source;

    // replace onDestroy handler to terminate the process AFTER everything is unloaded
    if (!defaultActivityDestroyHandler)
    {
        defaultActivityDestroyHandler = state->activity->callbacks->onDestroy;
        state->activity->callbacks->onDestroy = onActivityDestroy;
    }

    ANativeActivity_finish(state->activity);

    while (!state->destroyRequested)
    {
        // Read all pending events.
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            // Process this event.
            if (source != NULL)
                source->process(state, source);
        }
    }
}
开发者ID:ericwlange,项目名称:hemroid,代码行数:26,代码来源:gtkainit.c


示例7: while

void NativeEngine::GameLoop() {
    mApp->userData = this;
    mApp->onAppCmd = _handle_cmd_proxy;
    mApp->onInputEvent = _handle_input_proxy;

    while (1) {
        int ident, events;
        struct android_poll_source* source;
        bool wasAnimating = IsAnimating();

        // If not animating, block until we get an event; if animating, don't block.
        while ((ident = ALooper_pollAll(IsAnimating() ? 0 : -1, NULL, &events,
                (void**)&source)) >= 0) {

            // process event
            if (source != NULL) {
                source->process(mApp, source);
            }

            // are we exiting?
            if (mApp->destroyRequested) {
                return;
            }
        }

        if (IsAnimating()) {
            DoFrame();
        }
    }
}
开发者ID:Uliori,项目名称:Origami,代码行数:30,代码来源:native_engine.cpp


示例8: run

		void run(android_app* _app)
		{
			m_app = _app;
			m_app->userData = (void*)this;
			m_app->onAppCmd = onAppCmdCB;
			m_app->onInputEvent = onInputEventCB;

			const char* argv[1] = { "android.so" };
			m_mte.m_argc = 1;
			m_mte.m_argv = const_cast<char**>(argv);
			
			while (0 == m_app->destroyRequested)
			{
				int32_t num;
				android_poll_source* source;
				/*int32_t id =*/ ALooper_pollAll(-1, NULL, &num, (void**)&source);

				if (NULL != source)
				{
					source->process(m_app, source);
				}
			}

			m_thread.shutdown();
		}
开发者ID:miguelmartin75,项目名称:bgfx,代码行数:25,代码来源:entry_android.cpp


示例9: android_main

void android_main(struct android_app* state) {
    struct engine engine;

    // 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;
	PlatfromInit();

	//_InitSensor();
	//InitSensor();
	
	ANativeActivity_setWindowFlags(state->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0);

    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);
            }

			//_ProcessSensorData(ident);

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

        if (engine.animating) {

            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            engine_draw_frame(&engine);
        }
    }
}
开发者ID:garudaxc,项目名称:AndroidGL,代码行数:60,代码来源:main.cpp


示例10: gdk_android_process_events_until_display_ready

gboolean gdk_android_process_events_until_display_ready(struct android_app *app)
{
    int ident;
    int events;
    struct android_poll_source* source;
    while (1)
    {
        // Read all pending events.
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            // Process this event.
            if (source != NULL)
                source->process(app, source);

            // Check if we are exiting.
            if (app->destroyRequested != 0)
            {
                gdk_android_term_display();
                return FALSE;
            }

            if (_gdk_display)
                return TRUE;
        }
    }
}
开发者ID:ericwlange,项目名称:hemroid,代码行数:26,代码来源:gdkevents-android.c


示例11: android_main

void android_main(struct android_app* state) 
{
	state->onAppCmd     = app_handle_cmd;
	state->onInputEvent = app_handle_input;

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

	// 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(-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) {
				break;
			}
		}
	}
}
开发者ID:rrrfff,项目名称:ApkTest,代码行数:33,代码来源:main.cpp


示例12: engineContext

void EngineCore::mainLoop() {
    int ident;
    int events;
    struct android_poll_source* source;
    shared_ptr<EngineContext> engineContext(getEngineContext());
    app_dummy();

    while (true) {
        // If not animating, block forever waiting for events.
        // otherwise,  loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(
                    engineContext->isRendering() ? 0 : -1,
                    NULL, &events, (void**)&source)) >= 0) {
            if (ident == LOOPER_ID_MAIN || ident == LOOPER_ID_INPUT) {
                if (source != NULL) {
                    source->process(mApp, source);
                }
            }

            if (mApp->destroyRequested != 0) {
                DEBUG(Log::F_APP_CMD_EVENT, "destroy request received");
                return;
            }
        }

        // check needQuit() to give an early chance to stop drawing.
        if (engineContext->isRendering() && !engineContext->needQuit()) {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            getEngineContext()->updateDisplay();
        }
    }

}
开发者ID:jiayu1016,项目名称:dizzy,代码行数:35,代码来源:engine_core.cpp


示例13: ev_loop

void ev_loop(android_app *papp) {
    int32_t lr;
    int32_t le;
    bool first = true;
    android_poll_source *ps;

    log("starting event loop");
    ros::Time::init();

    while (true) {
        lr = ALooper_pollAll(-1, NULL, &le, (void **) &ps);
        if (lr < 0) {
            break;
        }
        if (ps) {
            log("event received");
            if (first) {
                open_bag();
                papp->onInputEvent = handle_event;
                first = false;
            }
            ps->process(papp, ps);
        }
        if (papp->destroyRequested) {
            log("quitting event loop");
            return;
        }
    }
}
开发者ID:osrf,项目名称:rosbag_ndk_player,代码行数:29,代码来源:record.cpp


示例14: _glfwPlatformPollEvents

void _glfwPlatformPollEvents( void )
{
    EGLint w, h;
    int events;
    struct android_poll_source *source;

    // Callback resized window event
    if( _glfwWin.opened == GL_TRUE && _glfwWin.resized == GL_TRUE ){
        _glfwWin.resized = GL_FALSE;
        eglQuerySurface( _glfwWin.display, _glfwWin.surface, EGL_WIDTH, &w );
        eglQuerySurface( _glfwWin.display, _glfwWin.surface, EGL_HEIGHT, &h );
        _glfwWin.width = w;
        _glfwWin.height = h;
        if( _glfwWin.windowSizeCallback )
        {
            _glfwWin.windowSizeCallback( _glfwWin.width, _glfwWin.height );
        }
    }

    // Callback other events
    while (ALooper_pollAll(0, NULL, &events, (void**) &source) >= 0) {
        if (source != NULL) {
            source->process(_glfwWin.app, source);
        }
        if(_glfwWin.app->destroyRequested != 0){
           _glfwWin.app->destroyRequested = 0;
           _glfwWin.opened = GL_FALSE;
           return;
        }
    }
}
开发者ID:KTaskn,项目名称:MMDAgent,代码行数:31,代码来源:android_window.c


示例15: while

void ShellAndroid::run()
{
    PosixTimer timer;

    double current_time = timer.get();

    while (true) {
        struct android_poll_source *source;
        while (true) {
            int timeout = (settings_.animate && app_.window) ? 0 : -1;
            if (ALooper_pollAll(timeout, nullptr, nullptr,
                    reinterpret_cast<void **>(&source)) < 0)
                break;

            if (source)
                source->process(&app_, source);
        }

        if (app_.destroyRequested)
            break;

        if (!app_.window)
            continue;

        acquire_back_buffer();

        double t = timer.get();
        add_game_time(static_cast<float>(t - current_time));

        present_back_buffer();

        current_time = t;
    }
}
开发者ID:AdamRLukaitis,项目名称:VulkanSamples,代码行数:34,代码来源:ShellAndroid.cpp


示例16: android_main

void android_main(android_app* state) {
	app_dummy();

	engine e;
	state->userData = &e;
	state->onAppCmd = [](android_app* app, int32_t cmd) {
		auto e = static_cast<engine*>(app->userData);
		switch (cmd) {
			case APP_CMD_INIT_WINDOW:
				init(e);
				draw(e);
				break;
		}
	};
	e.app = state;

	while (1) {
		int ident, events;
		android_poll_source* source;
		while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
			if (source != NULL) {
				source->process(state, source);
			}
			if (state->destroyRequested != 0) {
				return;
			}
		}
	}
}
开发者ID:kapsy,项目名称:original-native,代码行数:29,代码来源:original_native.cpp


示例17: app_dummy

	void Engine::run()
	{
		app_dummy();

		Timer timer;

		while (true)
		{
			int ident;
			int fdesc;
			int events;
			struct android_poll_source* source;

			while((ident = ALooper_pollAll(0, &fdesc, &events, (void**)&source)) >= 0)
			{
				if (source)
					source->process(mAndroidApp, source);
			}

			unsigned long long nanos = timer.nanos();
			timer.reset();

			if (mInited)
			{
				if (!mApp.update(nanos))
					break;

				mRender.frame();
			}
		}

		mApp.shutdown();
	}
开发者ID:ralphmorton,项目名称:Indico,代码行数:33,代码来源:IndicoEngine.cpp


示例18: run

		void run(android_app* _app)
		{
			m_app = _app;
			m_app->userData = (void*)this;
			m_app->onAppCmd = onAppCmdCB;
			m_app->onInputEvent = onInputEventCB;
			ANativeActivity_setWindowFlags(m_app->activity, 0
				| AWINDOW_FLAG_FULLSCREEN
				| AWINDOW_FLAG_KEEP_SCREEN_ON
				, 0
				);

			const char* argv[1] = { "android.so" };
			m_mte.m_argc = 1;
			m_mte.m_argv = const_cast<char**>(argv);
			
			while (0 == m_app->destroyRequested)
			{
				int32_t num;
				android_poll_source* source;
				/*int32_t id =*/ ALooper_pollAll(-1, NULL, &num, (void**)&source);

				if (NULL != source)
				{
					source->process(m_app, source);
				}
			}

			m_thread.shutdown();
		}
开发者ID:Bloodknight,项目名称:bgfx,代码行数:30,代码来源:entry_android.cpp


示例19: ProcessAndroidEvents

void ProcessAndroidEvents()
{
    do {
        // 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(g_engine.has_focus ? 0 : -1, NULL, &events,
                (void**)&source)) >= 0) {
    
            // Process this event.
            if (source != NULL) {
                source->process(g_engine.app, source);
            }
        
            // Check if we are exiting.
            if (g_engine.app->destroyRequested != 0) {
                engine_term_display(&g_engine);
                context->quit = true;
                return;
            }
        }
    } while (g_engine.display == NULL);
}
开发者ID:GrimDerp,项目名称:Pangolin,代码行数:28,代码来源:display_android.cpp


示例20: ALooper_pollAll

Vector3f SensorImpl::update()
{
    // Update our sensor data list
    ALooper_pollAll(0, NULL, NULL, NULL);

    return sensorData[m_index];
}
开发者ID:Sonkun,项目名称:SFML,代码行数:7,代码来源:SensorImpl.cpp



注:本文中的ALooper_pollAll函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AMIGAHW_PRESENT函数代码示例发布时间:2022-05-30
下一篇:
C++ AL_PRINT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap