Fixed line endings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14350 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -34,7 +34,7 @@ OscSendingDevice::OscSendingDevice(const std::string& address, int port, unsigne
|
||||
, _finishMultiTouchSequence(false)
|
||||
{
|
||||
setCapabilities(SEND_EVENTS);
|
||||
|
||||
|
||||
OSG_NOTICE << "OscDevice :: sending events to " << address << ":" << port << " ";
|
||||
#ifdef OSC_HOST_LITTLE_ENDIAN
|
||||
OSG_NOTICE << "(little endian)";
|
||||
@@ -43,7 +43,7 @@ OscSendingDevice::OscSendingDevice(const std::string& address, int port, unsigne
|
||||
#endif
|
||||
OSG_NOTICE << " (" << _numMessagesPerEvent << "msgs/event, " << _delayBetweenSendsInMilliSecs << "ms delay between msgs)";
|
||||
OSG_NOTICE << std::endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ void OscSendingDevice::sendEvent(const osgGA::Event &ea)
|
||||
{
|
||||
bool msg_sent(false);
|
||||
unsigned int num_messages = _numMessagesPerEvent;
|
||||
|
||||
|
||||
const osgGA::GUIEventAdapter* ui_event(ea.asGUIEventAdapter());
|
||||
|
||||
|
||||
if(ui_event && ((ui_event->getEventType() == osgGA::GUIEventAdapter::DRAG) || (ui_event->getEventType() == osgGA::GUIEventAdapter::MOVE)))
|
||||
num_messages = 1;
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < num_messages; ++i) {
|
||||
msg_sent = ui_event ? sendUIEventImpl(*ui_event, _msgId) : sendEventImpl(ea, _msgId);
|
||||
if ((_delayBetweenSendsInMilliSecs > 0) && (i < num_messages-1))
|
||||
@@ -70,7 +70,7 @@ void OscSendingDevice::sendEvent(const osgGA::Event &ea)
|
||||
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);
|
||||
@@ -95,24 +95,24 @@ bool OscSendingDevice::sendEventImpl(const osgGA::Event &ea, MsgIdType msg_id)
|
||||
std::string key = ea.getUserDataContainer()->getName();
|
||||
if (key.empty()) key = ea.getName();
|
||||
if (key.empty()) key = "user_data";
|
||||
|
||||
|
||||
sendUserDataContainer(transliterateKey(key), ea.getUserDataContainer(), true, msg_id);
|
||||
|
||||
|
||||
do_send = true;
|
||||
}
|
||||
|
||||
|
||||
if (do_send)
|
||||
{
|
||||
OSG_INFO << "OscDevice :: sending event per OSC " << std::endl;
|
||||
|
||||
|
||||
_transmitSocket.Send( _oscStream.Data(), _oscStream.Size() );
|
||||
_oscStream.Clear();
|
||||
}
|
||||
|
||||
|
||||
return do_send;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdType msg_id)
|
||||
{
|
||||
@@ -125,14 +125,14 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::SCROLL:
|
||||
beginSendInputRange(ea, msg_id);
|
||||
_oscStream << osc::BeginMessage("/osgga/mouse/scroll") << ea.getScrollingMotion() << ea.getScrollingDeltaX() << ea.getScrollingDeltaY() << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::PEN_PRESSURE:
|
||||
beginBundle(msg_id);
|
||||
_oscStream
|
||||
@@ -140,10 +140,10 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
<< ea.getPenPressure()
|
||||
<< osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
|
||||
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::PEN_ORIENTATION:
|
||||
beginBundle(msg_id);
|
||||
_oscStream
|
||||
@@ -155,7 +155,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
do_send = true;
|
||||
_oscStream << osc::EndBundle;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::PEN_PROXIMITY_ENTER:
|
||||
beginBundle(msg_id);
|
||||
_oscStream
|
||||
@@ -164,7 +164,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
<< osc::EndMessage;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::PEN_PROXIMITY_LEAVE:
|
||||
beginBundle(msg_id);
|
||||
_oscStream
|
||||
@@ -174,7 +174,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::PUSH:
|
||||
beginSendInputRange(ea, msg_id);
|
||||
if (!sendMultiTouchData(ea))
|
||||
@@ -182,7 +182,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::RELEASE:
|
||||
beginSendInputRange(ea, msg_id);
|
||||
if (!sendMultiTouchData(ea))
|
||||
@@ -190,7 +190,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::DOUBLECLICK:
|
||||
beginSendInputRange(ea, msg_id);
|
||||
if (!sendMultiTouchData(ea))
|
||||
@@ -198,7 +198,7 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::MOVE:
|
||||
case osgGA::GUIEventAdapter::DRAG:
|
||||
beginSendInputRange(ea, msg_id);
|
||||
@@ -207,44 +207,44 @@ bool OscSendingDevice::sendUIEventImpl(const osgGA::GUIEventAdapter &ea, MsgIdTy
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::KEYDOWN:
|
||||
beginBundle(msg_id);
|
||||
_oscStream << osc::BeginMessage("/osgga/key/press") << ea.getKey() << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::KEYUP:
|
||||
beginBundle(msg_id);
|
||||
_oscStream << osc::BeginMessage("/osgga/key/release") << ea.getKey() << osc::EndMessage;
|
||||
_oscStream << osc::EndBundle;
|
||||
do_send = true;
|
||||
break;
|
||||
|
||||
|
||||
case osgGA::GUIEventAdapter::USER:
|
||||
if (ea.getUserDataContainer())
|
||||
{
|
||||
std::string key = ea.getUserDataContainer()->getName();
|
||||
if (key.empty()) key = ea.getName();
|
||||
if (key.empty()) key = "user_data";
|
||||
|
||||
|
||||
sendUserDataContainer(transliterateKey(key), ea.getUserDataContainer(), true, msg_id);
|
||||
|
||||
|
||||
do_send = true;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (do_send)
|
||||
{
|
||||
_transmitSocket.Send( _oscStream.Data(), _oscStream.Size() );
|
||||
_oscStream.Clear();
|
||||
}
|
||||
|
||||
|
||||
return do_send;
|
||||
}
|
||||
|
||||
@@ -289,10 +289,10 @@ void OscSendingDevice::beginMultiTouchSequence() {
|
||||
|
||||
std::string application_name;
|
||||
getUserValue("tuio_application_name", application_name);
|
||||
|
||||
|
||||
if (application_name.empty())
|
||||
application_name = std::string("OpenSceneGraph ") + osgGetVersion() + "@127.0.0.1";
|
||||
|
||||
|
||||
_oscStream << osc::BeginMessage("/tuio/2Dcur") << "source" << application_name.c_str() << osc::EndMessage;
|
||||
_oscStream << osc::BeginMessage("/tuio/2Dcur") << "fseq" << static_cast<osc::int32>(_msgId) << osc::EndMessage;
|
||||
|
||||
@@ -303,43 +303,43 @@ bool OscSendingDevice::sendMultiTouchData(const osgGA::GUIEventAdapter &ea)
|
||||
{
|
||||
if(!ea.isMultiTouchEvent())
|
||||
return false;
|
||||
|
||||
|
||||
beginMultiTouchSequence();
|
||||
|
||||
|
||||
osgGA::GUIEventAdapter::TouchData* touch_data = ea.getTouchData();
|
||||
|
||||
|
||||
_oscStream << osc::BeginMessage("/tuio/2Dcur") << "alive";
|
||||
for(osgGA::GUIEventAdapter::TouchData::iterator i = touch_data->begin(); i != touch_data->end(); ++i)
|
||||
_oscStream << static_cast<osc::int32>(i->id);
|
||||
_oscStream << osc::EndMessage;
|
||||
|
||||
|
||||
unsigned int j(0);
|
||||
unsigned int num_ended(0);
|
||||
for(osgGA::GUIEventAdapter::TouchData::iterator i = touch_data->begin(); i != touch_data->end(); ++i, ++j)
|
||||
{
|
||||
float x = (ea.getTouchPointNormalizedX(j) + 1.0) / 2.0;
|
||||
float y =(ea.getTouchPointNormalizedY(j) + 1.0) / 2.0;
|
||||
|
||||
|
||||
// flip y if origin is not top/left
|
||||
if(ea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS)
|
||||
y *= -1;
|
||||
|
||||
|
||||
float vel_x(0), vel_y(0), accel(0);
|
||||
if (_lastEvent.valid())
|
||||
{
|
||||
// TODO: add velocity + acceleration
|
||||
}
|
||||
|
||||
|
||||
_oscStream << osc::BeginMessage("/tuio/2Dcur") << "set" << static_cast<osc::int32>(i->id) << x << y << vel_x << vel_y << accel << osc::EndMessage;
|
||||
if(i->phase == osgGA::GUIEventAdapter::TOUCH_ENDED)
|
||||
num_ended++;
|
||||
}
|
||||
|
||||
|
||||
_lastEvent = new osgGA::GUIEventAdapter(ea);
|
||||
|
||||
|
||||
_finishMultiTouchSequence = (num_ended == touch_data->getNumTouchPoints());
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
, _stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void apply(bool value) { _stream << value; }
|
||||
virtual void apply(char value) { _stream << value; }
|
||||
virtual void apply(unsigned char value) { _stream << value; }
|
||||
@@ -401,9 +401,9 @@ void OscSendingDevice::sendUserDataContainer(const std::string& key, const osg::
|
||||
if (asBundle) {
|
||||
beginBundle(msg_id);
|
||||
}
|
||||
|
||||
|
||||
OscSendingDeviceGetValueVisitor gvv(_oscStream);
|
||||
|
||||
|
||||
unsigned int num_objects = udc->getNumUserObjects();
|
||||
for(unsigned int i = 0; i < num_objects; ++i)
|
||||
{
|
||||
@@ -421,8 +421,8 @@ void OscSendingDevice::sendUserDataContainer(const std::string& key, const osg::
|
||||
_oscStream << osc::EndMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (asBundle)
|
||||
_oscStream << osc::EndBundle;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user