Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / gcscontrol / gcscontrolgadget.h
blob2a25bcef4bc5d628a1d88a4c8bff486552efbe65
1 /**
2 ******************************************************************************
4 * @file GCSControlgadget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
9 * @{
10 * @brief A gadget to control the UAV, either from the keyboard or a joystick
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef GCSControlGADGET_H_
29 #define GCSControlGADGET_H_
31 #include <coreplugin/iuavgadget.h>
32 #include "manualcontrolcommand.h"
33 #include "gcscontrolgadgetconfiguration.h"
34 #include "sdlgamepad/sdlgamepad.h"
35 #include <QTime>
36 #include "gcscontrolplugin.h"
37 #include <QUdpSocket>
38 #include <QHostAddress>
41 namespace Core {
42 class IUAVGadget;
44 // class QWidget;
45 // class QString;
46 class GCSControlGadgetWidget;
48 using namespace Core;
50 class GCSControlGadget : public Core::IUAVGadget {
51 Q_OBJECT
52 public:
53 GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent = 0, QObject *plugin = 0);
54 ~GCSControlGadget();
56 QList<int> context() const
58 return m_context;
60 QWidget *widget()
62 return m_widget;
64 QString contextHelpId() const
66 return QString();
69 void loadConfiguration(IUAVGadgetConfiguration *config);
71 private:
72 ManualControlCommand *getManualControlCommand();
73 double constrain(double value);
74 QTime joystickTime;
75 QWidget *m_widget;
76 QList<int> m_context;
77 UAVObject::Metadata mccInitialData;
78 int rollChannel;
79 int pitchChannel;
80 int yawChannel;
81 int throttleChannel;
82 int controlsMode;
83 buttonSettingsStruct buttonSettings[8];
84 double bound(double input);
85 double wrap(double input);
86 bool channelReverse[8];
87 QUdpSocket *control_sock;
90 signals:
91 void sticksChangedRemotely(double leftX, double leftY, double rightX, double rightY);
93 protected slots:
94 void manualControlCommandUpdated(UAVObject *);
95 void sticksChangedLocally(double leftX, double leftY, double rightX, double rightY);
96 void readUDPCommand();
98 // signals from joystick
99 void gamepads(quint8 count);
100 void buttonState(ButtonNumber number, bool pressed);
101 void axesValues(QListInt16 values);
105 #endif // GCSControlGADGET_H_