Added osgGA::Device class for integration of both physical and virtual devices.
Added template readFile(..) function to make it more convinient to cast to a specific object type. Added support for osgGA::Device to osgViewer. Added sdl plugin to provides very basic joystick osgGA::Device integration.
This commit is contained in:
@@ -735,6 +735,7 @@ void CompositeViewer::eventTraversal()
|
||||
masterCameraVPW *= viewport->computeWindowMatrix();
|
||||
}
|
||||
|
||||
// get events from all windows attached to Viewer.
|
||||
for(Contexts::iterator citr = contexts.begin();
|
||||
citr != contexts.end();
|
||||
++citr)
|
||||
@@ -925,6 +926,20 @@ void CompositeViewer::eventTraversal()
|
||||
++vitr)
|
||||
{
|
||||
View* view = vitr->get();
|
||||
|
||||
// get events from user Devices attached to Viewer.
|
||||
for(osgViewer::View::Devices::iterator eitr = view->getDevices().begin();
|
||||
eitr != view->getDevices().end();
|
||||
++eitr)
|
||||
{
|
||||
osgGA::Device* es = eitr->get();
|
||||
es->checkEvents();
|
||||
|
||||
// open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events?
|
||||
// for now assume now and just get the events directly without any reprojection.
|
||||
es->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime);
|
||||
}
|
||||
|
||||
view->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime);
|
||||
}
|
||||
|
||||
|
||||
@@ -2217,3 +2217,20 @@ bool View::computeIntersections(float x,float y, const osg::NodePath& nodePath,
|
||||
}
|
||||
|
||||
|
||||
void View::addDevice(osgGA::Device* eventSource)
|
||||
{
|
||||
Devices::iterator itr = std::find( _eventSources.begin(), _eventSources.end(), eventSource );
|
||||
if (itr==_eventSources.end())
|
||||
{
|
||||
_eventSources.push_back(eventSource);
|
||||
}
|
||||
}
|
||||
|
||||
void View::removeDevice(osgGA::Device* eventSource)
|
||||
{
|
||||
Devices::iterator itr = std::find( _eventSources.begin(), _eventSources.end(), eventSource );
|
||||
if (itr!=_eventSources.end())
|
||||
{
|
||||
_eventSources.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,6 +645,20 @@ void Viewer::eventTraversal()
|
||||
}
|
||||
|
||||
|
||||
// get events from user Devices attached to Viewer.
|
||||
for(Devices::iterator eitr = _eventSources.begin();
|
||||
eitr != _eventSources.end();
|
||||
++eitr)
|
||||
{
|
||||
osgGA::Device* es = eitr->get();
|
||||
es->checkEvents();
|
||||
|
||||
// open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events?
|
||||
// for now assume now and just get the events directly without any reprojection.
|
||||
es->getEventQueue()->takeEvents(events, cutOffTime);
|
||||
}
|
||||
|
||||
// get events from all windows attached to Viewer.
|
||||
for(Contexts::iterator citr = contexts.begin();
|
||||
citr != contexts.end();
|
||||
++citr)
|
||||
|
||||
Reference in New Issue
Block a user