all repos — mgba @ 374aca2ff7c9481951cb615e2931b7dc988042ed

mGBA Game Boy Advance Emulator

Move event polling to after framedraw only
Jeffrey Pfau jeffrey@endrift.com
Sat, 04 May 2013 14:49:04 -0700
commit

374aca2ff7c9481951cb615e2931b7dc988042ed

parent

ac0c7ba792aa794a22d8f984bb5e73d5f0eef032

1 files changed, 13 insertions(+), 12 deletions(-)

jump to
M src/main.csrc/main.c

@@ -127,6 +127,19 @@ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, renderer->d.outputBuffer);

glDrawArrays(GL_TRIANGLE_FAN, 0, 4); SDL_GL_SwapBuffers(); + + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_QUIT: + // FIXME: this isn't thread-safe + context->debugger->state = DEBUGGER_EXITING; + break; + case SDL_KEYDOWN: + case SDL_KEYUP: + _GBASDLHandleKeypress(context, &event.key); + break; + } + } pthread_mutex_lock(&renderer->d.mutex); pthread_cond_broadcast(&renderer->d.downCond); pthread_mutex_unlock(&renderer->d.mutex);

@@ -143,18 +156,6 @@ break;

} } pthread_mutex_unlock(&renderer->d.mutex); - } - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_QUIT: - // FIXME: this isn't thread-safe - context->debugger->state = DEBUGGER_EXITING; - break; - case SDL_KEYDOWN: - case SDL_KEYUP: - _GBASDLHandleKeypress(context, &event.key); - break; - } } } }