From 391a63f29fee4428269db9f818d58705035eba9d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 11 Jun 2024 09:09:12 -0700 Subject: [PATCH] Check raw keyboard input in checkkeys --- test/checkkeys.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/checkkeys.c b/test/checkkeys.c index e0baa5e052..278365bb4a 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -154,6 +154,19 @@ PrintText(const char *eventtype, const char *text) SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text); } +static void CountKeysDown(void) +{ + int i, count = 0, max_keys = 0; + const Uint8 *keystate = SDL_GetKeyboardState(&max_keys); + + for (i = 0; i < max_keys; ++i) { + if (keystate[i]) { + ++count; + } + } + SDL_Log("Keys down: %d\n", count); +} + static void loop(void) { SDL_Event event; @@ -178,6 +191,7 @@ static void loop(void) break; } } + CountKeysDown(); break; case SDL_EVENT_TEXT_EDITING: PrintText("EDIT", event.edit.text); @@ -239,6 +253,8 @@ int main(int argc, char *argv[]) { int w, h; + SDL_SetHint(SDL_HINT_WINDOWS_RAW_KEYBOARD, "1"); + /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) {