Initial support for Stream Deck Pro (other Stream Deck support to follow)

qcpfix
Phil Taylor 2023-03-25 09:09:42 +00:00
rodzic d7ba3d9d9a
commit ac58289188
10 zmienionych plików z 1396 dodań i 964 usunięć

Wyświetl plik

@ -17,27 +17,60 @@ controllerSetup::controllerSetup(QWidget* parent) :
controllerSetup::~controllerSetup() controllerSetup::~controllerSetup()
{ {
if (onEventProxy != Q_NULLPTR) {
delete onEventProxy;
delete onEvent;
}
if (offEventProxy != Q_NULLPTR) {
delete offEventProxy;
delete offEvent;
}
if (knobEventProxy != Q_NULLPTR) {
delete knobEventProxy;
delete knobEvent;
}
delete ui; delete ui;
} }
void controllerSetup::init()
{
updateDialog = new QDialog(this);
//updateDialog->setModal(true);
QGridLayout* udLayout = new QGridLayout;
updateDialog->setLayout(udLayout);
updateDialog->setBaseSize(1, 1);
onLabel = new QLabel("On");
udLayout->addWidget(onLabel,0,0);
onEvent = new QComboBox();
udLayout->addWidget(onEvent,0,1);
onLabel->setBuddy(onEvent);
offLabel = new QLabel("Off");
udLayout->addWidget(offLabel,1,0);
offEvent = new QComboBox();
udLayout->addWidget(offEvent,1,1);
offLabel->setBuddy(offEvent);
knobLabel = new QLabel("Knob");
udLayout->addWidget(knobLabel,2,0);
knobEvent = new QComboBox();
udLayout->addWidget(knobEvent,2,1);
knobLabel->setBuddy(knobEvent);
buttonColor = new QPushButton("Color");
udLayout->addWidget(buttonColor,3,0);
buttonLatch = new QCheckBox();
buttonLatch->setText("Toggle");
udLayout->addWidget(buttonLatch,3,1);
udLayout->setAlignment(buttonLatch,Qt::AlignRight);
udLayout->setSizeConstraint(QLayout::SetFixedSize);
updateDialog->hide();
connect(offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
connect(onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
connect(knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
connect(buttonColor, SIGNAL(clicked()), this, SLOT(buttonColorClicked()));
connect(buttonLatch, SIGNAL(stateChanged(int)), this, SLOT(latchStateChanged(int)));
}
void controllerSetup::mousePressed(controllerScene* scene, QPoint p) void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
{ {
Q_UNUSED (scene) // We might want it in the future?
// Receive mouse event from the scene // Receive mouse event from the scene
qDebug() << "Looking for button Point x=" << p.x() << " y=" << p.y(); qDebug() << "Looking for button Point x=" << p.x() << " y=" << p.y();
if (onEvent == Q_NULLPTR|| offEvent == Q_NULLPTR|| knobEvent == Q_NULLPTR) if (onEvent == Q_NULLPTR|| offEvent == Q_NULLPTR|| knobEvent == Q_NULLPTR)
@ -47,50 +80,66 @@ void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
} }
bool found = false; bool found = false;
QMutexLocker locker(mutex); QPoint gp = this->mapToGlobal(p);
for (auto b = buttons->begin(); b != buttons->end(); b++)
for (BUTTON& b : *buttons)
{ {
if (b->page == b->parent->currentPage && ui->tabWidget->currentWidget()->objectName() == b->path && b->pos.contains(p))
if (ui->tabWidget->currentWidget()->objectName() == b.devicePath && b.pos.contains(p))
{ {
found = true; found = true;
currentButton = &b; currentButton = b;
qDebug() << "Button" << currentButton->num << "On Event" << currentButton->onCommand->text << "Off Event" << currentButton->offCommand->text; qDebug() << "Button" << currentButton->num << "On Event" << currentButton->onCommand->text << "Off Event" << currentButton->offCommand->text;
updateDialog->setWindowTitle(QString("Update button %0").arg(b->num));
onEvent->blockSignals(true); onEvent->blockSignals(true);
onEvent->move(p);
onEvent->setCurrentIndex(onEvent->findData(currentButton->onCommand->index)); onEvent->setCurrentIndex(onEvent->findData(currentButton->onCommand->index));
onEvent->show(); onEvent->show();
onLabel->show();
onEvent->blockSignals(false); onEvent->blockSignals(false);
p.setY(p.y() + 40);
offEvent->blockSignals(true); offEvent->blockSignals(true);
offEvent->move(p);
offEvent->setCurrentIndex(offEvent->findData(currentButton->offCommand->index)); offEvent->setCurrentIndex(offEvent->findData(currentButton->offCommand->index));
offEvent->show(); offEvent->show();
offLabel->show();
offEvent->blockSignals(false); offEvent->blockSignals(false);
knobEvent->hide(); knobEvent->hide();
knobLabel->hide();
buttonLatch->blockSignals(true);
buttonLatch->setChecked(currentButton->toggle);
buttonLatch->blockSignals(false);
buttonLatch->show();
buttonColor->show();
currentKnob = Q_NULLPTR;
break; break;
} }
} }
if (!found) { if (!found) {
for (KNOB& k : *knobs) for (auto k = knobs->begin(); k != knobs->end(); k++)
{ {
if (ui->tabWidget->currentWidget()->objectName() == k.devicePath && k.pos.contains(p)) if (k->page == k->parent->currentPage && ui->tabWidget->currentWidget()->objectName() == k->path && k->pos.contains(p))
{ {
found = true; found = true;
currentKnob = &k; currentKnob = k;
qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text; qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text;
updateDialog->setWindowTitle(QString("Update knob %0").arg(k->num));
knobEvent->blockSignals(true); knobEvent->blockSignals(true);
knobEvent->move(p);
knobEvent->setCurrentIndex(knobEvent->findData(currentKnob->command->index)); knobEvent->setCurrentIndex(knobEvent->findData(currentKnob->command->index));
knobEvent->show(); knobEvent->show();
knobLabel->show();
knobEvent->blockSignals(false); knobEvent->blockSignals(false);
onEvent->hide(); onEvent->hide();
offEvent->hide(); offEvent->hide();
onLabel->hide();
offLabel->hide();
buttonLatch->hide();
buttonColor->hide();
currentButton = Q_NULLPTR;
break; break;
} }
} }
@ -98,26 +147,15 @@ void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
if(found) if(found)
{ {
found=false; updateDialog->show();
foreach (QGraphicsItem *item, scene->items()) updateDialog->move(gp);
{ updateDialog->adjustSize();
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 else
{ {
onEvent->hide(); updateDialog->hide();
offEvent->hide(); currentButton = Q_NULLPTR;
knobEvent->hide(); currentKnob = Q_NULLPTR;
} }
} }
@ -133,7 +171,7 @@ void controllerSetup::onEventIndexChanged(int index) {
currentButton->onText->setPos(currentButton->pos.center().x() - currentButton->onText->boundingRect().width() / 2, currentButton->onText->setPos(currentButton->pos.center().x() - currentButton->onText->boundingRect().width() / 2,
(currentButton->pos.center().y() - currentButton->onText->boundingRect().height() / 2)-6); (currentButton->pos.center().y() - currentButton->onText->boundingRect().height() / 2)-6);
// Signal that any button programming on the device should be completed. // Signal that any button programming on the device should be completed.
emit programButton(currentButton->devicePath,currentButton->num, currentButton->onCommand->text); emit sendRequest(currentButton->parent,usbFeatureType::featureButton,currentButton->num,currentButton->onCommand->text);
} }
} }
@ -152,6 +190,8 @@ void controllerSetup::offEventIndexChanged(int index) {
} }
} }
void controllerSetup::knobEventIndexChanged(int index) { void controllerSetup::knobEventIndexChanged(int index) {
Q_UNUSED(index); Q_UNUSED(index);
// If command is changed, delete current command and deep copy the new command // If command is changed, delete current command and deep copy the new command
@ -167,6 +207,34 @@ void controllerSetup::knobEventIndexChanged(int index) {
} }
} }
void controllerSetup::buttonColorClicked()
{
QColorDialog::ColorDialogOptions options;
options.setFlag(QColorDialog::ShowAlphaChannel, false);
options.setFlag(QColorDialog::DontUseNativeDialog, false);
QColor selColor = QColorDialog::getColor(initialColor, this, "Select Color", options);
if(!selColor.isValid())
{
return;
}
if (currentButton != Q_NULLPTR) {
QMutexLocker locker(mutex);
currentButton->background = selColor;
emit sendRequest(currentButton->parent,usbFeatureType::featureButton,currentButton->num,currentButton->onCommand->text,Q_NULLPTR,&currentButton->background);
}
}
void controllerSetup::latchStateChanged(int state)
{
if (currentButton != Q_NULLPTR) {
QMutexLocker locker(mutex);
currentButton->toggle=(int)state;
}
}
void controllerSetup::removeDevice(USBDEVICE* dev) void controllerSetup::removeDevice(USBDEVICE* dev)
{ {
QMutexLocker locker(mutex); QMutexLocker locker(mutex);
@ -241,13 +309,22 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
dev->message->setAlignment(Qt::AlignRight); dev->message->setAlignment(Qt::AlignRight);
connect(disabled, qOverload<bool>(&QCheckBox::clicked), connect(disabled, qOverload<bool>(&QCheckBox::clicked),
[dev,this,widget](bool checked) { this->disableClicked(dev->path,checked,widget); }); [dev,this,widget](bool checked) { this->disableClicked(dev,checked,widget); });
disabled->setChecked(dev->disabled); disabled->setChecked(dev->disabled);
QGraphicsView *view = new QGraphicsView(); QGraphicsView *view = new QGraphicsView();
layout->addWidget(view); layout->addWidget(view);
QSpinBox *page = new QSpinBox();
page->setValue(1);
page->setMinimum(1);
page->setMaximum(dev->pages);
page->setToolTip("Select current page to edit");
layout->addWidget(page,0,Qt::AlignBottom | Qt::AlignRight);
dev->pageSpin = page;
QHBoxLayout* senslayout = new QHBoxLayout(); QHBoxLayout* senslayout = new QHBoxLayout();
layout->addLayout(senslayout); layout->addLayout(senslayout);
QLabel* senslabel = new QLabel("Sensitivity"); QLabel* senslabel = new QLabel("Sensitivity");
@ -260,11 +337,11 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
senslayout->addWidget(sens); senslayout->addWidget(sens);
sens->setValue(cntrl->sensitivity); sens->setValue(cntrl->sensitivity);
connect(sens, &QSlider::valueChanged, connect(sens, &QSlider::valueChanged,
[dev,this](int val) { this->sensitivityMoved(dev->path,val); }); [dev,this](int val) { this->sensitivityMoved(dev,val); });
QImage image; QImage image;
switch (dev->usbDevice) { switch (dev->type.model) {
case shuttleXpress: case shuttleXpress:
image.load(":/resources/shuttlexpress.png"); image.load(":/resources/shuttlexpress.png");
break; break;
@ -283,6 +360,9 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
case QuickKeys: case QuickKeys:
image.load(":/resources/quickkeys.png"); image.load(":/resources/quickkeys.png");
break; break;
case StreamDeckPlus:
image.load(":/resources/streamdeckplus.png");
break;
default: default:
//ui->graphicsView->setSceneRect(scene->itemsBoundingRect()); //ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
this->adjustSize(); this->adjustSize();
@ -298,206 +378,176 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
#endif #endif
controllerScene * scene = new controllerScene(); controllerScene * scene = new controllerScene();
dev->scene = scene;
view->setScene(scene); view->setScene(scene);
connect(scene, SIGNAL(mousePressed(controllerScene *,QPoint)), this, SLOT(mousePressed(controllerScene *,QPoint))); connect(scene, SIGNAL(mousePressed(controllerScene*,QPoint)), this, SLOT(mousePressed(controllerScene*,QPoint)));
scene->addItem(bgImage); scene->addItem(bgImage);
QGridLayout* grid = new QGridLayout(); QGridLayout* grid = new QGridLayout();
layout->addLayout(grid); layout->addLayout(grid);
if (dev->usbDevice == QuickKeys) QLabel* brightlabel = new QLabel("Brightness");
{ grid->addWidget(brightlabel,0,0);
// Add QuickKeys section QComboBox *brightness = new QComboBox();
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,index); });
QLabel* brightlabel = new QLabel("Brightness"); QLabel* speedlabel = new QLabel("Speed");
grid->addWidget(brightlabel,0,0); grid->addWidget(speedlabel,0,1);
QComboBox *brightness = new QComboBox(); QComboBox *speed = new QComboBox();
brightness->addItem("Off"); speed->addItem("Fastest");
brightness->addItem("Low"); speed->addItem("Faster");
brightness->addItem("Medium"); speed->addItem("Normal");
brightness->addItem("High"); speed->addItem("Slower");
brightness->setCurrentIndex(cntrl->brightness); speed->addItem("Slowest");
grid->addWidget(brightness,1,0); speed->setCurrentIndex(cntrl->speed);
connect(brightness, qOverload<int>(&QComboBox::currentIndexChanged), grid->addWidget(speed,1,1);
[dev,this](int index) { this->brightnessChanged(dev->path,index); }); connect(speed, qOverload<int>(&QComboBox::currentIndexChanged),
[dev,this](int index) { this->speedChanged(dev,index); });
QLabel* speedlabel = new QLabel("Speed"); QLabel* orientlabel = new QLabel("Orientation");
grid->addWidget(speedlabel,0,1); grid->addWidget(orientlabel,0,2);
QComboBox *speed = new QComboBox(); QComboBox *orientation = new QComboBox();
speed->addItem("Fastest"); orientation->addItem("Rotate 0");
speed->addItem("Faster"); orientation->addItem("Rotate 90");
speed->addItem("Normal"); orientation->addItem("Rotate 180");
speed->addItem("Slower"); orientation->addItem("Rotate 270");
speed->addItem("Slowest"); orientation->setCurrentIndex(cntrl->orientation);
speed->setCurrentIndex(cntrl->speed); grid->addWidget(orientation,1,2);
grid->addWidget(speed,1,1); connect(orientation, qOverload<int>(&QComboBox::currentIndexChanged),
connect(speed, qOverload<int>(&QComboBox::currentIndexChanged), [dev,this](int index) { this->orientationChanged(dev,index); });
[dev,this](int index) { this->speedChanged(dev->path,index); });
QLabel* orientlabel = new QLabel("Orientation"); QLabel* colorlabel = new QLabel("Color");
grid->addWidget(orientlabel,0,2); grid->addWidget(colorlabel,0,3);
QComboBox *orientation = new QComboBox(); QPushButton* color = new QPushButton("Select");
orientation->addItem("Rotate 0"); grid->addWidget(color,1,3);
orientation->addItem("Rotate 90"); connect(color, &QPushButton::clicked,
orientation->addItem("Rotate 180"); [dev,this]() { this->colorPicker(dev); });
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"); QLabel* timeoutlabel = new QLabel("Timeout");
grid->addWidget(colorlabel,0,3); grid->addWidget(timeoutlabel,0,4);
QPushButton* color = new QPushButton("Select"); QSpinBox *timeout = new QSpinBox();
grid->addWidget(color,1,3); timeout->setValue(cntrl->timeout);
connect(color, &QPushButton::clicked, grid->addWidget(timeout,1,4);
[dev,this]() { this->colorPicker(dev->path); }); connect(timeout, qOverload<int>(&QSpinBox::valueChanged),
[dev,this](int index) { this->timeoutChanged(dev,index); });
QLabel* timeoutlabel = new QLabel("Timeout"); QLabel* pageslabel = new QLabel("Pages");
grid->addWidget(timeoutlabel,0,4); grid->addWidget(pageslabel,0,5);
QSpinBox *timeout = new QSpinBox(); QSpinBox *pages = new QSpinBox();
timeout->setValue(cntrl->timeout); pages->setValue(dev->pages);
grid->addWidget(timeout,1,4); pages->setMinimum(1);
connect(timeout, qOverload<int>(&QSpinBox::valueChanged), grid->addWidget(pages,1,5);
[dev,this](int index) { this->timeoutChanged(dev->path,index); }); connect(pages, qOverload<int>(&QSpinBox::valueChanged),
[dev,this](int index) { this->pagesChanged(dev,index); });
// Finally update the device with the default values for (int i=0;i<6;i++)
emit programSensitivity(dev->path, cntrl->sensitivity); grid->setColumnStretch(i,1);
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());
}
QLabel *helpText = new QLabel(); QLabel *helpText = new QLabel();
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->setText("<p><b>Button configuration:</b> Right-click on each button to configure it.</p>");
helpText->setAlignment(Qt::AlignCenter); helpText->setAlignment(Qt::AlignCenter);
layout->addWidget(helpText); layout->addWidget(helpText);
if (dev->usbDevice != usbNone)
{
offEvent = new QComboBox;
onEvent = new QComboBox;
knobEvent = new QComboBox;
onEvent->blockSignals(true);
offEvent->blockSignals(true);
knobEvent->blockSignals(true);
onEvent->clear(); onEvent->blockSignals(true);
offEvent->clear(); offEvent->blockSignals(true);
knobEvent->clear(); knobEvent->blockSignals(true);
onEvent->setMaxVisibleItems(5); onEvent->clear();
offEvent->setMaxVisibleItems(5); offEvent->clear();
knobEvent->setMaxVisibleItems(5); knobEvent->clear();
onEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); /*
offEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); onEvent->setMaxVisibleItems(5);
knobEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); offEvent->setMaxVisibleItems(5);
knobEvent->setMaxVisibleItems(5);
onEvent->setStyleSheet("combobox-popup: 0;"); onEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
offEvent->setStyleSheet("combobox-popup: 0;"); offEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
knobEvent->setStyleSheet("combobox-popup: 0;"); knobEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
for (COMMAND& c : *commands) { onEvent->setStyleSheet("combobox-popup: 0;");
if (c.cmdType == commandButton || c.text == "None") { offEvent->setStyleSheet("combobox-popup: 0;");
onEvent->addItem(c.text, c.index); knobEvent->setStyleSheet("combobox-popup: 0;");
offEvent->addItem(c.text, c.index); */
}
if (c.cmdType == commandKnob || c.text == "None") { for (COMMAND& c : *commands) {
knobEvent->addItem(c.text, c.index); if (c.cmdType == commandButton || c.text == "None") {
} onEvent->addItem(c.text, c.index);
offEvent->addItem(c.text, c.index);
} }
onEvent->blockSignals(false); if (c.cmdType == commandKnob || c.text == "None") {
offEvent->blockSignals(false); knobEvent->addItem(c.text, c.index);
knobEvent->blockSignals(false);
onEvent->hide();
offEvent->hide();
knobEvent->hide();
// Set button text
for (BUTTON& b : *buttons)
{
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.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);
scene->addItem(b.offText);
b.offText->setPos(b.pos.center().x() - b.offText->boundingRect().width() / 2,
(b.pos.center().y() - b.onText->boundingRect().height() / 2) + 6);
}
} }
// Set knob text
for (KNOB& k : *knobs)
{
if (k.devicePath == dev->path) {
k.text = new QGraphicsTextItem(k.command->text);
k.text->setDefaultTextColor(k.textColour);
scene->addItem(k.text);
k.text->setPos(k.pos.center().x() - k.text->boundingRect().width() / 2,
(k.pos.center().y() - k.text->boundingRect().height() / 2));
}
}
view->setSceneRect(scene->itemsBoundingRect());
// Add comboboxes to scene after everything else.
connect(offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
connect(onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
connect(knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
onEventProxy = new QGraphicsProxyWidget();
onEventProxy->setWidget(onEvent);
offEventProxy = new QGraphicsProxyWidget();
offEventProxy->setWidget(offEvent);
knobEventProxy = new QGraphicsProxyWidget();
knobEventProxy->setWidget(knobEvent);
this->adjustSize();
} }
onEvent->blockSignals(false);
offEvent->blockSignals(false);
knobEvent->blockSignals(false);
onEvent->hide();
offEvent->hide();
knobEvent->hide();
locker.unlock();
pageChanged(dev,1);
locker.relock();
view->setSceneRect(scene->itemsBoundingRect());
// Add comboboxes to scene after everything else.
// Attach pageChanged() here so we have access to all necessary vars
connect(page, qOverload<int>(&QSpinBox::valueChanged),
[dev, this](int index) { this->pageChanged(dev, index); });
this->adjustSize();
numTabs++; numTabs++;
// Finally update the device with the default values
emit sendRequest(dev,usbFeatureType::featureSensitivity,cntrl->sensitivity);
emit sendRequest(dev,usbFeatureType::featureBrightness,cntrl->brightness);
emit sendRequest(dev,usbFeatureType::featureOrientation,cntrl->orientation);
emit sendRequest(dev,usbFeatureType::featureSpeed,cntrl->speed);
emit sendRequest(dev,usbFeatureType::featureTimeout,cntrl->timeout);
emit sendRequest(dev,usbFeatureType::featureColor,1,cntrl->color.name(QColor::HexArgb));
} }
void controllerSetup::sensitivityMoved(QString path, int val) void controllerSetup::sensitivityMoved(USBDEVICE* dev, int val)
{ {
qInfo(logUsbControl()) << "Setting sensitivity" << val <<"for device" << path; qInfo(logUsbControl()) << "Setting sensitivity" << val <<"for device" << dev->path;
emit programSensitivity(path, val); emit sendRequest(dev,usbFeatureType::featureSensitivity,val);
} }
void controllerSetup::brightnessChanged(QString path, int index) void controllerSetup::brightnessChanged(USBDEVICE* dev, int index)
{ {
emit programBrightness(path, (quint8)index); emit sendRequest(dev,usbFeatureType::featureBrightness,index);
} }
void controllerSetup::orientationChanged(QString path, int index) void controllerSetup::orientationChanged(USBDEVICE* dev, int index)
{ {
emit programOrientation(path, (quint8)index); emit sendRequest(dev,usbFeatureType::featureOrientation,index);
} }
void controllerSetup::speedChanged(QString path, int index) void controllerSetup::speedChanged(USBDEVICE* dev, int index)
{ {
emit programSpeed(path, (quint8)index); emit sendRequest(dev,usbFeatureType::featureSpeed,index);
} }
void controllerSetup::colorPicker(QString path) void controllerSetup::colorPicker(USBDEVICE* dev)
{ {
QColorDialog::ColorDialogOptions options; QColorDialog::ColorDialogOptions options;
options.setFlag(QColorDialog::ShowAlphaChannel, false); options.setFlag(QColorDialog::ShowAlphaChannel, false);
@ -509,18 +559,112 @@ void controllerSetup::colorPicker(QString path)
selColor = initialColor; selColor = initialColor;
} }
initialColor = selColor; initialColor = selColor;
emit programWheelColour(path, (quint8)selColor.red(), (quint8)selColor.green(), (quint8)initialColor.blue()); emit sendRequest(dev,usbFeatureType::featureColor,1,selColor.name(QColor::HexArgb));
} }
void controllerSetup::timeoutChanged(QString path, int val) void controllerSetup::timeoutChanged(USBDEVICE* dev, int val)
{ {
emit programTimeout(path, (quint8)val); emit sendRequest(dev,usbFeatureType::featureTimeout,val);
emit programOverlay(path, 3, QString("Sleep timeout set to %0 minutes").arg(val)); emit sendRequest(dev,usbFeatureType::featureOverlay,val,QString("Sleep timeout set to %0 minutes").arg(val));
} }
void controllerSetup::disableClicked(QString path, bool clicked, QWidget* widget) void controllerSetup::pagesChanged(USBDEVICE* dev, int val)
{
emit programPages(dev,val);
dev->pageSpin->setMaximum(val); // Update pageSpin
}
void controllerSetup::pageChanged(USBDEVICE* dev, int val)
{
if (dev->currentPage == val) // We haven't changed page!
return;
if (val > dev->pages)
val=1;
if (val < 1)
val = dev->pages;
QMutexLocker locker(mutex);
int lastPage = dev->currentPage;
dev->currentPage=val;
dev->pageSpin->setValue(val);
// (re)set button text
for (auto b = buttons->begin();b != buttons->end(); b++)
{
if (b->parent == dev)
{
if (b->page == lastPage)
{
if (b->onText != Q_NULLPTR) {
dev->scene->removeItem(b->onText);
delete b->onText;
b->onText = Q_NULLPTR;
}
if (b->offText != Q_NULLPTR) {
dev->scene->removeItem(b->offText);
delete b->offText;
b->offText = Q_NULLPTR;
}
}
else if (b->page == dev->currentPage)
{
b->onText = new QGraphicsTextItem(b->onCommand->text);
b->onText->setDefaultTextColor(b->textColour);
dev->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 sendRequest(dev,usbFeatureType::featureButton,b->num,b->onCommand->text,Q_NULLPTR,&b->background);
b->offText = new QGraphicsTextItem(b->offCommand->text);
b->offText->setDefaultTextColor(b->textColour);
dev->scene->addItem(b->offText);
b->offText->setPos(b->pos.center().x() - b->offText->boundingRect().width() / 2,
(b->pos.center().y() - b->onText->boundingRect().height() / 2) + 6);
}
}
}
// Set knob text
for (auto k = knobs->begin();k != knobs->end(); k++)
{
if (k->parent == dev) {
if (k->page == lastPage)
{
if (k->text) {
dev->scene->removeItem(k->text);
delete k->text;
k->text = Q_NULLPTR;
}
}
else if (k->page == dev->currentPage)
{
k->text = new QGraphicsTextItem(k->command->text);
k->text->setDefaultTextColor(k->textColour);
dev->scene->addItem(k->text);
k->text->setPos(k->pos.center().x() - k->text->boundingRect().width() / 2,
(k->pos.center().y() - k->text->boundingRect().height() / 2));
}
}
}
}
void controllerSetup::disableClicked(USBDEVICE* dev, bool clicked, QWidget* widget)
{ {
// Disable checkbox has been clicked // Disable checkbox has been clicked
emit programDisable(path,clicked); emit programDisable(dev, clicked);
widget->setEnabled(!clicked); widget->setEnabled(!clicked);
} }
void controllerSetup::setConnected(USBDEVICE* dev)
{
if (dev->connected)
{
dev->message->setStyleSheet("QLabel { color : green; }");
dev->message->setText("Connected");
} else {
dev->message->setStyleSheet("QLabel { color : red; }");
dev->message->setText("Not Connected");
}
}

