Mercurial > sdl-ios-xcode
diff src/events/SDL_keyboard.c @ 4565:e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 21 Jul 2010 21:47:12 -0700 |
parents | dc9d77a26388 |
children | 1d7ea8724f4a |
line wrap: on
line diff
--- a/src/events/SDL_keyboard.c Wed Jul 21 00:11:56 2010 -0700 +++ b/src/events/SDL_keyboard.c Wed Jul 21 21:47:12 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_FALSE); + SDL_SendKeyboardKey(SDL_RELEASED, scancode); } } } @@ -627,12 +627,13 @@ } int -SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat) +SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; Uint16 modstate; Uint32 type; + Uint8 repeat; if (!scancode) { return 0; @@ -732,6 +733,7 @@ } /* Drop events that don't change state */ + repeat = (state && keyboard->keystate[scancode]); if (keyboard->keystate[scancode] == state && !repeat) { #if 0 printf("Keyboard event didn't change state - dropped!\n"); @@ -748,7 +750,7 @@ SDL_Event event; event.key.type = type; event.key.state = state; - event.key.repeat = repeat ? 1 : 0; + event.key.repeat = repeat; event.key.keysym.scancode = scancode; event.key.keysym.sym = keyboard->keymap[scancode]; event.key.keysym.mod = modstate;