From Stephan Huber,

"attached you'll find some modifications to Producer, osgGA and
osgProducer to enable Mac OS X support for

+ scrollwheels,
+ mightymouse-srollballs
+ new tracking-pads with scroll feature
+ tablet-support (pressure, proximity and pointertype) (Wacom only tested)

I think there was a bug in the windows-implementation of scroll-wheel
support (wrong order of ScrollingMotion-enum, casting problem) which is
fixed now.

The scrollwheel-code is a bit klunky across platforms, some devices on
OS X can report an absolute delta in pixel-coordinates not only the
direction, so for now there is scrollingMotion (which describes the
direction) and scrolldeltax and scrolldeltay. I decided to leave the
scrollingmotion-stuff to not break old code relying on this."
This commit is contained in:
Robert Osfield 2006-07-04 14:18:44 +00:00
parent b0d738384f
commit e7d9e91525
6 changed files with 113 additions and 7 deletions

View File

@ -57,6 +57,15 @@ class OSGGA_EXPORT EventQueue : public osg::Referenced
/** method for adapting mouse scroll wheel events, placing this event on the back of the event queue. */
void mouseScroll(GUIEventAdapter::ScrollingMotion sm);
/** method for adapting mouse scroll wheel events, placing this event on the back of the event queue. */
void mouseScroll2D(float x, float y);
/** method for adapting pen pressure events, placing this event on the back og the event queue.*/
void penPressure(float pressure);
/** method for adapting pen proximity events, placing this event on the back og the event queue.*/
void penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering);
/** method for updating in response to a mouse warp. Note, just moves the mouse position without creating a new event for it.*/
void mouseWarp(float x, float y);

View File

@ -50,7 +50,10 @@ public:
KEYUP,
FRAME,
RESIZE,
SCROLL
SCROLL,
PEN_PRESSURE,
PEN_PROXIMITY_ENTER,
PEN_PROXIMITY_LEAVE
};
enum KeySymbol
@ -231,10 +234,20 @@ public:
enum ScrollingMotion
{
SCROLL_NONE,
SCROLL_LEFT,
SCROLL_RIGHT,
SCROLL_UP,
SCROLL_DOWN
SCROLL_DOWN,
SCROLL_2D
};
enum TabletPointerType
{
UNKNOWN = 0,
PEN,
PUCK,
ERASER
};
public:
@ -319,9 +332,30 @@ public:
unsigned int getModKeyMask() const { return _modKeyMask; }
/// get the pressure, from a tablet input device (range 0 - 1)
float getPenPressure() const { return _pressure; }
/// sets the pressure from a tablet
void setPenPressure(float pressure) { _pressure = pressure; }
/// get the current used tablet pointer type
TabletPointerType getTabletPointerType() const { return _tabletPointerType; }
/// set the current used tablet pointer type
void setTabletPointerType(TabletPointerType pt) { _tabletPointerType = pt; }
void setScrollingMotion(ScrollingMotion motion) { _scrollingMotion = motion; }
/** get the scrolling x-delta */
float getScrollingDeltaX() const { return _scrollingDeltaX; }
/** get the scrolling y-delta */
float getScrollingDeltaY() const { return _scrollingDeltaY; }
/** sets the scrolling delta to x,y and the type of scrolling to SCROLL_2D */
void setScrollingMotionDelta(float x, float y) {
_scrollingMotion = SCROLL_2D;
_scrollingDeltaX = x;
_scrollingDeltaY = y;
}
ScrollingMotion getScrollingMotion() const { return _scrollingMotion; }
@ -360,10 +394,13 @@ public:
float _Ymin,_Ymax;
float _mx;
float _my;
float _pressure;
unsigned int _buttonMask;
unsigned int _modKeyMask;
ScrollingMotion _scrollingMotion;
float _scrollingDeltaX, _scrollingDeltaY;
MouseYOrientation _mouseYOrientation;
TabletPointerType _tabletPointerType;
};
}

View File

@ -37,6 +37,9 @@ class OSGPRODUCER_EXPORT KeyboardMouseCallback : public Producer::KeyboardMouseC
// override KeyboardMouseCallback methods.
virtual void mouseScroll( Producer::KeyboardMouseCallback::ScrollingMotion sm );
virtual void mouseScroll2D( float, float);
virtual void penPressure(float pressure);
virtual void penProximity(TabletPointerType, bool);
virtual void mouseMotion( float mx, float my);
virtual void passiveMouseMotion( float mx, float my);
virtual void mouseWarp( float mx, float my);