Wyświetl plik

@ -25,6 +25,7 @@
#include <QColorDialog> #include <QColorDialog>
#include <QWidget> #include <QWidget>
#include <QSpinBox> #include <QSpinBox>
#include <QCheckBox>
#include "usbcontroller.h" #include "usbcontroller.h"
@ -64,34 +65,36 @@ public:
~controllerSetup(); ~controllerSetup();
signals: signals:
void programButton(QString path, quint8 but, QString text); void sendRequest(USBDEVICE* dev, usbFeatureType request, quint8 val=0, QString text="", QImage* img=Q_NULLPTR, QColor* color=Q_NULLPTR);
void programSensitivity(QString path, quint8 level); void programDisable(USBDEVICE* dev, bool disable);
void programBrightness(QString path, quint8 level); void programPages(USBDEVICE* dev, int pages);
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);
void programDisable(QString path, bool disable);
public slots: public slots:
void init();
void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut); void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
void removeDevice(USBDEVICE* dev); void removeDevice(USBDEVICE* dev);
void mousePressed(controllerScene *scene,QPoint p); void mousePressed(controllerScene *scene,QPoint p);
void onEventIndexChanged(int index); void onEventIndexChanged(int index);
void offEventIndexChanged(int index); void offEventIndexChanged(int index);
void knobEventIndexChanged(int index); void knobEventIndexChanged(int index);
void sensitivityMoved(QString path, int val); void sensitivityMoved(USBDEVICE* dev, int val);
void brightnessChanged(QString path, int index); void brightnessChanged(USBDEVICE* dev, int index);
void orientationChanged(QString path, int index); void orientationChanged(USBDEVICE* dev, int index);
void speedChanged(QString path, int index); void speedChanged(USBDEVICE* dev, int index);
void colorPicker(QString path); void colorPicker(USBDEVICE* dev);
void timeoutChanged(QString path, int val); void buttonColorClicked();
void disableClicked(QString path, bool clicked, QWidget* widget); void latchStateChanged(int state);
void timeoutChanged(USBDEVICE* dev, int val);
void pageChanged(USBDEVICE* dev, int val);
void pagesChanged(USBDEVICE* dev, int val);
void disableClicked(USBDEVICE* dev, bool clicked, QWidget* widget);
void setConnected(USBDEVICE* dev);
private: private:
usbDeviceType usbDevice = usbNone; usbDeviceType type = usbNone;
Ui::controllerSetup* ui; Ui::controllerSetup* ui;
QGraphicsTextItem* textItem; QGraphicsTextItem* textItem;
QLabel* imgLabel; QLabel* imgLabel;
@ -99,17 +102,22 @@ private:
QVector<BUTTON>* buttons; QVector<BUTTON>* buttons;
QVector<KNOB>* knobs; QVector<KNOB>* knobs;
QVector<COMMAND>* commands; QVector<COMMAND>* commands;
usbMap* controllers; usbMap* controllers;
BUTTON* currentButton = Q_NULLPTR; BUTTON* currentButton = Q_NULLPTR;
KNOB* currentKnob = Q_NULLPTR; KNOB* currentKnob = Q_NULLPTR;
QComboBox* onEvent = Q_NULLPTR;
QComboBox* offEvent = Q_NULLPTR; // Update Dialog
QComboBox* knobEvent = Q_NULLPTR; QDialog * updateDialog;
QComboBox* qkBright = Q_NULLPTR; QComboBox* onEvent;
QGraphicsProxyWidget* onEventProxy = Q_NULLPTR; QComboBox* offEvent;
QGraphicsProxyWidget* offEventProxy = Q_NULLPTR; QComboBox* knobEvent;
QGraphicsProxyWidget* knobEventProxy = Q_NULLPTR; QLabel* onLabel;
QGraphicsProxyWidget* qkBrightProxy = Q_NULLPTR; QLabel* offLabel;
QLabel* knobLabel;
QPushButton* buttonColor;
QCheckBox *buttonLatch;
QString deviceName; QString deviceName;
QMutex* mutex; QMutex* mutex;
QColor initialColor = Qt::white; QColor initialColor = Qt::white;

