Commit c97b69b5 authored by Gregory Dymarek's avatar Gregory Dymarek

Activating Joystick module for all builds

parent f7ad3693
......@@ -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 \
......
......@@ -29,6 +29,7 @@
#include <QSettings>
#ifndef __mobile__
#define __sdljoystick__
#ifdef Q_OS_MAC
#include <SDL.h>
#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__
......@@ -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];
......
......@@ -27,6 +27,7 @@
#include <QQmlEngine>
#ifndef __mobile__
#define __sdljoystick__
#ifdef Q_OS_MAC
#include <SDL.h>
#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)
......
......@@ -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<ValuesWidgetController> ("QGroundControl.Controllers", 1, 0, "ValuesWidgetController");
qmlRegisterType<QGCMobileFileDialogController> ("QGroundControl.Controllers", 1, 0, "QGCMobileFileDialogController");
qmlRegisterType<RCChannelMonitorController> ("QGroundControl.Controllers", 1, 0, "RCChannelMonitorController");
qmlRegisterType<JoystickConfigController> ("QGroundControl.Controllers", 1, 0, "JoystickConfigController");
#ifndef __mobile__
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
qmlRegisterType<FirmwareUpgradeController> ("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
qmlRegisterType<JoystickConfigController> ("QGroundControl.Controllers", 1, 0, "JoystickConfigController");
qmlRegisterType<LogDownloadController> ("QGroundControl.Controllers", 1, 0, "LogDownloadController");
#endif
......
......@@ -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)
......
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