Cocoa : properly distinguish mouse from multitouch trackpad scroll events

Mighty mouse trackball now fires proper wheel events (and not trackpad pan ones)
This commit is contained in:
Damien Plisson
2010-01-13 17:43:42 +00:00
parent 75ec61d128
commit 32f4877c8c
2 changed files with 14 additions and 4 deletions

View File

@@ -280,6 +280,9 @@ protected:
/** Multitouch trackpad availability */
bool m_hasMultiTouchTrackpad;
/** Multitouch gesture in progress, useful to distinguish trackpad from mouse scroll events */
bool m_isGestureInProgress;
};
#endif // _GHOST_SYSTEM_COCOA_H_

View File

@@ -516,6 +516,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
m_modifierMask =0;
m_pressedMouseButtons =0;
m_isGestureInProgress = false;
m_cursorDelta_x=0;
m_cursorDelta_y=0;
m_outsideLoopEventProcessed = false;
@@ -885,6 +886,8 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
case NSOtherMouseDragged:
case NSEventTypeMagnify:
case NSEventTypeRotate:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
handleMouseEvent(event);
break;
@@ -896,8 +899,6 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
/* Trackpad features, fired only from OS X 10.5.2
case NSEventTypeGesture:
case NSEventTypeSwipe:
case NSEventTypeBeginGesture:
case NSEventTypeEndGesture:
break; */
/*Unused events
@@ -1352,8 +1353,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
case NSScrollWheel:
{
/* Send Wheel event if sent from the mouse, trackpad event otherwise */
if (!m_hasMultiTouchTrackpad || ([event subtype] == NSMouseEventSubtype)) {
/* Send trackpad event if inside a trackpad gesture, send wheel event otherwise */
if (!m_hasMultiTouchTrackpad || !m_isGestureInProgress) {
GHOST_TInt32 delta;
double deltaF = [event deltaY];
@@ -1399,6 +1400,12 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventRotate, mousePos.x, mousePos.y,
-[event rotation] * 5.0, 0));
}
case NSEventTypeBeginGesture:
m_isGestureInProgress = true;
break;
case NSEventTypeEndGesture:
m_isGestureInProgress = false;
break;
default:
return GHOST_kFailure;
break;