diff src/events/SDL_keyboard.c @ 4560:95352c671a6e

Added support for keyboard repeat (only tested on Windows so far)
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Jul 2010 23:25:24 -0700
parents 05ab4141ce93
children dc9d77a26388
line wrap: on
line diff
--- a/src/events/SDL_keyboard.c	Tue Jul 20 00:57:01 2010 -0700
+++ b/src/events/SDL_keyboard.c	Tue Jul 20 23:25:24 2010 -0700
@@ -566,7 +566,7 @@
 
     for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
         if (keyboard->keystate[scancode] == SDL_PRESSED) {
-            SDL_SendKeyboardKey(SDL_RELEASED, scancode);
+            SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
         }
     }
 }
@@ -627,7 +627,7 @@
 }
 
 int
-SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
+SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
     int posted;
@@ -732,7 +732,7 @@
     }
 
     /* Drop events that don't change state */
-    if (keyboard->keystate[scancode] == state) {
+    if (keyboard->keystate[scancode] == state && !repeat) {
 #if 0
         printf("Keyboard event didn't change state - dropped!\n");
 #endif
@@ -748,6 +748,7 @@
         SDL_Event event;
         event.key.type = type;
         event.key.state = state;
+        event.key.repeat = repeat ? 1 : 0;
         event.key.keysym.scancode = scancode;
         event.key.keysym.sym = keyboard->keymap[scancode];
         event.key.keysym.mod = modstate;