Mercurial > sdl-ios-xcode
comparison src/events/SDL_keyboard.c @ 4713:ba38983b10c2
Added preliminary keyboard event support
author | Paul Hunkin <paul@bieh.net> |
---|---|
date | Wed, 07 Jul 2010 00:43:23 +1200 |
parents | 25e45611fa3d |
children | 1f7ad083fd3c |
comparison
equal
deleted
inserted
replaced
4712:8319aa8fa4dc | 4713:ba38983b10c2 |
---|---|
692 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); | 692 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
693 int posted; | 693 int posted; |
694 Uint16 modstate; | 694 Uint16 modstate; |
695 Uint32 type; | 695 Uint32 type; |
696 | 696 |
697 if(!keyboard){ | |
698 return 7; | |
699 } | |
700 | |
701 if(!scancode){ | |
702 return 8; | |
703 } | |
704 | |
697 if (!keyboard || !scancode) { | 705 if (!keyboard || !scancode) { |
698 return 0; | 706 return 1; |
699 } | 707 } |
700 #if 0 | 708 #if 0 |
701 printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode), | 709 printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode), |
702 state == SDL_PRESSED ? "pressed" : "released"); | 710 state == SDL_PRESSED ? "pressed" : "released"); |
703 #endif | 711 #endif |
786 case SDL_RELEASED: | 794 case SDL_RELEASED: |
787 type = SDL_KEYUP; | 795 type = SDL_KEYUP; |
788 break; | 796 break; |
789 default: | 797 default: |
790 /* Invalid state -- bail */ | 798 /* Invalid state -- bail */ |
791 return 0; | 799 return 2; |
792 } | 800 } |
793 | 801 |
794 /* Drop events that don't change state */ | 802 /* Drop events that don't change state */ |
795 if (keyboard->keystate[scancode] == state) { | 803 if (keyboard->keystate[scancode] == state) { |
796 #if 0 | 804 #if 0 |
797 printf("Keyboard event didn't change state - dropped!\n"); | 805 printf("Keyboard event didn't change state - dropped!\n"); |
798 #endif | 806 #endif |
799 return 0; | 807 return 3; |
800 } | 808 } |
801 | 809 |
802 /* Update internal keyboard state */ | 810 /* Update internal keyboard state */ |
803 keyboard->keystate[scancode] = state; | 811 keyboard->keystate[scancode] = state; |
804 | 812 |
805 /* Post the event, if desired */ | 813 /* Post the event, if desired */ |
806 posted = 0; | 814 posted = 4; |
807 if (SDL_GetEventState(type) == SDL_ENABLE) { | 815 if (SDL_GetEventState(type) == SDL_ENABLE) { |
808 SDL_Event event; | 816 SDL_Event event; |
809 event.key.type = type; | 817 event.key.type = type; |
810 event.key.which = (Uint8) index; | 818 event.key.which = (Uint8) index; |
811 event.key.state = state; | 819 event.key.state = state; |