Fix view right-drag interaction with PUI
When PUI doesn’t handle the right-mouse down, ensure it ignores the mouse-up event.
This commit is contained in:
parent
bb315488e1
commit
aa9ad6a780
6 changed files with 48 additions and 21 deletions
|
@ -714,5 +714,14 @@ void FGMouseInput::doMouseMotion (int x, int y, const osgGA::GUIEventAdapter* ea
|
|||
d->mouseYNode->setIntValue(y);
|
||||
}
|
||||
|
||||
bool FGMouseInput::isRightDragToLookEnabled() const
|
||||
{
|
||||
if (!d->initialized) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (d->rightClickModeCycle == false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -43,11 +43,20 @@ public:
|
|||
FGMouseInput();
|
||||
virtual ~FGMouseInput();
|
||||
|
||||
virtual void init();
|
||||
virtual void update( double dt );
|
||||
void init() override;
|
||||
void update( double dt ) override;
|
||||
|
||||
static const char* subsystemName() { return "input-mouse"; }
|
||||
|
||||
void doMouseClick (int b, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter* ea);
|
||||
void doMouseMotion (int x, int y, const osgGA::GUIEventAdapter*);
|
||||
|
||||
/**
|
||||
* @brief isRightDragToLookEnabled - test if we're in right-mouse-drag
|
||||
* to adjust the view direction/position mode.
|
||||
* @return
|
||||
*/
|
||||
bool isRightDragToLookEnabled() const;
|
||||
private:
|
||||
void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ FGInput::FGInput ()
|
|||
if( fgGetBool("/sim/input/no-mouse-input",false) ) {
|
||||
SG_LOG(SG_INPUT,SG_ALERT,"Mouse input disabled!");
|
||||
} else {
|
||||
set_subsystem( "input-mouse", new FGMouseInput() );
|
||||
set_subsystem( FGMouseInput::subsystemName(), new FGMouseInput() );
|
||||
}
|
||||
|
||||
if( fgGetBool("/sim/input/no-keyboard-input",false) ) {
|
||||
|
|
|
@ -26,15 +26,9 @@
|
|||
#ifndef _INPUT_HXX
|
||||
#define _INPUT_HXX
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// General input mapping support.
|
||||
|
@ -61,6 +55,8 @@ public:
|
|||
*/
|
||||
virtual ~FGInput();
|
||||
|
||||
static const char* subsystemName() { return "input"; }
|
||||
|
||||
};
|
||||
|
||||
#endif // _INPUT_HXX
|
||||
|
|
|
@ -919,7 +919,7 @@ void fgCreateSubsystems(bool duringReset) {
|
|||
// Initialize the input subsystem.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
globals->add_subsystem("input", new FGInput, SGSubsystemMgr::GENERAL);
|
||||
globals->add_new_subsystem<FGInput>(SGSubsystemMgr::GENERAL);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
#include <Viewer/CameraGroup.hxx>
|
||||
#include <Viewer/FGEventHandler.hxx>
|
||||
|
||||
#include <Input/input.hxx>
|
||||
#include <Input/FGMouseInput.hxx>
|
||||
|
||||
// Old versions of PUI are missing these defines
|
||||
#ifndef PU_SCROLL_UP_BUTTON
|
||||
#define PU_SCROLL_UP_BUTTON 3
|
||||
|
@ -99,7 +102,9 @@ class PUIEventHandler : public osgGA::GUIEventHandler
|
|||
public:
|
||||
PUIEventHandler(PUICamera* cam) :
|
||||
_puiCamera(cam)
|
||||
{}
|
||||
{
|
||||
_mouse0RightButtonNode = fgGetNode("/devices/status/mice/mouse[0]/button[2]", true);
|
||||
}
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *nv) override
|
||||
{
|
||||
|
@ -117,22 +122,29 @@ public:
|
|||
case(osgGA::GUIEventAdapter::MOVE):
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
{
|
||||
FGMouseInput* mouseSubsystem = globals->get_subsystem<FGInput>()->get_subsystem<FGMouseInput>();
|
||||
if (mouseSubsystem &&
|
||||
mouseSubsystem->isRightDragToLookEnabled() &&
|
||||
_mouse0RightButtonNode->getBoolValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool handled = puMouse(scaledX, scaledY);
|
||||
return handled;
|
||||
}
|
||||
// you might thnk the code below is a good idea, but apparently it's not
|
||||
// PUI synthesises PU_DRAG internally, it doesn't want to see it delivered
|
||||
// from the windowing system
|
||||
#if 0
|
||||
case(osgGA::GUIEventAdapter::DRAG):
|
||||
{
|
||||
bool handled = puMouse(osgButtonToPUI(ea), PU_DRAG, scaledX, scaledY);
|
||||
return handled;
|
||||
}
|
||||
#endif
|
||||
|
||||
case(osgGA::GUIEventAdapter::PUSH):
|
||||
case(osgGA::GUIEventAdapter::RELEASE):
|
||||
{
|
||||
FGMouseInput* mouseSubsystem = globals->get_subsystem<FGInput>()->get_subsystem<FGMouseInput>();
|
||||
if (mouseSubsystem &&
|
||||
mouseSubsystem->isRightDragToLookEnabled() &&
|
||||
_mouse0RightButtonNode->getBoolValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool upOrDown = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE);
|
||||
bool handled = puMouse(osgButtonToPUI(ea), upOrDown, scaledX, scaledY);
|
||||
return handled;
|
||||
|
@ -215,6 +227,7 @@ private:
|
|||
}
|
||||
|
||||
PUICamera* _puiCamera;
|
||||
SGPropertyNode_ptr _mouse0RightButtonNode;
|
||||
};
|
||||
|
||||
// The pu getWindow callback is supposed to return a window ID that
|
||||
|
|
Loading…
Reference in a new issue