From Philipp Machler, "We have extended the support for Wacom Tablet devices:

- Mac OS X
  - not only pressure, but tilt and z-rotation is supported now
"
This commit is contained in:
Robert Osfield
2008-04-11 13:28:09 +00:00
parent 6fed4022a6
commit 76e0198007
5 changed files with 74 additions and 6 deletions

View File

@@ -99,6 +99,18 @@ void EventQueue::penPressure(float pressure, double time)
addEvent(event);
}
void EventQueue::penOrientation(float tiltX, float tiltY, float rotation, double time)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::PEN_ORIENTATION);
event->setPenTiltX(tiltX);
event->setPenTiltY(tiltY);
event->setPenRotation(rotation);
event->setTime(time);
addEvent(event);
}
void EventQueue::penProximity(GUIEventAdapter::TabletPointerType pt, bool isEntering, double time)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);

View File

@@ -39,6 +39,9 @@ GUIEventAdapter::GUIEventAdapter():
_mx(0.5),
_my(0.5),
_pressure(0.0),
_tiltX(0.0),
_tiltY(0.0),
_rotation(0.0),
_buttonMask(0),
_modKeyMask(0),
_scrollingMotion(SCROLL_NONE),
@@ -66,6 +69,9 @@ GUIEventAdapter::GUIEventAdapter(const GUIEventAdapter& rhs,const osg::CopyOp& c
_mx(rhs._mx),
_my(rhs._my),
_pressure(rhs._pressure),
_tiltX(rhs._tiltX),
_tiltY(rhs._tiltY),
_rotation(rhs._rotation),
_buttonMask(rhs._buttonMask),
_modKeyMask(rhs._modKeyMask),
_scrollingMotion(rhs._scrollingMotion),
@@ -100,3 +106,15 @@ void GUIEventAdapter::setInputRange(float Xmin, float Ymin, float Xmax, float Ym
_Xmax = Xmax;
_Ymax = Ymax;
}
const osg::Matrix GUIEventAdapter::getPenOrientation() const
{
float xRad = osg::DegreesToRadians ( getPenTiltY() );
float yRad = osg::DegreesToRadians ( getPenTiltX() );
float zRad = osg::DegreesToRadians ( getPenRotation() );
osg::Matrix xrot = osg::Matrix::rotate ( xRad, osg::Vec3f(1.0f, 0.0f, 0.0f) );
osg::Matrix yrot = osg::Matrix::rotate ( yRad, osg::Vec3f(0.0f, 0.0f, 1.0f) );
osg::Matrix zrot = osg::Matrix::rotate ( zRad, osg::Vec3f(0.0f, 1.0f, 0.0f) );
return ( zrot * yrot * xrot );
}

View File

@@ -864,6 +864,20 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
getEventQueue()->penProximity(pointerType, (theTabletRecord.enterProximity != 0));
}
// get tilt and rotation from the pen
TabletPointRec theTabletPointRecord;
if(noErr == GetEventParameter(theEvent, kEventParamTabletPointRec, typeTabletPointRec, NULL,
sizeof(TabletPointRec), NULL, (void *)&theTabletPointRecord))
{
int penRotation = (int)theTabletPointRecord.rotation * 9 / 575; //to get angle between 0 to 360 grad
penRotation = -(((penRotation + 180) % 360) - 180) ; //for same range on all plattforms we need -180 to 180
getEventQueue()->penOrientation (
theTabletPointRecord.tiltX * 60 / 32767.0f, //multiply with 60 to get angle between -60 to 60 grad
-theTabletPointRecord.tiltY * 60 / 32767.0f, //multiply with 60 to get angle between -60 to 60 grad
penRotation
);
}
switch(GetEventKind(theEvent))
{
case kEventMouseDown: