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);
|
d->mouseYNode->setIntValue(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FGMouseInput::isRightDragToLookEnabled() const
|
||||||
|
{
|
||||||
|
if (!d->initialized) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (d->rightClickModeCycle == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,20 @@ public:
|
||||||
FGMouseInput();
|
FGMouseInput();
|
||||||
virtual ~FGMouseInput();
|
virtual ~FGMouseInput();
|
||||||
|
|
||||||
virtual void init();
|
void init() override;
|
||||||
virtual void update( double dt );
|
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 doMouseClick (int b, int updown, int x, int y, bool mainWindow, const osgGA::GUIEventAdapter* ea);
|
||||||
void doMouseMotion (int x, int y, const osgGA::GUIEventAdapter*);
|
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:
|
private:
|
||||||
void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea);
|
void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ FGInput::FGInput ()
|
||||||
if( fgGetBool("/sim/input/no-mouse-input",false) ) {
|
if( fgGetBool("/sim/input/no-mouse-input",false) ) {
|
||||||
SG_LOG(SG_INPUT,SG_ALERT,"Mouse input disabled!");
|
SG_LOG(SG_INPUT,SG_ALERT,"Mouse input disabled!");
|
||||||
} else {
|
} else {
|
||||||
set_subsystem( "input-mouse", new FGMouseInput() );
|
set_subsystem( FGMouseInput::subsystemName(), new FGMouseInput() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fgGetBool("/sim/input/no-keyboard-input",false) ) {
|
if( fgGetBool("/sim/input/no-keyboard-input",false) ) {
|
||||||
|
|
|
@ -26,15 +26,9 @@
|
||||||
#ifndef _INPUT_HXX
|
#ifndef _INPUT_HXX
|
||||||
#define _INPUT_HXX
|
#define _INPUT_HXX
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# error This library requires C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// General input mapping support.
|
// General input mapping support.
|
||||||
|
@ -61,6 +55,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual ~FGInput();
|
virtual ~FGInput();
|
||||||
|
|
||||||
|
static const char* subsystemName() { return "input"; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _INPUT_HXX
|
#endif // _INPUT_HXX
|
||||||
|
|
|
@ -919,7 +919,7 @@ void fgCreateSubsystems(bool duringReset) {
|
||||||
// Initialize the input subsystem.
|
// 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/CameraGroup.hxx>
|
||||||
#include <Viewer/FGEventHandler.hxx>
|
#include <Viewer/FGEventHandler.hxx>
|
||||||
|
|
||||||
|
#include <Input/input.hxx>
|
||||||
|
#include <Input/FGMouseInput.hxx>
|
||||||
|
|
||||||
// Old versions of PUI are missing these defines
|
// Old versions of PUI are missing these defines
|
||||||
#ifndef PU_SCROLL_UP_BUTTON
|
#ifndef PU_SCROLL_UP_BUTTON
|
||||||
#define PU_SCROLL_UP_BUTTON 3
|
#define PU_SCROLL_UP_BUTTON 3
|
||||||
|
@ -99,7 +102,9 @@ class PUIEventHandler : public osgGA::GUIEventHandler
|
||||||
public:
|
public:
|
||||||
PUIEventHandler(PUICamera* cam) :
|
PUIEventHandler(PUICamera* cam) :
|
||||||
_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
|
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::MOVE):
|
||||||
case(osgGA::GUIEventAdapter::DRAG):
|
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);
|
bool handled = puMouse(scaledX, scaledY);
|
||||||
return handled;
|
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::PUSH):
|
||||||
case(osgGA::GUIEventAdapter::RELEASE):
|
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 upOrDown = (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE);
|
||||||
bool handled = puMouse(osgButtonToPUI(ea), upOrDown, scaledX, scaledY);
|
bool handled = puMouse(osgButtonToPUI(ea), upOrDown, scaledX, scaledY);
|
||||||
return handled;
|
return handled;
|
||||||
|
@ -215,6 +227,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
PUICamera* _puiCamera;
|
PUICamera* _puiCamera;
|
||||||
|
SGPropertyNode_ptr _mouse0RightButtonNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The pu getWindow callback is supposed to return a window ID that
|
// The pu getWindow callback is supposed to return a window ID that
|
||||||
|
|
Loading…
Reference in a new issue