Use std::vector to copy Spacemouse data from helper class to Application
This commit is contained in:
@@ -8,5 +8,5 @@
|
||||
GuiNativeEvent(const GuiNativeEvent&);
|
||||
GuiNativeEvent& operator=(const GuiNativeEvent&);
|
||||
GUIApplicationNativeEventAware *mainApp;
|
||||
static int motionDataArray[6];
|
||||
static std::vector<int>motionDataArray;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Implementation by Torsten Sadowski 2018
|
||||
|
||||
#include <spnav.h>
|
||||
|
||||
int Gui::GuiNativeEvent::motionDataArray[6];
|
||||
std::vector<int> Gui::GuiNativeEvent::motionDataArray(6,0);
|
||||
|
||||
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
|
||||
: QObject(app)
|
||||
@@ -57,7 +57,7 @@ void Gui::GuiNativeEvent::pollSpacenav()
|
||||
motionDataArray[3] = -ev.motion.rx;
|
||||
motionDataArray[4] = -ev.motion.rz;
|
||||
motionDataArray[5] = -ev.motion.ry;
|
||||
mainApp->postMotionEvent(&motionDataArray[0]);
|
||||
mainApp->postMotionEvent(motionDataArray);
|
||||
break;
|
||||
}
|
||||
case SPNAV_EVENT_BUTTON:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GUINATIVEEVENT_H
|
||||
#define GUINATIVEEVENT_H
|
||||
|
||||
#include <vector>
|
||||
#include <QObject>
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
@@ -32,7 +32,7 @@ Implementation by Torsten Sadowski 2018
|
||||
#undef Complex
|
||||
#endif // #if QT_VERSION >= 0x050000
|
||||
|
||||
int Gui::GuiNativeEvent::motionDataArray[6];
|
||||
std::vector<int> Gui::GuiNativeEvent::motionDataArray(6,0);
|
||||
|
||||
Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
|
||||
: QObject(app)
|
||||
@@ -117,7 +117,7 @@ bool Gui::GuiNativeEvent::xcbEventFilter(void *xcb_void, long* result)
|
||||
motionDataArray[4] = -navEvent.motion.rz;
|
||||
motionDataArray[5] = -navEvent.motion.ry;
|
||||
|
||||
inst->postMotionEvent(&motionDataArray[0]);
|
||||
inst->postMotionEvent(motionDataArray);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ bool Gui::GuiNativeEvent::x11EventFilter(XEvent *event)
|
||||
nMotionEvents--;
|
||||
if (nMotionEvents == 0)
|
||||
{
|
||||
mainApp->postMotionEvent(&motionDataArray[0]);
|
||||
mainApp->postMotionEvent(motionDataArray);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GUINATIVEEVENT_H
|
||||
#define GUINATIVEEVENT_H
|
||||
|
||||
#include <vector>
|
||||
#include <QObject>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
|
||||
@@ -15,7 +15,7 @@ with special thanks to marcxs for making the first steps
|
||||
#include <FCConfig.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
int Gui::GuiNativeEvent::motionDataArray[6];
|
||||
std::vector<int> Gui::GuiNativeEvent::motionDataArray(6,0);
|
||||
|
||||
UInt16 Gui::GuiNativeEvent::tdxClientID = 0;
|
||||
uint32_t Gui::GuiNativeEvent::lastButtons = 0;
|
||||
@@ -61,7 +61,7 @@ uint32_t Gui::GuiNativeEvent::lastButtons = 0;
|
||||
motionDataArray[3] = -msg->axis[3];
|
||||
motionDataArray[4] = msg->axis[4];
|
||||
motionDataArray[5] = msg->axis[5];
|
||||
inst->postMotionEvent(&motionDataArray[0]);
|
||||
inst->postMotionEvent(motionDataArray);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GUINATIVEEVENT_H
|
||||
#define GUINATIVEEVENT_H
|
||||
|
||||
#include <vector>
|
||||
#include <QObject>
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
@@ -28,6 +28,7 @@ http://www.3dconnexion.com/forum/viewtopic.php?f=19&t=4968&sid=72c018bdcf0e6edc9
|
||||
#include "GuiRawInputEventFilter.h"
|
||||
#endif // #if QT_VERSION >= 0x050000
|
||||
|
||||
std::vector<int> Gui::GuiNativeEvent::motionDataArray(6,0);
|
||||
Gui::GuiNativeEvent* Gui::GuiNativeEvent::gMouseInput = 0;
|
||||
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object,
|
||||
return true;
|
||||
}
|
||||
|
||||
void Gui::GUIApplicationNativeEventAware::postMotionEvent(int *const motionDataArray)
|
||||
void Gui::GUIApplicationNativeEventAware::postMotionEvent(std::vector<int> motionDataArray)
|
||||
{
|
||||
auto currentWidget(focusWidget());
|
||||
if (!currentWidget) {
|
||||
@@ -148,7 +148,7 @@ float Gui::GUIApplicationNativeEventAware::convertPrefToSensitivity(int value)
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::GUIApplicationNativeEventAware::importSettings(int *const motionDataArray)
|
||||
void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motionDataArray)
|
||||
{
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define GUIAPPLICATIONNATIVEEVENTAWARE_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <vector>
|
||||
|
||||
class QMainWindow;
|
||||
|
||||
@@ -44,11 +45,11 @@ namespace Gui
|
||||
bool isSpaceballPresent() const {return spaceballPresent;}
|
||||
void setSpaceballPresent(bool present) {spaceballPresent = present;}
|
||||
bool processSpaceballEvent(QObject *object, QEvent *event);
|
||||
void postMotionEvent(int *const motionDataArray);
|
||||
void postMotionEvent(std::vector<int> motionDataArray);
|
||||
void postButtonEvent(int buttonNumber, int buttonPress);
|
||||
private:
|
||||
bool spaceballPresent;
|
||||
void importSettings(int *const motionDataArray);
|
||||
void importSettings(std::vector<int>& motionDataArray);
|
||||
float convertPrefToSensitivity(int value);
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
GuiNativeEvent *nativeEvent;
|
||||
|
||||
Reference in New Issue
Block a user