Added support for keyboard repeat (only tested on Windows so far)

This commit is contained in:
Sam Lantinga 2010-07-20 23:25:24 -07:00
parent 871f32561d
commit 0e59ffc802
8 changed files with 57 additions and 47 deletions

View file

@ -53,7 +53,7 @@ print_modifiers(void)
}
static void
PrintKey(SDL_keysym * sym, int pressed)
PrintKey(SDL_keysym * sym, SDL_bool pressed, SDL_bool repeat)
{
/* Print the keycode, name and state */
if (sym->sym) {
@ -87,6 +87,9 @@ PrintKey(SDL_keysym * sym, int pressed)
}
}
print_modifiers();
if (repeat) {
printf(" (repeat)");
}
printf("\n");
}
@ -134,10 +137,8 @@ main(int argc, char *argv[])
SDL_WaitEvent(&event);
switch (event.type) {
case SDL_KEYDOWN:
PrintKey(&event.key.keysym, 1);
break;
case SDL_KEYUP:
PrintKey(&event.key.keysym, 0);
PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
break;
case SDL_TEXTINPUT:
PrintText(event.text.text);