From 049fda00cf71e23a25d6478e98c5d38129a1e295 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 6 Apr 2004 23:47:56 +0000 Subject: [PATCH] Fix more brain damage with keyboard handling. I think everything is working now. --- src/Main/fg_os_sdl.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Main/fg_os_sdl.cxx b/src/Main/fg_os_sdl.cxx index db97fcf63..eebb4ae7c 100644 --- a/src/Main/fg_os_sdl.cxx +++ b/src/Main/fg_os_sdl.cxx @@ -88,6 +88,7 @@ void fgOSOpenWindow(int w, int h, int bpp, // we may want to port the input maps to specify // explicitly, and will turn this off. SDL_EnableUNICODE(1); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); initCursors(); fgSetMouseCursor(MOUSE_CURSOR_POINTER); @@ -134,15 +135,16 @@ static void handleKey(int key, int keyup) case SDLK_F11: key = PU_KEY_F11; break; case SDLK_F12: key = PU_KEY_F12; break; } + int keymod = 0; if(keyup) { CurrentModifiers &= ~modmask; - CurrentModifiers |= KEYMOD_RELEASED; + keymod = CurrentModifiers | KEYMOD_RELEASED; } else { CurrentModifiers |= modmask; - CurrentModifiers &= ~KEYMOD_RELEASED; + keymod = CurrentModifiers & ~KEYMOD_RELEASED; } if(modmask == 0 && KeyHandler) - (*KeyHandler)(key, CurrentModifiers, CurrentMouseX, CurrentMouseY); + (*KeyHandler)(key, keymod, CurrentMouseX, CurrentMouseY); } // FIXME: need to export this and get the rest of FlightGear to use @@ -158,6 +160,7 @@ void fgOSMainLoop() { while(1) { SDL_Event e; + int key; while(SDL_PollEvent(&e)) { switch(e.type) { case SDL_QUIT: @@ -165,7 +168,9 @@ void fgOSMainLoop() break; case SDL_KEYDOWN: case SDL_KEYUP: - handleKey(e.key.keysym.unicode, e.key.state == SDL_RELEASED); + key = e.key.keysym.unicode; + if(key == 0) key = e.key.keysym.sym; + handleKey(key, e.key.state == SDL_RELEASED); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: -- 2.39.5