From Stephan Huber, introduced syncornization of osgGA::Device
This commit is contained in:
@@ -151,11 +151,12 @@ public:
|
||||
{
|
||||
if (_firstEventRemoteTimeStamp < 0)
|
||||
{
|
||||
_firstEventLocalTimeStamp = osg::Timer::instance()->time_s();
|
||||
_firstEventLocalTimeStamp = getEventQueue()->getTime();
|
||||
_firstEventRemoteTimeStamp = time_stamp;
|
||||
}
|
||||
|
||||
return _firstEventLocalTimeStamp + (time_stamp - _firstEventRemoteTimeStamp) / 1000.0;;
|
||||
double local_time = _firstEventLocalTimeStamp + (time_stamp - _firstEventRemoteTimeStamp);
|
||||
// std::cout << "ts: "<< time_stamp << " -> " << local_time << std::endl;
|
||||
return local_time;
|
||||
}
|
||||
|
||||
bool isNewer(double time_stamp)
|
||||
@@ -186,10 +187,13 @@ private:
|
||||
class SendKeystrokeRequestHandler : public RestHttpDevice::RequestHandler {
|
||||
public:
|
||||
SendKeystrokeRequestHandler(const std::string& request_path, int key) : RestHttpDevice::RequestHandler(request_path), _key(key) {}
|
||||
|
||||
virtual bool operator()(const std::string& request_path, const std::string& full_request_path, const Arguments& arguments, http::server::reply& reply)
|
||||
{
|
||||
getDevice()->getEventQueue()->keyPress(_key);
|
||||
getDevice()->getEventQueue()->keyRelease(_key);
|
||||
double local_time = getLocalTime(arguments, reply);
|
||||
|
||||
getDevice()->getEventQueue()->keyPress(_key, local_time);
|
||||
getDevice()->getEventQueue()->keyRelease(_key, local_time);
|
||||
|
||||
return sendOkReply(reply);
|
||||
}
|
||||
|
||||
@@ -250,6 +250,13 @@ void View::init()
|
||||
void View::setStartTick(osg::Timer_t tick)
|
||||
{
|
||||
_startTick = tick;
|
||||
|
||||
for(Devices::iterator eitr = _eventSources.begin();
|
||||
eitr != _eventSources.end();
|
||||
++eitr)
|
||||
{
|
||||
(*eitr)->getEventQueue()->setStartTick(_startTick);
|
||||
}
|
||||
}
|
||||
|
||||
void View::setSceneData(osg::Node* node)
|
||||
@@ -2224,6 +2231,9 @@ void View::addDevice(osgGA::Device* eventSource)
|
||||
{
|
||||
_eventSources.push_back(eventSource);
|
||||
}
|
||||
|
||||
if (eventSource)
|
||||
eventSource->getEventQueue()->setStartTick(getStartTick());
|
||||
}
|
||||
|
||||
void View::removeDevice(osgGA::Device* eventSource)
|
||||
|
||||
Reference in New Issue
Block a user