From 1007cbd115b909ea902d3e4b94521ba8e7a2e103 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 12 Dec 2010 04:09:32 +0000 Subject: [PATCH] GCS Control - Joystick buttons can now toggle GCSControl. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2220 ebee16cc-31ac-478f-84a7-5cbb03baadba --- ground/src/plugins/gcscontrol/gcscontrolgadget.cpp | 3 +++ .../gcscontrol/gcscontrolgadgetoptionspage.cpp | 6 ++++++ .../plugins/gcscontrol/gcscontrolgadgetoptionspage.h | 2 ++ .../plugins/gcscontrol/gcscontrolgadgetoptionspage.ui | 7 ++++++- .../src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp | 11 +++++++++++ .../src/plugins/gcscontrol/gcscontrolgadgetwidget.h | 2 ++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp index 2c67db21a..a465f1b2c 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -247,6 +247,9 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed) } break; case 2://GCS Control + bool currentCGSControl = ((GCSControlGadgetWidget *)m_widget)->getGCSControl(); + ((GCSControlGadgetWidget *)m_widget)->setGCSControl(!currentCGSControl); + break; } diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp index 6e4f6c938..ad0bf9a34 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp @@ -71,6 +71,11 @@ void GCSControlGadgetOptionsPage::buttonState(ButtonNumber number, bool pressed) void GCSControlGadgetOptionsPage::gamepads(quint8 count) { + /*options_page->AvailableControllerList->clear(); + for (int i=0;iAvailableControllerList->addItem(QString().sprintf("%d",i));//SDL_JoystickName(i)); + }*/ } @@ -202,6 +207,7 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent) connect(sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16))); connect(sdlGamepad,SIGNAL(buttonState(ButtonNumber,bool)),this,SLOT(buttonState(ButtonNumber,bool))); + connect(sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8))); return optionsPageWidget; } diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h index 5355cd2fc..a0e469a3a 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h @@ -31,6 +31,8 @@ #include "coreplugin/dialogs/ioptionspage.h" #include "gcscontrolplugin.h" #include "sdlgamepad/sdlgamepad.h" +#include + #include #include #include diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui index 6dee5ce9b..260aa4e04 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui @@ -122,8 +122,13 @@ - false + true + + + Default + + diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp index cb710cbd0..95bcdd484 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.cpp @@ -157,7 +157,18 @@ void GCSControlGadgetWidget::selectFlightMode(int state) obj->updated(); } +void GCSControlGadgetWidget::setGCSControl(bool newState) +{ + m_gcscontrol->checkBoxGcsControl->setChecked(newState); +}; +bool GCSControlGadgetWidget::getGCSControl(void) +{ + return m_gcscontrol->checkBoxGcsControl->isChecked(); +}; + + /** * @} * @} */ + diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h index 6bd54a8d7..99d4f50e8 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetwidget.h @@ -40,6 +40,8 @@ class GCSControlGadgetWidget : public QLabel public: GCSControlGadgetWidget(QWidget *parent = 0); ~GCSControlGadgetWidget(); + void setGCSControl(bool newState); + bool getGCSControl(void); signals: void sticksChanged(double leftX, double leftY, double rightX, double rightY);