src/video/cocoa/SDL_cocoakeyboard.m
changeset 4560 95352c671a6e
parent 4498 3d91e31fcf71
child 4565 e2d46c5c7483
     1.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Tue Jul 20 00:57:01 2010 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Tue Jul 20 23:25:24 2010 -0700
     1.3 @@ -219,14 +219,14 @@
     1.4          if (oldMask && oldMask != newMask) {        /* modifier up event */
     1.5              /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
     1.6              if (bit == NSAlphaShiftKeyMask) {
     1.7 -                SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
     1.8 +                SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
     1.9              }
    1.10 -            SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
    1.11 +            SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
    1.12          } else if (newMask && oldMask != newMask) { /* modifier down event */
    1.13 -            SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
    1.14 +            SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
    1.15              /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
    1.16              if (bit == NSAlphaShiftKeyMask) {
    1.17 -                SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
    1.18 +                SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
    1.19              }
    1.20          }
    1.21      }
    1.22 @@ -251,9 +251,9 @@
    1.23      newMask = newMods & device_independent_mask;
    1.24      
    1.25      if (oldMask && oldMask != newMask) {
    1.26 -        SDL_SendKeyboardKey(SDL_RELEASED, scancode);
    1.27 +        SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
    1.28      } else if (newMask && oldMask != newMask) {
    1.29 -        SDL_SendKeyboardKey(SDL_PRESSED, scancode);
    1.30 +        SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
    1.31      }
    1.32  }
    1.33  
    1.34 @@ -278,9 +278,9 @@
    1.35       * find out which it is.
    1.36       */
    1.37      if (new_dep_mask && old_dep_mask != new_dep_mask) {
    1.38 -        SDL_SendKeyboardKey(SDL_PRESSED, scancode);
    1.39 +        SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
    1.40      } else {
    1.41 -        SDL_SendKeyboardKey(SDL_RELEASED, scancode);
    1.42 +        SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
    1.43      }
    1.44  }
    1.45  
    1.46 @@ -351,7 +351,7 @@
    1.47          /* In this case, we can't detect the keyboard, so use the left side 
    1.48           * to represent both, and release it. 
    1.49           */
    1.50 -        SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
    1.51 +        SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
    1.52          return;
    1.53      }
    1.54  
    1.55 @@ -362,10 +362,10 @@
    1.56       * so I hope this doesn't cause other problems.
    1.57       */
    1.58      if ( left_device_dependent_mask & oldMods ) {
    1.59 -        SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
    1.60 +        SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
    1.61      }
    1.62      if ( right_device_dependent_mask & oldMods ) {
    1.63 -        SDL_SendKeyboardKey(SDL_RELEASED, right_scancode);
    1.64 +        SDL_SendKeyboardKey(SDL_RELEASED, right_scancode, SDL_FALSE);
    1.65      }
    1.66  }
    1.67  
    1.68 @@ -382,16 +382,16 @@
    1.69      newMask = newMods & NSAlphaShiftKeyMask;
    1.70  
    1.71      if (oldMask != newMask) {
    1.72 -        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
    1.73 -        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
    1.74 +        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
    1.75 +        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
    1.76      }
    1.77  
    1.78      oldMask = oldMods & NSNumericPadKeyMask;
    1.79      newMask = newMods & NSNumericPadKeyMask;
    1.80  
    1.81      if (oldMask != newMask) {
    1.82 -        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
    1.83 -        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
    1.84 +        SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
    1.85 +        SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
    1.86      }
    1.87  }
    1.88  
    1.89 @@ -670,6 +670,7 @@
    1.90      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.91      unsigned short scancode = [event keyCode];
    1.92      SDL_scancode code;
    1.93 +    SDL_bool repeat;
    1.94  #if 0
    1.95      const char *text;
    1.96  #endif
    1.97 @@ -688,17 +689,18 @@
    1.98  
    1.99      switch ([event type]) {
   1.100      case NSKeyDown:
   1.101 -        if (![event isARepeat]) {
   1.102 +        repeat = [event isARepeat] ? SDL_TRUE : SDL_FALSE;
   1.103 +        if (!repeat) {
   1.104              /* See if we need to rebuild the keyboard layout */
   1.105              UpdateKeymap(data);
   1.106 +        }
   1.107  
   1.108 -            SDL_SendKeyboardKey(SDL_PRESSED, code);
   1.109 +        SDL_SendKeyboardKey(SDL_PRESSED, code, repeat);
   1.110  #if 1
   1.111 -            if (code == SDL_SCANCODE_UNKNOWN) {
   1.112 -                fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
   1.113 -            }
   1.114 +        if (code == SDL_SCANCODE_UNKNOWN) {
   1.115 +            fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
   1.116 +        }
   1.117  #endif
   1.118 -        }
   1.119          if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
   1.120              /* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
   1.121              [data->fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
   1.122 @@ -712,7 +714,7 @@
   1.123          }
   1.124          break;
   1.125      case NSKeyUp:
   1.126 -        SDL_SendKeyboardKey(SDL_RELEASED, code);
   1.127 +        SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
   1.128          break;
   1.129      case NSFlagsChanged:
   1.130          /* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */