Commit 1d898067 authored by Matthias Krebs's avatar Matthias Krebs

Adding 3DMouse Support for LINUX (not completed)

parent e7036cd3
......@@ -625,6 +625,26 @@ win32-msvc2008|win32-msvc2010|linux {
-llibxbee
}
###################################################################
#### --- 3DConnexion 3d Mice support (e.g. spacenavigator) --- ####
###################################################################
# xdrvlib only supported by linux (theoretical all X11) systems
# You have to install the official 3DxWare driver for linux to use 3D mouse support on linux systems!
linux-g++|linux-g++-64{
exists(/usr/local/lib/libxdrvlib.so){
message("Including support for Magellan 3DxWare for linux system.")
SOURCES += src/input/Mouse6dofInput.cpp
HEADERS += src/input/Mouse6dofInput.h
LIBS += -L/usr/local/lib/ -lxdrvlib
INCLUDEPATH *= /usr/local/include
DEFINES += MOUSE_ENABLED_LINUX \
ParameterCheck # Hack: Has to be defined for magellan usage
}
}
# Support for Windows systems
# You have to install the official 3DxWare driver for Windows to use the 3D mouse support on Windows systems!
win32-msvc2008|win32-msvc2010 {
message("Including support for 3DxWare for Windows system.")
SOURCES += libs/thirdParty/3DMouse/win/MouseParameters.cpp \
......
......@@ -9,7 +9,18 @@
#include "Mouse6dofInput.h"
#include "UAS.h"
#include "UASManager.h"
#include "QMessageBox"
#ifdef MOUSE_ENABLED_LINUX
#include <QX11Info>
#include <X11/Xlib.h>
#undef Success // Eigen library doesn't work if Success is defined
extern "C"
{
#include "xdrvlib.h"
}
#endif // MOUSE_ENABLED_LINUX
#ifdef MOUSE_ENABLED_WIN
Mouse6dofInput::Mouse6dofInput(Mouse3DInput* mouseInput) :
mouse3DMax(0.075), // TODO: check maximum value fot plugged device
uas(NULL),
......@@ -30,6 +41,74 @@ Mouse6dofInput::Mouse6dofInput(Mouse3DInput* mouseInput) :
//connect(mouseInput, SIGNAL(On3dmouseKeyUp(int)), this, SLOT);
}
#endif //MOUSE_ENABLED_WIN
#ifdef MOUSE_ENABLED_LINUX
Mouse6dofInput::Mouse6dofInput(QWidget *parent) :
mouse3DMax(0.075), // TODO: check maximum value fot plugged device
uas(NULL),
done(false),
mouseActive(false),
xValue(0.0),
yValue(0.0),
zValue(0.0),
aValue(0.0),
bValue(0.0),
cValue(0.0)
{
}
#endif //MOUSE_ENABLED_LINUX
#ifdef MOUSE_ENABLED_LINUX
void Mouse6dofInput::init3dMouse(QWidget* parent)
{
if (!mouseActive)
{
// // man visudo --> then you can omit giving password (success not guarantied..)
// qDebug() << "Starting 3DxWare Daemon for 3dConnexion 3dMouse";
// QString processProgramm = "gksudo";
// QStringList processArguments;
// processArguments << "/etc/3DxWare/daemon/3dxsrv -d usb";
// process3dxDaemon = new QProcess();
// process3dxDaemon->start(processProgramm, processArguments);
// // process3dxDaemon->waitForFinished();
// // {
// // qDebug() << "... continuing without 3DxWare. May not be initialized properly!";
// // qDebug() << "Try in terminal as user root:" << processArguments.last();
// // }
Display *display = QX11Info::display();
if(!display)
{
qDebug() << "Cannot open display!" << endl;
}
if ( !MagellanInit( display, winId() ) )
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("No 3DxWare driver is running."));
msgBox.setInformativeText(tr("Enter in Terminal 'sudo /etc/3DxWare/daemon/3dxsrv -d usb'"));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
qDebug() << "No 3DxWare driver is running!";
return;
}
else
{
qDebug() << "Initialized 3dMouse";
mouseActive = true;
}
}
else
{
qDebug() << "3dMouse already initialized..";
}
}
#endif //MOUSE_ENABLED_LINUX
Mouse6dofInput::~Mouse6dofInput()
{
......
......@@ -10,7 +10,9 @@
#define MOUSE6DOFINPUT_H
#include <QThread>
#ifdef MOUSE_ENABLED_WIN
#include "Mouse3DInput.h"
#endif //MOUSE_ENABLED_WIN
#include "UASInterface.h"
......@@ -19,7 +21,14 @@ class Mouse6dofInput : public QThread
Q_OBJECT
public:
#ifdef MOUSE_ENABLED_WIN
Mouse6dofInput(Mouse3DInput* mouseInput);
#endif //MOUSE_ENABLED_WIN
#ifdef MOUSE_ENABLED_LINUX
Mouse6dofInput(QWidget* parent);
void init3dMouse(QWidget* parent);
#endif //MOUSE_ENABLED_LINUX
~Mouse6dofInput();
void run();
......@@ -28,7 +37,6 @@ public:
protected:
void init();
Mouse3DInput* mouse3D;
UASInterface* uas;
bool done;
bool mouseActive;
......
......@@ -189,6 +189,12 @@ MainWindow::MainWindow(QWidget *parent):
mouse = new Mouse6dofInput(mouseInput);
#endif //MOUSE_ENABLED_WIN
#if MOUSE_ENABLED_LINUX
emit initStatusChanged("Initializing 3D mouse interface.");
mouse = new Mouse6dofInput(this);
#endif //MOUSE_ENABLED_LINUX
// Connect link
if (autoReconnect)
{
......@@ -1726,3 +1732,11 @@ QList<QAction*> MainWindow::listLinkMenuActions(void)
{
return ui.menuNetwork->actions();
}
#ifdef MOUSE_ENABLED_LINUX
bool MainWindow::x11Event(XEvent *event)
{
emit x11EventOccured(event);
qDebug("XEvent occured...");
}
#endif // MOUSE_ENABLED_LINUX
......@@ -54,8 +54,8 @@ This file is part of the QGROUNDCONTROL project
#include "HUD.h"
#include "JoystickWidget.h"
#include "input/JoystickInput.h"
#ifdef MOUSE_ENABLED_WIN
#include "input/Mouse6dofInput.h"
#if (defined MOUSE_ENABLED_WIN) | (defined MOUSE_ENABLED_LINUX)
#include "Mouse6dofInput.h"
#endif // MOUSE_ENABLED_WIN
#include "DebugConsole.h"
#include "ParameterInterface.h"
......@@ -235,6 +235,8 @@ public slots:
signals:
void initStatusChanged(const QString& message);
/** @brief Forward X11Event to catch 3DMouse inputs */
void x11EventOccured(XEvent *event);
public:
QGCMAVLinkLogPlayer* getLogPlayer()
......@@ -375,11 +377,17 @@ protected:
JoystickInput* joystick;
#ifdef MOUSE_ENABLED_WIN
/** 3d Mouse support (WIN only) **/
/** @brief 3d Mouse support (WIN only) */
Mouse3DInput* mouseInput; ///< 3dConnexion 3dMouse SDK
Mouse6dofInput* mouse; ///< Implementation for 3dMouse input
#endif // MOUSE_ENABLED_WIN
#ifdef MOUSE_ENABLED_LINUX
/** @brief Reimplementation of X11Event to handle 3dMouse Events (magellan) */
bool x11Event(XEvent *event);
Mouse6dofInput* mouse; ///< Implementation for 3dMouse input
#endif // MOUSE_ENABLED_LINUX
/** User interface actions **/
QAction* connectUASAct;
QAction* disconnectUASAct;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment