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

This commit is contained in:
Sam Lantinga 2022-07-29 20:37:38 -07:00
parent 13e0c40ec2
commit 2241bd669f
2 changed files with 11 additions and 9 deletions

View File

@ -50,6 +50,7 @@
#define VERBOSE_RENDER 0x00000004 #define VERBOSE_RENDER 0x00000004
#define VERBOSE_EVENT 0x00000008 #define VERBOSE_EVENT 0x00000008
#define VERBOSE_AUDIO 0x00000010 #define VERBOSE_AUDIO 0x00000010
#define VERBOSE_MOTION 0x00000020
typedef struct typedef struct
{ {

View File

@ -28,7 +28,7 @@
static const char *video_usage[] = { static const char *video_usage[] = {
"[--video driver]", "[--renderer driver]", "[--gldebug]", "[--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]", "[--log all|error|system|audio|video|render|input]", "[--display N]",
"[--metal-window | --opengl-window | --vulkan-window]", "[--metal-window | --opengl-window | --vulkan-window]",
"[--fullscreen | --fullscreen-desktop | --windows N]", "[--title title]", "[--fullscreen | --fullscreen-desktop | --windows N]", "[--title title]",
@ -168,6 +168,10 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index)
state->verbose |= VERBOSE_EVENT; state->verbose |= VERBOSE_EVENT;
return 2; return 2;
} }
if (SDL_strcasecmp(argv[index], "event_motion") == 0) {
state->verbose |= (VERBOSE_EVENT | VERBOSE_MOTION);
return 2;
}
return -1; return -1;
} }
if (SDL_strcasecmp(argv[index], "--log") == 0) { if (SDL_strcasecmp(argv[index], "--log") == 0) {
@ -1464,13 +1468,6 @@ default: return "???";
static void static void
SDLTest_PrintEvent(SDL_Event * event) 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) { switch (event->type) {
case SDL_DISPLAYEVENT: case SDL_DISPLAYEVENT:
switch (event->display.event) { switch (event->display.event) {
@ -1826,8 +1823,12 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
static SDL_MouseMotionEvent lastEvent; static SDL_MouseMotionEvent lastEvent;
if (state->verbose & VERBOSE_EVENT) { if (state->verbose & VERBOSE_EVENT) {
if (((event->type != SDL_MOUSEMOTION) &&
(event->type != SDL_FINGERMOTION)) ||
((state->verbose & VERBOSE_MOTION) != 0)) {
SDLTest_PrintEvent(event); SDLTest_PrintEvent(event);
} }
}
switch (event->type) { switch (event->type) {
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT: