after OSG 2.4 upgrade, remove modifier workaround and comment out numpad
workaround (we have yet to verify if the latter is really obsolete)
This commit is contained in:
parent
de277df8b8
commit
dd3fbd50d8
3 changed files with 9 additions and 40 deletions
|
@ -30,31 +30,16 @@ FGManipulator::FGManipulator() :
|
||||||
statsEvent(new osgGA::GUIEventAdapter),
|
statsEvent(new osgGA::GUIEventAdapter),
|
||||||
statsType(osgViewer::StatsHandler::NO_STATS),
|
statsType(osgViewer::StatsHandler::NO_STATS),
|
||||||
currentModifiers(0),
|
currentModifiers(0),
|
||||||
osgModifiers(0),
|
|
||||||
resizable(true),
|
resizable(true),
|
||||||
mouseWarped(false),
|
mouseWarped(false),
|
||||||
scrollButtonPressed(false),
|
scrollButtonPressed(false)
|
||||||
useEventModifiers(false)
|
|
||||||
{
|
{
|
||||||
using namespace osgGA;
|
using namespace osgGA;
|
||||||
statsHandler->setKeyEventTogglesOnScreenStats(displayStatsKey);
|
statsHandler->setKeyEventTogglesOnScreenStats(displayStatsKey);
|
||||||
statsHandler->setKeyEventPrintsOutStats(printStatsKey);
|
statsHandler->setKeyEventPrintsOutStats(printStatsKey);
|
||||||
statsEvent->setEventType(GUIEventAdapter::KEYDOWN);
|
statsEvent->setEventType(GUIEventAdapter::KEYDOWN);
|
||||||
|
|
||||||
keyMaskMap[GUIEventAdapter::KEY_Shift_L]
|
#if 0
|
||||||
= 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;
|
|
||||||
keyMaskMap[GUIEventAdapter::KEY_Meta_L] = GUIEventAdapter::MODKEY_LEFT_META;
|
|
||||||
keyMaskMap[GUIEventAdapter::KEY_Meta_R] = GUIEventAdapter::MODKEY_RIGHT_META;
|
|
||||||
keyMaskMap[GUIEventAdapter::KEY_Super_L] = GUIEventAdapter::MODKEY_LEFT_META;
|
|
||||||
keyMaskMap[GUIEventAdapter::KEY_Super_R] = GUIEventAdapter::MODKEY_RIGHT_META;
|
|
||||||
// We have to implement numlock too.
|
// We have to implement numlock too.
|
||||||
numlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = '0';
|
numlockKeyMap[GUIEventAdapter::KEY_KP_Insert] = '0';
|
||||||
numlockKeyMap[GUIEventAdapter::KEY_KP_End] = '1';
|
numlockKeyMap[GUIEventAdapter::KEY_KP_End] = '1';
|
||||||
|
@ -66,6 +51,7 @@ FGManipulator::FGManipulator() :
|
||||||
numlockKeyMap[GUIEventAdapter::KEY_KP_Home] = '7';
|
numlockKeyMap[GUIEventAdapter::KEY_KP_Home] = '7';
|
||||||
numlockKeyMap[GUIEventAdapter::KEY_KP_Up] = '8';
|
numlockKeyMap[GUIEventAdapter::KEY_KP_Up] = '8';
|
||||||
numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9';
|
numlockKeyMap[GUIEventAdapter::KEY_KP_Page_Up] = '9';
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < 128; i++)
|
for (int i = 0; i < 128; i++)
|
||||||
release_keys[i] = i;
|
release_keys[i] = i;
|
||||||
|
@ -286,26 +272,17 @@ void FGManipulator::handleKey(const osgGA::GUIEventAdapter& ea, int& key,
|
||||||
case osgGA::GUIEventAdapter::KEY_KP_Subtract: key = '-'; break;
|
case osgGA::GUIEventAdapter::KEY_KP_Subtract: key = '-'; break;
|
||||||
}
|
}
|
||||||
osgGA::GUIEventAdapter::EventType eventType = ea.getEventType();
|
osgGA::GUIEventAdapter::EventType eventType = ea.getEventType();
|
||||||
|
|
||||||
|
#if 0
|
||||||
std::map<int, int>::iterator numPadIter = numlockKeyMap.find(key);
|
std::map<int, int>::iterator numPadIter = numlockKeyMap.find(key);
|
||||||
|
|
||||||
if (numPadIter != numlockKeyMap.end()) {
|
if (numPadIter != numlockKeyMap.end()) {
|
||||||
if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_NUM_LOCK) {
|
if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_NUM_LOCK) {
|
||||||
key = numPadIter->second;
|
key = numPadIter->second;
|
||||||
}
|
}
|
||||||
} else if (useEventModifiers) {
|
|
||||||
|
|
||||||
}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);
|
#endif
|
||||||
|
modifiers = osgToFGModifiers(ea.getModKeyMask());
|
||||||
currentModifiers = modifiers;
|
currentModifiers = modifiers;
|
||||||
if (eventType == osgGA::GUIEventAdapter::KEYUP)
|
if (eventType == osgGA::GUIEventAdapter::KEYUP)
|
||||||
modifiers |= KEYMOD_RELEASED;
|
modifiers |= KEYMOD_RELEASED;
|
||||||
|
|
|
@ -119,8 +119,6 @@ public:
|
||||||
bool getResizable() { return resizable; }
|
bool getResizable() { return resizable; }
|
||||||
void setResizable(bool _resizable) { resizable = _resizable; }
|
void setResizable(bool _resizable) { resizable = _resizable; }
|
||||||
|
|
||||||
bool getUseEventModifiers() { return useEventModifiers; }
|
|
||||||
void setUseEventModifiers(bool val) { useEventModifiers = val; }
|
|
||||||
protected:
|
protected:
|
||||||
osg::ref_ptr<osg::Node> _node;
|
osg::ref_ptr<osg::Node> _node;
|
||||||
fgIdleHandler idleHandler;
|
fgIdleHandler idleHandler;
|
||||||
|
@ -133,11 +131,9 @@ protected:
|
||||||
osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
|
osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
|
||||||
int statsType;
|
int statsType;
|
||||||
int currentModifiers;
|
int currentModifiers;
|
||||||
// work-around for OSG bug
|
#if 0
|
||||||
int osgModifiers;
|
|
||||||
typedef std::map<int, osgGA::GUIEventAdapter::ModKeyMask> KeyMaskMap;
|
|
||||||
KeyMaskMap keyMaskMap;
|
|
||||||
std::map<int, int> numlockKeyMap;
|
std::map<int, int> numlockKeyMap;
|
||||||
|
#endif
|
||||||
osg::Vec3d position;
|
osg::Vec3d position;
|
||||||
osg::Quat attitude;
|
osg::Quat attitude;
|
||||||
void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
|
void handleKey(const osgGA::GUIEventAdapter& ea, int& key, int& modifiers);
|
||||||
|
@ -146,9 +142,6 @@ protected:
|
||||||
// workaround for osgViewer double scroll events
|
// workaround for osgViewer double scroll events
|
||||||
bool scrollButtonPressed;
|
bool scrollButtonPressed;
|
||||||
int release_keys[128];
|
int release_keys[128];
|
||||||
// When the viewer is embedded, the host toolkit may deliver a
|
|
||||||
// valid event mask but not control keys.
|
|
||||||
bool useEventModifiers;
|
|
||||||
void handleStats(osgGA::GUIActionAdapter& us);
|
void handleStats(osgGA::GUIActionAdapter& us);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -268,7 +268,6 @@ void fgOSOpenWindow(int w, int h, int bpp, bool alpha,
|
||||||
camera->setViewport(new osg::Viewport(0, 0, realw, realh));
|
camera->setViewport(new osg::Viewport(0, 0, realw, realh));
|
||||||
camera->setProjectionResizePolicy(rsp);
|
camera->setProjectionResizePolicy(rsp);
|
||||||
//viewer->addSlave(camera.get());
|
//viewer->addSlave(camera.get());
|
||||||
globals->get_renderer()->getManipulator()->setUseEventModifiers(true);
|
|
||||||
viewer->setCameraManipulator(globals->get_renderer()->getManipulator());
|
viewer->setCameraManipulator(globals->get_renderer()->getManipulator());
|
||||||
// Let FG handle the escape key with a confirmation
|
// Let FG handle the escape key with a confirmation
|
||||||
viewer->setKeyEventSetsDone(0);
|
viewer->setKeyEventSetsDone(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue