瀏覽代碼

Added test code to validate SDL_WaitEventTimeout()

You can enable this by defining TEST_WAITEVENTTIMEOUT
Sam Lantinga 1 年之前
父節點
當前提交
5ddd97062e
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      test/testwm.c

+ 11 - 1
test/testwm.c

@@ -154,7 +154,17 @@ static void loop(void)
 {
     int i;
     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)) {
         SDLTest_CommonEvent(state, &event, &done);