Wyświetl plik

@ -399,6 +399,36 @@ typedef union capabilities_packet {
} *capabilities_packet_t; } *capabilities_packet_t;
typedef union streamdeck_image_header {
struct
{
quint8 cmd;
quint8 suffix;
quint8 button;
quint8 isLast;
quint16 length;
quint16 index;
};
char packet[8];
} *streamdeck_image_header_t;
typedef union streamdeck_lcd_header {
struct
{
quint8 cmd;
quint8 suffix;
quint16 x;
quint16 y;
quint16 width;
quint16 height;
quint8 isLast;
quint16 index;
quint16 length;
quint8 unused;
};
char packet[16];
} *streamdeck_lcd_header_t;
#pragma pack(pop) #pragma pack(pop)

Wyświetl plik

@ -7,5 +7,6 @@
<file>ecoder.png</file> <file>ecoder.png</file>
<file>quickkeys.png</file> <file>quickkeys.png</file>
<file>xbox.png</file> <file>xbox.png</file>
<file>streamdeckplus.png</file>
</qresource> </qresource>
</RCC> </RCC>

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 226 KiB

Plik diff jest za duży Load Diff

Wyświetl plik

@ -8,6 +8,7 @@
#include <QDateTime> #include <QDateTime>
#include <QRect> #include <QRect>
#include <QGraphicsTextItem> #include <QGraphicsTextItem>
#include <QSpinBox>
#include <QColor> #include <QColor>
#include <QVector> #include <QVector>
#include <QList> #include <QList>
@ -17,6 +18,10 @@
#include <QtEndian> #include <QtEndian>
#include <QUuid> #include <QUuid>
#include <QLabel> #include <QLabel>
#include <QImage>
#include <QPainter>
#include <QImageWriter>
#include <QBuffer>
#if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0) #if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
#include <QGamepad> #include <QGamepad>
@ -59,8 +64,28 @@ using namespace std;
#define HIDDATALENGTH 64 #define HIDDATALENGTH 64
#define MAX_STR 255 #define MAX_STR 255
struct USBTYPE {
USBTYPE() {}
USBTYPE(usbDeviceType model,quint32 manufacturerId, quint32 productId , quint32 usage, quint32 usagePage, int buttons, int knobs, int maxPayload, int iconSize) :
model(model), manufacturerId(manufacturerId), productId(productId), usage(usage), usagePage(usagePage), buttons(buttons), knobs(knobs),maxPayload(maxPayload), iconSize(iconSize) {}
usbDeviceType model = usbNone;
quint32 manufacturerId=0;
quint32 productId=0;
quint32 usage=0;
quint32 usagePage=0;
int buttons=0;
int knobs=0;
int maxPayload=0;
int iconSize=0;
};
struct USBDEVICE { struct USBDEVICE {
usbDeviceType usbDevice = usbNone; USBDEVICE() {}
USBDEVICE(USBTYPE type) : type(type) {}
USBTYPE type;
bool remove = false; bool remove = false;
bool connected = false; bool connected = false;
bool uiCreated = false; bool uiCreated = false;
@ -71,8 +96,6 @@ struct USBDEVICE {
QString serial = "<none>"; QString serial = "<none>";
QString deviceId = ""; QString deviceId = "";
QString path = ""; QString path = "";
quint16 vendorId = 0;
quint16 productId = 0;
int sensitivity = 1; int sensitivity = 1;
unsigned char jogpos=0; unsigned char jogpos=0;
unsigned char shutpos=0; unsigned char shutpos=0;
@ -88,6 +111,12 @@ struct USBDEVICE {
unsigned char lastDialPos=0; unsigned char lastDialPos=0;
QUuid uuid; QUuid uuid;
QLabel *message; QLabel *message;
int pages=1;
int currentPage=0;
QGraphicsScene* scene = Q_NULLPTR;
QSpinBox* pageSpin = Q_NULLPTR;
QImage image;
}; };
struct COMMAND { struct COMMAND {
@ -113,22 +142,27 @@ struct BUTTON {
BUTTON() {} BUTTON() {}
BUTTON(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) : BUTTON(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) :
dev(dev), num(num), name(""), pos(pos), textColour(textColour), onCommand(on), offCommand(off) {} dev(dev), num(num), name(""), pos(pos), textColour(textColour), onCommand(on), offCommand(off), on(onCommand->text), off(offCommand->text) {}
BUTTON(usbDeviceType dev, QString name, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) : BUTTON(usbDeviceType dev, QString name, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) :
dev(dev), num(-1), name(name), pos(pos), textColour(textColour), onCommand(on), offCommand(off) {} dev(dev), num(-1), name(name), pos(pos), textColour(textColour), onCommand(on), offCommand(off), on(onCommand->text), off(offCommand->text) {}
usbDeviceType dev; usbDeviceType dev;
USBDEVICE* parent;
int page=1;
int num; int num;
QString name; QString name;
QRect pos; QRect pos;
QColor textColour; QColor textColour;
const COMMAND* onCommand = Q_NULLPTR; const COMMAND* onCommand = Q_NULLPTR;
const COMMAND* offCommand = Q_NULLPTR; const COMMAND* offCommand = Q_NULLPTR;
QGraphicsTextItem* onText; QGraphicsTextItem* onText = Q_NULLPTR;
QGraphicsTextItem* offText; QGraphicsTextItem* offText;
QString on; QString on;
QString off; QString off;
QString devicePath; QString path;
QColor background = Qt::white;
bool toggle = false;
bool isOn = false;
}; };
@ -136,20 +170,25 @@ struct KNOB {
KNOB() {} KNOB() {}
KNOB(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* command) : KNOB(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* command) :
dev(dev), num(num), name(""), pos(pos), textColour(textColour), command(command) {} dev(dev), num(num), name(""), pos(pos), textColour(textColour), command(command), cmd(command->text) {}
usbDeviceType dev; usbDeviceType dev;
USBDEVICE* parent;
int page=1;
int num; int num;
QString name; QString name;
QRect pos; QRect pos;
QColor textColour; QColor textColour;
const COMMAND* command = Q_NULLPTR; const COMMAND* command = Q_NULLPTR;
QGraphicsTextItem* text; QGraphicsTextItem* text = Q_NULLPTR;
QString cmd; QString cmd;
QString devicePath; QString path;
}; };
struct CONTROLLER { struct CONTROLLER {
CONTROLLER() {}
CONTROLLER(USBDEVICE* dev) : dev(dev) {}
bool disabled=false; bool disabled=false;
int sensitivity=1; int sensitivity=1;
quint8 speed=2; quint8 speed=2;
@ -157,7 +196,12 @@ struct CONTROLLER {
quint8 brightness=2; quint8 brightness=2;
quint8 orientation=0; quint8 orientation=0;
QColor color=Qt::white; QColor color=Qt::white;
int pages=1;
cmds lcd=cmdNone;
USBDEVICE* dev;
}; };
typedef QMap<QString,CONTROLLER> usbMap; typedef QMap<QString,CONTROLLER> usbMap;
@ -176,17 +220,11 @@ public slots:
void runTimer(); void runTimer();
void ledControl(bool on, unsigned char num); void ledControl(bool on, unsigned char num);
void receivePTTStatus(bool on); void receivePTTStatus(bool on);
void getVersion(); void programPages(USBDEVICE* dev, int pages);
void programButton(QString path, quint8 val, QString text); void programDisable(USBDEVICE* dev, bool disabled);
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);
void programDisable(QString path, bool disabled);
void sendRequest(USBDEVICE *dev, usbFeatureType feature, quint8 val=0, QString text="", QImage* img=Q_NULLPTR, QColor* color=Q_NULLPTR);
void sendToLCD(QImage *img);
signals: signals:
void jogPlus(); void jogPlus();
@ -195,24 +233,27 @@ signals:
void doShuttle(bool plus, quint8 level); void doShuttle(bool plus, quint8 level);
void setBand(int band); void setBand(int band);
void button(const COMMAND* cmd); void button(const COMMAND* cmd);
void initUI();
void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut); void newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
void removeDevice(USBDEVICE* dev); void removeDevice(USBDEVICE* dev);
void setConnected(USBDEVICE* dev);
void changePage(USBDEVICE* dev, int page);
private: private:
void loadButtons(); void loadButtons();
void loadKnobs(); void loadKnobs();
void loadCommands(); void loadCommands();
int hidStatus = 1; int hidStatus = 1;
bool isOpen=false; bool isOpen=false;
int devicesConnected=0; int devicesConnected=0;
QVector<BUTTON>* buttonList; QVector<BUTTON>* buttonList;
QVector<KNOB>* knobList; QVector<KNOB>* knobList;
QList<QVector<KNOB>*> deviceKnobs;
QList<QVector<BUTTON>*> deviceButtons;
QVector<BUTTON> defaultButtons; QVector<BUTTON> defaultButtons;
QVector<KNOB> defaultKnobs; QVector<KNOB> defaultKnobs;
QVector<USBTYPE> knownDevices;
QVector<COMMAND> commands; QVector<COMMAND> commands;
QMap<QString,USBDEVICE> usbDevices; QMap<QString,USBDEVICE> usbDevices;
usbMap *controllers; usbMap *controllers;
@ -226,15 +267,6 @@ private:
QMutex* mutex=Q_NULLPTR; QMutex* mutex=Q_NULLPTR;
COMMAND sendCommand; COMMAND sendCommand;
unsigned short knownUsbDevices[6][5] = {
{shuttleXpress,0x0b33,0x0020,0x0000,0x0000},
{shuttlePro2,0x0b33,0x0030,0x0000,0x0000},
{RC28,0x0c26,0x001e,0x0000,0x0000},
{eCoderPlus, 0x1fc9, 0x0003,0x0000,0x0000},
{QuickKeys, 0x28bd, 0x5202,0x0001,0xff0a},
{QuickKeys, 0x28bd, 0x5203,0x0001,0xff0a}
};
protected: protected:
}; };

