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()
{
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;
}
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)
{
Q_UNUSED (scene) // We might want it in the future?
// Receive mouse event from the scene
qDebug() << "Looking for button Point x=" << p.x() << " y=" << p.y();
if (onEvent == Q_NULLPTR|| offEvent == Q_NULLPTR|| knobEvent == Q_NULLPTR)
@ -47,50 +80,66 @@ void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
}
bool found = false;
QMutexLocker locker(mutex);
QPoint gp = this->mapToGlobal(p);
for (BUTTON& b : *buttons)
for (auto b = buttons->begin(); b != buttons->end(); b++)
{
if (ui->tabWidget->currentWidget()->objectName() == b.devicePath && b.pos.contains(p))
if (b->page == b->parent->currentPage && ui->tabWidget->currentWidget()->objectName() == b->path && b->pos.contains(p))
{
found = true;
currentButton = &b;
currentButton = b;
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->move(p);
onEvent->setCurrentIndex(onEvent->findData(currentButton->onCommand->index));
onEvent->show();
onLabel->show();
onEvent->blockSignals(false);
p.setY(p.y() + 40);
offEvent->blockSignals(true);
offEvent->move(p);
offEvent->setCurrentIndex(offEvent->findData(currentButton->offCommand->index));
offEvent->show();
offLabel->show();
offEvent->blockSignals(false);
knobEvent->hide();
knobLabel->hide();
buttonLatch->blockSignals(true);
buttonLatch->setChecked(currentButton->toggle);
buttonLatch->blockSignals(false);
buttonLatch->show();
buttonColor->show();
currentKnob = Q_NULLPTR;
break;
}
}
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;
currentKnob = &k;
currentKnob = k;
qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text;
updateDialog->setWindowTitle(QString("Update knob %0").arg(k->num));
knobEvent->blockSignals(true);
knobEvent->move(p);
knobEvent->setCurrentIndex(knobEvent->findData(currentKnob->command->index));
knobEvent->show();
knobLabel->show();
knobEvent->blockSignals(false);
onEvent->hide();
offEvent->hide();
onLabel->hide();
offLabel->hide();
buttonLatch->hide();
buttonColor->hide();
currentButton = Q_NULLPTR;
break;
}
}
@ -98,26 +147,15 @@ void controllerSetup::mousePressed(controllerScene* scene, QPoint p)
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());
}
updateDialog->show();
updateDialog->move(gp);
updateDialog->adjustSize();
}
else
{
onEvent->hide();
offEvent->hide();
knobEvent->hide();
updateDialog->hide();
currentButton = Q_NULLPTR;
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->pos.center().y() - currentButton->onText->boundingRect().height() / 2)-6);
// 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) {
Q_UNUSED(index);
// 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)
{
QMutexLocker locker(mutex);
@ -241,13 +309,22 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
dev->message->setAlignment(Qt::AlignRight);
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);
QGraphicsView *view = new QGraphicsView();
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();
layout->addLayout(senslayout);
QLabel* senslabel = new QLabel("Sensitivity");
@ -260,11 +337,11 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
senslayout->addWidget(sens);
sens->setValue(cntrl->sensitivity);
connect(sens, &QSlider::valueChanged,
[dev,this](int val) { this->sensitivityMoved(dev->path,val); });
[dev,this](int val) { this->sensitivityMoved(dev,val); });
QImage image;
switch (dev->usbDevice) {
switch (dev->type.model) {
case shuttleXpress:
image.load(":/resources/shuttlexpress.png");
break;
@ -283,6 +360,9 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
case QuickKeys:
image.load(":/resources/quickkeys.png");
break;
case StreamDeckPlus:
image.load(":/resources/streamdeckplus.png");
break;
default:
//ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
this->adjustSize();
@ -298,206 +378,176 @@ void controllerSetup::newDevice(USBDEVICE* dev, CONTROLLER* cntrl, QVector<BUTTO
#endif
controllerScene * scene = new controllerScene();
dev->scene = 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);
QGridLayout* grid = new QGridLayout();
layout->addLayout(grid);
if (dev->usbDevice == QuickKeys)
{
// Add QuickKeys section
QLabel* brightlabel = new QLabel("Brightness");
grid->addWidget(brightlabel,0,0);
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");
grid->addWidget(brightlabel,0,0);
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->path,index); });
QLabel* speedlabel = new QLabel("Speed");
grid->addWidget(speedlabel,0,1);
QComboBox *speed = new QComboBox();
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,index); });
QLabel* speedlabel = new QLabel("Speed");
grid->addWidget(speedlabel,0,1);
QComboBox *speed = new QComboBox();
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();
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,index); });
QLabel* orientlabel = new QLabel("Orientation");
grid->addWidget(orientlabel,0,2);
QComboBox *orientation = new QComboBox();
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("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); });
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();
timeout->setValue(cntrl->timeout);
grid->addWidget(timeout,1,4);
connect(timeout, qOverload<int>(&QSpinBox::valueChanged),
[dev,this](int index) { this->timeoutChanged(dev,index); });
QLabel* timeoutlabel = new QLabel("Timeout");
grid->addWidget(timeoutlabel,0,4);
QSpinBox *timeout = new QSpinBox();
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());
}
QLabel* pageslabel = new QLabel("Pages");
grid->addWidget(pageslabel,0,5);
QSpinBox *pages = new QSpinBox();
pages->setValue(dev->pages);
pages->setMinimum(1);
grid->addWidget(pages,1,5);
connect(pages, qOverload<int>(&QSpinBox::valueChanged),
[dev,this](int index) { this->pagesChanged(dev,index); });
for (int i=0;i<6;i++)
grid->setColumnStretch(i,1);
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);
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();
offEvent->clear();
knobEvent->clear();
onEvent->blockSignals(true);
offEvent->blockSignals(true);
knobEvent->blockSignals(true);
onEvent->setMaxVisibleItems(5);
offEvent->setMaxVisibleItems(5);
knobEvent->setMaxVisibleItems(5);
onEvent->clear();
offEvent->clear();
knobEvent->clear();
onEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
offEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
knobEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
/*
onEvent->setMaxVisibleItems(5);
offEvent->setMaxVisibleItems(5);
knobEvent->setMaxVisibleItems(5);
onEvent->setStyleSheet("combobox-popup: 0;");
offEvent->setStyleSheet("combobox-popup: 0;");
knobEvent->setStyleSheet("combobox-popup: 0;");
onEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
offEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
knobEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
for (COMMAND& c : *commands) {
if (c.cmdType == commandButton || c.text == "None") {
onEvent->addItem(c.text, c.index);
offEvent->addItem(c.text, c.index);
}
onEvent->setStyleSheet("combobox-popup: 0;");
offEvent->setStyleSheet("combobox-popup: 0;");
knobEvent->setStyleSheet("combobox-popup: 0;");
*/
if (c.cmdType == commandKnob || c.text == "None") {
knobEvent->addItem(c.text, c.index);
}
for (COMMAND& c : *commands) {
if (c.cmdType == commandButton || c.text == "None") {
onEvent->addItem(c.text, c.index);
offEvent->addItem(c.text, c.index);
}
onEvent->blockSignals(false);
offEvent->blockSignals(false);
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);
}
if (c.cmdType == commandKnob || c.text == "None") {
knobEvent->addItem(c.text, c.index);
}
// 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++;
// 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;
emit programSensitivity(path, val);
qInfo(logUsbControl()) << "Setting sensitivity" << val <<"for device" << dev->path;
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;
options.setFlag(QColorDialog::ShowAlphaChannel, false);
@ -509,18 +559,112 @@ void controllerSetup::colorPicker(QString path)
selColor = initialColor;
}
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 programOverlay(path, 3, QString("Sleep timeout set to %0 minutes").arg(val));
emit sendRequest(dev,usbFeatureType::featureTimeout,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
emit programDisable(path,clicked);
emit programDisable(dev, 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 <QWidget>
#include <QSpinBox>
#include <QCheckBox>
#include "usbcontroller.h"
@ -64,34 +65,36 @@ public:
~controllerSetup();
signals:
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);
void programDisable(QString path, bool disable);
void sendRequest(USBDEVICE* dev, usbFeatureType request, quint8 val=0, QString text="", QImage* img=Q_NULLPTR, QColor* color=Q_NULLPTR);
void programDisable(USBDEVICE* dev, bool disable);
void programPages(USBDEVICE* dev, int pages);
public slots:
void init();
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 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);
void disableClicked(QString path, bool clicked, QWidget* widget);
void sensitivityMoved(USBDEVICE* dev, int val);
void brightnessChanged(USBDEVICE* dev, int index);
void orientationChanged(USBDEVICE* dev, int index);
void speedChanged(USBDEVICE* dev, int index);
void colorPicker(USBDEVICE* dev);
void buttonColorClicked();
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:
usbDeviceType usbDevice = usbNone;
usbDeviceType type = usbNone;
Ui::controllerSetup* ui;
QGraphicsTextItem* textItem;
QLabel* imgLabel;
@ -99,17 +102,22 @@ private:
QVector<BUTTON>* buttons;
QVector<KNOB>* knobs;
QVector<COMMAND>* commands;
usbMap* controllers;
BUTTON* currentButton = Q_NULLPTR;
KNOB* currentKnob = Q_NULLPTR;
QComboBox* onEvent = Q_NULLPTR;
QComboBox* offEvent = Q_NULLPTR;
QComboBox* knobEvent = Q_NULLPTR;
QComboBox* qkBright = Q_NULLPTR;
QGraphicsProxyWidget* onEventProxy = Q_NULLPTR;
QGraphicsProxyWidget* offEventProxy = Q_NULLPTR;
QGraphicsProxyWidget* knobEventProxy = Q_NULLPTR;
QGraphicsProxyWidget* qkBrightProxy = Q_NULLPTR;
// Update Dialog
QDialog * updateDialog;
QComboBox* onEvent;
QComboBox* offEvent;
QComboBox* knobEvent;
QLabel* onLabel;
QLabel* offLabel;
QLabel* knobLabel;
QPushButton* buttonColor;
QCheckBox *buttonLatch;
QString deviceName;
QMutex* mutex;
QColor initialColor = Qt::white;

