kopia lustrzana https://gitlab.com/eliggett/wfview
Support multiple USB controllers
rodzic
f3a25fade4
commit
792fac11d6
|
@ -7,65 +7,36 @@ controllerSetup::controllerSetup(QWidget* parent) :
|
|||
ui(new Ui::controllerSetup)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
scene = new controllerScene();
|
||||
connect(scene, SIGNAL(mousePressed(QPoint)), this, SLOT(mousePressed(QPoint)));
|
||||
ui->graphicsView->setScene(scene);
|
||||
ui->qkBrightCombo->setVisible(false);
|
||||
ui->qkOrientCombo->setVisible(false);
|
||||
ui->qkSpeedCombo->setVisible(false);
|
||||
ui->qkColorButton->setVisible(false);
|
||||
ui->qkTimeoutSpin->setVisible(false);
|
||||
ui->qkTimeoutLabel->setVisible(false);
|
||||
textItem = scene->addText("No USB controller found");
|
||||
textItem->setDefaultTextColor(Qt::gray);
|
||||
ui->tabWidget->clear();
|
||||
ui->tabWidget->hide();
|
||||
noControllersText = new QLabel("No USB controller found");
|
||||
noControllersText->setStyleSheet("QLabel { color : gray; }");
|
||||
ui->hboxLayout->addWidget(noControllersText);
|
||||
this->resize(this->sizeHint());
|
||||
}
|
||||
|
||||
controllerSetup::~controllerSetup()
|
||||
{
|
||||
/*
|
||||
// Remove any existing button text:
|
||||
for (QGraphicsItem* item : scene->items())
|
||||
{
|
||||
QGraphicsTextItem* txt = qgraphicsitem_cast<QGraphicsTextItem*>(item);
|
||||
if (!txt || txt == textItem)
|
||||
continue;
|
||||
scene->removeItem(txt);
|
||||
delete txt;
|
||||
}
|
||||
|
||||
if (onEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(onEventProxy);
|
||||
onEventProxy = Q_NULLPTR;
|
||||
delete onEventProxy;
|
||||
delete onEvent;
|
||||
onEvent = Q_NULLPTR;
|
||||
}
|
||||
|
||||
if (offEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(offEventProxy);
|
||||
offEventProxy = Q_NULLPTR;
|
||||
delete offEventProxy;
|
||||
delete offEvent;
|
||||
offEvent = Q_NULLPTR;
|
||||
}
|
||||
|
||||
if (knobEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(knobEventProxy);
|
||||
knobEventProxy = Q_NULLPTR;
|
||||
delete knobEventProxy;
|
||||
delete knobEvent;
|
||||
knobEvent = Q_NULLPTR;
|
||||
}
|
||||
*/
|
||||
|
||||
if (bgImage != Q_NULLPTR) {
|
||||
scene->removeItem(bgImage);
|
||||
delete bgImage;
|
||||
bgImage = Q_NULLPTR;
|
||||
}
|
||||
|
||||
delete textItem;
|
||||
delete scene;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void controllerSetup::mousePressed(QPoint p)
|
||||
void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
|
||||
{
|
||||
// Receive mouse event from the scene
|
||||
qDebug() << "Looking for button Point x=" << p.x() << " y=" << p.y();
|
||||
|
@ -79,9 +50,11 @@ void controllerSetup::mousePressed(QPoint p)
|
|||
QMutexLocker locker(mutex);
|
||||
|
||||
|
||||
|
||||
for (BUTTON& b : *buttons)
|
||||
{
|
||||
if (b.dev == currentDevice && b.pos.contains(p))
|
||||
|
||||
if (ui->tabWidget->currentWidget()->objectName() == b.devicePath && b.pos.contains(p))
|
||||
{
|
||||
found = true;
|
||||
currentButton = &b;
|
||||
|
@ -106,7 +79,7 @@ void controllerSetup::mousePressed(QPoint p)
|
|||
if (!found) {
|
||||
for (KNOB& k : *knobs)
|
||||
{
|
||||
if (k.dev == currentDevice && k.pos.contains(p))
|
||||
if (ui->tabWidget->currentWidget()->objectName() == k.devicePath && k.pos.contains(p))
|
||||
{
|
||||
found = true;
|
||||
currentKnob = &k;
|
||||
|
@ -123,7 +96,25 @@ void controllerSetup::mousePressed(QPoint p)
|
|||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if(found)
|
||||
{
|
||||
found=false;
|
||||
foreach (QGraphicsItem *item, scene->items())
|
||||
{
|
||||
QGraphicsProxyWidget *node = dynamic_cast<QGraphicsProxyWidget *>(item);
|
||||
if (node) {
|
||||
found=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
scene->addItem(offEvent->graphicsProxyWidget());
|
||||
scene->addItem(onEvent->graphicsProxyWidget());
|
||||
scene->addItem(knobEvent->graphicsProxyWidget());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onEvent->hide();
|
||||
offEvent->hide();
|
||||
knobEvent->hide();
|
||||
|
@ -140,7 +131,7 @@ void controllerSetup::onEventIndexChanged(int index) {
|
|||
currentButton->onText->setPos(currentButton->pos.center().x() - currentButton->onText->boundingRect().width() / 2,
|
||||
(currentButton->pos.center().y() - currentButton->onText->boundingRect().height() / 2)-6);
|
||||
// Signal that any button programming on the device should be completed.
|
||||
emit programButton(currentButton->num, currentButton->onCommand->text);
|
||||
emit programButton(currentButton->devicePath,currentButton->num, currentButton->onCommand->text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +159,33 @@ void controllerSetup::knobEventIndexChanged(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void controllerSetup::removeDevice(USBDEVICE* dev)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut)
|
||||
int remove = -1;
|
||||
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
auto widget = ui->tabWidget->widget(i);
|
||||
if (widget->objectName() == dev->path) {
|
||||
qDeleteAll(widget->findChildren<QWidget *>("", Qt::FindDirectChildrenOnly));
|
||||
remove = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove != -1) {
|
||||
qInfo(logUsbControl()) << "Removing tab" << dev->product;
|
||||
ui->tabWidget->removeTab(remove);
|
||||
}
|
||||
if (ui->tabWidget->count() == 0)
|
||||
{
|
||||
ui->tabWidget->hide();
|
||||
noControllersText->show();
|
||||
this->adjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut)
|
||||
{
|
||||
buttons = but;
|
||||
knobs = kb;
|
||||
|
@ -178,100 +194,141 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
// Remove any existing button text:
|
||||
for (QGraphicsItem* item : scene->items())
|
||||
noControllersText->hide();
|
||||
QWidget* tab = new QWidget();
|
||||
tab->setObjectName(dev->path);
|
||||
QWidget* widget = new QWidget(tab);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(widget);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
QGraphicsView *view = new QGraphicsView(widget);
|
||||
layout->addWidget(view);
|
||||
|
||||
QHBoxLayout* senslayout = new QHBoxLayout(widget);
|
||||
layout->addLayout(senslayout);
|
||||
QLabel* senslabel = new QLabel("Sensitivity");
|
||||
senslayout->addWidget(senslabel);
|
||||
QSlider *sens = new QSlider(widget);
|
||||
sens->setMinimum(1);
|
||||
sens->setMaximum(21);
|
||||
sens->setOrientation(Qt::Horizontal);
|
||||
sens->setInvertedAppearance(true);
|
||||
senslayout->addWidget(sens);
|
||||
sens->setValue(cntrl->sensitivity);
|
||||
connect(sens, &QSlider::valueChanged,
|
||||
[dev,this](int val) { this->sensitivityMoved(dev->path,val); });
|
||||
|
||||
if (dev->usbDevice == QuickKeys)
|
||||
{
|
||||
QGraphicsTextItem* txt = qgraphicsitem_cast<QGraphicsTextItem*>(item);
|
||||
if (!txt || txt==textItem)
|
||||
continue;
|
||||
scene->removeItem(txt);
|
||||
delete txt;
|
||||
// Add QuickKeys section
|
||||
|
||||
QGridLayout* grid = new QGridLayout(widget);
|
||||
layout->addLayout(grid);
|
||||
QLabel* brightlabel = new QLabel("Brightness");
|
||||
grid->addWidget(brightlabel,0,0);
|
||||
QComboBox *brightness = new QComboBox(widget);
|
||||
brightness->addItem("Off");
|
||||
brightness->addItem("Low");
|
||||
brightness->addItem("Medium");
|
||||
brightness->addItem("High");
|
||||
brightness->setCurrentIndex(cntrl->brightness);
|
||||
grid->addWidget(brightness,1,0);
|
||||
connect(brightness, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[dev,this](int index) { this->brightnessChanged(dev->path,index); });
|
||||
|
||||
QLabel* speedlabel = new QLabel("Speed");
|
||||
grid->addWidget(speedlabel,0,1);
|
||||
QComboBox *speed = new QComboBox(widget);
|
||||
speed->addItem("Fastest");
|
||||
speed->addItem("Faster");
|
||||
speed->addItem("Normal");
|
||||
speed->addItem("Slower");
|
||||
speed->addItem("Slowest");
|
||||
speed->setCurrentIndex(cntrl->speed);
|
||||
grid->addWidget(speed,1,1);
|
||||
connect(speed, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[dev,this](int index) { this->speedChanged(dev->path,index); });
|
||||
|
||||
QLabel* orientlabel = new QLabel("Orientation");
|
||||
grid->addWidget(orientlabel,0,2);
|
||||
QComboBox *orientation = new QComboBox(widget);
|
||||
orientation->addItem("Rotate 0");
|
||||
orientation->addItem("Rotate 90");
|
||||
orientation->addItem("Rotate 180");
|
||||
orientation->addItem("Rotate 270");
|
||||
orientation->setCurrentIndex(cntrl->orientation);
|
||||
grid->addWidget(orientation,1,2);
|
||||
connect(orientation, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
[dev,this](int index) { this->orientationChanged(dev->path,index); });
|
||||
|
||||
QLabel* colorlabel = new QLabel("Dial Color");
|
||||
grid->addWidget(colorlabel,0,3);
|
||||
QPushButton* color = new QPushButton("Select");
|
||||
grid->addWidget(color,1,3);
|
||||
connect(color, &QPushButton::clicked,
|
||||
[dev,this]() { this->colorPicker(dev->path); });
|
||||
|
||||
QLabel* timeoutlabel = new QLabel("Timeout");
|
||||
grid->addWidget(timeoutlabel,0,4);
|
||||
QSpinBox *timeout = new QSpinBox(widget);
|
||||
timeout->setValue(cntrl->timeout);
|
||||
grid->addWidget(timeout,1,4);
|
||||
connect(timeout, qOverload<int>(&QSpinBox::valueChanged),
|
||||
[dev,this](int index) { this->timeoutChanged(dev->path,index); });
|
||||
|
||||
// Finally update the device with the default values
|
||||
emit programSensitivity(dev->path, cntrl->sensitivity);
|
||||
emit programBrightness(dev->path,cntrl->brightness);
|
||||
emit programOrientation(dev->path,cntrl->orientation);
|
||||
emit programSpeed(dev->path,cntrl->speed);
|
||||
emit programTimeout(dev->path,cntrl->timeout);
|
||||
emit programWheelColour(dev->path, cntrl->color.red(), cntrl->color.green(), cntrl->color.blue());
|
||||
}
|
||||
|
||||
if (bgImage != Q_NULLPTR) {
|
||||
scene->removeItem(bgImage);
|
||||
delete bgImage;
|
||||
bgImage = Q_NULLPTR;
|
||||
}
|
||||
if (onEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(onEventProxy);
|
||||
onEventProxy = Q_NULLPTR;
|
||||
delete onEvent;
|
||||
onEvent = Q_NULLPTR;
|
||||
}
|
||||
if (offEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(offEventProxy);
|
||||
offEventProxy = Q_NULLPTR;
|
||||
delete offEvent;
|
||||
offEvent = Q_NULLPTR;
|
||||
}
|
||||
if (knobEventProxy != Q_NULLPTR) {
|
||||
scene->removeItem(knobEventProxy);
|
||||
knobEventProxy = Q_NULLPTR;
|
||||
delete knobEvent;
|
||||
knobEvent = Q_NULLPTR;
|
||||
}
|
||||
QLabel *helpText = new QLabel(widget);
|
||||
helpText->setText("<p><b>Button configuration:</b> Right-click on each button to configure it.</p><p>Top selection is command to send when button is pressed and bottom is (optional) command to send when button is released.</p>");
|
||||
helpText->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(helpText);
|
||||
|
||||
QImage image;
|
||||
|
||||
switch (devType) {
|
||||
switch (dev->usbDevice) {
|
||||
case shuttleXpress:
|
||||
image.load(":/resources/shuttlexpress.png");
|
||||
deviceName = "shuttleXpress";
|
||||
break;
|
||||
case shuttlePro2:
|
||||
image.load(":/resources/shuttlepro.png");
|
||||
deviceName = "shuttlePro2";
|
||||
break;
|
||||
case RC28:
|
||||
image.load(":/resources/rc28.png");
|
||||
deviceName = "RC28";
|
||||
break;
|
||||
case xBoxGamepad:
|
||||
image.load(":/resources/xbox.png");
|
||||
deviceName = "XBox";
|
||||
break;
|
||||
case eCoderPlus:
|
||||
image.load(":/resources/ecoder.png");
|
||||
deviceName = "eCoderPlus";
|
||||
break;
|
||||
case QuickKeys:
|
||||
image.load(":/resources/quickkeys.png");
|
||||
deviceName = "QuickKeys";
|
||||
break;
|
||||
default:
|
||||
textItem->show();
|
||||
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
|
||||
//ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
|
||||
this->adjustSize();
|
||||
break;
|
||||
}
|
||||
|
||||
textItem->hide();
|
||||
bgImage = new QGraphicsPixmapItem(QPixmap::fromImage(image));
|
||||
|
||||
QGraphicsItem* bgImage = new QGraphicsPixmapItem(QPixmap::fromImage(image));
|
||||
view->setMinimumSize(bgImage->boundingRect().width() + 2, bgImage->boundingRect().height() + 2);
|
||||
this->setMinimumSize(bgImage->boundingRect().width() + 370, bgImage->boundingRect().height() + 250);
|
||||
controllerScene * scene = new controllerScene();
|
||||
view->setScene(scene);
|
||||
connect(scene, SIGNAL(mousePressed(controllerScene *,QPoint)), this, SLOT(mousePressed(controllerScene *,QPoint)));
|
||||
scene->addItem(bgImage);
|
||||
|
||||
ui->graphicsView->setMinimumSize(bgImage->boundingRect().width() + 100, bgImage->boundingRect().height() + 2);
|
||||
currentDevice = devType;
|
||||
ui->tabWidget->addTab(tab,dev->product);
|
||||
ui->tabWidget->show();
|
||||
|
||||
if (currentDevice == QuickKeys) {
|
||||
ui->qkBrightCombo->setVisible(true);
|
||||
ui->qkOrientCombo->setVisible(true);
|
||||
ui->qkSpeedCombo->setVisible(true);
|
||||
ui->qkColorButton->setVisible(true);
|
||||
ui->qkTimeoutSpin->setVisible(true);
|
||||
ui->qkTimeoutLabel->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->qkBrightCombo->setVisible(false);
|
||||
ui->qkOrientCombo->setVisible(false);
|
||||
ui->qkSpeedCombo->setVisible(false);
|
||||
ui->qkColorButton->setVisible(false);
|
||||
ui->qkTimeoutSpin->setVisible(false);
|
||||
ui->qkTimeoutLabel->setVisible(false);
|
||||
}
|
||||
|
||||
if (currentDevice != usbNone)
|
||||
if (dev->usbDevice != usbNone)
|
||||
{
|
||||
offEvent = new QComboBox;
|
||||
onEvent = new QComboBox;
|
||||
|
@ -320,13 +377,13 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
for (BUTTON& b : *buttons)
|
||||
{
|
||||
|
||||
if (b.dev == currentDevice) {
|
||||
if (b.devicePath == dev->path) {
|
||||
b.onText = new QGraphicsTextItem(b.onCommand->text);
|
||||
b.onText->setDefaultTextColor(b.textColour);
|
||||
scene->addItem(b.onText);
|
||||
b.onText->setPos(b.pos.center().x() - b.onText->boundingRect().width() / 2,
|
||||
(b.pos.center().y() - b.onText->boundingRect().height() / 2) - 6);
|
||||
emit programButton(b.num, b.onCommand->text); // Program the button with ontext if supported
|
||||
emit programButton(b.devicePath,b.num, b.onCommand->text); // Program the button with ontext if supported
|
||||
|
||||
b.offText = new QGraphicsTextItem(b.offCommand->text);
|
||||
b.offText->setDefaultTextColor(b.textColour);
|
||||
|
@ -340,7 +397,7 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
|
||||
for (KNOB& k : *knobs)
|
||||
{
|
||||
if (k.dev == currentDevice) {
|
||||
if (k.devicePath == dev->path) {
|
||||
k.text = new QGraphicsTextItem(k.command->text);
|
||||
k.text->setDefaultTextColor(k.textColour);
|
||||
scene->addItem(k.text);
|
||||
|
@ -348,74 +405,59 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
|||
(k.pos.center().y() - k.text->boundingRect().height() / 2));
|
||||
}
|
||||
}
|
||||
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
|
||||
ui->graphicsView->resize(ui->graphicsView->sizeHint());
|
||||
//this->resize(this->sizeHint());
|
||||
this->adjustSize();
|
||||
view->setSceneRect(scene->itemsBoundingRect());
|
||||
|
||||
// Add comboboxes to scene after everything else.
|
||||
offEventProxy = scene->addWidget(offEvent);
|
||||
connect(offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
|
||||
onEventProxy = scene->addWidget(onEvent);
|
||||
connect(onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
|
||||
knobEventProxy = scene->addWidget(knobEvent);
|
||||
connect(knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
|
||||
|
||||
if (currentDevice == QuickKeys) {
|
||||
// Finally update the device with the default values
|
||||
emit programBrightness((quint8)ui->qkBrightCombo->currentIndex() - 1);
|
||||
emit programOrientation((quint8)ui->qkOrientCombo->currentIndex());
|
||||
emit programSpeed((quint8)ui->qkSpeedCombo->currentIndex());
|
||||
emit programTimeout((quint8)ui->qkTimeoutSpin->value());
|
||||
emit programWheelColour((quint8)initialColor.red(), (quint8)initialColor.green(), (quint8)initialColor.blue());
|
||||
}
|
||||
onEventProxy = new QGraphicsProxyWidget();
|
||||
onEventProxy->setWidget(onEvent);
|
||||
offEventProxy = new QGraphicsProxyWidget();
|
||||
offEventProxy->setWidget(offEvent);
|
||||
knobEventProxy = new QGraphicsProxyWidget();
|
||||
knobEventProxy->setWidget(knobEvent);
|
||||
|
||||
this->adjustSize();
|
||||
//QTimer::singleShot(0, this, [this,view]() {this->resize(view->minimumSizeHint());});
|
||||
}
|
||||
|
||||
|
||||
numTabs++;
|
||||
|
||||
}
|
||||
|
||||
void controllerSetup::receiveSensitivity(int val)
|
||||
{
|
||||
ui->sensitivitySlider->blockSignals(true);
|
||||
ui->sensitivitySlider->setValue(val);
|
||||
ui->sensitivitySlider->blockSignals(false);
|
||||
//ui->sensitivitySlider->blockSignals(true);
|
||||
//ui->sensitivitySlider->setValue(val);
|
||||
// ui->sensitivitySlider->blockSignals(false);
|
||||
}
|
||||
|
||||
void controllerSetup::on_sensitivitySlider_valueChanged(int val)
|
||||
void controllerSetup::sensitivityMoved(QString path, int val)
|
||||
{
|
||||
emit sendSensitivity(val);
|
||||
qInfo(logUsbControl()) << "Setting sensitivity" << val <<"for device" << path;
|
||||
emit programSensitivity(path, val);
|
||||
}
|
||||
|
||||
void controllerSetup::on_qkBrightCombo_currentIndexChanged(int index)
|
||||
void controllerSetup::brightnessChanged(QString path, int index)
|
||||
{
|
||||
if (index) {
|
||||
emit programBrightness((quint8)index - 1);
|
||||
}
|
||||
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
|
||||
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
|
||||
emit programBrightness(path, (quint8)index);
|
||||
}
|
||||
|
||||
void controllerSetup::on_qkOrientCombo_currentIndexChanged(int index)
|
||||
void controllerSetup::orientationChanged(QString path, int index)
|
||||
{
|
||||
if (index) {
|
||||
emit programOrientation((quint8)index);
|
||||
emit programOverlay(3, QString("Orientation set to %0").arg(ui->qkOrientCombo->currentText()));
|
||||
}
|
||||
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
|
||||
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
|
||||
emit programOrientation(path, (quint8)index);
|
||||
}
|
||||
|
||||
void controllerSetup::on_qkSpeedCombo_currentIndexChanged(int index)
|
||||
void controllerSetup::speedChanged(QString path, int index)
|
||||
{
|
||||
if (index) {
|
||||
emit programSpeed((quint8)index);
|
||||
emit programOverlay(3, QString("Dial speed set to %0").arg(ui->qkSpeedCombo->currentText()));
|
||||
}
|
||||
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
|
||||
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
|
||||
emit programSpeed(path, (quint8)index);
|
||||
}
|
||||
|
||||
void controllerSetup::on_qkColorButton_clicked()
|
||||
void controllerSetup::colorPicker(QString path)
|
||||
{
|
||||
|
||||
QColorDialog::ColorDialogOptions options;
|
||||
options.setFlag(QColorDialog::ShowAlphaChannel, false);
|
||||
options.setFlag(QColorDialog::DontUseNativeDialog, false);
|
||||
|
@ -426,35 +468,12 @@ void controllerSetup::on_qkColorButton_clicked()
|
|||
selColor = initialColor;
|
||||
}
|
||||
initialColor = selColor;
|
||||
emit programWheelColour((quint8)selColor.red(), (quint8)selColor.green(), (quint8)initialColor.blue());
|
||||
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
|
||||
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
|
||||
emit programWheelColour(path, (quint8)selColor.red(), (quint8)selColor.green(), (quint8)initialColor.blue());
|
||||
}
|
||||
|
||||
void controllerSetup::on_qkTimeoutSpin_valueChanged(int arg1)
|
||||
void controllerSetup::timeoutChanged(QString path, int val)
|
||||
{
|
||||
emit programTimeout((quint8)arg1);
|
||||
emit programOverlay(3, QString("Sleep timeout set to %0 minutes").arg(arg1));
|
||||
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
|
||||
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
|
||||
emit programTimeout(path, (quint8)val);
|
||||
emit programOverlay(path, 3, QString("Sleep timeout set to %0 minutes").arg(val));
|
||||
}
|
||||
|
||||
void controllerSetup::setDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color)
|
||||
{
|
||||
ui->qkBrightCombo->blockSignals(true);
|
||||
ui->qkSpeedCombo->blockSignals(true);
|
||||
ui->qkOrientCombo->blockSignals(true);
|
||||
ui->qkTimeoutSpin->blockSignals(true);
|
||||
|
||||
ui->qkBrightCombo->setCurrentIndex((int)bright);
|
||||
ui->qkOrientCombo->setCurrentIndex((int)orient);
|
||||
ui->qkSpeedCombo->setCurrentIndex((int)speed);
|
||||
ui->qkTimeoutSpin->setValue((int)timeout);
|
||||
initialColor = color;
|
||||
|
||||
ui->qkBrightCombo->blockSignals(false);
|
||||
ui->qkSpeedCombo->blockSignals(false);
|
||||
ui->qkOrientCombo->blockSignals(false);
|
||||
ui->qkTimeoutSpin->blockSignals(false);
|
||||
|
||||
}
|
|
@ -14,14 +14,41 @@
|
|||
#include <QLabel>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QAbstractItemView>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QColorDialog>
|
||||
#include <QWidget>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "usbcontroller.h"
|
||||
|
||||
|
||||
class controllerScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
QGraphicsLineItem* item = Q_NULLPTR;
|
||||
|
||||
signals:
|
||||
void mousePressed(controllerScene* scene, QPoint p);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event) {
|
||||
|
||||
if (event->button() == Qt::RightButton)
|
||||
{
|
||||
emit mousePressed(this, event->scenePos().toPoint());
|
||||
}
|
||||
else
|
||||
{
|
||||
QGraphicsScene::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class controllerSetup;
|
||||
|
@ -36,43 +63,41 @@ public:
|
|||
~controllerSetup();
|
||||
|
||||
signals:
|
||||
void sendSensitivity(int val);
|
||||
void programButton(quint8 but, QString text);
|
||||
void programBrightness(quint8 level);
|
||||
void programWheelColour(quint8 r, quint8 g, quint8 b);
|
||||
void programOverlay(quint8 duration, QString text);
|
||||
void programOrientation(quint8 value);
|
||||
void programSpeed(quint8 value);
|
||||
void programTimeout(quint8 value);
|
||||
void updateSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
|
||||
void programButton(QString path, quint8 but, QString text);
|
||||
void programSensitivity(QString path, quint8 level);
|
||||
void programBrightness(QString path, quint8 level);
|
||||
void programWheelColour(QString path, quint8 r, quint8 g, quint8 b);
|
||||
void programOverlay(QString path, quint8 duration, QString text);
|
||||
void programOrientation(QString path, quint8 value);
|
||||
void programSpeed(QString path, quint8 value);
|
||||
void programTimeout(QString path, quint8 value);
|
||||
|
||||
public slots:
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
|
||||
void mousePressed(QPoint p);
|
||||
void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
|
||||
void removeDevice(USBDEVICE* dev);
|
||||
void mousePressed(controllerScene *scene,QPoint p);
|
||||
void onEventIndexChanged(int index);
|
||||
void offEventIndexChanged(int index);
|
||||
void knobEventIndexChanged(int index);
|
||||
void receiveSensitivity(int val);
|
||||
void on_sensitivitySlider_valueChanged(int val);
|
||||
void on_qkBrightCombo_currentIndexChanged(int index);
|
||||
void on_qkOrientCombo_currentIndexChanged(int index);
|
||||
void on_qkSpeedCombo_currentIndexChanged(int index);
|
||||
void on_qkColorButton_clicked();
|
||||
void on_qkTimeoutSpin_valueChanged(int arg1);
|
||||
void setDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
|
||||
void sensitivityMoved(QString path, int val);
|
||||
void brightnessChanged(QString path, int index);
|
||||
void orientationChanged(QString path, int index);
|
||||
void speedChanged(QString path, int index);
|
||||
void colorPicker(QString path);
|
||||
void timeoutChanged(QString path, int val);
|
||||
|
||||
private:
|
||||
|
||||
usbDeviceType usbDevice = usbNone;
|
||||
Ui::controllerSetup* ui;
|
||||
QGraphicsScene* scene;
|
||||
QGraphicsTextItem* textItem;
|
||||
QGraphicsItem* bgImage = Q_NULLPTR;
|
||||
QLabel* imgLabel;
|
||||
unsigned char currentDevice = 0;
|
||||
QVector<BUTTON>* buttons;
|
||||
QVector<KNOB>* knobs;
|
||||
QVector<COMMAND>* commands;
|
||||
usbMap* controllers;
|
||||
BUTTON* currentButton = Q_NULLPTR;
|
||||
KNOB* currentKnob = Q_NULLPTR;
|
||||
QComboBox* onEvent = Q_NULLPTR;
|
||||
|
@ -86,31 +111,32 @@ private:
|
|||
QString deviceName;
|
||||
QMutex* mutex;
|
||||
QColor initialColor = Qt::white;
|
||||
|
||||
QLabel* noControllersText;
|
||||
|
||||
int numTabs=0;
|
||||
|
||||
// Below are used for each tab:
|
||||
/*
|
||||
QList<QWidget *> tabs;
|
||||
QList<QVBoxLayout *> layouts;
|
||||
QList<QWidget *> widgets;
|
||||
QList<QGraphicsView *> graphicsViews;
|
||||
QList<QGraphicsScene*> scenes;
|
||||
QList<QGraphicsItem*> bgImages;
|
||||
QList<QSlider *>sensitivitys;
|
||||
|
||||
// Just used for QuickKeys device
|
||||
QList<QComboBox *>brightCombos;
|
||||
QList<QComboBox *>speedCombos;
|
||||
QList<QComboBox *>orientCombos;
|
||||
QList<QPushButton *>colorButtons;
|
||||
QList<QSpinBox *>timeoutSpins;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
||||
class controllerScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
QGraphicsLineItem* item = Q_NULLPTR;
|
||||
|
||||
signals:
|
||||
void mousePressed(QPoint p);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event) {
|
||||
|
||||
if (event->button() == Qt::RightButton)
|
||||
{
|
||||
emit mousePressed(event->scenePos().toPoint());
|
||||
}
|
||||
else
|
||||
{
|
||||
QGraphicsScene::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>442</width>
|
||||
<height>343</height>
|
||||
<width>788</width>
|
||||
<height>646</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Controller setup</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="7" column="0">
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
|
@ -60,196 +60,25 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QComboBox" name="qkBrightCombo">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Brightness</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Low</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Medium</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>High</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="qkSpeedCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Speed</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Fastest</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Faster</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Slower</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Slowest</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="qkOrientCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Orientation</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rotate 0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rotate 90</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rotate 180</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rotate 270</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="qkColorButton">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="qkTimeoutLabel">
|
||||
<property name="text">
|
||||
<string>Timeout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="qkTimeoutSpin">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Sensitivity</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="sensitivitySlider">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>21</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-weight:700;">Button configuration: </span>Right-click on each button to configure it.</p><p align="center">Top selection is command to send when button is pressed and bottom is (optional) command to send when button is released.</p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGraphicsView" name="graphicsView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Tab 2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
10
prefs.h
10
prefs.h
|
@ -2,9 +2,11 @@
|
|||
#define PREFS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <QColor>
|
||||
#include <QMap>
|
||||
#include "wfviewtypes.h"
|
||||
|
||||
|
||||
struct preferences {
|
||||
// Program:
|
||||
QString version;
|
||||
|
@ -46,12 +48,6 @@ struct preferences {
|
|||
bool niceTS;
|
||||
bool automaticSidebandSwitching = true;
|
||||
bool enableUSBControllers;
|
||||
int usbSensitivity;
|
||||
quint8 usbSpeed;
|
||||
quint8 usbTimeout;
|
||||
quint8 usbBrightness;
|
||||
quint8 usbOrientation;
|
||||
QColor usbColor;
|
||||
|
||||
// LAN:
|
||||
bool enableLAN;
|
||||
|
|
|
@ -872,6 +872,18 @@ void rigCommander::setDataMode(bool dataOn, unsigned char filter)
|
|||
prepDataAndSend(payload);
|
||||
}
|
||||
|
||||
void rigCommander::getFrequency(unsigned char vfo)
|
||||
{
|
||||
if (rigCaps.hasVFOAB || rigCaps.hasVFOMS)
|
||||
{
|
||||
QByteArray payload("\x25");
|
||||
payload.append(vfo);
|
||||
prepDataAndSend(payload);
|
||||
} else {
|
||||
getFrequency();
|
||||
}
|
||||
}
|
||||
|
||||
void rigCommander::getFrequency()
|
||||
{
|
||||
// figure out frequency and then respond with haveFrequency();
|
||||
|
@ -1675,11 +1687,9 @@ void rigCommander::parseCommand()
|
|||
parseFrequency();
|
||||
break;
|
||||
case '\x25':
|
||||
if((int)payloadIn[1] == 0)
|
||||
{
|
||||
emit haveFrequency(parseFrequency(payloadIn, 5));
|
||||
}
|
||||
break;
|
||||
// Parse both VFOs
|
||||
emit haveFrequency(parseFrequency(payloadIn, 5));
|
||||
break;
|
||||
case '\x01':
|
||||
//qInfo(logRig()) << "Have mode data";
|
||||
this->parseMode();
|
||||
|
@ -4591,6 +4601,7 @@ void rigCommander::parseFrequency()
|
|||
// payloadIn[01] = ; // . XX KHz
|
||||
|
||||
// printHex(payloadIn, false, true);
|
||||
|
||||
frequencyMhz = 0.0;
|
||||
if (payloadIn.length() == 7)
|
||||
{
|
||||
|
@ -4680,40 +4691,25 @@ freqt rigCommander::parseFrequency(QByteArray data, unsigned char lastPosition)
|
|||
// NOTE: This function was written on the IC-7300, which has no need for 100 MHz and 1 GHz.
|
||||
// Therefore, this function has to go to position +1 to retrieve those numbers for the IC-9700.
|
||||
|
||||
// TODO: 64-bit value is incorrect, multiplying by wrong numbers.
|
||||
|
||||
float freq = 0.0;
|
||||
|
||||
freqt freqs;
|
||||
freqs.MHzDouble = 0;
|
||||
freqs.Hz = 0;
|
||||
|
||||
// MHz:
|
||||
freq += 100*(data[lastPosition+1] & 0x0f);
|
||||
freq += (1000*((data[lastPosition+1] & 0xf0) >> 4));
|
||||
|
||||
freq += data[lastPosition] & 0x0f;
|
||||
freq += 10*((data[lastPosition] & 0xf0) >> 4);
|
||||
|
||||
freqs.Hz += (data[lastPosition] & 0x0f) * 1E6;
|
||||
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10; // 10 MHz
|
||||
|
||||
// Does Frequency contain 100 MHz/1 GHz data?
|
||||
if(data.length() >= lastPosition+1)
|
||||
{
|
||||
freqs.Hz += (data[lastPosition+1] & 0x0f) * 1E6 * 100; // 100 MHz
|
||||
freqs.Hz += ((data[lastPosition+1] & 0xf0) >> 4) * 1E6 * 1000; // 1000 MHz
|
||||
}
|
||||
|
||||
// Does Frequency contain VFO data? (\x25 command)
|
||||
if (lastPosition-4 >= 0 && (quint8)data[lastPosition-4] < 0x02 && (quint8)data[lastPosition-4] >= 0x00)
|
||||
{
|
||||
freqs.VFO=(selVFO_t)(quint8)data[lastPosition-4];
|
||||
}
|
||||
|
||||
// Hz:
|
||||
freq += ((data[lastPosition-1] & 0xf0) >>4)/10.0 ;
|
||||
freq += (data[lastPosition-1] & 0x0f) / 100.0;
|
||||
|
||||
freq += ((data[lastPosition-2] & 0xf0) >> 4) / 1000.0;
|
||||
freq += (data[lastPosition-2] & 0x0f) / 10000.0;
|
||||
|
||||
freq += ((data[lastPosition-3] & 0xf0) >> 4) / 100000.0;
|
||||
freq += (data[lastPosition-3] & 0x0f) / 1000000.0;
|
||||
freqs.Hz += (data[lastPosition] & 0x0f) * 1E6;
|
||||
freqs.Hz += ((data[lastPosition] & 0xf0) >> 4) * 1E6 * 10; // 10 MHz
|
||||
|
||||
freqs.Hz += (data[lastPosition-1] & 0x0f) * 10E3; // 10 KHz
|
||||
freqs.Hz += ((data[lastPosition-1] & 0xf0) >> 4) * 100E3; // 100 KHz
|
||||
|
|
|
@ -70,6 +70,7 @@ public slots:
|
|||
|
||||
// Frequency, Mode, BSR:
|
||||
void setFrequency(unsigned char vfo, freqt freq);
|
||||
void getFrequency(unsigned char vfo);
|
||||
void getFrequency();
|
||||
void selectVFO(vfo_t vfo);
|
||||
void equalizeVFOsAB();
|
||||
|
|
1493
usbcontroller.cpp
1493
usbcontroller.cpp
Plik diff jest za duży
Load Diff
126
usbcontroller.h
126
usbcontroller.h
|
@ -11,9 +11,12 @@
|
|||
#include <QColor>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QMutex>
|
||||
#include <QIODevice>
|
||||
#include <QtEndian>
|
||||
#include <QUuid>
|
||||
#include <QLabel>
|
||||
|
||||
#if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
#include <QGamepad>
|
||||
|
@ -53,10 +56,36 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define HIDDATALENGTH 64
|
||||
#define MAX_STR 255
|
||||
|
||||
struct USBDEVICE {
|
||||
usbDeviceType usbDevice = usbNone;
|
||||
bool connected = false;
|
||||
hid_device* handle = NULL;
|
||||
QString product = "";
|
||||
QString manufacturer = "";
|
||||
QString serial = "<none>";
|
||||
QString deviceId = "";
|
||||
QString path = "";
|
||||
quint16 vendorId = 0;
|
||||
quint16 productId = 0;
|
||||
int sensitivity = 1;
|
||||
unsigned char jogpos=0;
|
||||
unsigned char shutpos=0;
|
||||
unsigned char shutMult = 0;
|
||||
int jogCounter = 0;
|
||||
quint32 buttons = 0;
|
||||
quint32 knobs = 0;
|
||||
QList<int> knobValues;
|
||||
QList<quint8> knobSend;
|
||||
QTime lastusbController = QTime::currentTime();
|
||||
QByteArray lastData = QByteArray(8,0x0);
|
||||
unsigned char lastDialPos=0;
|
||||
QUuid uuid;
|
||||
|
||||
};
|
||||
|
||||
struct COMMAND {
|
||||
COMMAND() {}
|
||||
|
||||
|
@ -72,6 +101,7 @@ struct COMMAND {
|
|||
usbCommandType cmdType = commandButton;
|
||||
int command=0;
|
||||
unsigned char suffix=0x0;
|
||||
int value=0;
|
||||
availableBands band=bandGen;
|
||||
mode_kind mode=modeLSB;
|
||||
};
|
||||
|
@ -93,7 +123,9 @@ struct BUTTON {
|
|||
const COMMAND* offCommand = Q_NULLPTR;
|
||||
QGraphicsTextItem* onText;
|
||||
QGraphicsTextItem* offText;
|
||||
|
||||
QString on;
|
||||
QString off;
|
||||
QString devicePath;
|
||||
};
|
||||
|
||||
|
||||
|
@ -110,9 +142,21 @@ struct KNOB {
|
|||
QColor textColour;
|
||||
const COMMAND* command = Q_NULLPTR;
|
||||
QGraphicsTextItem* text;
|
||||
|
||||
QString cmd;
|
||||
QString devicePath;
|
||||
};
|
||||
|
||||
struct CONTROLLER {
|
||||
int sensitivity=1;
|
||||
quint8 speed=2;
|
||||
quint8 timeout=30;
|
||||
quint8 brightness=2;
|
||||
quint8 orientation=0;
|
||||
QColor color=Qt::white;
|
||||
};
|
||||
typedef QMap<QString,CONTROLLER> usbMap;
|
||||
|
||||
|
||||
#if defined(USB_CONTROLLER)
|
||||
class usbController : public QObject
|
||||
{
|
||||
|
@ -123,23 +167,20 @@ public:
|
|||
~usbController();
|
||||
|
||||
public slots:
|
||||
void init(int sens, QMutex *mut);
|
||||
void init(QMutex* mut,usbMap* prefs ,QVector<BUTTON>* buts,QVector<KNOB>* knobs);
|
||||
void run();
|
||||
void runTimer();
|
||||
void ledControl(bool on, unsigned char num);
|
||||
void receiveCommands(QVector<COMMAND>*);
|
||||
void receiveButtons(QVector<BUTTON>*);
|
||||
void receiveKnobs(QVector<KNOB>*);
|
||||
void receivePTTStatus(bool on);
|
||||
void getVersion();
|
||||
void receiveSensitivity(int val);
|
||||
void programButton(quint8 val, QString text);
|
||||
void programBrightness(quint8 val);
|
||||
void programOrientation(quint8 val);
|
||||
void programSpeed(quint8 val);
|
||||
void programWheelColour(quint8 r, quint8 g, quint8 b);
|
||||
void programOverlay(quint8 duration, QString text);
|
||||
void programTimeout(quint8 val);
|
||||
void programButton(QString path, quint8 val, QString text);
|
||||
void programSensitivity(QString path, quint8 val);
|
||||
void programBrightness(QString path, quint8 val);
|
||||
void programOrientation(QString path, quint8 val);
|
||||
void programSpeed(QString path, quint8 val);
|
||||
void programWheelColour(QString path, quint8 r, quint8 g, quint8 b);
|
||||
void programOverlay(QString path, quint8 duration, QString text);
|
||||
void programTimeout(QString path, quint8 val);
|
||||
|
||||
signals:
|
||||
void jogPlus();
|
||||
|
@ -148,48 +189,40 @@ signals:
|
|||
void doShuttle(bool plus, quint8 level);
|
||||
void setBand(int band);
|
||||
void button(const COMMAND* cmd);
|
||||
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
|
||||
void sendSensitivity(int val);
|
||||
void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
|
||||
void removeDevice(USBDEVICE* dev);
|
||||
|
||||
private:
|
||||
hid_device* handle=NULL;
|
||||
void loadButtons();
|
||||
void loadKnobs();
|
||||
void loadCommands();
|
||||
int hidStatus = 1;
|
||||
bool isOpen=false;
|
||||
quint32 buttons = 0;
|
||||
quint32 knobs = 0;
|
||||
unsigned char jogpos=0;
|
||||
unsigned char shutpos=0;
|
||||
unsigned char shutMult = 0;
|
||||
int jogCounter = 0;
|
||||
QTime lastusbController = QTime::currentTime();
|
||||
QByteArray lastData = QByteArray(8,0x0);
|
||||
unsigned char lastDialPos=0;
|
||||
int devicesConnected=0;
|
||||
QVector<BUTTON>* buttonList;
|
||||
QVector<KNOB>* knobList;
|
||||
QVector<COMMAND>* commands = Q_NULLPTR;
|
||||
QString product="";
|
||||
QString manufacturer="";
|
||||
QString serial="<none>";
|
||||
QString deviceId = "";
|
||||
QString path = "";
|
||||
quint16 vendorId = 0;
|
||||
quint16 productId = 0;
|
||||
int sensitivity = 1;
|
||||
QList<int> knobValues;
|
||||
QList<quint8> knobSend;
|
||||
QMutex* mutex=Q_NULLPTR;
|
||||
QColor currentColour;
|
||||
|
||||
QList<QVector<KNOB>*> deviceKnobs;
|
||||
QList<QVector<BUTTON>*> deviceButtons;
|
||||
|
||||
QVector<BUTTON> defaultButtons;
|
||||
QVector<KNOB> defaultKnobs;
|
||||
QVector<COMMAND> commands;
|
||||
QMap<QString,USBDEVICE> usbDevices;
|
||||
usbMap *controllers;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
|
||||
QGamepad* gamepad=Q_NULLPTR;
|
||||
#endif
|
||||
void buttonState(QString but, bool val);
|
||||
void buttonState(QString but, double val);
|
||||
usbDeviceType usbDevice = usbNone;
|
||||
QColor currentColour;
|
||||
|
||||
QMutex* mutex=Q_NULLPTR;
|
||||
|
||||
unsigned short knownUsbDevices[6][5] = {
|
||||
{shuttleXpress,0x0b33,0x0020,0x0000,0x0000},
|
||||
{shuttlePro2,0x0b33,0x0030,0x0000,0x0000},
|
||||
{RC28,0x0c26,0x001e,0x0004,0x0004},
|
||||
{RC28,0x0c26,0x001e,0x0000,0x0000},
|
||||
{eCoderPlus, 0x1fc9, 0x0003,0x0000,0x0000},
|
||||
{QuickKeys, 0x28bd, 0x5202,0x0001,0xff0a},
|
||||
{QuickKeys, 0x28bd, 0x5203,0x0001,0xff0a}
|
||||
|
@ -198,6 +231,15 @@ private:
|
|||
protected:
|
||||
};
|
||||
|
||||
|
||||
class usbControllerDev : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
437
wfmain.cpp
437
wfmain.cpp
|
@ -76,7 +76,9 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
|
|||
qRegisterMetaType<QVector<BUTTON>*>();
|
||||
qRegisterMetaType<QVector<KNOB>*>();
|
||||
qRegisterMetaType<QVector<COMMAND>*>();
|
||||
qRegisterMetaType<const CONTROLLER*>();
|
||||
qRegisterMetaType<const COMMAND*>();
|
||||
qRegisterMetaType<const USBDEVICE*>();
|
||||
qRegisterMetaType<QList<radio_cap_packet>>();
|
||||
qRegisterMetaType<QList<spotData>>();
|
||||
qRegisterMetaType<networkStatus>();
|
||||
|
@ -338,6 +340,7 @@ void wfmain::rigConnections()
|
|||
|
||||
connect(rig, SIGNAL(haveFrequency(freqt)), this, SLOT(receiveFreq(freqt)));
|
||||
connect(this, SIGNAL(getFrequency()), rig, SLOT(getFrequency()));
|
||||
connect(this, SIGNAL(getFrequency(unsigned char)), rig, SLOT(getFrequency(unsigned char)));
|
||||
connect(this, SIGNAL(getMode()), rig, SLOT(getMode()));
|
||||
connect(this, SIGNAL(getDataMode()), rig, SLOT(getDataMode()));
|
||||
connect(this, SIGNAL(setDataMode(bool, unsigned char)), rig, SLOT(setDataMode(bool, unsigned char)));
|
||||
|
@ -1678,26 +1681,20 @@ void wfmain::setupUsbControllerDevice()
|
|||
connect(usbControllerDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char)));
|
||||
connect(usbControllerDev, SIGNAL(button(const COMMAND*)), this, SLOT(buttonControl(const COMMAND*)));
|
||||
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
|
||||
connect(usbControllerDev, SIGNAL(newDevice(unsigned char, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*, QMutex*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*,QMutex*)));
|
||||
connect(usbControllerDev, SIGNAL(removeDevice(USBDEVICE *)), shut, SLOT(removeDevice(USBDEVICE *)));
|
||||
connect(usbControllerDev, SIGNAL(newDevice(USBDEVICE *, CONTROLLER *, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*, QMutex*)), shut, SLOT(newDevice(USBDEVICE *,CONTROLLER *, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*,QMutex*)));
|
||||
usbControllerThread->start(QThread::LowestPriority);
|
||||
|
||||
connect(this, SIGNAL(sendUsbControllerCommands(QVector<COMMAND>*)), usbControllerDev, SLOT(receiveCommands(QVector<COMMAND>*)));
|
||||
connect(this, SIGNAL(sendUsbControllerButtons(QVector<BUTTON>*)), usbControllerDev, SLOT(receiveButtons(QVector<BUTTON>*)));
|
||||
connect(this, SIGNAL(sendUsbControllerKnobs(QVector<KNOB>*)), usbControllerDev, SLOT(receiveKnobs(QVector<KNOB>*)));
|
||||
connect(shut, SIGNAL(sendSensitivity(int)), usbControllerDev, SLOT(receiveSensitivity(int)));
|
||||
connect(shut, SIGNAL(sendSensitivity(int)), this, SLOT(receiveUsbSensitivity(int)));
|
||||
connect(usbControllerDev, SIGNAL(sendSensitivity(int)), shut, SLOT(receiveSensitivity(int)));
|
||||
connect(shut, SIGNAL(programButton(quint8, QString)), usbControllerDev, SLOT(programButton(quint8, QString)));
|
||||
connect(shut, SIGNAL(programBrightness(quint8)), usbControllerDev, SLOT(programBrightness(quint8)));
|
||||
connect(shut, SIGNAL(programOrientation(quint8)), usbControllerDev, SLOT(programOrientation(quint8)));
|
||||
connect(shut, SIGNAL(programSpeed(quint8)), usbControllerDev, SLOT(programSpeed(quint8)));
|
||||
connect(shut, SIGNAL(programWheelColour(quint8, quint8, quint8)), usbControllerDev, SLOT(programWheelColour(quint8, quint8, quint8)));
|
||||
connect(shut, SIGNAL(programOverlay(quint8, QString)), usbControllerDev, SLOT(programOverlay(quint8, QString)));
|
||||
connect(shut, SIGNAL(programTimeout(quint8)), usbControllerDev, SLOT(programTimeout(quint8)));
|
||||
connect(shut, SIGNAL(updateSettings(quint8, quint8, quint8, quint8, QColor)), this, SLOT(receiveUsbSettings(quint8, quint8, quint8, quint8, QColor)));
|
||||
connect(shut, SIGNAL(programButton(QString, quint8, QString)), usbControllerDev, SLOT(programButton(QString, quint8, QString)));
|
||||
connect(shut, SIGNAL(programSensitivity(QString, quint8)), usbControllerDev, SLOT(programSensitivity(QString, quint8)));
|
||||
connect(shut, SIGNAL(programBrightness(QString, quint8)), usbControllerDev, SLOT(programBrightness(QString, quint8)));
|
||||
connect(shut, SIGNAL(programOrientation(QString, quint8)), usbControllerDev, SLOT(programOrientation(QString, quint8)));
|
||||
connect(shut, SIGNAL(programSpeed(QString, quint8)), usbControllerDev, SLOT(programSpeed(QString, quint8)));
|
||||
connect(shut, SIGNAL(programWheelColour(QString, quint8, quint8, quint8)), usbControllerDev, SLOT(programWheelColour(QString, quint8, quint8, quint8)));
|
||||
connect(shut, SIGNAL(programOverlay(QString, quint8, QString)), usbControllerDev, SLOT(programOverlay(QString, quint8, QString)));
|
||||
connect(shut, SIGNAL(programTimeout(QString, quint8)), usbControllerDev, SLOT(programTimeout(QString, quint8)));
|
||||
connect(this, SIGNAL(setPTT(bool)), usbControllerDev, SLOT(receivePTTStatus(bool)));
|
||||
connect(this, SIGNAL(initUsbController(int, QMutex*)), usbControllerDev, SLOT(init(int, QMutex*)));
|
||||
connect(this, SIGNAL(initUsbDefaults(quint8, quint8, quint8, quint8, QColor)), shut, SLOT(setDefaults(quint8, quint8, quint8, quint8, QColor)));
|
||||
connect(this, SIGNAL(initUsbController(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)), usbControllerDev, SLOT(init(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -1841,8 +1838,29 @@ void wfmain::buttonControl(const COMMAND* cmd)
|
|||
ui->scopeBWCombo->setCurrentIndex(ui->scopeBWCombo->count() - 1);
|
||||
}
|
||||
break;
|
||||
case cmdSetFreq:
|
||||
{
|
||||
if (freqLock) break;
|
||||
freqt f;
|
||||
if (cmd->suffix) {
|
||||
f.Hz = roundFrequencyWithStep(freqb.Hz, cmd->value, tsWfScrollHz);
|
||||
} else {
|
||||
f.Hz = roundFrequencyWithStep(freq.Hz, cmd->value, tsWfScrollHz);
|
||||
}
|
||||
f.MHzDouble = f.Hz / (double)1E6;
|
||||
f.VFO=(selVFO_t)cmd->suffix;
|
||||
issueCmdUniquePriority((cmds)cmd->command, f);
|
||||
if (!cmd->suffix) {
|
||||
freq = f;
|
||||
ui->freqLabel->setText(QString("%1").arg(f.MHzDouble, 0, 'f'));
|
||||
} else {
|
||||
freqb = f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
issueCmdUniquePriority((cmds)cmd->command, cmd->suffix);
|
||||
qInfo(logUsbControl()) << "Command fell through command:" << cmd->command << "suffix" << cmd->suffix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1904,12 +1922,6 @@ void wfmain::setDefPrefs()
|
|||
defPrefs.waterfallFormat = 0;
|
||||
defPrefs.audioSystem = qtAudio;
|
||||
defPrefs.enableUSBControllers = false;
|
||||
defPrefs.usbSensitivity = 1;
|
||||
defPrefs.usbSpeed = 3;
|
||||
defPrefs.usbTimeout = 30;
|
||||
defPrefs.usbBrightness = 3;
|
||||
defPrefs.usbOrientation = 3;
|
||||
defPrefs.usbColor = Qt::white;
|
||||
|
||||
udpDefPrefs.ipAddress = QString("");
|
||||
udpDefPrefs.controlLANPort = 50001;
|
||||
|
@ -2459,7 +2471,6 @@ void wfmain::loadSettings()
|
|||
settings->beginGroup("USB");
|
||||
/* Load USB buttons*/
|
||||
prefs.enableUSBControllers = settings->value("EnableUSBControllers", defPrefs.enableUSBControllers).toBool();
|
||||
prefs.usbSensitivity = settings->value("USBSensitivity", defPrefs.usbSensitivity).toInt();
|
||||
ui->enableUsbChk->blockSignals(true);
|
||||
ui->enableUsbChk->setChecked(prefs.enableUSBControllers);
|
||||
ui->enableUsbChk->blockSignals(false);
|
||||
|
@ -2467,56 +2478,38 @@ void wfmain::loadSettings()
|
|||
ui->usbButtonsResetBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbCommandsResetBtn->setEnabled(prefs.enableUSBControllers);
|
||||
ui->usbResetLbl->setVisible(prefs.enableUSBControllers);
|
||||
|
||||
prefs.usbBrightness = (quint8)settings->value("USBBrightness", defPrefs.usbBrightness).toInt();
|
||||
prefs.usbOrientation = (quint8)settings->value("USBOrientation", defPrefs.usbOrientation).toInt();
|
||||
prefs.usbSpeed = (quint8)settings->value("USBSpeed", defPrefs.usbSpeed).toInt();
|
||||
prefs.usbTimeout = (quint8)settings->value("USBBTimeout", defPrefs.usbTimeout).toInt();
|
||||
prefs.usbColor.setNamedColor(settings->value("USBColor", defPrefs.usbColor.name(QColor::HexArgb)).toString());
|
||||
|
||||
/*Ensure that no operations on the usb commands/buttons/knobs take place*/
|
||||
QMutexLocker locker(&usbMutex);
|
||||
|
||||
if (prefs.enableUSBControllers) {
|
||||
// Setup USB Controller
|
||||
setupUsbControllerDevice();
|
||||
emit initUsbController(prefs.usbSensitivity, &usbMutex);
|
||||
emit sendUsbControllerCommands(&usbCommands);
|
||||
emit sendUsbControllerButtons(&usbButtons);
|
||||
emit sendUsbControllerKnobs(&usbKnobs);
|
||||
emit initUsbDefaults(prefs.usbBrightness, prefs.usbOrientation, prefs.usbSpeed, prefs.usbTimeout, prefs.usbColor);
|
||||
}
|
||||
|
||||
int numCommands = settings->beginReadArray("Commands");
|
||||
// This is the last time the commands were changed (v1.58)
|
||||
if (numCommands == 0 || priorVersionFloat < 1.58) {
|
||||
int numControllers = settings->beginReadArray("Controllers");
|
||||
if (numControllers == 0) {
|
||||
settings->endArray();
|
||||
// We have no buttons so create defaults
|
||||
resetUsbCommands();
|
||||
}
|
||||
else {
|
||||
for (int nc = 0; nc < numCommands; nc++)
|
||||
usbControllers.clear();
|
||||
for (int nc = 0; nc < numControllers; nc++)
|
||||
{
|
||||
settings->setArrayIndex(nc);
|
||||
COMMAND comm;
|
||||
comm.index = settings->value("Num", 0).toInt();
|
||||
comm.text = settings->value("Text", "").toString();
|
||||
comm.command = settings->value("Command", 0).toInt();
|
||||
comm.band = (availableBands)settings->value("Band", 0).toInt();
|
||||
comm.mode = (mode_kind)settings->value("Mode", 0).toInt();
|
||||
comm.suffix = (unsigned char)settings->value("Suffix", 0).toInt();
|
||||
comm.cmdType = (usbCommandType)settings->value("CommandType", 0).toInt();
|
||||
usbCommands.append(comm);
|
||||
CONTROLLER tempPrefs;
|
||||
QString tempPath = settings->value("Path", "").toString();
|
||||
tempPrefs.sensitivity = settings->value("Sensitivity", 1).toInt();
|
||||
tempPrefs.brightness = (quint8)settings->value("Brightness", 2).toInt();
|
||||
tempPrefs.orientation = (quint8)settings->value("Orientation", 2).toInt();
|
||||
tempPrefs.speed = (quint8)settings->value("Speed", 2).toInt();
|
||||
tempPrefs.timeout = (quint8)settings->value("Timeout", 30).toInt();
|
||||
tempPrefs.color.setNamedColor(settings->value("Color", QColor(Qt::white).name(QColor::HexArgb)).toString());
|
||||
|
||||
if (!tempPath.isEmpty()) {
|
||||
usbControllers.insert(tempPath,tempPrefs);
|
||||
}
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
int numButtons = settings->beginReadArray("Buttons");
|
||||
// This is the last time the buttons were changed, (v1.58)
|
||||
if (numButtons == 0 || priorVersionFloat < 1.58) {
|
||||
if (numButtons == 0) {
|
||||
settings->endArray();
|
||||
// We have no buttons so create defaults
|
||||
resetUsbButtons();
|
||||
}
|
||||
else {
|
||||
usbButtons.clear();
|
||||
|
@ -2524,6 +2517,7 @@ void wfmain::loadSettings()
|
|||
{
|
||||
settings->setArrayIndex(nb);
|
||||
BUTTON butt;
|
||||
butt.devicePath = settings->value("Path", "").toString();
|
||||
butt.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
|
||||
butt.num = settings->value("Num", 0).toInt();
|
||||
butt.name = settings->value("Name", "").toString();
|
||||
|
@ -2533,31 +2527,17 @@ void wfmain::loadSettings()
|
|||
settings->value("Height", 0).toInt());
|
||||
butt.textColour = QColor((settings->value("Colour", "Green").toString()));
|
||||
|
||||
QString on = settings->value("OnCommand", "None").toString();
|
||||
QString off = settings->value("OffCommand", "None").toString();
|
||||
|
||||
QVector<COMMAND>::iterator usbc = usbCommands.begin();
|
||||
|
||||
while (usbc != usbCommands.end())
|
||||
{
|
||||
if (on == usbc->text)
|
||||
butt.onCommand = usbc;
|
||||
if (off == usbc->text)
|
||||
butt.offCommand = usbc;
|
||||
++usbc;
|
||||
}
|
||||
usbButtons.append(butt);
|
||||
|
||||
butt.on = settings->value("OnCommand", "None").toString();
|
||||
butt.off = settings->value("OffCommand", "None").toString();
|
||||
if (!butt.devicePath.isEmpty())
|
||||
usbButtons.append(butt);
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
int numKnobs = settings->beginReadArray("Knobs");
|
||||
// This is the last time the knobs were changed, (v1.58)
|
||||
if (numKnobs == 0 || priorVersionFloat < 1.58) {
|
||||
if (numKnobs == 0) {
|
||||
settings->endArray();
|
||||
// We have no knobs so create defaults
|
||||
resetUsbKnobs();
|
||||
}
|
||||
else {
|
||||
usbKnobs.clear();
|
||||
|
@ -2565,6 +2545,7 @@ void wfmain::loadSettings()
|
|||
{
|
||||
settings->setArrayIndex(nk);
|
||||
KNOB kb;
|
||||
kb.devicePath = settings->value("Path", "").toString();
|
||||
kb.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
|
||||
kb.num = settings->value("Num", 0).toInt();
|
||||
kb.name = settings->value("Name", "").toString();
|
||||
|
@ -2574,23 +2555,22 @@ void wfmain::loadSettings()
|
|||
settings->value("Height", 0).toInt());
|
||||
kb.textColour = QColor((settings->value("Colour", "Green").toString()));
|
||||
|
||||
QString cmd = settings->value("Command", "None").toString();
|
||||
|
||||
QVector<COMMAND>::iterator usbc = usbCommands.begin();
|
||||
|
||||
while (usbc != usbCommands.end())
|
||||
{
|
||||
if (cmd == usbc->text) {
|
||||
kb.command = usbc;
|
||||
}
|
||||
++usbc;
|
||||
}
|
||||
usbKnobs.append(kb);
|
||||
kb.cmd = settings->value("Command", "None").toString();
|
||||
if (!kb.devicePath.isEmpty())
|
||||
usbKnobs.append(kb);
|
||||
}
|
||||
settings->endArray();
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
|
||||
if (prefs.enableUSBControllers) {
|
||||
// Setup USB Controller
|
||||
setupUsbControllerDevice();
|
||||
emit initUsbController(&usbMutex,&usbControllers,&usbButtons,&usbKnobs);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2990,23 +2970,42 @@ void wfmain::saveSettings()
|
|||
|
||||
#if defined(USB_CONTROLLER)
|
||||
settings->beginGroup("USB");
|
||||
// Store USB Controller
|
||||
|
||||
settings->setValue("EnableUSBControllers", prefs.enableUSBControllers);
|
||||
settings->setValue("USBSensitivity", prefs.usbSensitivity);
|
||||
|
||||
settings->setValue("USBBrightness", prefs.usbBrightness);
|
||||
settings->setValue("USBOrientation", prefs.usbOrientation);
|
||||
settings->setValue("USBSpeed", prefs.usbSpeed);
|
||||
settings->setValue("USBTimeout", prefs.usbTimeout);
|
||||
settings->setValue("USBColor", prefs.usbColor.name(QColor::HexArgb));
|
||||
|
||||
QMutexLocker locker(&usbMutex);
|
||||
|
||||
// Store USB Controller
|
||||
|
||||
settings->beginWriteArray("Controllers");
|
||||
int nc=0;
|
||||
|
||||
usbMap::const_iterator i = usbControllers.constBegin();
|
||||
while (i != usbControllers.constEnd())
|
||||
{
|
||||
settings->setArrayIndex(nc);
|
||||
|
||||
settings->setValue("Path", i.key());
|
||||
settings->setValue("Sensitivity", i.value().sensitivity);
|
||||
settings->setValue("Brightness", i.value().brightness);
|
||||
settings->setValue("Orientation", i.value().orientation);
|
||||
settings->setValue("Speed", i.value().speed);
|
||||
settings->setValue("Timeout", i.value().timeout);
|
||||
settings->setValue("Color", i.value().color.name(QColor::HexArgb));
|
||||
|
||||
++i;
|
||||
++nc;
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
||||
settings->beginWriteArray("Buttons");
|
||||
for (int nb = 0; nb < usbButtons.count(); nb++)
|
||||
{
|
||||
settings->setArrayIndex(nb);
|
||||
settings->setValue("Dev", usbButtons[nb].dev);
|
||||
settings->setValue("Num", usbButtons[nb].num);
|
||||
settings->setValue("Path", usbButtons[nb].devicePath);
|
||||
settings->setValue("Name", usbButtons[nb].name);
|
||||
settings->setValue("Left", usbButtons[nb].pos.left());
|
||||
settings->setValue("Top", usbButtons[nb].pos.top());
|
||||
|
@ -3027,6 +3026,7 @@ void wfmain::saveSettings()
|
|||
settings->setArrayIndex(nk);
|
||||
settings->setValue("Dev", usbKnobs[nk].dev);
|
||||
settings->setValue("Num", usbKnobs[nk].num);
|
||||
settings->setValue("Path", usbKnobs[nk].devicePath);
|
||||
settings->setValue("Left", usbKnobs[nk].pos.left());
|
||||
settings->setValue("Top", usbKnobs[nk].pos.top());
|
||||
settings->setValue("Width", usbKnobs[nk].pos.width());
|
||||
|
@ -3038,22 +3038,6 @@ void wfmain::saveSettings()
|
|||
|
||||
settings->endArray();
|
||||
|
||||
settings->beginWriteArray("Commands");
|
||||
for (int nc = 0; nc < usbCommands.count(); nc++)
|
||||
{
|
||||
settings->setArrayIndex(nc);
|
||||
|
||||
settings->setValue("Num", usbCommands[nc].index);
|
||||
settings->setValue("Text", usbCommands[nc].text);
|
||||
settings->setValue("Command", usbCommands[nc].command);
|
||||
settings->setValue("Band", usbCommands[nc].band);
|
||||
settings->setValue("Mode", usbCommands[nc].mode);
|
||||
settings->setValue("Suffix", usbCommands[nc].suffix);
|
||||
settings->setValue("CommandType", usbCommands[nc].cmdType);
|
||||
}
|
||||
|
||||
settings->endArray();
|
||||
|
||||
settings->endGroup();
|
||||
#endif
|
||||
|
||||
|
@ -4072,6 +4056,9 @@ void wfmain::doCmd(cmds cmd)
|
|||
case cmdGetFreq:
|
||||
emit getFrequency();
|
||||
break;
|
||||
case cmdGetFreqB:
|
||||
emit getFrequency((unsigned char)1);
|
||||
break;
|
||||
case cmdGetMode:
|
||||
emit getMode();
|
||||
break;
|
||||
|
@ -4841,6 +4828,11 @@ void wfmain::initPeriodicCommands()
|
|||
insertPeriodicCommand(cmdGetTxRxMeter, 128);
|
||||
|
||||
insertSlowPeriodicCommand(cmdGetFreq, 128);
|
||||
|
||||
if (rigCaps.hasVFOAB || rigCaps.hasVFOMS) {
|
||||
insertSlowPeriodicCommand(cmdGetFreqB, 128);
|
||||
}
|
||||
|
||||
insertSlowPeriodicCommand(cmdGetMode, 128);
|
||||
if(rigCaps.hasTransmit)
|
||||
insertSlowPeriodicCommand(cmdGetPTT, 128);
|
||||
|
@ -4870,7 +4862,6 @@ void wfmain::initPeriodicCommands()
|
|||
insertPeriodicRapidCmdUnique(cmdGetTPBFOuter);
|
||||
insertPeriodicRapidCmdUnique(cmdGetPassband);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wfmain::insertPeriodicRapidCmd(cmds cmd)
|
||||
|
@ -4977,9 +4968,13 @@ void wfmain::receiveFreq(freqt freqStruct)
|
|||
qint64 tnow_ms = QDateTime::currentMSecsSinceEpoch();
|
||||
if(tnow_ms - lastFreqCmdTime_ms > delayedCommand->interval() * 2)
|
||||
{
|
||||
ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
|
||||
freq = freqStruct;
|
||||
rpt->handleUpdateCurrentMainFrequency(freqStruct);
|
||||
if (freqStruct.VFO == selVFO_t::activeVFO) {
|
||||
ui->freqLabel->setText(QString("%1").arg(freqStruct.MHzDouble, 0, 'f'));
|
||||
freq = freqStruct;
|
||||
rpt->handleUpdateCurrentMainFrequency(freqStruct);
|
||||
} else {
|
||||
freqb = freqStruct;
|
||||
}
|
||||
} else {
|
||||
qDebug(logSystem()) << "Rejecting stale frequency: " << freqStruct.Hz << " Hz, delta time ms = " << tnow_ms - lastFreqCmdTime_ms\
|
||||
<< ", tnow_ms " << tnow_ms << ", last: " << lastFreqCmdTime_ms;
|
||||
|
@ -9189,11 +9184,7 @@ void wfmain::on_enableUsbChk_clicked(bool checked)
|
|||
if (checked) {
|
||||
// Setup USB Controller
|
||||
setupUsbControllerDevice();
|
||||
emit initUsbController(prefs.usbSensitivity, &usbMutex);
|
||||
emit sendUsbControllerCommands(&usbCommands);
|
||||
emit sendUsbControllerButtons(&usbButtons);
|
||||
emit sendUsbControllerKnobs(&usbKnobs);
|
||||
emit initUsbDefaults(prefs.usbBrightness, prefs.usbOrientation, prefs.usbSpeed, prefs.usbTimeout, prefs.usbColor);
|
||||
emit initUsbController(&usbMutex,&usbControllers,&usbButtons,&usbKnobs);
|
||||
}
|
||||
else {
|
||||
if (shut != Q_NULLPTR) {
|
||||
|
@ -9227,8 +9218,8 @@ void wfmain::on_usbButtonsResetBtn_clicked()
|
|||
QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
qInfo(logUsbControl()) << "Resetting USB buttons to default values";
|
||||
resetUsbButtons();
|
||||
resetUsbKnobs();
|
||||
//resetUsbButtons();
|
||||
//resetUsbKnobs();
|
||||
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
||||
}
|
||||
}
|
||||
|
@ -9241,7 +9232,7 @@ void wfmain::on_usbCommandsResetBtn_clicked()
|
|||
QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Ok) {
|
||||
qInfo(logUsbControl()) << "Resetting USB commands to default values";
|
||||
resetUsbCommands();
|
||||
//resetUsbCommands();
|
||||
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
||||
}
|
||||
|
||||
|
@ -9333,197 +9324,3 @@ void wfmain::on_cwButton_clicked()
|
|||
cw->activateWindow();
|
||||
}
|
||||
|
||||
void wfmain::resetUsbButtons()
|
||||
{
|
||||
#ifdef USB_CONTROLLER
|
||||
qInfo(logUsbControl) << "Resetting USB Buttons to defaults";
|
||||
usbButtons.clear();
|
||||
|
||||
// ShuttleXpress
|
||||
usbButtons.append(BUTTON(shuttleXpress, 4, QRect(25, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttleXpress, 5, QRect(101, 72, 83, 88), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttleXpress, 6, QRect(238, 26, 134, 69), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttleXpress, 7, QRect(452, 72, 77, 86), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttleXpress, 8, QRect(504, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
// ShuttlePro2
|
||||
usbButtons.append(BUTTON(shuttlePro2, 0, QRect(60, 66, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 1, QRect(114, 50, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 2, QRect(169, 47, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 3, QRect(225, 59, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 4, QRect(41, 132, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 5, QRect(91, 105, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 6, QRect(144, 93, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 7, QRect(204, 99, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 8, QRect(253, 124, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 9, QRect(50, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 10, QRect(210, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 11, QRect(50, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 12, QRect(210, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 13, QRect(30, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(shuttlePro2, 14, QRect(280, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
// RC28
|
||||
usbButtons.append(BUTTON(RC28, 0, QRect(52, 445, 238, 64), Qt::red, &usbCommands[1], &usbCommands[2])); // PTT On/OFF
|
||||
usbButtons.append(BUTTON(RC28, 1, QRect(52, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(RC28, 2, QRect(193, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
// Xbox Gamepad
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "UP", QRect(256, 229, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "DOWN", QRect(256, 316, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "LEFT", QRect(203, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "RIGHT", QRect(303, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "SELECT", QRect(302, 160, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "START", QRect(412, 163, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "Y", QRect(534, 104, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "X", QRect(485, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "B", QRect(590, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "A", QRect(534, 202, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "L1", QRect(123, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "R1", QRect(562, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "LEFTX", QRect(143, 119, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "LEFTY", QRect(162, 132, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "RIGHTX", QRect(430, 298, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(xBoxGamepad, "RIGHTY", QRect(453, 233, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
// eCoder
|
||||
usbButtons.append(BUTTON(eCoderPlus, 1, QRect(87, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 2, QRect(168, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 3, QRect(249, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 4, QRect(329, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 5, QRect(410, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 6, QRect(87, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 7, QRect(168, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 8, QRect(249, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 9, QRect(329, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 10, QRect(410, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 11, QRect(87, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 12, QRect(410, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 13, QRect(87, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 14, QRect(410, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 16, QRect(128, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 17, QRect(256, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 18, QRect(380, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 19, QRect(124, 2, 55, 30), Qt::red, &usbCommands[1], &usbCommands[2]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 20, QRect(290, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(eCoderPlus, 21, QRect(404, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
// QuickKeys
|
||||
usbButtons.append(BUTTON(QuickKeys, 0, QRect(77, 204, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 1, QRect(77, 276, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 2, QRect(77, 348, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 3, QRect(77, 422, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 4, QRect(230, 204, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 5, QRect(230, 276, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 6, QRect(230, 348, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 7, QRect(230, 422, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 8, QRect(143, 515, 55, 40), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
usbButtons.append(BUTTON(QuickKeys, 9, QRect(139, 68, 65, 65), Qt::white, &usbCommands[0], &usbCommands[0]));
|
||||
|
||||
emit sendUsbControllerButtons(&usbButtons);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void wfmain::resetUsbKnobs()
|
||||
{
|
||||
#ifdef USB_CONTROLLER
|
||||
qInfo(logUsbControl) << "Resetting USB Knobs to defaults";
|
||||
usbKnobs.clear();
|
||||
// eCoder
|
||||
usbKnobs.append(KNOB(eCoderPlus, 1, QRect(120, 153, 72, 27), Qt::green, &usbCommands[0]));
|
||||
usbKnobs.append(KNOB(eCoderPlus, 2, QRect(242, 153, 72, 27), Qt::green, &usbCommands[0]));
|
||||
usbKnobs.append(KNOB(eCoderPlus, 3, QRect(362, 153, 72, 27), Qt::green, &usbCommands[0]));
|
||||
emit sendUsbControllerKnobs(&usbKnobs);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void wfmain::resetUsbCommands()
|
||||
{
|
||||
#ifdef USB_CONTROLLER
|
||||
qInfo(logUsbControl) << "Resetting USB Commands to defaults";
|
||||
usbCommands.clear();
|
||||
int num = 0;
|
||||
usbCommands.append(COMMAND(num++, "None", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "PTT On", commandButton, cmdSetPTT, 0x1));
|
||||
usbCommands.append(COMMAND(num++, "PTT Off", commandButton, cmdSetPTT, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "PTT Toggle", commandButton, cmdPTTToggle, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Tune", commandButton, cmdStartATU, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Step+", commandButton, cmdSetStepUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Step-", commandButton, cmdSetStepDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Span+", commandButton, cmdSetSpanUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Span-", commandButton, cmdSetSpanDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode+", commandButton, cmdSetModeUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode-", commandButton, cmdSetModeDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Mode LSB", commandButton, cmdSetMode, modeLSB));
|
||||
usbCommands.append(COMMAND(num++, "Mode USB", commandButton, cmdSetMode, modeUSB));
|
||||
usbCommands.append(COMMAND(num++, "Mode LSBD", commandButton, cmdSetMode, modeLSB_D));
|
||||
usbCommands.append(COMMAND(num++, "Mode USBD", commandButton, cmdSetMode, modeUSB_D));
|
||||
usbCommands.append(COMMAND(num++, "Mode CW", commandButton, cmdSetMode, modeCW));
|
||||
usbCommands.append(COMMAND(num++, "Mode CWR", commandButton, cmdSetMode, modeCW_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode FM", commandButton, cmdSetMode, modeFM));
|
||||
usbCommands.append(COMMAND(num++, "Mode AM", commandButton, cmdSetMode, modeAM));
|
||||
usbCommands.append(COMMAND(num++, "Mode RTTY", commandButton, cmdSetMode, modeRTTY));
|
||||
usbCommands.append(COMMAND(num++, "Mode RTTYR", commandButton, cmdSetMode, modeRTTY_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode PSK", commandButton, cmdSetMode, modePSK));
|
||||
usbCommands.append(COMMAND(num++, "Mode PSKR", commandButton, cmdSetMode, modePSK_R));
|
||||
usbCommands.append(COMMAND(num++, "Mode DV", commandButton, cmdSetMode, modeDV));
|
||||
usbCommands.append(COMMAND(num++, "Mode DD", commandButton, cmdSetMode, modeDD));
|
||||
usbCommands.append(COMMAND(num++, "Band+", commandButton, cmdSetBandUp, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Band-", commandButton, cmdSetBandDown, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Band 23cm", commandButton, cmdGetBandStackReg, band23cm));
|
||||
usbCommands.append(COMMAND(num++, "Band 70cm", commandButton, cmdGetBandStackReg, band70cm));
|
||||
usbCommands.append(COMMAND(num++, "Band 2m", commandButton, cmdGetBandStackReg, band2m));
|
||||
usbCommands.append(COMMAND(num++, "Band AIR", commandButton, cmdGetBandStackReg, bandAir));
|
||||
usbCommands.append(COMMAND(num++, "Band WFM", commandButton, cmdGetBandStackReg, bandWFM));
|
||||
usbCommands.append(COMMAND(num++, "Band 4m", commandButton, cmdGetBandStackReg, band4m));
|
||||
usbCommands.append(COMMAND(num++, "Band 6m", commandButton, cmdGetBandStackReg, band6m));
|
||||
usbCommands.append(COMMAND(num++, "Band 10m", commandButton, cmdGetBandStackReg, band10m));
|
||||
usbCommands.append(COMMAND(num++, "Band 12m", commandButton, cmdGetBandStackReg, band12m));
|
||||
usbCommands.append(COMMAND(num++, "Band 15m", commandButton, cmdGetBandStackReg, band15m));
|
||||
usbCommands.append(COMMAND(num++, "Band 17m", commandButton, cmdGetBandStackReg, band17m));
|
||||
usbCommands.append(COMMAND(num++, "Band 20m", commandButton, cmdGetBandStackReg, band20m));
|
||||
usbCommands.append(COMMAND(num++, "Band 30m", commandButton, cmdGetBandStackReg, band30m));
|
||||
usbCommands.append(COMMAND(num++, "Band 40m", commandButton, cmdGetBandStackReg, band40m));
|
||||
usbCommands.append(COMMAND(num++, "Band 60m", commandButton, cmdGetBandStackReg, band60m));
|
||||
usbCommands.append(COMMAND(num++, "Band 80m", commandButton, cmdGetBandStackReg, band80m));
|
||||
usbCommands.append(COMMAND(num++, "Band 160m", commandButton, cmdGetBandStackReg, band160m));
|
||||
usbCommands.append(COMMAND(num++, "Band 630m", commandButton, cmdGetBandStackReg, band630m));
|
||||
usbCommands.append(COMMAND(num++, "Band 2200m", commandButton, cmdGetBandStackReg, band2200m));
|
||||
usbCommands.append(COMMAND(num++, "Band GEN", commandButton, cmdGetBandStackReg, bandGen));
|
||||
usbCommands.append(COMMAND(num++, "NR On", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "NR Off", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "NB On", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "NB Off", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Split On", commandButton, cmdNone, 0x01));
|
||||
usbCommands.append(COMMAND(num++, "Split Off", commandButton, cmdNone, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "Swap VFO", commandButton, cmdVFOSwap, 0x0));
|
||||
usbCommands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "TX Power", commandKnob, cmdSetTxPower, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Mic Gain", commandKnob, cmdSetMicGain, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Mod Level", commandKnob, cmdSetModLevel, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Squelch", commandKnob, cmdSetSql, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "IF Shift", commandKnob, cmdSetIFShift, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "In PBT", commandKnob, cmdSetTPBFInner, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "Out PBT", commandKnob, cmdSetTPBFOuter, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "CW Pitch", commandKnob, cmdSetCwPitch, 0xff));
|
||||
usbCommands.append(COMMAND(num++, "CW Speed", commandKnob, cmdSetKeySpeed, 0xff));
|
||||
emit sendUsbControllerCommands(&usbCommands);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wfmain::receiveUsbSensitivity(int val) {
|
||||
prefs.usbSensitivity = val;
|
||||
}
|
||||
|
||||
void wfmain::receiveUsbSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color)
|
||||
{
|
||||
qInfo(logUsbControl()) << QString("USB brightness: %0 orentation: %1 speed: %2 timeout: %3 color: %4").arg(bright).arg(orient).arg(speed).arg(timeout).arg(color.name());
|
||||
prefs.usbBrightness = bright;
|
||||
prefs.usbOrientation = orient;
|
||||
prefs.usbSpeed = speed;
|
||||
prefs.usbTimeout = timeout;
|
||||
prefs.usbColor = color;
|
||||
}
|
||||
|
|
18
wfmain.h
18
wfmain.h
|
@ -19,6 +19,7 @@
|
|||
#include <QMutexLocker>
|
||||
#include <QColorDialog>
|
||||
#include <QColor>
|
||||
#include <QMap>
|
||||
|
||||
#include "logcategories.h"
|
||||
#include "wfviewtypes.h"
|
||||
|
@ -90,6 +91,7 @@ signals:
|
|||
|
||||
// Frequency, mode, band:
|
||||
void getFrequency();
|
||||
void getFrequency(unsigned char);
|
||||
void setFrequency(unsigned char vfo, freqt freq);
|
||||
void getMode();
|
||||
void setMode(unsigned char modeIndex, unsigned char modeFilter);
|
||||
|
@ -225,11 +227,7 @@ signals:
|
|||
void openShuttle();
|
||||
void requestRigState();
|
||||
void stateUpdated();
|
||||
void initUsbController(int sens, QMutex* mutex);
|
||||
void sendUsbControllerCommands(QVector<COMMAND>* cmds);
|
||||
void sendUsbControllerButtons(QVector<BUTTON>* buts);
|
||||
void sendUsbControllerKnobs(QVector<KNOB>* kbs);
|
||||
void initUsbDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
|
||||
void initUsbController(QMutex* mutex,usbMap* prefs ,QVector<BUTTON>* buts,QVector<KNOB>* knobs);
|
||||
void setClusterUdpPort(int port);
|
||||
void setClusterEnableUdp(bool udp);
|
||||
void setClusterEnableTcp(bool tcp);
|
||||
|
@ -354,8 +352,6 @@ private slots:
|
|||
void showStatusBarText(QString text);
|
||||
void receiveBaudRate(quint32 baudrate);
|
||||
void radioSelection(QList<radio_cap_packet> radios);
|
||||
void receiveUsbSensitivity(int val);
|
||||
void receiveUsbSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
|
||||
|
||||
|
||||
// Added for RC28/Shuttle support
|
||||
|
@ -926,6 +922,7 @@ private:
|
|||
double oldLowerFreq;
|
||||
double oldUpperFreq;
|
||||
freqt freq;
|
||||
freqt freqb;
|
||||
float tsKnobMHz;
|
||||
|
||||
unsigned char setModeVal=0;
|
||||
|
@ -1073,9 +1070,6 @@ private:
|
|||
|
||||
void updateUsbButtons();
|
||||
|
||||
void resetUsbButtons();
|
||||
void resetUsbKnobs();
|
||||
void resetUsbCommands();
|
||||
int oldFreqDialVal;
|
||||
|
||||
rigCapabilities rigCaps;
|
||||
|
@ -1151,9 +1145,9 @@ private:
|
|||
usbController *usbControllerDev = Q_NULLPTR;
|
||||
QThread *usbControllerThread = Q_NULLPTR;
|
||||
QString usbDeviceName;
|
||||
QVector<COMMAND> usbCommands;
|
||||
QVector<BUTTON> usbButtons;
|
||||
QVector<KNOB> usbKnobs;
|
||||
usbMap usbControllers;
|
||||
QMutex usbMutex;
|
||||
#endif
|
||||
|
||||
|
@ -1191,7 +1185,9 @@ Q_DECLARE_METATYPE(rigstate*)
|
|||
Q_DECLARE_METATYPE(QVector <BUTTON>*)
|
||||
Q_DECLARE_METATYPE(QVector <KNOB>*)
|
||||
Q_DECLARE_METATYPE(QVector <COMMAND>*)
|
||||
Q_DECLARE_METATYPE(const CONTROLLER*)
|
||||
Q_DECLARE_METATYPE(const COMMAND*)
|
||||
Q_DECLARE_METATYPE(const USBDEVICE*)
|
||||
Q_DECLARE_METATYPE(codecType)
|
||||
Q_DECLARE_METATYPE(errorType)
|
||||
Q_DECLARE_METATYPE(enum duplexMode)
|
||||
|
|
|
@ -147,7 +147,7 @@ struct timekind {
|
|||
};
|
||||
|
||||
enum cmds {
|
||||
cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdSetFreq, cmdGetMode, cmdSetMode,
|
||||
cmdNone, cmdGetRigID, cmdGetRigCIV, cmdGetFreq, cmdGetFreqB, cmdSetFreq, cmdGetMode, cmdSetMode,
|
||||
cmdGetDataMode, cmdSetModeFilter, cmdSetDataModeOn, cmdSetDataModeOff, cmdGetRitEnabled, cmdGetRitValue,
|
||||
cmdSpecOn, cmdSpecOff, cmdDispEnable, cmdDispDisable, cmdGetRxGain, cmdSetRxRfGain, cmdGetAfGain, cmdSetAfGain,
|
||||
cmdGetSql, cmdSetSql, cmdGetIFShift, cmdSetIFShift, cmdGetTPBFInner, cmdSetTPBFInner,
|
||||
|
|
Ładowanie…
Reference in New Issue