Wyświetl plik

@ -85,6 +85,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
qRegisterMetaType<networkAudioLevels>(); qRegisterMetaType<networkAudioLevels>();
qRegisterMetaType<codecType>(); qRegisterMetaType<codecType>();
qRegisterMetaType<errorType>(); qRegisterMetaType<errorType>();
qRegisterMetaType<usbFeatureType>();
haveRigCaps = false; haveRigCaps = false;
@ -1678,25 +1679,24 @@ void wfmain::setupUsbControllerDevice()
connect(usbControllerThread, SIGNAL(started()), usbControllerDev, SLOT(run())); connect(usbControllerThread, SIGNAL(started()), usbControllerDev, SLOT(run()));
connect(usbControllerThread, SIGNAL(finished()), usbControllerDev, SLOT(deleteLater())); connect(usbControllerThread, SIGNAL(finished()), usbControllerDev, SLOT(deleteLater()));
connect(usbControllerDev, SIGNAL(sendJog(int)), this, SLOT(changeFrequency(int))); connect(usbControllerDev, SIGNAL(sendJog(int)), this, SLOT(changeFrequency(int)));
connect(usbControllerDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char))); 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(button(const COMMAND*)), this, SLOT(buttonControl(const COMMAND*)));
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int))); connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
connect(usbControllerDev, SIGNAL(removeDevice(USBDEVICE *)), shut, SLOT(removeDevice(USBDEVICE *))); 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*))); connect(usbControllerDev, SIGNAL(initUI()), shut, SLOT(init()));
connect(usbControllerDev, SIGNAL(changePage(USBDEVICE*, int)), shut, SLOT(pageChanged(USBDEVICE*, int)));
connect(usbControllerDev, SIGNAL(setConnected(USBDEVICE*)), shut, SLOT(setConnected(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); usbControllerThread->start(QThread::LowestPriority);
connect(shut, SIGNAL(programButton(QString, quint8, QString)), usbControllerDev, SLOT(programButton(QString, quint8, QString))); connect(shut, SIGNAL(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)), usbControllerDev, SLOT(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)));
connect(shut, SIGNAL(programSensitivity(QString, quint8)), usbControllerDev, SLOT(programSensitivity(QString, quint8))); connect(this, SIGNAL(sendControllerRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)), usbControllerDev, SLOT(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)));
connect(shut, SIGNAL(programBrightness(QString, quint8)), usbControllerDev, SLOT(programBrightness(QString, quint8))); connect(shut, SIGNAL(programPages(USBDEVICE*, int)), usbControllerDev, SLOT(programPages(USBDEVICE*, int)));
connect(shut, SIGNAL(programOrientation(QString, quint8)), usbControllerDev, SLOT(programOrientation(QString, quint8))); connect(shut, SIGNAL(programDisable(USBDEVICE*, bool)), usbControllerDev, SLOT(programDisable(USBDEVICE*, bool)));
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(shut, SIGNAL(programDisable(QString, bool)), usbControllerDev, SLOT(programDisable(QString, bool)));
connect(this, SIGNAL(setPTT(bool)), usbControllerDev, SLOT(receivePTTStatus(bool))); connect(this, SIGNAL(setPTT(bool)), usbControllerDev, SLOT(receivePTTStatus(bool)));
connect(this, SIGNAL(initUsbController(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)), usbControllerDev, SLOT(init(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*))); connect(this, SIGNAL(initUsbController(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)), usbControllerDev, SLOT(init(QMutex*,usbMap*,QVector<BUTTON>*,QVector<KNOB>*)));
#endif #endif
} }
@ -2496,11 +2496,13 @@ void wfmain::loadSettings()
QString tempPath = settings->value("Path", "").toString(); QString tempPath = settings->value("Path", "").toString();
tempPrefs.disabled = settings->value("Disabled", false).toBool(); tempPrefs.disabled = settings->value("Disabled", false).toBool();
tempPrefs.sensitivity = settings->value("Sensitivity", 1).toInt(); tempPrefs.sensitivity = settings->value("Sensitivity", 1).toInt();
tempPrefs.pages = settings->value("Pages", 1).toInt();
tempPrefs.brightness = (quint8)settings->value("Brightness", 2).toInt(); tempPrefs.brightness = (quint8)settings->value("Brightness", 2).toInt();
tempPrefs.orientation = (quint8)settings->value("Orientation", 2).toInt(); tempPrefs.orientation = (quint8)settings->value("Orientation", 2).toInt();
tempPrefs.speed = (quint8)settings->value("Speed", 2).toInt(); tempPrefs.speed = (quint8)settings->value("Speed", 2).toInt();
tempPrefs.timeout = (quint8)settings->value("Timeout", 30).toInt(); tempPrefs.timeout = (quint8)settings->value("Timeout", 30).toInt();
tempPrefs.color.setNamedColor(settings->value("Color", QColor(Qt::white).name(QColor::HexArgb)).toString()); tempPrefs.color.setNamedColor(settings->value("Color", QColor(Qt::white).name(QColor::HexArgb)).toString());
tempPrefs.lcd = (cmds)settings->value("LCD",0).toInt();
if (!tempPath.isEmpty()) { if (!tempPath.isEmpty()) {
usbControllers.insert(tempPath,tempPrefs); usbControllers.insert(tempPath,tempPrefs);
@ -2519,7 +2521,8 @@ void wfmain::loadSettings()
{ {
settings->setArrayIndex(nb); settings->setArrayIndex(nb);
BUTTON butt; BUTTON butt;
butt.devicePath = settings->value("Path", "").toString(); butt.path = settings->value("Path", "").toString();
butt.page = settings->value("Page", 1).toInt();
butt.dev = (usbDeviceType)settings->value("Dev", 0).toInt(); butt.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
butt.num = settings->value("Num", 0).toInt(); butt.num = settings->value("Num", 0).toInt();
butt.name = settings->value("Name", "").toString(); butt.name = settings->value("Name", "").toString();
@ -2527,11 +2530,13 @@ void wfmain::loadSettings()
settings->value("Top", 0).toInt(), settings->value("Top", 0).toInt(),
settings->value("Width", 0).toInt(), settings->value("Width", 0).toInt(),
settings->value("Height", 0).toInt()); settings->value("Height", 0).toInt());
butt.textColour = QColor((settings->value("Colour", "Green").toString())); butt.textColour.setNamedColor(settings->value("Colour", QColor(Qt::white).name(QColor::HexArgb)).toString());
butt.background.setNamedColor(settings->value("Background", QColor(Qt::white).name(QColor::HexArgb)).toString());
butt.toggle = settings->value("Toggle", false).toBool();
butt.on = settings->value("OnCommand", "None").toString(); butt.on = settings->value("OnCommand", "None").toString();
butt.off = settings->value("OffCommand", "None").toString(); butt.off = settings->value("OffCommand", "None").toString();
if (!butt.devicePath.isEmpty()) if (!butt.path.isEmpty())
usbButtons.append(butt); usbButtons.append(butt);
} }
settings->endArray(); settings->endArray();
@ -2547,7 +2552,8 @@ void wfmain::loadSettings()
{ {
settings->setArrayIndex(nk); settings->setArrayIndex(nk);
KNOB kb; KNOB kb;
kb.devicePath = settings->value("Path", "").toString(); kb.path = settings->value("Path", "").toString();
kb.page = settings->value("Page", 1).toInt();
kb.dev = (usbDeviceType)settings->value("Dev", 0).toInt(); kb.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
kb.num = settings->value("Num", 0).toInt(); kb.num = settings->value("Num", 0).toInt();
kb.name = settings->value("Name", "").toString(); kb.name = settings->value("Name", "").toString();
@ -2558,7 +2564,7 @@ void wfmain::loadSettings()
kb.textColour = QColor((settings->value("Colour", "Green").toString())); kb.textColour = QColor((settings->value("Colour", "Green").toString()));
kb.cmd = settings->value("Command", "None").toString(); kb.cmd = settings->value("Command", "None").toString();
if (!kb.devicePath.isEmpty()) if (!kb.path.isEmpty())
usbKnobs.append(kb); usbKnobs.append(kb);
} }
settings->endArray(); settings->endArray();
@ -2979,6 +2985,7 @@ void wfmain::saveSettings()
// Store USB Controller // Store USB Controller
settings->remove("Controllers");
settings->beginWriteArray("Controllers"); settings->beginWriteArray("Controllers");
int nc=0; int nc=0;
@ -2994,7 +3001,9 @@ void wfmain::saveSettings()
settings->setValue("Orientation", i.value().orientation); settings->setValue("Orientation", i.value().orientation);
settings->setValue("Speed", i.value().speed); settings->setValue("Speed", i.value().speed);
settings->setValue("Timeout", i.value().timeout); settings->setValue("Timeout", i.value().timeout);
settings->setValue("Pages", i.value().pages);
settings->setValue("Color", i.value().color.name(QColor::HexArgb)); settings->setValue("Color", i.value().color.name(QColor::HexArgb));
settings->setValue("LCD", i.value().lcd);
++i; ++i;
++nc; ++nc;
@ -3002,19 +3011,24 @@ void wfmain::saveSettings()
settings->endArray(); settings->endArray();
settings->remove("Buttons");
settings->beginWriteArray("Buttons"); settings->beginWriteArray("Buttons");
for (int nb = 0; nb < usbButtons.count(); nb++) for (int nb = 0; nb < usbButtons.count(); nb++)
{ {
settings->setArrayIndex(nb); settings->setArrayIndex(nb);
settings->setValue("Page", usbButtons[nb].page);
settings->setValue("Dev", usbButtons[nb].dev); settings->setValue("Dev", usbButtons[nb].dev);
settings->setValue("Num", usbButtons[nb].num); settings->setValue("Num", usbButtons[nb].num);
settings->setValue("Path", usbButtons[nb].devicePath); settings->setValue("Path", usbButtons[nb].path);
settings->setValue("Name", usbButtons[nb].name); settings->setValue("Name", usbButtons[nb].name);
settings->setValue("Left", usbButtons[nb].pos.left()); settings->setValue("Left", usbButtons[nb].pos.left());
settings->setValue("Top", usbButtons[nb].pos.top()); settings->setValue("Top", usbButtons[nb].pos.top());
settings->setValue("Width", usbButtons[nb].pos.width()); settings->setValue("Width", usbButtons[nb].pos.width());
settings->setValue("Height", usbButtons[nb].pos.height()); settings->setValue("Height", usbButtons[nb].pos.height());
settings->setValue("Colour", usbButtons[nb].textColour.name()); settings->setValue("Colour", usbButtons[nb].textColour.name(QColor::HexArgb));
settings->setValue("Background", usbButtons[nb].background.name(QColor::HexArgb));
settings->setValue("Toggle", usbButtons[nb].toggle);
if (usbButtons[nb].onCommand != Q_NULLPTR) if (usbButtons[nb].onCommand != Q_NULLPTR)
settings->setValue("OnCommand", usbButtons[nb].onCommand->text); settings->setValue("OnCommand", usbButtons[nb].onCommand->text);
if (usbButtons[nb].offCommand != Q_NULLPTR) if (usbButtons[nb].offCommand != Q_NULLPTR)
@ -3023,13 +3037,15 @@ void wfmain::saveSettings()
settings->endArray(); settings->endArray();
settings->remove("Knobs");
settings->beginWriteArray("Knobs"); settings->beginWriteArray("Knobs");
for (int nk = 0; nk < usbKnobs.count(); nk++) for (int nk = 0; nk < usbKnobs.count(); nk++)
{ {
settings->setArrayIndex(nk); settings->setArrayIndex(nk);
settings->setValue("Page", usbKnobs[nk].page);
settings->setValue("Dev", usbKnobs[nk].dev); settings->setValue("Dev", usbKnobs[nk].dev);
settings->setValue("Num", usbKnobs[nk].num); settings->setValue("Num", usbKnobs[nk].num);
settings->setValue("Path", usbKnobs[nk].devicePath); settings->setValue("Path", usbKnobs[nk].path);
settings->setValue("Left", usbKnobs[nk].pos.left()); settings->setValue("Left", usbKnobs[nk].pos.left());
settings->setValue("Top", usbKnobs[nk].pos.top()); settings->setValue("Top", usbKnobs[nk].pos.top());
settings->setValue("Width", usbKnobs[nk].pos.width()); settings->setValue("Width", usbKnobs[nk].pos.width());
@ -5241,9 +5257,31 @@ void wfmain::receiveSpectrumData(QByteArray spectrum, double startFreq, double e
wf->yAxis->setRange(0,wfLength - 1); wf->yAxis->setRange(0,wfLength - 1);
wf->xAxis->setRange(0, spectWidth-1); wf->xAxis->setRange(0, spectWidth-1);
wf->replot(); wf->replot();
// Send to USB Controllers if requested
usbMap::const_iterator i = usbControllers.constBegin();
while (i != usbControllers.constEnd())
{
if (i.value().dev != Q_NULLPTR && i.value().lcd == cmdLCDWaterfall )
{
lcdImage = wf->toPixmap(800,100,1.0).toImage();
emit sendControllerRequest(i.value().dev, usbFeatureType::featureLCD, 0, "", &lcdImage);
}
else if (i.value().dev != Q_NULLPTR && i.value().lcd == cmdLCDSpectrum)
{
lcdImage = plot->toPixmap(800,100,1.0).toImage();
emit sendControllerRequest(i.value().dev, usbFeatureType::featureLCD, 0, "", &lcdImage);
}
++i;
}
} }
oldPlotFloor = plotFloor; oldPlotFloor = plotFloor;
oldPlotCeiling = plotCeiling; oldPlotCeiling = plotCeiling;
} }
} }

