-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
This patch fixes the use of the keypad with numlock in the osgViewer
version of FlightGear. I'd be interested to hear if this has any
problems with non-US keyboards.
This also restores the handling of resize events while trying to stay
out of the way of the multiple display code.
Enjoy,
Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGgDtjeDhWHdXrDRURAgewAJ4jvVWMikdCyOYKNttXpzl0sLblgwCgiQDP
/rrEw4O+cPgEF1N2LYKO15w=
=iecE
-----END PGP SIGNATURE-----
diff --git a/src/Main/FGManipulator.cxx b/src/Main/FGManipulator.cxx
index de88d5e..8bffc93 100644
--- a/src/Main/FGManipulator.cxx
+++ b/src/Main/FGManipulator.cxx
@@ -13,20 +13,31 @@
FGManipulator::FGManipulator() :
idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0),
- osgModifiers(0)
+ osgModifiers(0), resizable(true)
{
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Shift_L]
- = osgGA::GUIEventAdapter::MODKEY_LEFT_SHIFT;
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Shift_R]
- = osgGA::GUIEventAdapter::MODKEY_RIGHT_SHIFT;
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Control_L]
- = osgGA::GUIEventAdapter::MODKEY_LEFT_CTRL;
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Control_R]
- = osgGA::GUIEventAdapter::MODKEY_RIGHT_CTRL;
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Alt_L]
- = osgGA::GUIEventAdapter::MODKEY_LEFT_ALT;
- keyMaskMap[osgGA::GUIEventAdapter::KEY_Alt_R]
- = osgGA::GUIEventAdapter::MODKEY_RIGHT_ALT;
+ using namespace osgGA;
+
+ keyMaskMap[GUIEventAdapter::KEY_Shift_L]
+ = GUIEventAdapter::MODKEY_LEFT_SHIFT;
+ keyMaskMap[GUIEventAdapter::KEY_Shift_R]
+ = GUIEventAdapter::MODKEY_RIGHT_SHIFT;
+ keyMaskMap[GUIEventAdapter::KEY_Control_L]
+ = GUIEventAdapter::MODKEY_LEFT_CTRL;
+ keyMaskMap[GUIEventAdapter::KEY_Control_R]
+ = GUIEventAdapter::MODKEY_RIGHT_CTRL;
+ keyMaskMap[GUIEventAdapter::KEY_Alt_L] = GUIEventAdapter::MODKEY_LEFT_ALT;
+ keyMaskMap[GUIEventAdapter::KEY_Alt_R] = GUIEventAdapter::MODKEY_RIGHT_ALT;
+ // We have to implement numlock too.
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = '0';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_End] = '1';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Down] = '2';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Down] = '3';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Left] = '4';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Begin] = '5';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Right] = '6';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Home] = '7';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Up] = '8';
+ numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9';
}
void FGManipulator::setByMatrix(const osg::Matrixd& matrix)
@@ -160,7 +171,11 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea,
if (mouseMotionHandler)
(*mouseMotionHandler)(x, y);
return true;
- case osgGA::GUIEventAdapter::CLOSE_WINDOW:
+ case osgGA::GUIEventAdapter::RESIZE:
+ if (resizable && windowResizeHandler)
+ (*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
+ return true;
+ case osgGA::GUIEventAdapter::CLOSE_WINDOW:
case osgGA::GUIEventAdapter::QUIT_APPLICATION:
fgOSExit(0);
return true;
@@ -201,27 +216,30 @@ void FGManipulator::handleKey(const osgGA::GUIEventAdapter& ea, int& key,
case osgGA::GUIEventAdapter::KEY_F10: key = PU_KEY_F10; break;
case osgGA::GUIEventAdapter::KEY_F11: key = PU_KEY_F11; break;
case osgGA::GUIEventAdapter::KEY_F12: key = PU_KEY_F12; break;
- case osgGA::GUIEventAdapter::KEY_KP_0: key = 364; break;
- case osgGA::GUIEventAdapter::KEY_KP_1: key = 363; break;
- case osgGA::GUIEventAdapter::KEY_KP_2: key = 359; break;
- case osgGA::GUIEventAdapter::KEY_KP_3: key = 361; break;
- case osgGA::GUIEventAdapter::KEY_KP_4: key = 356; break;
- case osgGA::GUIEventAdapter::KEY_KP_5: key = 309; break;
- case osgGA::GUIEventAdapter::KEY_KP_6: key = 358; break;
- case osgGA::GUIEventAdapter::KEY_KP_7: key = 362; break;
- case osgGA::GUIEventAdapter::KEY_KP_8: key = 357; break;
- case osgGA::GUIEventAdapter::KEY_KP_9: key = 360; break;
- case osgGA::GUIEventAdapter::KEY_KP_Enter: key = 269; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Delete: key = '.'; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Enter: key = '\r'; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Add: key = '+'; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Divide: key = '/'; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Multiply: key = '*'; break;
+ case osgGA::GUIEventAdapter::KEY_KP_Subtract: key = '-'; break;
}
osgGA::GUIEventAdapter::EventType eventType = ea.getEventType();
- // Track the modifiers because OSG is currently (2.0) broken
- KeyMaskMap::iterator iter = keyMaskMap.find(key);
- if (iter != keyMaskMap.end()) {
- int mask = iter->second;
- if (eventType == osgGA::GUIEventAdapter::KEYUP)
- osgModifiers &= ~mask;
- else
- osgModifiers |= mask;
+ std::map<int, int>::iterator numPadIter = numlockKeyMap.find(key);
+
+ if (numPadIter != numlockKeyMap.end()) {
+ if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_NUM_LOCK) {
+ key = numPadIter->second;
+ }
+ } else {
+ // Track the modifiers because OSG is currently (2.0) broken
+ KeyMaskMap::iterator iter = keyMaskMap.find(key);
+ if (iter != keyMaskMap.end()) {
+ int mask = iter->second;
+ if (eventType == osgGA::GUIEventAdapter::KEYUP)
+ osgModifiers &= ~mask;
+ else
+ osgModifiers |= mask;
+ }
}
modifiers = osgToFGModifiers(osgModifiers);
currentModifiers = modifiers;
diff --git a/src/Main/FGManipulator.hxx b/src/Main/FGManipulator.hxx
index e20033d..78fb872 100644
--- a/src/Main/FGManipulator.hxx
+++ b/src/Main/FGManipulator.hxx
@@ -106,6 +106,12 @@ public:
void setPosition(const osg::Vec3d position) { this->position = position; }
void setAttitude(const osg::Quat attitude) { this->attitude = attitude; }
+ /** Whether or not resizing is supported. It might not be when
+ * using multiple displays.
+ */
+ bool getResizable() { return resizable; }
+ void setResizable(bool _resizable) { resizable = _resizable; }
+
protected:
osg::ref_ptr<osg::Node> _node;
fgIdleHandler idleHandler;
@@ -119,9 +125,10 @@ protected:
int osgModifiers;
typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
KeyMaskMap keyMaskMap;
+ std::map<int, int> numlockKeyMap;
osg::Vec3d position;
osg::Quat attitude;
void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
-
+ bool resizable;
};
#endif
diff --git a/src/Main/fg_os_osgviewer.cxx b/src/Main/fg_os_osgviewer.cxx
index ccc2632..fd850e6 100644
--- a/src/Main/fg_os_osgviewer.cxx
+++ b/src/Main/fg_os_osgviewer.cxx
@@ -146,6 +146,8 @@ void fgOSOpenWindow(int w, int h, int bpp,
// that achieves some magic ordering og the slaves so that we end up
// in the main window more often.
// This can be sorted out better when we got rid of glut and sdl.
+ FGManipulator* manipulator = globals->get_renderer()->getManipulator();
+ int nCameras = 0;
if (fgHasNode("/sim/rendering/camera")) {
SGPropertyNode* renderingNode = fgGetNode("/sim/rendering");
for (int i = 0; i < renderingNode->nChildren(); ++i) {
@@ -153,6 +155,7 @@ void fgOSOpenWindow(int w, int h, int bpp,
if (strcmp(cameraNode->getName(), "camera") != 0)
continue;
+ nCameras++;
// get a new copy of the traits struct
osg::ref_ptr<osg::GraphicsContext::Traits> cameraTraits;
cameraTraits = new osg::GraphicsContext::Traits(*traits);
@@ -195,6 +198,8 @@ void fgOSOpenWindow(int w, int h, int bpp,
camera->setProjectionResizePolicy(rsp);
viewer->addSlave(camera.get(), osg::Matrix::translate(-shearx, -sheary, 0), osg::Matrix());
}
+ if (nCameras > 1)
+ manipulator->setResizable(false);
}
// now the main camera ...
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel