test: SDLTest_PrintEvent now reports key event mod state.

This commit is contained in:
Ryan C. Gordon 2023-11-28 13:07:56 -05:00
parent 7d25a443c4
commit d42fa25a9e

View file

@ -1630,19 +1630,23 @@ static void SDLTest_PrintEvent(SDL_Event *event)
} }
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
SDL_Log("SDL EVENT: Keyboard: key pressed in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s", case SDL_KEYUP: {
char modstr[64];
if (event->key.keysym.mod) {
modstr[0] = '\0';
SDLTest_PrintModState(modstr, sizeof (modstr), event->key.keysym.mod);
} else {
SDL_strlcpy(modstr, "NONE", sizeof (modstr));
}
SDL_Log("SDL EVENT: Keyboard: key %s in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s, mods = %s",
(event->type == SDL_KEYDOWN) ? "pressed" : "released",
event->key.windowID, event->key.windowID,
event->key.keysym.scancode, event->key.keysym.scancode,
SDL_GetScancodeName(event->key.keysym.scancode), SDL_GetScancodeName(event->key.keysym.scancode),
event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym),
break; modstr);
case SDL_KEYUP:
SDL_Log("SDL EVENT: Keyboard: key released in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s",
event->key.windowID,
event->key.keysym.scancode,
SDL_GetScancodeName(event->key.keysym.scancode),
event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
break; break;
}
case SDL_TEXTEDITING: case SDL_TEXTEDITING:
SDL_Log("SDL EVENT: Keyboard: text editing \"%s\" in window %" SDL_PRIu32, SDL_Log("SDL EVENT: Keyboard: text editing \"%s\" in window %" SDL_PRIu32,
event->edit.text, event->edit.windowID); event->edit.text, event->edit.windowID);