_bindingsDown = readBindingList(configNode->getChildren("binding"), modelRoot);
readOptionalBindingList(configNode, modelRoot, "mod-up", _bindingsUp);
- readOptionalBindingList(configNode, modelRoot, "hovered", _hover);
+
+
+ if (configNode->hasChild("cursor")) {
+ _cursorName = configNode->getStringValue("cursor");
+ }
}
-
+
+ void addHoverBindings(const SGPropertyNode* hoverNode,
+ SGPropertyNode* modelRoot)
+ {
+ _hover = readBindingList(hoverNode->getChildren("binding"), modelRoot);
+ }
+
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
{
if (_buttons.find(button) == _buttons.end()) {
fireBindingList(_hover, params.ptr());
return true;
}
+
+ std::string getCursor() const
+ { return _cursorName; }
private:
SGBindingList _bindingsDown;
SGBindingList _bindingsUp;
bool _repeatable;
double _repeatInterval;
double _repeatTime;
+ std::string _cursorName;
};
class VncVisitor : public osg::NodeVisitor {
innerSetupPickGroup(commonGroup, parent);
SGSceneUserData* ud = SGSceneUserData::getOrCreateSceneUserData(commonGroup);
+ PickCallback* pickCb = NULL;
+
// add actions that become macro and command invocations
std::vector<SGPropertyNode_ptr> actions;
actions = getConfig()->getChildren("action");
- for (unsigned int i = 0; i < actions.size(); ++i)
- ud->addPickCallback(new PickCallback(actions[i], getModelRoot()));
+ for (unsigned int i = 0; i < actions.size(); ++i) {
+ pickCb = new PickCallback(actions[i], getModelRoot());
+ ud->addPickCallback(pickCb);
+ }
+
+ if (getConfig()->hasChild("hovered")) {
+ if (!pickCb) {
+ // make a trivial PickCallback to hang the hovered off of
+ SGPropertyNode_ptr dummyNode(new SGPropertyNode);
+ pickCb = new PickCallback(dummyNode.ptr(), getModelRoot());
+ }
+
+ pickCb->addHoverBindings(getConfig()->getNode("hovered"), getModelRoot());
+ }
+
// Look for the VNC sessions that want raw mouse input
actions = getConfig()->getChildren("vncaction");
for (unsigned int i = 0; i < actions.size(); ++i)
} else if (dragDir == "horizontal") {
_dragDirection = DRAG_HORIZONTAL;
}
+
+ if (configNode->hasChild("cursor")) {
+ _cursorName = configNode->getStringValue("cursor");
+ } else {
+ DragDirection dir = effectiveDragDirection();
+ if (dir == DRAG_VERTICAL) {
+ _cursorName = "drag-vertical";
+ } else if (dir == DRAG_HORIZONTAL) {
+ _cursorName = "drag-horizontal";
+ }
+ }
}
virtual bool buttonPressed(int button, const osgGA::GUIEventAdapter* ea, const Info&)
fireBindingList(_releaseAction);
}
-
+
+ DragDirection effectiveDragDirection() const
+ {
+ if (_dragDirection == DRAG_DEFAULT) {
+ // respect the current default settings - this allows runtime
+ // setting of the default drag direction.
+ return static_knobDragAlternateAxis ? DRAG_VERTICAL : DRAG_HORIZONTAL;
+ }
+
+ return _dragDirection;
+ }
+
virtual void mouseMoved(const osgGA::GUIEventAdapter* ea)
{
_mousePos = eventToWindowCoords(ea);
// user is dragging, disable repeat behaviour
_hasDragged = true;
}
-
- DragDirection dragDir = _dragDirection;
- if (dragDir == DRAG_DEFAULT) {
- // respect the current default settings - this allows runtime
- // setting of the default drag direction.
- dragDir = static_knobDragAlternateAxis ? DRAG_VERTICAL : DRAG_HORIZONTAL;
- }
-
- double delta = (dragDir == DRAG_VERTICAL) ? deltaMouse.y() : deltaMouse.x();
+
+ double delta = (effectiveDragDirection() == DRAG_VERTICAL) ? deltaMouse.y() : deltaMouse.x();
// per-animation scale factor lets the aircraft author tune for expectations,
// eg heading setting vs 5-state switch.
// then we scale by a global sensitivity, which the user can set.
if (fabs(delta) >= 1.0) {
// determine direction from sign of delta
Direction dir = (delta > 0.0) ? DIRECTION_INCREASE : DIRECTION_DECREASE;
- fire(ea->getModKeyMask(), dir);
+ fire(ea->getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT, dir);
_lastFirePos = _mousePos;
}
}
fireBindingList(_hover, params.ptr());
return true;
}
+
+ void setCursor(const std::string& aName)
+ {
+ _cursorName = aName;
+ }
+
+ virtual std::string getCursor() const
+ { return _cursorName; }
+
private:
void fire(bool isShifted, Direction dir)
{
osg::Vec2d _mousePos, ///< current window coords location of the mouse
_lastFirePos; ///< mouse location where we last fired the bindings
double _dragScale;
+
+ std::string _cursorName;
};
///////////////////////////////////////////////////////////////////////////////