comparison src/video/quartz/SDL_QuartzEvents.m @ 561:4bcf7dd06c47

Date: Sat, 14 Dec 2002 13:33:05 -0500 From: Darrell Walisser Subject: Re: crash in SDL / OSX > Yes, compose keys and other "dead" keys should have unicode 0. > As a hack, if you get multiple composed characters, you can send the > sequence with a valid unicode and a keysym of 0. It's because of > things like this that I'm separating the key and char events in SDL 2.0 I've done this and here's the patch.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Dec 2002 09:09:31 +0000
parents 2536446a92de
children 04dcaf3da918
comparison
equal deleted inserted replaced
560:37c31c12eb70 561:4bcf7dd06c47
204 } 204 }
205 205
206 static void QZ_DoKey (_THIS, int state, NSEvent *event) { 206 static void QZ_DoKey (_THIS, int state, NSEvent *event) {
207 207
208 NSString *chars; 208 NSString *chars;
209 int i; 209 unsigned int numChars;
210 SDL_keysym key; 210 SDL_keysym key;
211 211
212 /* 212 /*
213 An event can contain multiple characters 213 A key event can contain multiple characters,
214 I'll ignore this fact for now, since there 214 or no characters at all. In most cases, it
215 is only one virtual key code per event, so 215 will contain a single character. If it contains
216 no good way to handle this. 216 0 characters, we'll use 0 as the unicode. If it
217 contains multiple characters, we'll use 0 as
218 the scancode/keysym.
217 */ 219 */
218 chars = [ event characters ]; 220 chars = [ event characters ];
219 for (i =0; i < 1 /*[ chars length ] */; i++) { 221 numChars = [ chars length ];
222
223 if (numChars == 1) {
220 224
221 key.scancode = [ event keyCode ]; 225 key.scancode = [ event keyCode ];
222 key.sym = keymap [ key.scancode ]; 226 key.sym = keymap [ key.scancode ];
223 key.unicode = [ chars characterAtIndex:i]; 227 key.unicode = [ chars characterAtIndex:0 ];
224 key.mod = KMOD_NONE; 228 key.mod = KMOD_NONE;
225 229
226 SDL_PrivateKeyboard (state, &key); 230 SDL_PrivateKeyboard (state, &key);
231 }
232 else if (numChars == 0) {
233
234 key.scancode = [ event keyCode ];
235 key.sym = keymap [ key.scancode ];
236 key.unicode = 0;
237 key.mod = KMOD_NONE;
238
239 SDL_PrivateKeyboard (state, &key);
240 }
241 else /* (numChars > 1) */ {
242
243 int i;
244 for (i = 0; i < numChars; i++) {
245
246 key.scancode = 0;
247 key.sym = 0;
248 key.unicode = [ chars characterAtIndex:i];
249 key.mod = KMOD_NONE;
250
251 SDL_PrivateKeyboard (state, &key);
252 }
227 } 253 }
228 } 254 }
229 255
230 static void QZ_DoModifiers (_THIS, unsigned int newMods) { 256 static void QZ_DoModifiers (_THIS, unsigned int newMods) {
231 257