Browse Source

Use ALooper_pollOnce

pull/659/head
hsdk123 1 year ago committed by GitHub
parent
commit
fe930052d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 49
      src/Magnum/Platform/AndroidApplication.cpp

49
src/Magnum/Platform/AndroidApplication.cpp

@ -662,30 +662,41 @@ void AndroidApplication::exec(android_app* state, Containers::Pointer<AndroidApp
Data data{instancer, ANativeActivity_onCreate}; Data data{instancer, ANativeActivity_onCreate};
state->userData = &data; state->userData = &data;
for(;;) { /* Read all pending events. Block and wait for them only if the app
/* Read all pending events. Block and wait for them only if the app doesn't want to redraw immediately WHY THIS GODDAMN THING DOESNT
doesn't want to redraw immediately WHY THIS GODDAMN THING DOESNT HAVE SOMETHING LIKE WAIT FOR EVENT SO I NEED TO TANGLE THIS TANGLED
HAVE SOMETHING LIKE WAIT FOR EVENT SO I NEED TO TANGLE THIS TANGLED MESS OF HELL
MESS OF HELL */
int ident, events; WHY THIS HAS TO BE HANDLED HERE WHILE EVERY OTHER THING
android_poll_source* source; IS HANDLED THROUGH CALLBACK GODDAMMIT
while((ident = ALooper_pollAll(
data.instance && (data.instance->_flags & Flag::Redraw) ? 0 : -1, reference:
nullptr, &events, reinterpret_cast<void**>(&source))) >= 0) https://github.com/android/ndk-samples/pull/1008/files
{ */
/* Process this event OH SIR MAY MY POOR EXISTENCE CALL THIS while (!state->destroyRequested)
FUNCTION FOR YOU IF YOU DON'T MIND? */ {
if(source) source->process(state, source); android_poll_source* source = nullptr;
const auto timeout_ms = (data.instance && (data.instance->_flags & Flag::Redraw) ?
/* Exit WHY THIS HAS TO BE HANDLED HERE WHILE EVERY OTHER THING 0 : -1 /* negative value: wait indefinitely until an event appears */);
IS HANDLED THROUGH CALLBACK GODDAMMIT */
if(state->destroyRequested != 0) return; const auto result = ALooper_pollOnce(timeout_ms, nullptr, nullptr,
reinterpret_cast<void**>(&source));
if (result == ALOOPER_POLL_ERROR) {
return;
}
/* Process this event OH SIR MAY MY POOR EXISTENCE CALL THIS
FUNCTION FOR YOU IF YOU DON'T MIND? */
if(source) {
source->process(state, source);
} }
/* Redraw the app if it wants to be redrawn. Frame limiting is done by /* Redraw the app if it wants to be redrawn. Frame limiting is done by
Android itself */ Android itself */
if(data.instance && (data.instance->_flags & Flag::Redraw)) if(data.instance && (data.instance->_flags & Flag::Redraw)) {
data.instance->drawEvent(); data.instance->drawEvent();
}
} }
state->userData = nullptr; state->userData = nullptr;

Loading…
Cancel
Save