Added test code to validate SDL_WaitEventTimeout()

You can enable this by defining TEST_WAITEVENTTIMEOUT
main
Sam Lantinga 2024-01-25 06:29:15 -08:00
parent d6ebbc2fa4
commit 5ddd97062e
1 changed files with 11 additions and 1 deletions

View File

@ -154,7 +154,17 @@ static void loop(void)
{ {
int i; int i;
SDL_Event event; SDL_Event event;
/* Check for events */
#ifdef TEST_WAITEVENTTIMEOUT
/* Wait up to 20 ms for input, as a test */
Uint64 then = SDL_GetTicks();
if (SDL_WaitEventTimeout(NULL, 20)) {
SDL_Log("Got an event!\n");
}
Uint64 now = SDL_GetTicks();
SDL_Log("Waited %d ms for events\n", (int)(now - then));
#endif
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
SDLTest_CommonEvent(state, &event, &done); SDLTest_CommonEvent(state, &event, &done);