Added support for 0x and numeric defintion of keys to be used with <click_to_event> functionality.

This commit is contained in:
Robert Osfield 2012-11-30 16:52:59 +00:00
parent 6eb3b2f091
commit d831f1b538
2 changed files with 20 additions and 0 deletions

View File

@ -136,6 +136,7 @@ public:
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *) virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{ {
OSG_INFO<<"ForwardToDeviceEventHandler::setEvent("<<ea.getKey()<<")"<<std::endl;
_device->sendEvent(ea); _device->sendEvent(ea);
return false; return false;
} }

View File

@ -1371,13 +1371,32 @@ bool ReaderWriterP3DXML::getKeyPositionInner(osgDB::XmlNode*cur, osgPresentation
std::string key = cur->getTrimmedContents(); std::string key = cur->getTrimmedContents();
unsigned int keyValue = 0; unsigned int keyValue = 0;
if (key.empty())
{
OSG_NOTICE<<"Warning: empty <key></key> is invalid, ignoring tag."<<std::endl;
return false;
}
StringKeyMap::const_iterator itr=_stringKeyMap.find(key); StringKeyMap::const_iterator itr=_stringKeyMap.find(key);
if (itr != _stringKeyMap.end()) if (itr != _stringKeyMap.end())
{ {
keyValue = itr->second; keyValue = itr->second;
} }
if (key.find("0x",0,2)!=std::string::npos)
{
std::istringstream iss(key);
iss>>std::hex>>keyValue;
OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() hex result = "<<keyValue<<std::endl;
}
else if (key.size()>1 && (key[0]>='0' && key[0]<='9'))
{
std::istringstream iss(key);
iss>>keyValue;
OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() numeric result = "<<keyValue<<std::endl;
}
else if (key.length()==1) else if (key.length()==1)
{ {
OSG_INFO<<"ReaderWriterP3DXML::getKeyPositionInner() alphanumeric result = "<<keyValue<<std::endl;
keyValue = key[0]; keyValue = key[0];
} }
else else