From 235c29913a62494008b4e866e6ac351a87dd1feb Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 3 Feb 2013 17:21:50 +0000 Subject: [PATCH] Make the knob mouse-wheel direction configurable. Add a global setting to control the mouse-wheel direction of the knob; a future commit will expose this in the FG GUI. --- simgear/scene/model/SGPickAnimation.cxx | 14 ++++++++++++-- simgear/scene/model/SGPickAnimation.hxx | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/simgear/scene/model/SGPickAnimation.cxx b/simgear/scene/model/SGPickAnimation.cxx index a02a207d..839d881d 100644 --- a/simgear/scene/model/SGPickAnimation.cxx +++ b/simgear/scene/model/SGPickAnimation.cxx @@ -361,6 +361,8 @@ static void readOptionalBindingList(const SGPropertyNode* aNode, SGPropertyNode* } +static bool static_knobMouseWheelAlternateDirection = false; + class SGKnobAnimation::KnobPickCallback : public SGPickCallback { public: KnobPickCallback(const SGPropertyNode* configNode, @@ -400,11 +402,14 @@ public: if ((button == 0) && (ea->getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_ALT)) { button = 1; } + + int increaseMouseWheel = static_knobMouseWheelAlternateDirection ? 3 : 4; + int decreaseMouseWheel = static_knobMouseWheelAlternateDirection ? 4 : 3; _direction = DIRECTION_NONE; - if ((button == 0) || (button == 4)) { + if ((button == 0) || (button == increaseMouseWheel)) { _direction = DIRECTION_CLOCKWISE; - } else if ((button == 1) || (button == 3)) { + } else if ((button == 1) || (button == decreaseMouseWheel)) { _direction = DIRECTION_ANTICLOCKWISE; } else { return false; @@ -518,3 +523,8 @@ SGKnobAnimation::createAnimationGroup(osg::Group& parent) return transform; } +void SGKnobAnimation::setAlternateMouseWheelDirection(bool aToggle) +{ + static_knobMouseWheelAlternateDirection = aToggle; +} + diff --git a/simgear/scene/model/SGPickAnimation.hxx b/simgear/scene/model/SGPickAnimation.hxx index 615fef04..bf52078d 100644 --- a/simgear/scene/model/SGPickAnimation.hxx +++ b/simgear/scene/model/SGPickAnimation.hxx @@ -54,6 +54,12 @@ public: SGPropertyNode* modelRoot); virtual osg::Group* createAnimationGroup(osg::Group& parent); + /** + * by default mouse wheel up corresponds to increment (CW) + * and mouse-wheel down corresponds to decrement (CCW). + * Since no one can agree on that, make it a global toggle. + */ + static void setAlternateMouseWheelDirection(bool aToggle); private: class KnobPickCallback; class UpdateCallback;