comparison src/video/cocoa/SDL_cocoakeyboard.m @ 4925:514f811a4887

Removed support for 10.3.9 Fixed building on Mac OS X 10.5
author Sam Lantinga <slouken@libsdl.org>
date Wed, 01 Dec 2010 12:23:16 -0800
parents c24ba2cc9583
children 25d4feb7c127
comparison
equal deleted inserted replaced
4924:455c0dad84df 4925:514f811a4887
169 DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", theRange.location, theRange.length); 169 DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", theRange.location, theRange.length);
170 return nil; 170 return nil;
171 } 171 }
172 172
173 /* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */ 173 /* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */
174 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
174 - (long) conversationIdentifier 175 - (long) conversationIdentifier
176 #else
177 - (NSInteger) conversationIdentifier
178 #endif
175 { 179 {
176 return (long) self; 180 return (long) self;
177 } 181 }
178 182
179 // This method returns the index for character that is 183 // This method returns the index for character that is
476 } 480 }
477 481
478 static void 482 static void
479 UpdateKeymap(SDL_VideoData *data) 483 UpdateKeymap(SDL_VideoData *data)
480 { 484 {
481 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 485 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
482 TISInputSourceRef key_layout; 486 TISInputSourceRef key_layout;
483 #else 487 #else
484 KeyboardLayoutRef key_layout; 488 KeyboardLayoutRef key_layout;
485 #endif 489 #endif
486 const void *chr_data; 490 const void *chr_data;
487 int i; 491 int i;
488 SDL_scancode scancode; 492 SDL_scancode scancode;
489 SDLKey keymap[SDL_NUM_SCANCODES]; 493 SDLKey keymap[SDL_NUM_SCANCODES];
490 494
491 /* See if the keymap needs to be updated */ 495 /* See if the keymap needs to be updated */
492 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 496 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
493 key_layout = TISCopyCurrentKeyboardLayoutInputSource(); 497 key_layout = TISCopyCurrentKeyboardLayoutInputSource();
494 #else 498 #else
495 KLGetCurrentKeyboardLayout(&key_layout); 499 KLGetCurrentKeyboardLayout(&key_layout);
496 #endif 500 #endif
497 if (key_layout == data->key_layout) { 501 if (key_layout == data->key_layout) {
500 data->key_layout = key_layout; 504 data->key_layout = key_layout;
501 505
502 SDL_GetDefaultKeymap(keymap); 506 SDL_GetDefaultKeymap(keymap);
503 507
504 /* Try Unicode data first (preferred as of Mac OS X 10.5) */ 508 /* Try Unicode data first (preferred as of Mac OS X 10.5) */
505 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 509 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
506 CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData); 510 CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData);
507 if (uchrDataRef) 511 if (uchrDataRef)
508 chr_data = CFDataGetBytePtr(uchrDataRef); 512 chr_data = CFDataGetBytePtr(uchrDataRef);
509 else 513 else
510 goto cleanup; 514 goto cleanup;
542 } 546 }
543 SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); 547 SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
544 return; 548 return;
545 } 549 }
546 550
547 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 551 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
548 cleanup: 552 cleanup:
549 CFRelease(key_layout); 553 CFRelease(key_layout);
550 #else 554 #else
551 /* Fall back to older style key map data */ 555 /* Fall back to older style key map data */
552 KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data); 556 KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);