Tim MOORE:
FGManipulator.*: "This patch works around a bug in OSG's handling of modifier keys. The symptom of the bug is that modifier keys don't appear to be released." fg_os_osgviewer.cxx: "This patch fixes the test for support of cursor changes in OSG 2.0."
This commit is contained in:
parent
28da7c0a90
commit
b5917d62d2
3 changed files with 40 additions and 7 deletions
|
@ -10,6 +10,25 @@
|
|||
// event handling method is also a convenient place to run the the FG
|
||||
// idle and draw handlers.
|
||||
|
||||
FGManipulator::FGManipulator() :
|
||||
idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
|
||||
mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0),
|
||||
osgModifiers(0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
void FGManipulator::setByMatrix(const osg::Matrixd& matrix)
|
||||
{
|
||||
// Yuck
|
||||
|
@ -194,9 +213,19 @@ void FGManipulator::handleKey(const osgGA::GUIEventAdapter& ea, int& key,
|
|||
case osgGA::GUIEventAdapter::KEY_KP_9: key = 360; break;
|
||||
case osgGA::GUIEventAdapter::KEY_KP_Enter: key = 269; break;
|
||||
}
|
||||
modifiers = osgToFGModifiers(ea.getModKeyMask());
|
||||
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;
|
||||
}
|
||||
modifiers = osgToFGModifiers(osgModifiers);
|
||||
currentModifiers = modifiers;
|
||||
if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP)
|
||||
if (eventType == osgGA::GUIEventAdapter::KEYUP)
|
||||
modifiers |= KEYMOD_RELEASED;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef FGMANIPULATOR_H
|
||||
#define FGMANIPULATOR_H 1
|
||||
|
||||
#include <map>
|
||||
#include <osg/Quat>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
|
||||
|
@ -8,10 +9,8 @@
|
|||
|
||||
class FGManipulator : public osgGA::MatrixManipulator {
|
||||
public:
|
||||
FGManipulator() :
|
||||
idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
|
||||
mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0)
|
||||
{}
|
||||
FGManipulator();
|
||||
|
||||
virtual ~FGManipulator() {}
|
||||
|
||||
virtual const char* className() const {return "FGManipulator"; }
|
||||
|
@ -116,6 +115,10 @@ protected:
|
|||
fgMouseClickHandler mouseClickHandler;
|
||||
fgMouseMotionHandler mouseMotionHandler;
|
||||
int currentModifiers;
|
||||
// work-around for OSG bug
|
||||
int osgModifiers;
|
||||
typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
|
||||
KeyMaskMap keyMaskMap;
|
||||
osg::Vec3d position;
|
||||
osg::Quat attitude;
|
||||
void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#include "globals.hxx"
|
||||
#include "renderer.hxx"
|
||||
|
||||
#if ((1 == OSG_VERSION_MAJOR) && (9 == OSG_VERSION_MINOR) && \
|
||||
#if ((2 <= OSG_VERSION_MAJOR) || \
|
||||
(1 == OSG_VERSION_MAJOR) && (9 == OSG_VERSION_MINOR) && \
|
||||
(8 <= OSG_VERSION_PATCH)) || \
|
||||
((1 == OSG_VERSION_MAJOR) && (9 < OSG_VERSION_MINOR)) || \
|
||||
(1 < OSG_VERSION_MAJOR)
|
||||
|
|
Loading…
Reference in a new issue