Wyświetl plik

@ -399,6 +399,36 @@ typedef union capabilities_packet {
} *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)

Wyświetl plik

@ -7,5 +7,6 @@
<file>ecoder.png</file>
<file>quickkeys.png</file>
<file>xbox.png</file>
<file>streamdeckplus.png</file>
</qresource>
</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 <QRect>
#include <QGraphicsTextItem>
#include <QSpinBox>
#include <QColor>
#include <QVector>
#include <QList>
@ -17,6 +18,10 @@
#include <QtEndian>
#include <QUuid>
#include <QLabel>
#include <QImage>
#include <QPainter>
#include <QImageWriter>
#include <QBuffer>
#if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
#include <QGamepad>
@ -59,8 +64,28 @@ using namespace std;
#define HIDDATALENGTH 64
#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 {
usbDeviceType usbDevice = usbNone;
USBDEVICE() {}
USBDEVICE(USBTYPE type) : type(type) {}
USBTYPE type;
bool remove = false;
bool connected = false;
bool uiCreated = false;
@ -71,8 +96,6 @@ struct USBDEVICE {
QString serial = "<none>";
QString deviceId = "";
QString path = "";
quint16 vendorId = 0;
quint16 productId = 0;
int sensitivity = 1;
unsigned char jogpos=0;
unsigned char shutpos=0;
@ -88,6 +111,12 @@ struct USBDEVICE {
unsigned char lastDialPos=0;
QUuid uuid;
QLabel *message;
int pages=1;
int currentPage=0;
QGraphicsScene* scene = Q_NULLPTR;
QSpinBox* pageSpin = Q_NULLPTR;
QImage image;
};
struct COMMAND {
@ -113,22 +142,27 @@ struct BUTTON {
BUTTON() {}
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) {}
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(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) :
dev(dev), num(-1), name(name), pos(pos), textColour(textColour), onCommand(on), offCommand(off), on(onCommand->text), off(offCommand->text) {}
usbDeviceType dev;
USBDEVICE* parent;
int page=1;
int num;
QString name;
QRect pos;
QColor textColour;
const COMMAND* onCommand = Q_NULLPTR;
const COMMAND* offCommand = Q_NULLPTR;
QGraphicsTextItem* onText;
QGraphicsTextItem* onText = Q_NULLPTR;
QGraphicsTextItem* offText;
QString on;
QString off;
QString devicePath;
QString path;
QColor background = Qt::white;
bool toggle = false;
bool isOn = false;
};
@ -136,20 +170,25 @@ struct KNOB {
KNOB() {}
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;
USBDEVICE* parent;
int page=1;
int num;
QString name;
QRect pos;
QColor textColour;
const COMMAND* command = Q_NULLPTR;
QGraphicsTextItem* text;
QGraphicsTextItem* text = Q_NULLPTR;
QString cmd;
QString devicePath;
QString path;
};
struct CONTROLLER {
CONTROLLER() {}
CONTROLLER(USBDEVICE* dev) : dev(dev) {}
bool disabled=false;
int sensitivity=1;
quint8 speed=2;
@ -157,7 +196,12 @@ struct CONTROLLER {
quint8 brightness=2;
quint8 orientation=0;
QColor color=Qt::white;
int pages=1;
cmds lcd=cmdNone;
USBDEVICE* dev;
};
typedef QMap<QString,CONTROLLER> usbMap;
@ -176,17 +220,11 @@ public slots:
void runTimer();
void ledControl(bool on, unsigned char num);
void receivePTTStatus(bool on);
void getVersion();
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);
void programDisable(QString path, bool disabled);
void programPages(USBDEVICE* dev, int pages);
void programDisable(USBDEVICE* dev, 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:
void jogPlus();
@ -195,24 +233,27 @@ signals:
void doShuttle(bool plus, quint8 level);
void setBand(int band);
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 removeDevice(USBDEVICE* dev);
void setConnected(USBDEVICE* dev);
void changePage(USBDEVICE* dev, int page);
private:
void loadButtons();
void loadKnobs();
void loadCommands();
int hidStatus = 1;
bool isOpen=false;
int devicesConnected=0;
QVector<BUTTON>* buttonList;
QVector<KNOB>* knobList;
QList<QVector<KNOB>*> deviceKnobs;
QList<QVector<BUTTON>*> deviceButtons;
QVector<BUTTON> defaultButtons;
QVector<KNOB> defaultKnobs;
QVector<USBTYPE> knownDevices;
QVector<COMMAND> commands;
QMap<QString,USBDEVICE> usbDevices;
usbMap *controllers;
@ -226,15 +267,6 @@ private:
QMutex* mutex=Q_NULLPTR;
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:
};

Wyświetl plik

@ -85,6 +85,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
qRegisterMetaType<networkAudioLevels>();
qRegisterMetaType<codecType>();
qRegisterMetaType<errorType>();
qRegisterMetaType<usbFeatureType>();
haveRigCaps = false;
@ -1678,25 +1679,24 @@ void wfmain::setupUsbControllerDevice()
connect(usbControllerThread, SIGNAL(started()), usbControllerDev, SLOT(run()));
connect(usbControllerThread, SIGNAL(finished()), usbControllerDev, SLOT(deleteLater()));
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(setBand(int)), this, SLOT(setBand(int)));
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(removeDevice(USBDEVICE*)), shut, SLOT(removeDevice(USBDEVICE*)));
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);
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(shut, SIGNAL(programDisable(QString, bool)), usbControllerDev, SLOT(programDisable(QString, bool)));
connect(shut, SIGNAL(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)), usbControllerDev, SLOT(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)));
connect(this, SIGNAL(sendControllerRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)), usbControllerDev, SLOT(sendRequest(USBDEVICE*, usbFeatureType, quint8, QString, QImage*, QColor *)));
connect(shut, SIGNAL(programPages(USBDEVICE*, int)), usbControllerDev, SLOT(programPages(USBDEVICE*, int)));
connect(shut, SIGNAL(programDisable(USBDEVICE*, bool)), usbControllerDev, SLOT(programDisable(USBDEVICE*, 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>*)));
#endif
}
@ -2496,11 +2496,13 @@ void wfmain::loadSettings()
QString tempPath = settings->value("Path", "").toString();
tempPrefs.disabled = settings->value("Disabled", false).toBool();
tempPrefs.sensitivity = settings->value("Sensitivity", 1).toInt();
tempPrefs.pages = settings->value("Pages", 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());
tempPrefs.lcd = (cmds)settings->value("LCD",0).toInt();
if (!tempPath.isEmpty()) {
usbControllers.insert(tempPath,tempPrefs);
@ -2519,7 +2521,8 @@ void wfmain::loadSettings()
{
settings->setArrayIndex(nb);
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.num = settings->value("Num", 0).toInt();
butt.name = settings->value("Name", "").toString();
@ -2527,11 +2530,13 @@ void wfmain::loadSettings()
settings->value("Top", 0).toInt(),
settings->value("Width", 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.off = settings->value("OffCommand", "None").toString();
if (!butt.devicePath.isEmpty())
if (!butt.path.isEmpty())
usbButtons.append(butt);
}
settings->endArray();
@ -2547,7 +2552,8 @@ void wfmain::loadSettings()
{
settings->setArrayIndex(nk);
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.num = settings->value("Num", 0).toInt();
kb.name = settings->value("Name", "").toString();
@ -2558,7 +2564,7 @@ void wfmain::loadSettings()
kb.textColour = QColor((settings->value("Colour", "Green").toString()));
kb.cmd = settings->value("Command", "None").toString();
if (!kb.devicePath.isEmpty())
if (!kb.path.isEmpty())
usbKnobs.append(kb);
}
settings->endArray();
@ -2979,6 +2985,7 @@ void wfmain::saveSettings()
// Store USB Controller
settings->remove("Controllers");
settings->beginWriteArray("Controllers");
int nc=0;
@ -2994,7 +3001,9 @@ void wfmain::saveSettings()
settings->setValue("Orientation", i.value().orientation);
settings->setValue("Speed", i.value().speed);
settings->setValue("Timeout", i.value().timeout);
settings->setValue("Pages", i.value().pages);
settings->setValue("Color", i.value().color.name(QColor::HexArgb));
settings->setValue("LCD", i.value().lcd);
++i;
++nc;
@ -3002,19 +3011,24 @@ void wfmain::saveSettings()
settings->endArray();
settings->remove("Buttons");
settings->beginWriteArray("Buttons");
for (int nb = 0; nb < usbButtons.count(); nb++)
{
settings->setArrayIndex(nb);
settings->setValue("Page", usbButtons[nb].page);
settings->setValue("Dev", usbButtons[nb].dev);
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("Left", usbButtons[nb].pos.left());
settings->setValue("Top", usbButtons[nb].pos.top());
settings->setValue("Width", usbButtons[nb].pos.width());
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)
settings->setValue("OnCommand", usbButtons[nb].onCommand->text);
if (usbButtons[nb].offCommand != Q_NULLPTR)
@ -3023,13 +3037,15 @@ void wfmain::saveSettings()
settings->endArray();
settings->remove("Knobs");
settings->beginWriteArray("Knobs");
for (int nk = 0; nk < usbKnobs.count(); nk++)
{
settings->setArrayIndex(nk);
settings->setValue("Page", usbKnobs[nk].page);
settings->setValue("Dev", usbKnobs[nk].dev);
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("Top", usbKnobs[nk].pos.top());
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->xAxis->setRange(0, spectWidth-1);
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;
oldPlotCeiling = plotCeiling;
}
}

Wyświetl plik

@ -238,6 +238,7 @@ signals:
void setClusterTimeout(int timeout);
void setClusterSkimmerSpots(bool enable);
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:
void setAudioDevicesUI();
@ -1144,7 +1145,7 @@ private:
#if defined (USB_CONTROLLER)
usbController *usbControllerDev = Q_NULLPTR;
QThread *usbControllerThread = Q_NULLPTR;
QString usbDeviceName;
QString typeName;
QVector<BUTTON> usbButtons;
QVector<KNOB> usbKnobs;
usbMap usbControllers;
@ -1160,6 +1161,7 @@ private:
QMutex clusterMutex;
QColor clusterColor;
audioDevices* audioDev = Q_NULLPTR;
QImage lcdImage;
};
Q_DECLARE_METATYPE(struct rigCapabilities)
@ -1194,6 +1196,7 @@ Q_DECLARE_METATYPE(enum duplexMode)
Q_DECLARE_METATYPE(enum rptAccessTxRx)
Q_DECLARE_METATYPE(struct rptrTone_t)
Q_DECLARE_METATYPE(struct rptrAccessData_t)
Q_DECLARE_METATYPE(enum usbFeatureType)
//void (*wfmain::logthistext)(QString text) = NULL;

Wyświetl plik

@ -169,7 +169,9 @@ enum cmds {
cmdGetBandStackReg, cmdGetKeySpeed, cmdSetKeySpeed, cmdGetBreakMode, cmdSetBreakMode, cmdSendCW, cmdStopCW, cmdGetDashRatio, cmdSetDashRatio,
cmdSetTime, cmdSetDate, cmdSetUTCOffset,
// 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 {
@ -194,7 +196,14 @@ enum codecType { LPCM, PCMU, OPUS };
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 usbFeatureType { featureReset,featureResetKeys, featureEventsA, featureEventsB, featureFirmware, featureSerial, featureButton, featureSensitivity, featureBrightness,
featureOrientation, featureSpeed, featureColor, featureOverlay, featureTimeout, featureLCD };
#endif // WFVIEWTYPES_H