comparison src/video/x11/SDL_x11events.c @ 412:ac59b067815b

Fix uninitialized variable warning
author Sam Lantinga <slouken@libsdl.org>
date Thu, 13 Jun 2002 16:54:38 +0000
parents f6ffac90895c
children 864a66f028d8
comparison
equal deleted inserted replaced
411:8c4999b0ac10 412:ac59b067815b
833 * key_vec is a bit vector of keycodes (256 bits) 833 * key_vec is a bit vector of keycodes (256 bits)
834 */ 834 */
835 void X11_SetKeyboardState(Display *display, const char *key_vec) 835 void X11_SetKeyboardState(Display *display, const char *key_vec)
836 { 836 {
837 char keys_return[32]; 837 char keys_return[32];
838 int i, gen_event; 838 int i;
839 KeyCode xcode[SDLK_LAST]; 839 KeyCode xcode[SDLK_LAST];
840 Uint8 new_kstate[SDLK_LAST]; 840 Uint8 new_kstate[SDLK_LAST];
841 Uint8 *kstate = SDL_GetKeyState(NULL); 841 Uint8 *kstate = SDL_GetKeyState(NULL);
842 SDLMod modstate; 842 SDLMod modstate;
843 Window junk_window; 843 Window junk_window;
844 int x, y; 844 int x, y;
845 unsigned int mask; 845 unsigned int mask;
846 846
847 /* The first time the window is mapped, we initialize key state */ 847 /* The first time the window is mapped, we initialize key state */
848 if ( ! key_vec ) { 848 if ( ! key_vec ) {
849 XQueryKeymap(display, keys_return);
849 key_vec = keys_return; 850 key_vec = keys_return;
850 XQueryKeymap(display, keys_return);
851 gen_event = 0;
852 } else {
853 #if 1 /* We no longer generate key down events, just update state */
854 gen_event = 0;
855 #else
856 gen_event = 1;
857 #endif
858 } 851 }
859 852
860 /* Get the keyboard modifier state */ 853 /* Get the keyboard modifier state */
861 modstate = 0; 854 modstate = 0;
862 get_modifier_masks(display); 855 get_modifier_masks(display);
925 break; 918 break;
926 default: 919 default:
927 break; 920 break;
928 } 921 }
929 } 922 }
930 if ( kstate[i] == state ) 923 if ( kstate[i] != state ) {
931 continue;
932
933 /*
934 * Send a fake keyboard event correcting the difference between
935 * SDL's keyboard state and the actual. Note that there is no
936 * way to find out the scancode for key releases, but since all
937 * keys are released when focus is lost only keypresses should
938 * be sent here
939 */
940 if ( gen_event ) {
941 SDL_keysym sk;
942 memset(&sk, 0, sizeof(sk));
943 sk.sym = i;
944 sk.scancode = xcode[i]; /* only valid for key press */
945 SDL_PrivateKeyboard(state, &sk);
946 } else {
947 kstate[i] = state; 924 kstate[i] = state;
948 } 925 }
949 } 926 }
950 927
951 /* Hack - set toggle key state */ 928 /* Hack - set toggle key state */