1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GCS Control plugin: now fully configurable (mode 1 to mode 4), and with joystick channel mapping as well. Not tested in-flight!

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2093 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-11-07 22:16:45 +00:00 committed by edouard
parent d826350b26
commit 3c4a5a04c0
11 changed files with 302 additions and 144 deletions

View File

@ -26,13 +26,15 @@
*/
#include "gcscontrolgadget.h"
#include "gcscontrolgadgetwidget.h"
#include "gcscontrolgadgetconfiguration.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include <QDebug>
#define JOYSTICK_UPDATE_RATE 50
GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent) :
GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent, QObject *plugin) :
IUAVGadget(classId, parent),
m_widget(widget)
{
@ -42,17 +44,12 @@ GCSControlGadget::GCSControlGadget(QString classId, GCSControlGadgetWidget *widg
manualControlCommandUpdated(getManualControlCommand());
connect(this, SIGNAL(aboutToQuit()), &sdlGamepad, SLOT(quit()));
if(sdlGamepad.init()) {
joystickTime.start();
sdlGamepad.start();
qRegisterMetaType<QListInt16>("QListInt16");
qRegisterMetaType<ButtonNumber>("ButtonNumber");
joystickTime.start();
GCSControlPlugin *pl = dynamic_cast<GCSControlPlugin*>(plugin);
connect(pl->sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8)));
connect(pl->sdlGamepad,SIGNAL(buttonState(ButtonNumber,bool)),this,SLOT(buttonState(ButtonNumber,bool)));
connect(pl->sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16)));
connect(&sdlGamepad,SIGNAL(gamepads(quint8)),this,SLOT(gamepads(quint8)));
connect(&sdlGamepad,SIGNAL(buttonState(ButtonNumber,bool)),this,SLOT(buttonState(ButtonNumber,bool)));
connect(&sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16)));
}
}
GCSControlGadget::~GCSControlGadget()
@ -62,10 +59,16 @@ GCSControlGadget::~GCSControlGadget()
void GCSControlGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
GCSControlGadgetConfiguration *GCSControlConfig = qobject_cast< GCSControlGadgetConfiguration*>(config);
QList<int> ql = GCSControlConfig->getChannelsMapping();
rollChannel = ql.at(0);
pitchChannel = ql.at(1);
yawChannel = ql.at(2);
throttleChannel = ql.at(3);
controlsMode = GCSControlConfig->getControlsMode();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
}
ManualControlCommand* GCSControlGadget::getManualControlCommand() {
@ -79,9 +82,30 @@ void GCSControlGadget::manualControlCommandUpdated(UAVObject * obj) {
double pitch = obj->getField("Pitch")->getDouble();
double yaw = obj->getField("Yaw")->getDouble();
double throttle = obj->getField("Throttle")->getDouble();
emit sticksChangedRemotely(yaw,-pitch,roll,throttle);
// Remap RPYT to left X/Y and right X/Y depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
emit sticksChangedRemotely(yaw,pitch,roll,throttle);
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
emit sticksChangedRemotely(yaw,throttle,roll,pitch);
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
emit sticksChangedRemotely(roll,pitch,yaw,throttle);
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
emit sticksChangedRemotely(roll,throttle,yaw,pitch);
break;
}
}
/**
Update the manual commands - maps depending on mode
*/
void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double rightX, double rightY) {
ManualControlCommand * obj = getManualControlCommand();
double oldRoll = obj->getField("Roll")->getDouble();
@ -89,10 +113,42 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r
double oldYaw = obj->getField("Yaw")->getDouble();
double oldThrottle = obj->getField("Throttle")->getDouble();
double newRoll = rightX;
double newPitch = -leftY;
double newYaw = leftX;
double newThrottle = rightY;
double newRoll;
double newPitch;
double newYaw;
double newThrottle;
// Remap left X/Y and right X/Y to RPYT depending on mode
switch (controlsMode) {
case 1:
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
newRoll = rightX;
newPitch = leftY;
newYaw = leftX;
newThrottle = rightY;
break;
case 2:
// Mode 2: LeftX = Yaw, LeftY = Throttle, RightX = Roll, RightY = Pitch
newRoll = rightX;
newPitch = rightY;
newYaw = leftX;
newThrottle = leftY;
break;
case 3:
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
newRoll = leftX;
newPitch = leftY;
newYaw = rightX;
newThrottle = rightY;
break;
case 4:
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
newRoll = leftX;
newPitch = rightY;
newYaw = rightX;
newThrottle = leftY;
break;
}
if((newThrottle != oldThrottle) || (newPitch != oldPitch) || (newYaw != oldYaw) || (newRoll != oldRoll)) {
obj->getField("Roll")->setDouble(newRoll);
@ -105,8 +161,8 @@ void GCSControlGadget::sticksChangedLocally(double leftX, double leftY, double r
void GCSControlGadget::gamepads(quint8 count)
{
sdlGamepad.setGamepad(0);
sdlGamepad.setTickRate(JOYSTICK_UPDATE_RATE);
// sdlGamepad.setGamepad(0);
// sdlGamepad.setTickRate(JOYSTICK_UPDATE_RATE);
}
void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
@ -115,13 +171,38 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
void GCSControlGadget::axesValues(QListInt16 values)
{
double leftX = values[0];
double leftY = values[1];
double rightX = values[2];
double rightY = values[3];
int chMax = values.length();
if (rollChannel > chMax || pitchChannel > chMax ||
yawChannel > chMax || throttleChannel > chMax ) {
qDebug() << "GCSControl: configuration is inconsistent with current joystick! Aborting update.";
return;
}
double rValue = (rollChannel > -1) ? values[rollChannel] : 0;
double pValue = (pitchChannel > -1) ? values[pitchChannel] : 0;
double yValue = (yawChannel > -1) ? values[yawChannel] : 0;
double tValue = (throttleChannel > -1) ? values[throttleChannel] : 0;
double max = 32767;
if(joystickTime.elapsed() > JOYSTICK_UPDATE_RATE) {
joystickTime.restart();
sticksChangedLocally(leftX/max,-leftY/max,rightX/max,-rightY/max);
// Remap RPYT to left X/Y and right X/Y depending on mode
// Mode 1: LeftX = Yaw, LeftY = Pitch, RightX = Roll, RightY = Throttle
// Mode 2: LeftX = Yaw, LeftY = THrottle, RightX = Roll, RightY = Pitch
// Mode 3: LeftX = Roll, LeftY = Pitch, RightX = Yaw, RightY = Throttle
// Mode 4: LeftX = Roll, LeftY = Throttle, RightX = Yaw, RightY = Pitch;
switch (controlsMode) {
case 1:
sticksChangedLocally(yValue/max,-pValue/max,rValue/max,-tValue/max);
break;
case 2:
sticksChangedLocally(yValue/max,-tValue/max,rValue/max,-pValue/max);
break;
case 3:
sticksChangedLocally(rValue/max,-pValue/max,yValue/max,-tValue/max);
break;
case 4:
sticksChangedLocally(rValue/max,-tValue/max,yValue/max,-pValue/max);
break;
}
}
}

View File

@ -32,6 +32,7 @@
#include <uavobjects/manualcontrolcommand.h>
#include "sdlgamepad/sdlgamepad.h"
#include <QTime>
#include "gcscontrolplugin.h"
namespace Core {
class IUAVGadget;
@ -46,7 +47,7 @@ class GCSControlGadget : public Core::IUAVGadget
{
Q_OBJECT
public:
GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent = 0);
GCSControlGadget(QString classId, GCSControlGadgetWidget *widget, QWidget *parent = 0, QObject *plugin=0);
~GCSControlGadget();
QList<int> context() const { return m_context; }
@ -57,11 +58,15 @@ public:
private:
ManualControlCommand* getManualControlCommand();
SDLGamepad sdlGamepad;
QTime joystickTime;
QWidget *m_widget;
QList<int> m_context;
UAVObject::Metadata mccInitialData;
int rollChannel;
int pitchChannel;
int yawChannel;
int throttleChannel;
int controlsMode;
signals:
void sticksChangedRemotely(double leftX, double leftY, double rightX, double rightY);

View File

@ -32,42 +32,38 @@
*
*/
GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
IUAVGadgetConfiguration(classId, parent),
rollChannel(-1),
pitchChannel(-1),
yawChannel(-1),
throttleChannel(-1)
{
//if a saved configuration exists load it
if(qSettings != 0) {
/*
BaudRateType speed;
DataBitsType databits;
FlowType flow;
ParityType parity;
StopBitsType stopbits;
int ispeed = qSettings->value("defaultSpeed").toInt();
int idatabits = qSettings->value("defaultDataBits").toInt();
int iflow = qSettings->value("defaultFlow").toInt();
int iparity = qSettings->value("defaultParity").toInt();
int istopbits = qSettings->value("defaultStopBits").toInt();
QString port = qSettings->value("defaultPort").toString();
QString conMode = qSettings->value("connectionMode").toString();
databits = (DataBitsType) idatabits;
flow = (FlowType)iflow;
parity = (ParityType)iparity;
stopbits = (StopBitsType)istopbits;
speed = (BaudRateType)ispeed;
m_defaultPort = port;
m_defaultSpeed = speed;
m_defaultDataBits = databits;
m_defaultFlow = flow;
m_defaultParity = parity;
m_defaultStopBits = stopbits;
m_connectionMode = conMode;
*/
controlsMode = qSettings->value("controlsMode").toInt();
rollChannel = qSettings->value("rollChannel").toInt();
pitchChannel = qSettings->value("pitchChannel").toInt();
yawChannel = qSettings->value("yawChannel").toInt();
throttleChannel = qSettings->value("throttleChannel").toInt();
}
}
void GCSControlGadgetConfiguration::setRPYTchannels(int roll, int pitch, int yaw, int throttle) {
rollChannel = roll;
pitchChannel = pitch;
yawChannel = yaw;
throttleChannel = throttle;
}
QList<int> GCSControlGadgetConfiguration::getChannelsMapping()
{
QList<int> ql;
ql << rollChannel << pitchChannel << yawChannel << throttleChannel;
return ql;
}
/**
* Clones a configuration.
*
@ -76,16 +72,12 @@ IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone()
{
GCSControlGadgetConfiguration *m = new GCSControlGadgetConfiguration(this->classId());
/*
m->controlsMode = controlsMode;
m->rollChannel = rollChannel;
m->pitchChannel = pitchChannel;
m->yawChannel = yawChannel;
m->throttleChannel = throttleChannel;
m->m_defaultSpeed = m_defaultSpeed;
m->m_defaultDataBits = m_defaultDataBits;
m->m_defaultFlow = m_defaultFlow;
m->m_defaultParity = m_defaultParity;
m->m_defaultStopBits = m_defaultStopBits;
m->m_defaultPort = m_defaultPort;
m->m_connectionMode = m_connectionMode;
*/
return m;
}
@ -94,13 +86,9 @@ IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone()
*
*/
void GCSControlGadgetConfiguration::saveConfig(QSettings* settings) const {
/*
settings->setValue("defaultSpeed", m_defaultSpeed);
settings->setValue("defaultDataBits", m_defaultDataBits);
settings->setValue("defaultFlow", m_defaultFlow);
settings->setValue("defaultParity", m_defaultParity);
settings->setValue("defaultStopBits", m_defaultStopBits);
settings->setValue("defaultPort", m_defaultPort);
settings->setValue("connectionMode", m_connectionMode);
*/
settings->setValue("controlsMode", controlsMode);
settings->setValue("rollChannel", rollChannel);
settings->setValue("pitchChannel", pitchChannel);
settings->setValue("yawChannel", yawChannel);
settings->setValue("throttleChannel", throttleChannel);
}

View File

@ -38,43 +38,24 @@ class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration
public:
explicit GCSControlGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
/*
void setConnectionMode(QString mode) { m_connectionMode = mode; }
QString connectionMode() { return m_connectionMode; }
void setControlsMode(int mode) { controlsMode = mode; }
void setRPYTchannels(int roll, int pitch, int yaw, int throttle);
int getControlsMode() { return controlsMode; }
QList<int> getChannelsMapping();
//set port configuration functions
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;}
void setFlow(FlowType flow) {m_defaultFlow=flow;}
void setParity(ParityType parity) {m_defaultParity=parity;}
void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;}
void setPort(QString port){m_defaultPort=port;}
void setTimeOut(long timeout){m_defaultTimeOut=timeout;}
//get port configuration functions
QString port(){return m_defaultPort;}
BaudRateType speed() {return m_defaultSpeed;}
FlowType flow() {return m_defaultFlow;}
DataBitsType dataBits() {return m_defaultDataBits;}
StopBitsType stopBits() {return m_defaultStopBits;}
ParityType parity() {return m_defaultParity;}
long timeOut(){return m_defaultTimeOut;}
*/
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone();
private:
/*
QString m_connectionMode;
QString m_defaultPort;
BaudRateType m_defaultSpeed;
DataBitsType m_defaultDataBits;
FlowType m_defaultFlow;
ParityType m_defaultParity;
StopBitsType m_defaultStopBits;
long m_defaultTimeOut;
*/
int controlsMode; // Mode1 to Mode4
// Joystick mappings for roll/pitch/yaw/throttle:
int rollChannel;
int pitchChannel;
int yawChannel;
int throttleChannel;
};

View File

@ -43,7 +43,7 @@ GCSControlGadgetFactory::~GCSControlGadgetFactory()
IUAVGadget* GCSControlGadgetFactory::createGadget(QWidget *parent) {
GCSControlGadgetWidget* gadgetWidget = new GCSControlGadgetWidget(parent);
return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent);
return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent, this->parent());
}
IUAVGadgetConfiguration *GCSControlGadgetFactory::createConfiguration(QSettings* qSettings)
@ -53,7 +53,7 @@ IUAVGadgetConfiguration *GCSControlGadgetFactory::createConfiguration(QSettings*
IOptionsPage *GCSControlGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new GCSControlGadgetOptionsPage(qobject_cast<GCSControlGadgetConfiguration*>(config));
return new GCSControlGadgetOptionsPage(qobject_cast<GCSControlGadgetConfiguration*>(config), this->parent());
}

