diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 895ca89e0a7b46996c48d3f825cafe18ca0808e5..8dbedee403b7e57c34ce4f9b0034d60dba2e8621 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -265,6 +265,7 @@ HEADERS += \ src/HomePositionManager.h \ src/Joystick/Joystick.h \ src/Joystick/JoystickManager.h \ + src/VehicleSetup/JoystickConfigController.h \ src/FollowMe/FollowMe.h \ src/JsonHelper.h \ src/LogCompressor.h \ @@ -387,7 +388,6 @@ HEADERS += \ src/GPS/GPSManager.h \ src/GPS/GPSPositionMessage.h \ src/GPS/GPSProvider.h \ - src/VehicleSetup/JoystickConfigController.h \ src/ViewWidgets/CustomCommandWidget.h \ src/ViewWidgets/CustomCommandWidgetController.h \ src/ViewWidgets/LogDownload.h \ @@ -420,6 +420,7 @@ SOURCES += \ src/HomePositionManager.cc \ src/Joystick/Joystick.cc \ src/Joystick/JoystickManager.cc \ + src/VehicleSetup/JoystickConfigController.cc \ src/JsonHelper.cc \ src/FollowMe/FollowMe.cc \ src/LogCompressor.cc \ @@ -526,7 +527,6 @@ SOURCES += \ src/GPS/RTCM/RTCMMavlink.cc \ src/GPS/GPSManager.cc \ src/GPS/GPSProvider.cc \ - src/VehicleSetup/JoystickConfigController.cc \ src/ViewWidgets/CustomCommandWidget.cc \ src/ViewWidgets/CustomCommandWidgetController.cc \ src/ViewWidgets/LogDownload.cc \ diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index 37d6140f24f0cbc518f81cef3ce2d36d30976cbb..f499e8366c4d5b6b686b4c18506904ea2bedece9 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -29,6 +29,7 @@ #include #ifndef __mobile__ + #define __sdljoystick__ #ifdef Q_OS_MAC #include #else @@ -52,7 +53,6 @@ const char* Joystick::_rgFunctionSettingsKey[Joystick::maxFunction] = { }; Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int sdlIndex, MultiVehicleManager* multiVehicleManager) -#ifndef __mobile__ : _sdlIndex(sdlIndex) , _exitThread(false) , _name(name) @@ -68,15 +68,8 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int sdlI , _activeVehicle(NULL) , _pollingStartedForCalibration(false) , _multiVehicleManager(multiVehicleManager) -#endif // __mobile__ { -#ifdef __mobile__ - Q_UNUSED(name) - Q_UNUSED(axisCount) - Q_UNUSED(buttonCount) - Q_UNUSED(sdlIndex) - Q_UNUSED(multiVehicleManager) -#else + _rgAxisValues = new int[_axisCount]; _rgCalibration = new Calibration_t[_axisCount]; _rgButtonValues = new bool[_buttonCount]; @@ -90,20 +83,17 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int sdlI } _loadSettings(); -#endif // __mobile __ + } Joystick::~Joystick() { -#ifndef __mobile__ delete _rgAxisValues; delete _rgCalibration; delete _rgButtonValues; delete _rgButtonActions; -#endif } -#ifndef __mobile__ void Joystick::_loadSettings(void) { @@ -257,6 +247,7 @@ float Joystick::_adjustRange(int value, Calibration_t calibration) void Joystick::run(void) { +#ifdef __sdljoystick__ SDL_Joystick* sdlJoystick = SDL_JoystickOpen(_sdlIndex); if (!sdlJoystick) { @@ -363,6 +354,7 @@ void Joystick::run(void) } SDL_JoystickClose(sdlJoystick); +#endif } void Joystick::startPolling(Vehicle* vehicle) @@ -579,4 +571,3 @@ bool Joystick::_validButton(int button) return button >= 0 && button < _buttonCount; } -#endif // __mobile__ diff --git a/src/Joystick/Joystick.h b/src/Joystick/Joystick.h index c26752ff81cc50c9566c08cdceb9e400b53625b2..6eb2d405796081cbf5e711879de3a6f0dcbedc01 100644 --- a/src/Joystick/Joystick.h +++ b/src/Joystick/Joystick.h @@ -63,7 +63,6 @@ public: ThrottleModeMax } ThrottleMode_t; -#ifndef __mobile__ Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(bool calibrated MEMBER _calibrated NOTIFY calibratedChanged) @@ -174,7 +173,6 @@ private: bool _pollingStartedForCalibration; MultiVehicleManager* _multiVehicleManager; -#endif // __mobile__ private: static const char* _rgFunctionSettingsKey[maxFunction]; diff --git a/src/Joystick/JoystickManager.cc b/src/Joystick/JoystickManager.cc index 70defba4065ee9d2efa5c147d8052500c15418c2..ae16d0a895cd5b3330b59f2ca87181b93a1823cf 100644 --- a/src/Joystick/JoystickManager.cc +++ b/src/Joystick/JoystickManager.cc @@ -27,6 +27,7 @@ #include #ifndef __mobile__ + #define __sdljoystick__ #ifdef Q_OS_MAC #include #else @@ -55,7 +56,7 @@ void JoystickManager::setToolbox(QGCToolbox *toolbox) QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); -#ifndef __mobile__ +#ifdef __sdljoystick__ if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0) { qWarning() << "Couldn't initialize SimpleDirectMediaLayer:" << SDL_GetError(); return; @@ -95,7 +96,6 @@ void JoystickManager::setToolbox(QGCToolbox *toolbox) void JoystickManager::_setActiveJoystickFromSettings(void) { -#ifndef __mobile__ QSettings settings; settings.beginGroup(_settingsGroup); @@ -107,7 +107,6 @@ void JoystickManager::_setActiveJoystickFromSettings(void) setActiveJoystick(_name2JoystickMap.value(name, _name2JoystickMap.first())); settings.setValue(_settingsKeyActiveJoystick, _activeJoystick->name()); -#endif } Joystick* JoystickManager::activeJoystick(void) @@ -117,9 +116,6 @@ Joystick* JoystickManager::activeJoystick(void) void JoystickManager::setActiveJoystick(Joystick* joystick) { -#ifdef __mobile__ - Q_UNUSED(joystick) -#else QSettings settings; if (!_name2JoystickMap.contains(joystick->name())) { @@ -138,7 +134,6 @@ void JoystickManager::setActiveJoystick(Joystick* joystick) emit activeJoystickChanged(_activeJoystick); emit activeJoystickNameChanged(_activeJoystick->name()); -#endif } QVariantList JoystickManager::joysticks(void) @@ -159,11 +154,7 @@ QStringList JoystickManager::joystickNames(void) QString JoystickManager::activeJoystickName(void) { -#ifdef __mobile__ - return QString(); -#else return _activeJoystick ? _activeJoystick->name() : QString(); -#endif } void JoystickManager::setActiveJoystickName(const QString& name) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 3a12a5c90afa6a251430f2ee44c2085442f45d97..17df42f9ea6535fa44b709555c87f61eaeb49727 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -103,6 +103,7 @@ #include "PX4AirframeLoader.h" #include "ValuesWidgetController.h" #include "AppMessages.h" +#include "JoystickConfigController.h" #ifndef __ios__ #include "SerialLink.h" @@ -112,7 +113,6 @@ #include "QGCFileDialog.h" #include "QGCMessageBox.h" #include "FirmwareUpgradeController.h" - #include "JoystickConfigController.h" #include "MainWindow.h" #endif @@ -459,12 +459,11 @@ void QGCApplication::_initCommon(void) qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ValuesWidgetController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "QGCMobileFileDialogController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "RCChannelMonitorController"); - + qmlRegisterType ("QGroundControl.Controllers", 1, 0, "JoystickConfigController"); #ifndef __mobile__ qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController"); - qmlRegisterType ("QGroundControl.Controllers", 1, 0, "JoystickConfigController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "LogDownloadController"); #endif diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 0c062ae11dbd61a1639172a05fca22327e7612c4..05132aa20f0e27adc0faeaae84e7a00a7bdfc151 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -1095,7 +1095,6 @@ void Vehicle::setJoystickEnabled(bool enabled) void Vehicle::_startJoystick(bool start) { -#ifndef __mobile__ Joystick* joystick = _joystickManager->activeJoystick(); if (joystick) { if (start) { @@ -1106,9 +1105,6 @@ void Vehicle::_startJoystick(bool start) joystick->stopPolling(); } } -#else - Q_UNUSED(start); -#endif } bool Vehicle::active(void)