Mercurial > sdl-ios-xcode
comparison src/video/quartz/SDL_QuartzEvents.m @ 624:fb78cadbfeb8
More-than-three mouse button support for Quartz target.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 27 May 2003 07:33:11 +0000 |
parents | bf816ce70144 |
children | 52864d66d168 |
comparison
equal
deleted
inserted
replaced
623:477917048b91 | 624:fb78cadbfeb8 |
---|---|
376 rls = IONotificationPortGetRunLoopSource (thePortRef); | 376 rls = IONotificationPortGetRunLoopSource (thePortRef); |
377 CFRunLoopAddSource (CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); | 377 CFRunLoopAddSource (CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); |
378 CFRelease (rls); | 378 CFRelease (rls); |
379 } | 379 } |
380 | 380 |
381 | |
382 // Try to map Quartz mouse buttons to SDL's lingo... | |
383 static int QZ_OtherMouseButtonToSDL(int button) | |
384 { | |
385 switch (button) | |
386 { | |
387 case 0: | |
388 return(SDL_BUTTON_LEFT); // 1 | |
389 case 1: | |
390 return(SDL_BUTTON_RIGHT); // 3 | |
391 case 2: | |
392 return(SDL_BUTTON_MIDDLE); // 2 | |
393 } | |
394 | |
395 // >= 3: skip 4 & 5, since those are the SDL mousewheel buttons. | |
396 return(button + 3); | |
397 } | |
398 | |
399 | |
381 static void QZ_PumpEvents (_THIS) | 400 static void QZ_PumpEvents (_THIS) |
382 { | 401 { |
383 int firstMouseEvent; | 402 int firstMouseEvent; |
384 CGMouseDelta dx, dy; | 403 CGMouseDelta dx, dy; |
385 | 404 |
418 event = [ NSApp nextEventMatchingMask:NSAnyEventMask | 437 event = [ NSApp nextEventMatchingMask:NSAnyEventMask |
419 untilDate:distantPast | 438 untilDate:distantPast |
420 inMode: NSDefaultRunLoopMode dequeue:YES ]; | 439 inMode: NSDefaultRunLoopMode dequeue:YES ]; |
421 if (event != nil) { | 440 if (event != nil) { |
422 | 441 |
442 int button; | |
423 unsigned int type; | 443 unsigned int type; |
424 BOOL isForGameWin; | 444 BOOL isForGameWin; |
425 BOOL isInGameWin; | 445 BOOL isInGameWin; |
426 | 446 |
427 #define DO_MOUSE_DOWN(button) do { \ | 447 #define DO_MOUSE_DOWN(button) do { \ |
464 else { | 484 else { |
465 DO_MOUSE_DOWN (SDL_BUTTON_LEFT); | 485 DO_MOUSE_DOWN (SDL_BUTTON_LEFT); |
466 } | 486 } |
467 } | 487 } |
468 break; | 488 break; |
469 case NSOtherMouseDown: DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE); break; | 489 |
470 case NSRightMouseDown: DO_MOUSE_DOWN (SDL_BUTTON_RIGHT); break; | |
471 case NSLeftMouseUp: | 490 case NSLeftMouseUp: |
472 if ( last_virtual_button != 0 ) { | 491 if ( last_virtual_button != 0 ) { |
473 DO_MOUSE_UP (last_virtual_button); | 492 DO_MOUSE_UP (last_virtual_button); |
474 last_virtual_button = 0; | 493 last_virtual_button = 0; |
475 } | 494 } |
476 else { | 495 else { |
477 DO_MOUSE_UP (SDL_BUTTON_LEFT); | 496 DO_MOUSE_UP (SDL_BUTTON_LEFT); |
478 } | 497 } |
479 break; | 498 break; |
480 case NSOtherMouseUp: DO_MOUSE_UP (SDL_BUTTON_MIDDLE); break; | 499 |
481 case NSRightMouseUp: DO_MOUSE_UP (SDL_BUTTON_RIGHT); break; | 500 case NSOtherMouseDown: |
501 case NSRightMouseDown: | |
502 button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]); | |
503 DO_MOUSE_DOWN (button); | |
504 break; | |
505 | |
506 case NSOtherMouseUp: | |
507 case NSRightMouseUp: | |
508 button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]); | |
509 DO_MOUSE_UP (button); | |
510 break; | |
511 | |
482 case NSSystemDefined: | 512 case NSSystemDefined: |
483 /* | 513 /* |
484 Future: up to 32 "mouse" buttons can be handled. | 514 Future: up to 32 "mouse" buttons can be handled. |
485 if ([event subtype] == 7) { | 515 if ([event subtype] == 7) { |
486 unsigned int buttons; | 516 unsigned int buttons; |