View File

@ -37,7 +37,47 @@ GCSControlGadgetOptionsPage::GCSControlGadgetOptionsPage(GCSControlGadgetConfigu
IOptionsPage(parent),
m_config(config)
{
options_page = NULL;
sdlGamepad = dynamic_cast<GCSControlPlugin*>(parent)->sdlGamepad;
}
GCSControlGadgetOptionsPage::~GCSControlGadgetOptionsPage()
{
}
void GCSControlGadgetOptionsPage::buttonState(ButtonNumber number, bool pressed)
{
}
void GCSControlGadgetOptionsPage::gamepads(quint8 count)
{
}
void GCSControlGadgetOptionsPage::axesValues(QListInt16 values)
{
if (options_page) {
QList<QProgressBar*> pbList;
pbList << options_page->joyCh0 <<
options_page->joyCh1 << options_page->joyCh2 <<
options_page->joyCh3 << options_page->joyCh4 <<
options_page->joyCh5 << options_page->joyCh6 <<
options_page->joyCh7;
int i=0;
foreach (qint16 value, values) {
if (i>7) break; // We only support 7 channels
if (pbList.at(i)->minimum() > value)
pbList.at(i)->setMinimum(value);
if (pbList.at(i)->maximum() < value)
pbList.at(i)->setMaximum(value);
pbList.at(i++)->setValue(value);
}
}
}
@ -48,6 +88,31 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent)
QWidget *optionsPageWidget = new QWidget;
options_page->setupUi(optionsPageWidget);
QList<QComboBox*> chList;
chList << options_page->channel0 << options_page->channel1 <<
options_page->channel2 << options_page->channel3 <<
options_page->channel4 << options_page->channel5 <<
options_page->channel6 << options_page->channel7;
QStringList chOptions;
chOptions << "None" << "Roll" << "Pitch" << "Yaw" << "Throttle";
foreach (QComboBox* qb, chList) {
qb->addItems(chOptions);
}
// Controls mode are from 1 to 4.
if (m_config->getControlsMode()>0 && m_config->getControlsMode() < 5)
options_page->controlsMode->setCurrentIndex(m_config->getControlsMode()-1);
else
qDebug() << "GCSControl: Invalid control modes setting! Did you edit by hand?";
QList<int> ql = m_config->getChannelsMapping();
for (int i=0; i<4; i++) {
if (ql.at(i) > -1)
chList.at(ql.at(i))->setCurrentIndex(i+1);
}
connect(sdlGamepad,SIGNAL(axesValues(QListInt16)),this,SLOT(axesValues(QListInt16)));
return optionsPageWidget;
}
@ -59,10 +124,36 @@ QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent)
*/
void GCSControlGadgetOptionsPage::apply()
{
m_config->setControlsMode(options_page->controlsMode->currentIndex()+1);
QList<QComboBox*> chList;
chList << options_page->channel0 << options_page->channel1 <<
options_page->channel2 << options_page->channel3 <<
options_page->channel4 << options_page->channel5 <<
options_page->channel6 << options_page->channel7;
int roll=-1 , pitch=-1, yaw=-1, throttle=-1;
for (int i=0; i<chList.length(); i++) {
switch (chList.at(i)->currentIndex()) {
case 1:
roll = i;
break;
case 2:
pitch =i;
break;
case 3:
yaw = i;
break;
case 4:
throttle = i;
break;
}
}
m_config->setRPYTchannels(roll,pitch,yaw,throttle);
}
void GCSControlGadgetOptionsPage::finish()
{
disconnect(sdlGamepad,0,this,0);
delete options_page;
options_page = NULL;
}