Wyświetl plik

@ -238,6 +238,7 @@ signals:
void setClusterTimeout(int timeout); void setClusterTimeout(int timeout);
void setClusterSkimmerSpots(bool enable); void setClusterSkimmerSpots(bool enable);
void setFrequencyRange(double low, double high); void setFrequencyRange(double low, double high);
void sendControllerRequest(USBDEVICE* dev, usbFeatureType request, quint8 val=0, QString text="", QImage* img=Q_NULLPTR, QColor* color=Q_NULLPTR);
private slots: private slots:
void setAudioDevicesUI(); void setAudioDevicesUI();
@ -1144,7 +1145,7 @@ private:
#if defined (USB_CONTROLLER) #if defined (USB_CONTROLLER)
usbController *usbControllerDev = Q_NULLPTR; usbController *usbControllerDev = Q_NULLPTR;
QThread *usbControllerThread = Q_NULLPTR; QThread *usbControllerThread = Q_NULLPTR;
QString usbDeviceName; QString typeName;
QVector<BUTTON> usbButtons; QVector<BUTTON> usbButtons;
QVector<KNOB> usbKnobs; QVector<KNOB> usbKnobs;
usbMap usbControllers; usbMap usbControllers;
@ -1160,6 +1161,7 @@ private:
QMutex clusterMutex; QMutex clusterMutex;
QColor clusterColor; QColor clusterColor;
audioDevices* audioDev = Q_NULLPTR; audioDevices* audioDev = Q_NULLPTR;
QImage lcdImage;
}; };
Q_DECLARE_METATYPE(struct rigCapabilities) Q_DECLARE_METATYPE(struct rigCapabilities)
@ -1194,6 +1196,7 @@ Q_DECLARE_METATYPE(enum duplexMode)
Q_DECLARE_METATYPE(enum rptAccessTxRx) Q_DECLARE_METATYPE(enum rptAccessTxRx)
Q_DECLARE_METATYPE(struct rptrTone_t) Q_DECLARE_METATYPE(struct rptrTone_t)
Q_DECLARE_METATYPE(struct rptrAccessData_t) Q_DECLARE_METATYPE(struct rptrAccessData_t)
Q_DECLARE_METATYPE(enum usbFeatureType)
//void (*wfmain::logthistext)(QString text) = NULL; //void (*wfmain::logthistext)(QString text) = NULL;

