Hi Christian,
The usual way to avoid pollution of 3rd party #defines to to make sure
that the polluters are included after the ones that are effected. If
this isn't possible then to #undef the problem #defines.
Another possible route would be to simply use a non polutting headers
and lib for joystick support. I've used SDL for joystick support in
the past without problems.
Robert.
On 1 February 2012 08:51, Christian Schulte christian.schu...@onera.fr wrote:
Hello everyone,
after some headaches I have found a solution to a compile problem in a
program using osgGA::GUIEventHandler and linux/input.h (neccesary for make
work an old joystick model, not possible to be modified). Here is an
exctract of the code which throw the error Expected unqualified id before
: for lines 619 and 622 :
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::FRAME):
{
osgViewer::View* view =
dynamic_castosgViewer::View*(gUIActionAdapter);
if (view == NULL) return false;
updateResolution(view);
break;
}
case (osgGA::GUIEventAdapter::KEYUP):
{
switch (ea.getKey()) {
case ('f'):
arbreUtile-setPropValuebool(graphic.windows.fullScreen,
!arbreUtile-getPropValuebool(graphic.windows.fullScreen,false));
break;
case (osgGA::GUIEventAdapter::KEY_Pause):
arbreUtile-setPropValuebool(sim.pause,!
arbreUtile-getPropValuebool(sim.pause,false));
break;
case (osgGA::GUIEventAdapter::KEY_F2): // This is line 619
arbreUtile-setPropValuebool(graphic.windows.showGui, !
arbreUtile-getPropValuebool(graphic.windows.showGui,false));
break;
case (osgGA::GUIEventAdapter::KEY_F12): // This is line 622
arbreUtile-setPropValuebool(graphic.windows.record,
! arbreUtile-getPropValuebool(graphic.windows.record, false));
break;
default:
break;
}
break;
}
default:
return false;
}
The option -save-temps allowed me to have a look at the file after
pre-compiler which gives :
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::FRAME):
{
osgViewer::View* view =
dynamic_castosgViewer::View*(gUIActionAdapter);
if (view == NULL) return false;
updateResolution(view);
break;
}
case (osgGA::GUIEventAdapter::KEYUP):
{
switch (ea.getKey()) {
case ('f'):
arbreUtile-setPropValuebool(graphic.windows.fullScreen,
!arbreUtile-getPropValuebool(graphic.windows.fullScreen,false));
break;
case (osgGA::GUIEventAdapter::KEY_Pause):
arbreUtile-setPropValuebool(sim.pause,!
arbreUtile-getPropValuebool(sim.pause,false));
break;
case (osgGA::GUIEventAdapter::60): // This is line 619
arbreUtile-setPropValuebool(graphic.windows.showGui, !
arbreUtile-getPropValuebool(graphic.windows.showGui,false));
break;
case (osgGA::GUIEventAdapter::80): // This is line 622
arbreUtile-setPropValuebool(graphic.windows.record,
! arbreUtile-getPropValuebool(graphic.windows.record, false));
break;
default:
break;
}
break;
}
default:
return false;
}
As you can see, KEY_F2 and KEY_F12 has been replaced by a numeric value, but
not KEY_Pause... In fact the file linux/input.h contains a list of define
for the keyboard, including :
#define KEY_F2 60
...
#define KEY_F12 88
...
#define KEY_PAUSE 119
Temporally, we had to undef KEY_F2 and KEY_12 in order to compile and link
correctly our program.
I you have some hints to do this differently and in a cleaner way :-) I'm
ready to test other solutions (but I cannot exclude linux/input.h)
Thanks,
Cheers
Christian
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org