src/video/cocoa/SDL_cocoakeyboard.m
changeset 9898 0da384bef562
parent 9619 b94b6d0bff0f
child 9915 77cf2d1b7215
equal deleted inserted replaced
9897:b9b4c1bbb778 9898:0da384bef562
   396     DoSidedModifiers(scancode, data->modifierFlags, modifierFlags);
   396     DoSidedModifiers(scancode, data->modifierFlags, modifierFlags);
   397     data->modifierFlags = modifierFlags;
   397     data->modifierFlags = modifierFlags;
   398 }
   398 }
   399 
   399 
   400 static void
   400 static void
   401 UpdateKeymap(SDL_VideoData *data)
   401 UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
   402 {
   402 {
   403     TISInputSourceRef key_layout;
   403     TISInputSourceRef key_layout;
   404     const void *chr_data;
   404     const void *chr_data;
   405     int i;
   405     int i;
   406     SDL_Scancode scancode;
   406     SDL_Scancode scancode;
   452             if (len > 0 && s[0] != 0x10) {
   452             if (len > 0 && s[0] != 0x10) {
   453                 keymap[scancode] = s[0];
   453                 keymap[scancode] = s[0];
   454             }
   454             }
   455         }
   455         }
   456         SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
   456         SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
       
   457         if (send_event) {
       
   458             SDL_SendKeymapChangedEvent();
       
   459         }
   457         return;
   460         return;
   458     }
   461     }
   459 
   462 
   460 cleanup:
   463 cleanup:
   461     CFRelease(key_layout);
   464     CFRelease(key_layout);
   464 void
   467 void
   465 Cocoa_InitKeyboard(_THIS)
   468 Cocoa_InitKeyboard(_THIS)
   466 {
   469 {
   467     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   470     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   468 
   471 
   469     UpdateKeymap(data);
   472     UpdateKeymap(data, SDL_FALSE);
   470 
   473 
   471     /* Set our own names for the platform-dependent but layout-independent keys */
   474     /* Set our own names for the platform-dependent but layout-independent keys */
   472     /* This key is NumLock on the MacBook keyboard. :) */
   475     /* This key is NumLock on the MacBook keyboard. :) */
   473     /*SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear");*/
   476     /*SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear");*/
   474     SDL_SetScancodeName(SDL_SCANCODE_LALT, "Left Option");
   477     SDL_SetScancodeName(SDL_SCANCODE_LALT, "Left Option");
   562 
   565 
   563     switch ([event type]) {
   566     switch ([event type]) {
   564     case NSKeyDown:
   567     case NSKeyDown:
   565         if (![event isARepeat]) {
   568         if (![event isARepeat]) {
   566             /* See if we need to rebuild the keyboard layout */
   569             /* See if we need to rebuild the keyboard layout */
   567             UpdateKeymap(data);
   570             UpdateKeymap(data, SDL_TRUE);
   568         }
   571         }
   569 
   572 
   570         SDL_SendKeyboardKey(SDL_PRESSED, code);
   573         SDL_SendKeyboardKey(SDL_PRESSED, code);
   571 #if 1
   574 #if 1
   572         if (code == SDL_SCANCODE_UNKNOWN) {
   575         if (code == SDL_SCANCODE_UNKNOWN) {