View File

@ -87,6 +87,24 @@ void EventQueue::windowResize(float Xmin, float Ymin, float Xmax, float Ymax)
addEvent(event);
}
void EventQueue::penPressure(float pressure)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::PEN_PRESSURE);
event->setPenPressure(pressure);
addEvent(event);
}
void EventQueue::penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType( (isEntering) ? GUIEventAdapter::PEN_PROXIMITY_ENTER : GUIEventAdapter::PEN_PROXIMITY_LEAVE);
event->setTabletPointerType(pt);
addEvent(event);
}
void EventQueue::mouseScroll(GUIEventAdapter::ScrollingMotion sm)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
@ -96,6 +114,16 @@ void EventQueue::mouseScroll(GUIEventAdapter::ScrollingMotion sm)
addEvent(event);
}
void EventQueue::mouseScroll2D(float x, float y)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::SCROLL);
event->setScrollingMotionDelta(x,y);
addEvent(event);
}
void EventQueue::mouseWarp(float x, float y)
{
_accumulateEventState->setX(x);

View File

@ -26,10 +26,14 @@ GUIEventAdapter::GUIEventAdapter():
_Ymax(1.0),
_mx(0.5),
_my(0.5),
_pressure(0.0),
_buttonMask(0),
_modKeyMask(0),
_scrollingMotion(SCROLL_DOWN),
_mouseYOrientation(Y_INCREASING_DOWNWARDS)
_scrollingMotion(SCROLL_NONE),
_scrollingDeltaX(0),
_scrollingDeltaY(0),
_mouseYOrientation(Y_INCREASING_DOWNWARDS),
_tabletPointerType(UNKNOWN)
{}
GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs):
@ -44,10 +48,14 @@ GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs):
_Ymax(rhs._Ymax),
_mx(rhs._mx),
_my(rhs._my),
_pressure(rhs._pressure),
_buttonMask(rhs._buttonMask),
_modKeyMask(rhs._modKeyMask),
_scrollingMotion(rhs._scrollingMotion),
_mouseYOrientation(rhs._mouseYOrientation)
_scrollingDeltaX(rhs._scrollingDeltaX),
_scrollingDeltaY(rhs._scrollingDeltaY),
_mouseYOrientation(rhs._mouseYOrientation),
_tabletPointerType(rhs._tabletPointerType)
{}
GUIEventAdapter::~GUIEventAdapter()

View File

@ -25,12 +25,33 @@ void KeyboardMouseCallback::mouseScroll( Producer::KeyboardMouseCallback::Scroll
switch(sm)
{
case(Producer::KeyboardMouseCallback::ScrollNone): break;
case(Producer::KeyboardMouseCallback::ScrollLeft): _eventQueue->mouseScroll(osgGA::GUIEventAdapter::SCROLL_LEFT); break;
case(Producer::KeyboardMouseCallback::ScrollRight): _eventQueue->mouseScroll(osgGA::GUIEventAdapter::SCROLL_RIGHT); break;
case(Producer::KeyboardMouseCallback::ScrollUp): _eventQueue->mouseScroll(osgGA::GUIEventAdapter::SCROLL_UP); break;
case(Producer::KeyboardMouseCallback::ScrollDown): _eventQueue->mouseScroll(osgGA::GUIEventAdapter::SCROLL_DOWN); break;
case(Producer::KeyboardMouseCallback::Scroll2D): _eventQueue->mouseScroll(osgGA::GUIEventAdapter::SCROLL_2D); break;
}
}
}
void KeyboardMouseCallback::mouseScroll2D( float x, float y )
{
updateWindowSize();
if (_eventQueue.valid()) _eventQueue->mouseScroll2D(x,y);
}
void KeyboardMouseCallback::penPressure( float pressure )
{
updateWindowSize();
if (_eventQueue.valid()) _eventQueue->penPressure(pressure);
}
void KeyboardMouseCallback::penProximity(TabletPointerType pt, bool isEntering)
{
updateWindowSize();
if (_eventQueue.valid()) _eventQueue->penProximity((osgGA::GUIEventAdapter::TabletPointerType)pt, isEntering);
}
void KeyboardMouseCallback::buttonPress( float mx, float my, unsigned int mbutton )
{
updateWindowSize();