View File

@ -29,8 +29,8 @@
#define GCSCONTROLGADGETOPTIONSPAGE_H
#include "coreplugin/dialogs/ioptionspage.h"
#include "QString"
#include <QStringList>
#include "gcscontrolplugin.h"
#include "sdlgamepad/sdlgamepad.h"
#include <QDebug>
namespace Core {
@ -50,6 +50,7 @@ class GCSControlGadgetOptionsPage : public IOptionsPage
Q_OBJECT
public:
explicit GCSControlGadgetOptionsPage(GCSControlGadgetConfiguration *config, QObject *parent = 0);
~GCSControlGadgetOptionsPage();
QWidget *createPage(QWidget *parent);
void apply();
@ -58,20 +59,14 @@ public:
private:
Ui::GCSControlGadgetOptionsPage *options_page;
GCSControlGadgetConfiguration *m_config;
SDLGamepad *sdlGamepad;
/*
QStringList BaudRateTypeString;
QStringList BaudRateTypeStringALL;
QStringList DataBitsTypeStringALL;
QStringList ParityTypeStringALL;
QStringList StopBitsTypeStringALL;
QStringList DataBitsTypeString;
QStringList ParityTypeString;
QStringList StopBitsTypeString;
QStringList FlowTypeString;
*/
protected slots:
// signals from joystick
void gamepads(quint8 count);
void buttonState(ButtonNumber number, bool pressed);
void axesValues(QListInt16 values);
private slots:
};
#endif // GCSCONTROLGADGETOPTIONSPAGE_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>587</width>
<height>359</height>
<height>379</height>
</rect>
</property>
<property name="sizePolicy">
@ -36,7 +36,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="connectionMode">
<widget class="QComboBox" name="controlsMode">
<item>
<property name="text">
<string>Mode 1</string>
@ -81,8 +81,11 @@
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Define the external input device you want to use here.</string>
<string>Only joystick is implemented at this stage, so this control is disabled.</string>
</property>
<item>
<property name="text">
@ -110,7 +113,7 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage2" native="true">
<widget class="QWidget" name="tabWidgetPage2">
<attribute name="title">
<string>Joystick</string>
</attribute>
@ -121,7 +124,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QComboBox" name="comboBox_2"/>
<widget class="QComboBox" name="channel0"/>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="checkBox">
@ -138,77 +141,77 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="comboBox_3"/>
<widget class="QComboBox" name="channel1"/>
</item>
<item row="4" column="0">
<widget class="QComboBox" name="comboBox_4"/>
<widget class="QComboBox" name="channel2"/>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="comboBox_5"/>
<widget class="QComboBox" name="channel3"/>
</item>
<item row="6" column="0">
<widget class="QComboBox" name="comboBox_6"/>
<widget class="QComboBox" name="channel4"/>
</item>
<item row="7" column="0">
<widget class="QComboBox" name="comboBox_7"/>
<widget class="QComboBox" name="channel5"/>
</item>
<item row="8" column="0">
<widget class="QComboBox" name="comboBox_8"/>
<widget class="QComboBox" name="channel6"/>
</item>
<item row="9" column="0">
<widget class="QComboBox" name="comboBox_9"/>
<widget class="QComboBox" name="channel7"/>
</item>
<item row="3" column="1">
<widget class="QProgressBar" name="progressBar">
<widget class="QProgressBar" name="joyCh1">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QProgressBar" name="progressBar_2">
<widget class="QProgressBar" name="joyCh0">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QProgressBar" name="progressBar_3">
<widget class="QProgressBar" name="joyCh2">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QProgressBar" name="progressBar_4">
<widget class="QProgressBar" name="joyCh3">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="progressBar_5">
<widget class="QProgressBar" name="joyCh4">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QProgressBar" name="progressBar_6">
<widget class="QProgressBar" name="joyCh5">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QProgressBar" name="progressBar_7">
<widget class="QProgressBar" name="joyCh6">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QProgressBar" name="progressBar_8">
<widget class="QProgressBar" name="joyCh7">
<property name="value">
<number>24</number>
</property>
@ -267,7 +270,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage3" native="true">
<widget class="QWidget" name="tabWidgetPage3">
<attribute name="title">
<string>Audio</string>
</attribute>

