Commit c97b69b5 authored by Gregory Dymarek's avatar Gregory Dymarek

Activating Joystick module for all builds

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