1
0
Fork 0

Fix more brain damage with keyboard handling. I think everything is

working now.
This commit is contained in:
andy 2004-04-06 23:47:56 +00:00
parent 96afa68cad
commit 049fda00cf

View file

@ -88,6 +88,7 @@ void fgOSOpenWindow(int w, int h, int bpp,
// we may want to port the input maps to specify <mod-shift> // we may want to port the input maps to specify <mod-shift>
// explicitly, and will turn this off. // explicitly, and will turn this off.
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
initCursors(); initCursors();
fgSetMouseCursor(MOUSE_CURSOR_POINTER); 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_F11: key = PU_KEY_F11; break;
case SDLK_F12: key = PU_KEY_F12; break; case SDLK_F12: key = PU_KEY_F12; break;
} }
int keymod = 0;
if(keyup) { if(keyup) {
CurrentModifiers &= ~modmask; CurrentModifiers &= ~modmask;
CurrentModifiers |= KEYMOD_RELEASED; keymod = CurrentModifiers | KEYMOD_RELEASED;
} else { } else {
CurrentModifiers |= modmask; CurrentModifiers |= modmask;
CurrentModifiers &= ~KEYMOD_RELEASED; keymod = CurrentModifiers & ~KEYMOD_RELEASED;
} }
if(modmask == 0 && KeyHandler) 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 // FIXME: need to export this and get the rest of FlightGear to use
@ -158,6 +160,7 @@ void fgOSMainLoop()
{ {
while(1) { while(1) {
SDL_Event e; SDL_Event e;
int key;
while(SDL_PollEvent(&e)) { while(SDL_PollEvent(&e)) {
switch(e.type) { switch(e.type) {
case SDL_QUIT: case SDL_QUIT:
@ -165,7 +168,9 @@ void fgOSMainLoop()
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: 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; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP: