Mercurial > sdl-ios-xcode
comparison src/video/dga/SDL_dgaevents.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 | 19418e4422cb |
comparison
equal
deleted
inserted
replaced
1326:9439c2f1da89 | 1327:d12a63a8d95a |
---|---|
35 #include "../x11/SDL_x11dyn.h" | 35 #include "../x11/SDL_x11dyn.h" |
36 | 36 |
37 /* Heheh we're using X11 event code */ | 37 /* Heheh we're using X11 event code */ |
38 extern int X11_Pending(Display *display); | 38 extern int X11_Pending(Display *display); |
39 extern void X11_InitKeymap(void); | 39 extern void X11_InitKeymap(void); |
40 extern SDL_keysym *X11_TranslateKey(Display *display, XIC ic, XKeyEvent *xkey, | 40 extern SDLKey X11_TranslateKeycode(Display *display, KeyCode kc); |
41 KeyCode kc, SDL_keysym *keysym); | |
42 | 41 |
43 static int DGA_DispatchEvent(_THIS) | 42 static int DGA_DispatchEvent(_THIS) |
44 { | 43 { |
45 int posted; | 44 int posted; |
46 SDL_NAME(XDGAEvent) xevent; | 45 SDL_NAME(XDGAEvent) xevent; |
72 posted = SDL_PrivateMouseButton(SDL_RELEASED, | 71 posted = SDL_PrivateMouseButton(SDL_RELEASED, |
73 xevent.xbutton.button, 0, 0); | 72 xevent.xbutton.button, 0, 0); |
74 } | 73 } |
75 break; | 74 break; |
76 | 75 |
77 /* Key press or release? */ | 76 /* Key press? */ |
78 case KeyPress: | 77 case KeyPress: { |
79 case KeyRelease: { | |
80 SDL_keysym keysym; | 78 SDL_keysym keysym; |
79 KeyCode keycode; | |
81 XKeyEvent xkey; | 80 XKeyEvent xkey; |
82 | 81 |
83 SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); | 82 SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); |
84 posted = SDL_PrivateKeyboard((xevent.type == KeyPress), | 83 keycode = xkey.keycode; |
85 X11_TranslateKey(DGA_Display, NULL/*no XIC*/, | 84 #ifdef DEBUG_XEVENTS |
86 &xkey, xkey.keycode, | 85 printf("KeyPress (X11 keycode = 0x%X)\n", xkey.keycode); |
87 &keysym)); | 86 #endif |
87 /* Get the translated SDL virtual keysym */ | |
88 keysym.scancode = keycode; | |
89 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); | |
90 keysym.mod = KMOD_NONE; | |
91 keysym.unicode = 0; | |
92 | |
93 /* Look up the translated value for the key event */ | |
94 if ( SDL_TranslateUNICODE ) { | |
95 static XComposeStatus state; | |
96 char keybuf[32]; | |
97 | |
98 if ( pXLookupString(&xkey, keybuf, sizeof(keybuf), NULL, &state) ) { | |
99 /* | |
100 * FIXME: XLookupString() may yield more than one | |
101 * character, so we need a mechanism to allow for | |
102 * this (perhaps null keypress events with a | |
103 * unicode value) | |
104 */ | |
105 keysym.unicode = (Uint8)keybuf[0]; | |
106 } | |
107 } | |
108 posted = SDL_PrivateKeyboard(SDL_PRESSED, &keysym); | |
88 } | 109 } |
110 break; | |
111 | |
112 /* Key release? */ | |
113 case KeyRelease: { | |
114 SDL_keysym keysym; | |
115 KeyCode keycode; | |
116 XKeyEvent xkey; | |
117 | |
118 SDL_NAME(XDGAKeyEventToXKeyEvent)(&xevent.xkey, &xkey); | |
119 keycode = xkey.keycode; | |
120 #ifdef DEBUG_XEVENTS | |
121 printf("KeyRelease (X11 keycode = 0x%X)\n", xkey.keycode); | |
122 #endif | |
123 /* Get the translated SDL virtual keysym */ | |
124 keysym.scancode = keycode; | |
125 keysym.sym = X11_TranslateKeycode(DGA_Display, keycode); | |
126 keysym.mod = KMOD_NONE; | |
127 keysym.unicode = 0; | |
128 posted = SDL_PrivateKeyboard(SDL_RELEASED, &keysym); | |
129 } | |
130 break; | |
131 | |
89 break; | 132 break; |
90 | 133 |
91 } | 134 } |
92 return(posted); | 135 return(posted); |
93 } | 136 } |