From 0d3c67078529cebf6f09b5262bfafe7b64d55ece Mon Sep 17 00:00:00 2001 From: Torsten Sadowski Date: Tue, 6 Nov 2018 22:16:34 +0100 Subject: [PATCH] Use std::vector to copy Spacemouse data from helper class to Application --- src/Gui/3Dconnexion/GuiNativeEventCommon.h | 2 +- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 4 ++-- src/Gui/3Dconnexion/GuiNativeEventLinux.h | 1 + src/Gui/3Dconnexion/GuiNativeEventLinuxX11.cpp | 6 +++--- src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h | 1 + src/Gui/3Dconnexion/GuiNativeEventMac.cpp | 4 ++-- src/Gui/3Dconnexion/GuiNativeEventMac.h | 1 + src/Gui/3Dconnexion/GuiNativeEventWin32.cpp | 1 + src/Gui/GuiApplicationNativeEventAware.cpp | 4 ++-- src/Gui/GuiApplicationNativeEventAware.h | 5 +++-- 10 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Gui/3Dconnexion/GuiNativeEventCommon.h b/src/Gui/3Dconnexion/GuiNativeEventCommon.h index fb17f65e0b..acf901059e 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventCommon.h +++ b/src/Gui/3Dconnexion/GuiNativeEventCommon.h @@ -8,5 +8,5 @@ GuiNativeEvent(const GuiNativeEvent&); GuiNativeEvent& operator=(const GuiNativeEvent&); GUIApplicationNativeEventAware *mainApp; - static int motionDataArray[6]; + static std::vectormotionDataArray; diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp index 4099928285..eb3f607d1d 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp @@ -13,7 +13,7 @@ Implementation by Torsten Sadowski 2018 #include -int Gui::GuiNativeEvent::motionDataArray[6]; +std::vector 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: diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinux.h b/src/Gui/3Dconnexion/GuiNativeEventLinux.h index ad5161f9bf..f5621948c2 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinux.h +++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.h @@ -1,6 +1,7 @@ #ifndef GUINATIVEEVENT_H #define GUINATIVEEVENT_H +#include #include class QMainWindow; diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.cpp b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.cpp index 2a38e75252..02cce7b814 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.cpp @@ -32,7 +32,7 @@ Implementation by Torsten Sadowski 2018 #undef Complex #endif // #if QT_VERSION >= 0x050000 -int Gui::GuiNativeEvent::motionDataArray[6]; +std::vector 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; diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h index f6871aad63..1a0632e701 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h +++ b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h @@ -1,6 +1,7 @@ #ifndef GUINATIVEEVENT_H #define GUINATIVEEVENT_H +#include #include #if QT_VERSION >= 0x050000 diff --git a/src/Gui/3Dconnexion/GuiNativeEventMac.cpp b/src/Gui/3Dconnexion/GuiNativeEventMac.cpp index fd27ecd35e..45bcfc3e46 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventMac.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventMac.cpp @@ -15,7 +15,7 @@ with special thanks to marcxs for making the first steps #include #include -int Gui::GuiNativeEvent::motionDataArray[6]; +std::vector 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; } diff --git a/src/Gui/3Dconnexion/GuiNativeEventMac.h b/src/Gui/3Dconnexion/GuiNativeEventMac.h index 4710e4f36c..b6effb7b43 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventMac.h +++ b/src/Gui/3Dconnexion/GuiNativeEventMac.h @@ -1,6 +1,7 @@ #ifndef GUINATIVEEVENT_H #define GUINATIVEEVENT_H +#include #include class QMainWindow; diff --git a/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp b/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp index 468829cb16..12cffc8bf6 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventWin32.cpp @@ -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 Gui::GuiNativeEvent::motionDataArray(6,0); Gui::GuiNativeEvent* Gui::GuiNativeEvent::gMouseInput = 0; diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index 748bf8de04..8f6d134cd2 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -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 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& motionDataArray) { ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion"); diff --git a/src/Gui/GuiApplicationNativeEventAware.h b/src/Gui/GuiApplicationNativeEventAware.h index eac9f07adc..156a0f7504 100644 --- a/src/Gui/GuiApplicationNativeEventAware.h +++ b/src/Gui/GuiApplicationNativeEventAware.h @@ -26,6 +26,7 @@ #define GUIAPPLICATIONNATIVEEVENTAWARE_H #include +#include 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 motionDataArray); void postButtonEvent(int buttonNumber, int buttonPress); private: bool spaceballPresent; - void importSettings(int *const motionDataArray); + void importSettings(std::vector& motionDataArray); float convertPrefToSensitivity(int value); #if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND) GuiNativeEvent *nativeEvent;