More-than-three mouse button support for Quartz target.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 27 May 2003 07:33:11 +0000
changeset 624fb78cadbfeb8
parent 623 477917048b91
child 625 c56665b2360a
More-than-three mouse button support for Quartz target.
src/video/quartz/SDL_QuartzEvents.m
     1.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Sun May 25 02:17:52 2003 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Tue May 27 07:33:11 2003 +0000
     1.3 @@ -378,6 +378,25 @@
     1.4       CFRelease (rls);
     1.5  }
     1.6  
     1.7 +
     1.8 +// Try to map Quartz mouse buttons to SDL's lingo...
     1.9 +static int QZ_OtherMouseButtonToSDL(int button)
    1.10 +{
    1.11 +    switch (button)
    1.12 +    {
    1.13 +        case 0:
    1.14 +            return(SDL_BUTTON_LEFT);   // 1
    1.15 +        case 1:
    1.16 +            return(SDL_BUTTON_RIGHT);  // 3
    1.17 +        case 2:
    1.18 +            return(SDL_BUTTON_MIDDLE); // 2
    1.19 +    }
    1.20 +
    1.21 +    // >= 3: skip 4 & 5, since those are the SDL mousewheel buttons.
    1.22 +    return(button + 3);
    1.23 +}
    1.24 +
    1.25 +
    1.26  static void QZ_PumpEvents (_THIS)
    1.27  {
    1.28      int firstMouseEvent;
    1.29 @@ -420,6 +439,7 @@
    1.30                                      inMode: NSDefaultRunLoopMode dequeue:YES ];
    1.31          if (event != nil) {
    1.32  
    1.33 +            int button;
    1.34              unsigned int type;
    1.35              BOOL isForGameWin;
    1.36              BOOL isInGameWin;
    1.37 @@ -466,8 +486,7 @@
    1.38                          }
    1.39                      }
    1.40                      break;
    1.41 -                case NSOtherMouseDown: DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE); break;
    1.42 -                case NSRightMouseDown: DO_MOUSE_DOWN (SDL_BUTTON_RIGHT);  break;
    1.43 +
    1.44                  case NSLeftMouseUp:
    1.45                      if ( last_virtual_button != 0 ) {
    1.46                          DO_MOUSE_UP (last_virtual_button);
    1.47 @@ -477,8 +496,19 @@
    1.48                          DO_MOUSE_UP (SDL_BUTTON_LEFT);
    1.49                      }
    1.50                      break;
    1.51 -                case NSOtherMouseUp:   DO_MOUSE_UP (SDL_BUTTON_MIDDLE); break;
    1.52 -                case NSRightMouseUp:   DO_MOUSE_UP (SDL_BUTTON_RIGHT);  break;
    1.53 +
    1.54 +                case NSOtherMouseDown:
    1.55 +                case NSRightMouseDown:
    1.56 +                    button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]);
    1.57 +                    DO_MOUSE_DOWN (button);
    1.58 +                    break;
    1.59 +
    1.60 +                case NSOtherMouseUp:
    1.61 +                case NSRightMouseUp:
    1.62 +                    button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]);
    1.63 +                    DO_MOUSE_UP (button);
    1.64 +                    break;
    1.65 +
    1.66                  case NSSystemDefined:
    1.67                      /*
    1.68                          Future: up to 32 "mouse" buttons can be handled.