本文整理汇总了C++中ALooper_pollAll函数的典型用法代码示例。如果您正苦于以下问题:C++ ALooper_pollAll函数的具体用法?C++ ALooper_pollAll怎么用?C++ ALooper_pollAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ALooper_pollAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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();
}
}
}
示例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();
}
示例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);
}
}
}
示例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;
}
}
}
示例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;
}
}
}
}
示例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();
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}