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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user