comparison src/events/SDL_keyboard.c @ 1327:d12a63a8d95a

Resolved bug #130 Use XFilterEvent() to handle dead-key composition under X11 Cleaned up the code in preparation for 1.3 API changes
author Sam Lantinga <slouken@libsdl.org>
date Sat, 04 Feb 2006 08:35:11 +0000
parents c9b51268668f
children 450721ad5436
comparison
equal deleted inserted replaced
1326:9439c2f1da89 1327:d12a63a8d95a
395 repeatable = 0; 395 repeatable = 0;
396 396
397 if ( state == SDL_PRESSED ) { 397 if ( state == SDL_PRESSED ) {
398 keysym->mod = (SDLMod)modstate; 398 keysym->mod = (SDLMod)modstate;
399 switch (keysym->sym) { 399 switch (keysym->sym) {
400 case SDLK_UNKNOWN:
401 break;
400 case SDLK_NUMLOCK: 402 case SDLK_NUMLOCK:
401 modstate ^= KMOD_NUM; 403 modstate ^= KMOD_NUM;
402 if ( ! (modstate&KMOD_NUM) ) 404 if ( ! (modstate&KMOD_NUM) )
403 state = SDL_RELEASED; 405 state = SDL_RELEASED;
404 keysym->mod = (SDLMod)modstate; 406 keysym->mod = (SDLMod)modstate;
440 repeatable = 1; 442 repeatable = 1;
441 break; 443 break;
442 } 444 }
443 } else { 445 } else {
444 switch (keysym->sym) { 446 switch (keysym->sym) {
447 case SDLK_UNKNOWN:
448 break;
445 case SDLK_NUMLOCK: 449 case SDLK_NUMLOCK:
446 case SDLK_CAPSLOCK: 450 case SDLK_CAPSLOCK:
447 /* Only send keydown events */ 451 /* Only send keydown events */
448 return(0); 452 return(0);
449 case SDLK_LCTRL: 453 case SDLK_LCTRL:
497 default: 501 default:
498 /* Invalid state -- bail */ 502 /* Invalid state -- bail */
499 return(0); 503 return(0);
500 } 504 }
501 505
502 /* Drop events that don't change state */ 506 if ( keysym->sym != SDLK_UNKNOWN ) {
503 if ( SDL_KeyState[keysym->sym] == state ) { 507 /* Drop events that don't change state */
508 if ( SDL_KeyState[keysym->sym] == state ) {
504 #if 0 509 #if 0
505 printf("Keyboard event didn't change state - dropped!\n"); 510 printf("Keyboard event didn't change state - dropped!\n");
506 #endif 511 #endif
507 return(0); 512 return(0);
508 } 513 }
509 514
510 /* Update internal keyboard state */ 515 /* Update internal keyboard state */
511 SDL_ModState = (SDLMod)modstate; 516 SDL_ModState = (SDLMod)modstate;
512 SDL_KeyState[keysym->sym] = state; 517 SDL_KeyState[keysym->sym] = state;
518 }
513 519
514 /* Post the event, if desired */ 520 /* Post the event, if desired */
515 posted = 0; 521 posted = 0;
516 if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) { 522 if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) {
517 event.key.state = state; 523 event.key.state = state;