Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzEvents.m @ 4049:60f677630282 SDL-1.2
Added key composition support, courtesy of Kuon
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 11 Jul 2007 07:53:12 +0000 |
parents | f5794774970d |
children | 58a5055da431 |
comparison
equal
deleted
inserted
replaced
4048:3e380b8247aa | 4049:60f677630282 |
---|---|
252 } | 252 } |
253 | 253 |
254 static void QZ_DoKey (_THIS, int state, NSEvent *event) { | 254 static void QZ_DoKey (_THIS, int state, NSEvent *event) { |
255 | 255 |
256 NSString *chars; | 256 NSString *chars; |
257 unsigned int numChars; | 257 unsigned int i, numChars; |
258 SDL_keysym key; | 258 SDL_keysym key; |
259 | 259 |
260 /* | 260 /* |
261 A key event can contain multiple characters, | 261 A key event can contain multiple characters, |
262 or no characters at all. In most cases, it | 262 or no characters at all. In most cases, it |
263 will contain a single character. If it contains | 263 will contain a single character. If it contains |
264 0 characters, we'll use 0 as the unicode. If it | 264 0 characters, we'll use 0 as the unicode. If it |
265 contains multiple characters, we'll use 0 as | 265 contains multiple characters, we'll use 0 as |
266 the scancode/keysym. | 266 the scancode/keysym. |
267 */ | 267 */ |
268 if (SDL_TranslateUNICODE) { | 268 if (SDL_TranslateUNICODE && state == SDL_PRESSED) { |
269 [field_edit interpretKeyEvents:[NSArray arrayWithObject:event]]; | |
269 chars = [ event characters ]; | 270 chars = [ event characters ]; |
270 numChars = [ chars length ]; | 271 numChars = [ chars length ]; |
271 } else { | 272 } else { |
272 numChars = 0; | 273 numChars = 0; |
273 } | 274 } |
279 key.unicode = 0; | 280 key.unicode = 0; |
280 key.mod = KMOD_NONE; | 281 key.mod = KMOD_NONE; |
281 | 282 |
282 SDL_PrivateKeyboard (state, &key); | 283 SDL_PrivateKeyboard (state, &key); |
283 } | 284 } |
284 else if (numChars == 1) { | 285 else if (numChars >= 1) { |
285 | 286 |
286 key.scancode = [ event keyCode ]; | 287 key.scancode = [ event keyCode ]; |
287 key.sym = keymap [ key.scancode ]; | 288 key.sym = keymap [ key.scancode ]; |
288 key.unicode = [ chars characterAtIndex:0 ]; | 289 key.unicode = [ chars characterAtIndex:0 ]; |
289 key.mod = KMOD_NONE; | 290 key.mod = KMOD_NONE; |
290 | 291 |
291 SDL_PrivateKeyboard (state, &key); | 292 SDL_PrivateKeyboard (state, &key); |
292 } | |
293 else /* (numChars > 1) */ { | |
294 | 293 |
295 int i; | 294 for (i = 1; i < numChars; i++) { |
296 for (i = 0; i < numChars; i++) { | |
297 | 295 |
298 key.scancode = 0; | 296 key.scancode = 0; |
299 key.sym = 0; | 297 key.sym = 0; |
300 key.unicode = [ chars characterAtIndex:i]; | 298 key.unicode = [ chars characterAtIndex:i]; |
301 key.mod = KMOD_NONE; | 299 key.mod = KMOD_NONE; |