From Stephan Huber, "attached is a new zip containing two small fixes:

* forwarded touch-events do have a correct input-range from 0 .. 1
* I refactored sending touch-events per osc so the receiver can detect a TOUCH_ENDED better"
This commit is contained in:
Robert Osfield
2014-01-24 10:10:43 +00:00
parent 4886a8941d
commit 29ab577bc3
2 changed files with 18 additions and 14 deletions

View File

@@ -67,6 +67,21 @@ void OscSendingDevice::sendEvent(const osgGA::Event &ea)
if ((_delayBetweenSendsInMilliSecs > 0) && (i < num_messages-1))
OpenThreads::Thread::microSleep(1000 * _delayBetweenSendsInMilliSecs);
}
if (_finishMultiTouchSequence)
{
// if the last touch-point ended we'll need to send an empty tuio-bundle, so the receiver gets a chance to clean up
_msgId++;
for(unsigned int i = 0; i < num_messages; ++i) {
beginBundle(_msgId);
beginMultiTouchSequence();
_oscStream << osc::EndBundle;
_transmitSocket.Send( _oscStream.Data(), _oscStream.Size() );
_oscStream.Clear();
}
_finishMultiTouchSequence = false;
}
if (msg_sent)
_msgId++;
}
@@ -226,21 +241,8 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
if (do_send)
{
// OSG_INFO << "OscDevice :: sending ui-event per OSC " << std::endl;
_transmitSocket.Send( _oscStream.Data(), _oscStream.Size() );
_oscStream.Clear();
if (_finishMultiTouchSequence)
{
// if the last touch-point ended we'll need to send an empty tuio-bundle, so the receiver gets a chance to clean up
beginBundle(msg_id);
beginMultiTouchSequence();
_oscStream << osc::EndBundle;
_transmitSocket.Send( _oscStream.Data(), _oscStream.Size() );
_oscStream.Clear();
_finishMultiTouchSequence = false;
}
}
return do_send;

View File

@@ -99,6 +99,8 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
else if ((_operation == FORWARD_TOUCH_EVENT) && ea.isMultiTouchEvent())
{
osg::ref_ptr<osgGA::GUIEventAdapter> cloned_ea = osg::clone(&ea);
cloned_ea->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS);
osgGA::GUIEventAdapter::TouchData* touch_data = cloned_ea->getTouchData();
@@ -130,7 +132,7 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
// std::cout << ea.getX() << "/" << ea.getY() << " -- " << i->x << " " << i->y << " -> " << local.x() <<"/" << local.z() << std::endl;
i->x = local.x();
i->y = local.z();
i->y = 1 + local.z(); // no idea why I have to add 1 to get y in the range [0..1]
}