View File

@ -78,7 +78,11 @@ GCSControlGadgetWidget::~GCSControlGadgetWidget()
// Do nothing
}
void GCSControlGadgetWidget::updateSticks(double leftX, double leftY, double rightX, double rightY) {
void GCSControlGadgetWidget::updateSticks(double nleftX, double nleftY, double nrightX, double nrightY) {
leftX = nleftX;
leftY = nleftY;
rightX = nrightX;
rightY = nrightY;
m_gcscontrol->widgetLeftStick->changePosition(leftX,leftY);
m_gcscontrol->widgetRightStick->changePosition(rightX,rightY);
}

View File

@ -46,6 +46,12 @@ bool GCSControlPlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
sdlGamepad = new SDLGamepad();
if(sdlGamepad->init()) {
sdlGamepad->start();
qRegisterMetaType<QListInt16>("QListInt16");
qRegisterMetaType<ButtonNumber>("ButtonNumber");
}
mf = new GCSControlGadgetFactory(this);
addAutoReleasedObject(mf);

View File

@ -29,19 +29,23 @@
#define GCSControlPLUGIN_H_
#include <extensionsystem/iplugin.h>
#include "sdlgamepad/sdlgamepad.h"
class GCSControlGadgetFactory;
class GCSControlPlugin : public ExtensionSystem::IPlugin
{
public:
GCSControlPlugin();
GCSControlPlugin();
~GCSControlPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
SDLGamepad *sdlGamepad;
private:
GCSControlGadgetFactory *mf;
};
#endif /* GCSControlPLUGIN_H_ */