Wyświetl plik

@ -169,7 +169,9 @@ enum cmds {
cmdGetBandStackReg, cmdGetKeySpeed, cmdSetKeySpeed, cmdGetBreakMode, cmdSetBreakMode, cmdSendCW, cmdStopCW, cmdGetDashRatio, cmdSetDashRatio, cmdGetBandStackReg, cmdGetKeySpeed, cmdSetKeySpeed, cmdGetBreakMode, cmdSetBreakMode, cmdSendCW, cmdStopCW, cmdGetDashRatio, cmdSetDashRatio,
cmdSetTime, cmdSetDate, cmdSetUTCOffset, cmdSetTime, cmdSetDate, cmdSetUTCOffset,
// Below Only used for USB Controller at the moment. // Below Only used for USB Controller at the moment.
cmdSetBandUp, cmdSetBandDown, cmdSetModeUp, cmdSetModeDown, cmdSetStepUp, cmdSetStepDown, cmdSetSpanUp, cmdSetSpanDown, cmdIFFilterUp, cmdIFFilterDown cmdSetBandUp, cmdSetBandDown, cmdSetModeUp, cmdSetModeDown, cmdSetStepUp, cmdSetStepDown,
cmdSetSpanUp, cmdSetSpanDown, cmdIFFilterUp, cmdIFFilterDown, cmdPageDown, cmdPageUp,
cmdLCDWaterfall, cmdLCDSpectrum
}; };
struct commandtype { struct commandtype {
@ -194,7 +196,14 @@ enum codecType { LPCM, PCMU, OPUS };
enum passbandActions {passbandStatic, pbtInnerMove, pbtOuterMove, pbtMoving, passbandResizing}; enum passbandActions {passbandStatic, pbtInnerMove, pbtOuterMove, pbtMoving, passbandResizing};
enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2, RC28, xBoxGamepad, unknownGamepad, eCoderPlus, QuickKeys}; enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2,
RC28, xBoxGamepad, unknownGamepad, eCoderPlus, QuickKeys,
StreamDeckMini,StreamDeckMiniV2,StreamDeckOriginal,StreamDeckOriginalV2,
StreamDeckOriginalMK2,StreamDeckXL,StreamDeckXLV2,StreamDeckPedal, StreamDeckPlus
};
enum usbCommandType{ commandButton, commandKnob }; enum usbCommandType{ commandButton, commandKnob };
enum usbFeatureType { featureReset,featureResetKeys, featureEventsA, featureEventsB, featureFirmware, featureSerial, featureButton, featureSensitivity, featureBrightness,
featureOrientation, featureSpeed, featureColor, featureOverlay, featureTimeout, featureLCD };
#endif // WFVIEWTYPES_H #endif // WFVIEWTYPES_H