From Stephan Huber, "attached you'll find a proposal for handling multi-touch-events with

osgGA. My approach is to bundle all touchpoints into one custom data
structure which is attached to an GUIEventAdapter.

The current approach simulates a moving mouse for the first touch-point,
so basic manipulators do work, sort of.

I created a MultiTouchTrackballManipulator-class, one touch-point does
rotate the view, two touch-points pan and zoom the view as known from
the iphone or other similar multi-touch-devices. A double-tap (similar
to a double-click) resets the manipulator to its home-position.

The multi-touch-trackball-implementation is not the best, see it as a
first starting point. (there's a demo-video at http://vimeo.com/15017377 )"
This commit is contained in:
Robert Osfield
2010-11-22 17:30:44 +00:00
parent 27afe58f77
commit e36c4d3a3b
7 changed files with 325 additions and 4 deletions

View File

@@ -344,6 +344,57 @@ void EventQueue::keyRelease(int key, double time)
addEvent(event);
}
GUIEventAdapter* EventQueue::touchBegan(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time)
{
// emulate left mouse button press
_accumulateEventState->setButtonMask((1) | _accumulateEventState->getButtonMask());
_accumulateEventState->setX(x);
_accumulateEventState->setY(y);
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::PUSH);
event->setTime(time);
event->addTouchPoint(id, phase, x, y, 0);
addEvent(event);
return event;
}
GUIEventAdapter* EventQueue::touchMoved(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, double time)
{
_accumulateEventState->setX(x);
_accumulateEventState->setY(y);
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::DRAG);
event->setTime(time);
event->addTouchPoint(id, phase, x, y, 0);
addEvent(event);
return event;
}
GUIEventAdapter* EventQueue::touchEnded(unsigned int id, GUIEventAdapter::TouchPhase phase, float x, float y, unsigned int tap_count, double time)
{
_accumulateEventState->setButtonMask(~(1) & _accumulateEventState->getButtonMask());
_accumulateEventState->setX(x);
_accumulateEventState->setY(y);
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);
event->setEventType(GUIEventAdapter::RELEASE);
event->setTime(time);
event->addTouchPoint(id, phase, x, y, tap_count);
addEvent(event);
return event;
}
void EventQueue::closeWindow(double time)
{
GUIEventAdapter* event = new GUIEventAdapter(*_accumulateEventState);