Commit 2241bd669fcb96046390e2a08eeea5864a832b15

Sam Lantinga 2022-07-29T20:37:38

Added a command line option `--info event_motion` to show mouse and finger motion events

diff --git a/include/SDL_test_common.h b/include/SDL_test_common.h
index 0f50967..b86520d 100644
--- a/include/SDL_test_common.h
+++ b/include/SDL_test_common.h
@@ -50,6 +50,7 @@
 #define VERBOSE_RENDER  0x00000004
 #define VERBOSE_EVENT   0x00000008
 #define VERBOSE_AUDIO   0x00000010
+#define VERBOSE_MOTION  0x00000020
 
 typedef struct
 {
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 44013f6..c86742c 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -28,7 +28,7 @@
 
 static const char *video_usage[] = {
     "[--video driver]", "[--renderer driver]", "[--gldebug]",
-    "[--info all|video|modes|render|event]",
+    "[--info all|video|modes|render|event|event_motion]",
     "[--log all|error|system|audio|video|render|input]", "[--display N]",
     "[--metal-window | --opengl-window | --vulkan-window]",
     "[--fullscreen | --fullscreen-desktop | --windows N]", "[--title title]",
@@ -168,6 +168,10 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
             state->verbose |= VERBOSE_EVENT;
             return 2;
         }
+        if (SDL_strcasecmp(argv[index], "event_motion") == 0) {
+            state->verbose |= (VERBOSE_EVENT | VERBOSE_MOTION);
+            return 2;
+        }
         return -1;
     }
     if (SDL_strcasecmp(argv[index], "--log") == 0) {
@@ -1464,13 +1468,6 @@ default: return "???";
 static void
 SDLTest_PrintEvent(SDL_Event * event)
 {
-#ifndef VERBOSE_MOTION_EVENTS
-    if ((event->type == SDL_MOUSEMOTION) || (event->type == SDL_FINGERMOTION)) {
-        /* Mouse and finger motion are really spammy */
-        return;
-    }
-#endif
-
     switch (event->type) {
     case SDL_DISPLAYEVENT:
         switch (event->display.event) {
@@ -1826,7 +1823,11 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
     static SDL_MouseMotionEvent lastEvent;
 
     if (state->verbose & VERBOSE_EVENT) {
-        SDLTest_PrintEvent(event);
+        if (((event->type != SDL_MOUSEMOTION) &&
+             (event->type != SDL_FINGERMOTION)) ||
+            ((state->verbose & VERBOSE_MOTION) != 0)) {
+            SDLTest_PrintEvent(event);
+        }
     }
 
     switch (event->type) {