From 29ab577bc3b463a4417336395a963f02d63fbc14 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jan 2014 10:10:43 +0000 Subject: [PATCH] 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" --- src/osgPlugins/osc/OscSendingDevice.cpp | 28 ++++++++++--------- .../deprecated/PickEventHandler.cpp | 4 ++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/osgPlugins/osc/OscSendingDevice.cpp b/src/osgPlugins/osc/OscSendingDevice.cpp index dcdfbb234..06b456e28 100644 --- a/src/osgPlugins/osc/OscSendingDevice.cpp +++ b/src/osgPlugins/osc/OscSendingDevice.cpp @@ -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; diff --git a/src/osgPresentation/deprecated/PickEventHandler.cpp b/src/osgPresentation/deprecated/PickEventHandler.cpp index cc0d91d77..bbad67000 100644 --- a/src/osgPresentation/deprecated/PickEventHandler.cpp +++ b/src/osgPresentation/deprecated/PickEventHandler.cpp @@ -99,6 +99,8 @@ bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA else if ((_operation == FORWARD_TOUCH_EVENT) && ea.isMultiTouchEvent()) { osg::ref_ptr 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] }