Merge branch 'master' into sidetone

qcpfix
Phil Taylor 2023-02-14 18:48:10 +00:00
commit 6f1d4e24b7
17 zmienionych plików z 1542 dodań i 294 usunięć

266
CHANGELOG
Wyświetl plik

@ -1,3 +1,179 @@
commit dd4770a85ff462913c223fcb1a9aeff65cce0a5d
Merge: 32e6622 3582c95
Author: Phil Taylor <phil@m0vse.uk>
Date: Mon Feb 13 15:37:26 2023 +0000
Merge branch 'collision-detection' into ecoder
commit 32e662237bebcf46f337d173a195849f4d98ee7a
Author: Phil Taylor <phil@m0vse.uk>
Date: Mon Feb 13 15:14:27 2023 +0000
Make ptt react correctly
commit 3582c95c58185a951ecb1b242bec974d835082df
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 23:14:39 2023 +0000
Fixes to collision detection.
commit da71bb3bc3d244a6d33307d180d8cc5f4069b7aa
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 23:14:51 2023 +0000
Remove debugging
commit 0397b4b68aab860bd1aa8ca9ab1a4ff0828b11df
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 23:14:39 2023 +0000
Fixes to collision detection.
commit feac83b997da6dfff3170813fa0b16150482d7fb
Author: Phil Taylor <phil@m0vse.uk>
Date: Sat Feb 11 11:40:30 2023 +0000
Attempt at simple collision detection
commit 9afc661c4c52276fafb5b866f09e4d52024b5943
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 17:17:29 2023 +0000
Update usbcontroller.cpp
commit 6de14df1da5e2303c6c2b89e2b399ae3312657be
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 17:14:26 2023 +0000
Fix compile warnings
commit 7e89e9f457f2867bd2f5a00f2299281cd6100eef
Author: Phil Taylor <phil@m0vse.uk>
Date: Sun Feb 12 16:45:21 2023 +0000
Add support for Xencelabs QuickKeys
commit 3cb54f9cd7c512ada7b63bc1507a4dee805f85e6
Author: Phil Taylor <phil@m0vse.uk>
Date: Sat Feb 11 11:40:30 2023 +0000
Attempt at simple collision detection
commit 80838e4f82068a6e7ad042e06abc073626f4ad69
Author: Phil Taylor <phil@m0vse.uk>
Date: Sat Feb 11 11:39:18 2023 +0000
Some more changes
commit 54c75d5defaff2014f96b8256d621f832b557211
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:52:51 2023 +0000
Multiply knob values * 10
commit 8b59efbf336bae5bae8d2f85ed4e94c2067bf492
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:40:11 2023 +0000
Another try
commit 9db06989279270b03f5d968c03015e4d249d6e49
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:26:34 2023 +0000
Quick test
commit 251239e445b2faf2f1ee5d4eae8668b522de5268
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:13:50 2023 +0000
Update usbcontroller.cpp
commit a3a82cd442a2a6a2fa428e99e9401d360996e9b1
Merge: 3461a0e 6e5e22a
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:11:42 2023 +0000
Merge branch 'master' into ecoder
commit 3461a0e5e51b68517561cbdfbedd19141725f7c6
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 18:10:32 2023 +0000
Correct usbMutex
commit 3429786e106f2c145c8987d5b4a39e63134a789b
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 15:51:01 2023 +0000
Reset knobValues to 0 after sending
commit c2e9100a40f4550fd51e312ac359034d8323f552
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 15:47:23 2023 +0000
Hopefully fix random buttons
commit c8a29bb40096de3fd4b77d7c7f218531a1372647
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 15:23:57 2023 +0000
Add mutex to ensure thread safety
commit fa47bfb4bc37fe96e0e602eabf8ed267342a9928
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 13:34:04 2023 +0000
Update usbcontroller.cpp
commit 82425b445e21a6ef1381a39d10c666cc4910e082
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 13:28:09 2023 +0000
Try again
commit 7aa75466600a50578e335ae5f47c8ef257382596
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 09:52:51 2023 +0000
More work on knobs
commit 4e61a455b5cf7f9679d7182c494c8ea2b6156b81
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 00:31:12 2023 +0000
Hide setup screen if disabled
commit cad3bb9418020ff9583d25d688b397afd88f6fea
Author: Phil Taylor <phil@m0vse.uk>
Date: Fri Feb 10 00:27:01 2023 +0000
Various (I hope) improvements!
commit 1f1800f046a32a969c17d1d48d2dd826ffc4081e
Author: Phil Taylor <phil@m0vse.uk>
Date: Thu Feb 9 18:43:42 2023 +0000
Flip bits in knob command
commit 5ed380c03d792de91ba15a14549b46ca8d8cabca
Author: Phil Taylor <phil@m0vse.uk>
Date: Thu Feb 9 18:35:07 2023 +0000
Remove debug setup
commit a8951813f5a69f17d044f8f723fc23702c0f7bc1
Author: Phil Taylor <phil@m0vse.uk>
Date: Thu Feb 9 13:21:51 2023 +0000
Provisional support for knobs
commit 6e5e22a672e430d872eddb232bcc8491134dc13d
Author: Roeland Jansen <roeland.jansen69@gmail.com>
Date: Wed Feb 8 19:00:44 2023 +0100
another compile fix
commit bbbfe38e0bfc5280e349049c126dcf2792c06b52
Author: Elliott Liggett <kilocharlie8@gmail.com>
Date: Wed Feb 8 08:26:36 2023 -0800
@ -10,6 +186,13 @@ Date: Wed Feb 8 11:26:33 2023 +0100
compilation fixes
commit 17a65472646b1113da2c4b7dcccf3763f41d3085
Merge: cb339ed 0ff2551
Author: Phil Taylor <phil@m0vse.uk>
Date: Wed Feb 8 10:15:16 2023 +0000
Merge branch 'master' into ecoder
commit 1515e135e5434ab7c334214ff10165e484536906
Author: Phil Taylor <phil@m0vse.uk>
Date: Wed Feb 8 10:12:48 2023 +0000
@ -22,6 +205,89 @@ Date: Tue Feb 7 23:29:50 2023 +0000
Fix compile if controller disabled
commit cb339edc1f4881df29db1d4d9f93b38e8316aa8d
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 23:29:50 2023 +0000
Fix compile if controller disabled
commit f4a86ac02e5996d61bdddef0f69b4ce92b19a4de
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 23:05:42 2023 +0000
Add more buttons
commit b783f8057a8e1d4e85db4e89de14c059b22e8169
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 22:37:26 2023 +0000
tuning knob?
commit 10640381387bac9893122e9fd7a2530e52522e50
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 21:12:02 2023 +0000
Another try
commit dda3c8ee9d52855be21cfcf3288664bf52d7c8de
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 21:01:54 2023 +0000
Update usbcontroller.cpp
commit 63b8a356e85528ec8dbbbfc403a7d317e6e2705f
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 20:59:53 2023 +0000
Another try for buttons
commit 4fc37290e516e8507137b4f91084967749f22381
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 20:51:20 2023 +0000
try to fix ecoder buttons
commit 72e8bc6fa6903e6094de58084e96509f1b8f6f7c
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 20:32:46 2023 +0000
Remove debug code
commit 8a28a8976090f433c0822fc66d9aa01b107bc215
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 19:41:39 2023 +0000
Correct order!
commit 5298949f3a50ebb7fba6e265ba656a300679a2be
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 19:37:33 2023 +0000
Add support for ecoder buttons
commit 1e217bc5b82b43f63d75e3f3db4f6f8b29bcbeb2
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 19:02:05 2023 +0000
Some initial updates
commit fbea7f1a136f9f5e2b6b3cc599be14c344294fd7
Merge: b373685 32639c5
Author: Phil Taylor <phil@m0vse.uk>
Date: Tue Feb 7 18:41:02 2023 +0000
Merge branch 'ecoderplus' into 'ecoder'
Ecoderplus
See merge request eliggett/wfview!17
commit 32639c5394409abb05b95c7d292c09d9bda375f3
Author: Dawid Szymanski - SQ6EMM/SN6M <dawszy@arhea.pl>
Date: Tue Feb 7 18:41:02 2023 +0000
Ecoderplus
commit b373685fd31f7d6cf21a117650a9bbdf17e5d107
Author: Roeland Jansen <roeland.jansen69@gmail.com>
Date: Tue Feb 7 18:56:41 2023 +0100

Wyświetl plik

@ -103,6 +103,8 @@ void commHandler::sendDataOut(const QByteArray &writeData)
qint64 bytesWritten;
previousSent = writeData;
if(PTTviaRTS)
{
// Size: 1 2 3 4 5 6 7 8
@ -170,6 +172,15 @@ void commHandler::receiveDataIn()
port->startTransaction();
inPortData = port->readAll();
if (inPortData.startsWith("\xFC\xFC\xFC\xFC\xFC"))
{
// Colission detected by remote end, re-send previous command.
qInfo(logSerial()) << "Collision detected by remote, resending previous command";
port->commitTransaction();
sendDataOut(previousSent);
return;
}
if(inPortData.size() == 1)
{
// Generally for baud <= 9600
@ -185,7 +196,6 @@ void commHandler::receiveDataIn()
}
}
if (inPortData.startsWith("\xFE\xFE"))
{
if(inPortData.contains("\xFC"))

Wyświetl plik

@ -57,6 +57,7 @@ private:
//QDataStream stream;
QByteArray outPortData;
QByteArray inPortData;
QByteArray previousSent;
//QDataStream outStream;
//QDataStream inStream;

Wyświetl plik

@ -10,30 +10,75 @@ controllerSetup::controllerSetup(QWidget* parent) :
scene = new controllerScene();
connect(scene, SIGNAL(mousePressed(QPoint)), this, SLOT(mousePressed(QPoint)));
ui->graphicsView->setScene(scene);
ui->qkBrightCombo->setVisible(false);
ui->qkOrientCombo->setVisible(false);
ui->qkSpeedCombo->setVisible(false);
ui->qkColorButton->setVisible(false);
ui->qkTimeoutSpin->setVisible(false);
ui->qkTimeoutLabel->setVisible(false);
textItem = scene->addText("No USB controller found");
textItem->setDefaultTextColor(Qt::gray);
this->resize(this->sizeHint());
connect(&onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
}
controllerSetup::~controllerSetup()
{
/*
// Remove any existing button text:
for (QGraphicsItem* item : scene->items())
{
QGraphicsTextItem* txt = qgraphicsitem_cast<QGraphicsTextItem*>(item);
if (!txt || txt == textItem)
continue;
scene->removeItem(txt);
delete txt;
}
if (onEventProxy != Q_NULLPTR) {
scene->removeItem(onEventProxy);
onEventProxy = Q_NULLPTR;
delete onEvent;
onEvent = Q_NULLPTR;
}
if (offEventProxy != Q_NULLPTR) {
scene->removeItem(offEventProxy);
offEventProxy = Q_NULLPTR;
delete offEvent;
offEvent = Q_NULLPTR;
}
if (knobEventProxy != Q_NULLPTR) {
scene->removeItem(knobEventProxy);
knobEventProxy = Q_NULLPTR;
delete knobEvent;
knobEvent = Q_NULLPTR;
}
*/
if (bgImage != Q_NULLPTR) {
scene->removeItem(bgImage);
delete bgImage;
bgImage = Q_NULLPTR;
}
delete textItem;
delete scene;
delete ui;
if (bgImage != Q_NULLPTR) {
delete bgImage;
}
}
void controllerSetup::mousePressed(QPoint p)
{
// 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)
{
qInfo(logUsbControl()) << "Event missing, cannot continue...";
return;
}
bool found = false;
QMutexLocker locker(mutex);
for (BUTTON& b : *buttons)
{
if (b.dev == currentDevice && b.pos.contains(p))
@ -41,58 +86,97 @@ void controllerSetup::mousePressed(QPoint p)
found = true;
currentButton = &b;
qDebug() << "Button" << currentButton->num << "On Event" << currentButton->onCommand->text << "Off Event" << currentButton->offCommand->text;
// Add off event first so it doesn't obscure on event.
if (offEventProxy == Q_NULLPTR) {
offEventProxy = scene->addWidget(&offEvent);
}
if (onEventProxy == Q_NULLPTR) {
onEventProxy = scene->addWidget(&onEvent);
}
onEvent.blockSignals(true);
onEvent.move(p);
onEvent.setCurrentIndex(currentButton->onCommand->index);
onEvent.show();
onEvent.blockSignals(false);
onEvent->blockSignals(true);
onEvent->move(p);
onEvent->setCurrentIndex(onEvent->findData(currentButton->onCommand->index));
onEvent->show();
onEvent->blockSignals(false);
p.setY(p.y() + 40);
offEvent.blockSignals(true);
offEvent.move(p);
offEvent.setCurrentIndex(currentButton->offCommand->index);
offEvent.show();
offEvent.blockSignals(false);
offEvent->blockSignals(true);
offEvent->move(p);
offEvent->setCurrentIndex(offEvent->findData(currentButton->offCommand->index));
offEvent->show();
offEvent->blockSignals(false);
knobEvent->hide();
break;
}
}
if (!found) {
onEvent.hide();
offEvent.hide();
for (KNOB& k : *knobs)
{
if (k.dev == currentDevice && k.pos.contains(p))
{
found = true;
currentKnob = &k;
qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text;
knobEvent->blockSignals(true);
knobEvent->move(p);
knobEvent->setCurrentIndex(knobEvent->findData(currentKnob->command->index));
knobEvent->show();
knobEvent->blockSignals(false);
onEvent->hide();
offEvent->hide();
break;
}
}
}
if (!found) {
onEvent->hide();
offEvent->hide();
knobEvent->hide();
}
}
void controllerSetup::onEventIndexChanged(int index) {
qDebug() << "On Event for button" << currentButton->num << "Event" << index;
if (currentButton != Q_NULLPTR && index < commands->size()) {
currentButton->onCommand = &commands->at(index);
Q_UNUSED(index);
if (currentButton != Q_NULLPTR && onEvent->currentData().toInt() < commands->size()) {
QMutexLocker locker(mutex);
currentButton->onCommand = &commands->at(onEvent->currentData().toInt());
currentButton->onText->setPlainText(currentButton->onCommand->text);
currentButton->onText->setPos(currentButton->pos.center().x() - currentButton->onText->boundingRect().width() / 2,
(currentButton->pos.center().y() - currentButton->onText->boundingRect().height() / 2)-6);
// Signal that any button programming on the device should be completed.
emit programButton(currentButton->num, currentButton->onCommand->text);
}
}
void controllerSetup::offEventIndexChanged(int index) {
qDebug() << "Off Event for button" << currentButton->num << "Event" << index;
if (currentButton != Q_NULLPTR && index < commands->size()) {
currentButton->offCommand = &commands->at(index);
Q_UNUSED(index);
if (currentButton != Q_NULLPTR && offEvent->currentData().toInt() < commands->size()) {
QMutexLocker locker(mutex);
currentButton->offCommand = &commands->at(offEvent->currentData().toInt());
currentButton->offText->setPlainText(currentButton->offCommand->text);
currentButton->offText->setPos(currentButton->pos.center().x() - currentButton->offText->boundingRect().width() / 2,
(currentButton->pos.center().y() - currentButton->offText->boundingRect().height() / 2)+6);
}
}
void controllerSetup::knobEventIndexChanged(int index) {
Q_UNUSED(index);
if (currentKnob != Q_NULLPTR && knobEvent->currentData().toInt() < commands->size()) {
QMutexLocker locker(mutex);
currentKnob->command = &commands->at(knobEvent->currentData().toInt());
currentKnob->text->setPlainText(currentKnob->command->text);
currentKnob->text->setPos(currentKnob->pos.center().x() - currentKnob->text->boundingRect().width() / 2,
(currentKnob->pos.center().y() - currentKnob->text->boundingRect().height() / 2));
}
}
void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<COMMAND>* cmd)
void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut)
{
buttons = but;
knobs = kb;
commands = cmd;
mutex = mut;
QMutexLocker locker(mutex);
// Remove any existing button text:
for (QGraphicsItem* item : scene->items())
@ -101,17 +185,33 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
if (!txt || txt==textItem)
continue;
scene->removeItem(txt);
delete txt;
}
if (bgImage != Q_NULLPTR) {
scene->removeItem(bgImage);
delete bgImage;
bgImage = Q_NULLPTR;
if (onEventProxy != Q_NULLPTR)
scene->removeItem(onEventProxy);
if (offEventProxy != Q_NULLPTR)
scene->removeItem(offEventProxy);
}
if (onEventProxy != Q_NULLPTR) {
scene->removeItem(onEventProxy);
onEventProxy = Q_NULLPTR;
delete onEvent;
onEvent = Q_NULLPTR;
}
if (offEventProxy != Q_NULLPTR) {
scene->removeItem(offEventProxy);
offEventProxy = Q_NULLPTR;
delete offEvent;
offEvent = Q_NULLPTR;
}
if (knobEventProxy != Q_NULLPTR) {
scene->removeItem(knobEventProxy);
knobEventProxy = Q_NULLPTR;
delete knobEvent;
knobEvent = Q_NULLPTR;
}
QImage image;
switch (devType) {
@ -131,13 +231,21 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
image.load(":/resources/xbox.png");
deviceName = "XBox";
break;
case eCoderPlus:
image.load(":/resources/ecoder.png");
deviceName = "eCoderPlus";
break;
case QuickKeys:
image.load(":/resources/quickkeys.png");
deviceName = "QuickKeys";
break;
default:
textItem->show();
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
this->adjustSize();
return;
break;
}
textItem->hide();
bgImage = new QGraphicsPixmapItem(QPixmap::fromImage(image));
scene->addItem(bgImage);
@ -145,48 +253,123 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
ui->graphicsView->setMinimumSize(bgImage->boundingRect().width() + 100, bgImage->boundingRect().height() + 2);
currentDevice = devType;
onEvent.blockSignals(true);
offEvent.blockSignals(true);
onEvent.clear();
offEvent.clear();
onEvent.setMaxVisibleItems(5);
offEvent.setMaxVisibleItems(5);
onEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
offEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
onEvent.setStyleSheet("combobox-popup: 0;");
offEvent.setStyleSheet("combobox-popup: 0;");
for (COMMAND &c : *commands) {
onEvent.addItem(c.text);
offEvent.addItem(c.text);
if (currentDevice == QuickKeys) {
ui->qkBrightCombo->setVisible(true);
ui->qkOrientCombo->setVisible(true);
ui->qkSpeedCombo->setVisible(true);
ui->qkColorButton->setVisible(true);
ui->qkTimeoutSpin->setVisible(true);
ui->qkTimeoutLabel->setVisible(true);
}
onEvent.blockSignals(false);
offEvent.blockSignals(false);
// Set button text
for (BUTTON& b : *buttons)
else
{
ui->qkBrightCombo->setVisible(false);
ui->qkOrientCombo->setVisible(false);
ui->qkSpeedCombo->setVisible(false);
ui->qkColorButton->setVisible(false);
ui->qkTimeoutSpin->setVisible(false);
ui->qkTimeoutLabel->setVisible(false);
}
if (b.dev == currentDevice) {
//b.onCommand = &commands->at(0);
b.onText = new QGraphicsTextItem(b.onCommand->text);
b.onText->setDefaultTextColor(b.textColour);
scene->addItem(b.onText);
b.onText->setPos(b.pos.x(), b.pos.y());
if (currentDevice != usbNone)
{
offEvent = new QComboBox;
onEvent = new QComboBox;
knobEvent = new QComboBox;
//b.offCommand = &commands->at(0);
b.offText = new QGraphicsTextItem(b.offCommand->text);
b.offText->setDefaultTextColor(b.textColour);
scene->addItem(b.offText);
b.offText->setPos(b.pos.x(), b.pos.y() + 10);
onEvent->blockSignals(true);
offEvent->blockSignals(true);
knobEvent->blockSignals(true);
onEvent->clear();
offEvent->clear();
knobEvent->clear();
onEvent->setMaxVisibleItems(5);
offEvent->setMaxVisibleItems(5);
knobEvent->setMaxVisibleItems(5);
onEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
offEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
knobEvent->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
onEvent->setStyleSheet("combobox-popup: 0;");
offEvent->setStyleSheet("combobox-popup: 0;");
knobEvent->setStyleSheet("combobox-popup: 0;");
for (COMMAND& c : *commands) {
if (c.cmdType == commandButton || c.text == "None") {
onEvent->addItem(c.text, c.index);
offEvent->addItem(c.text, c.index);
}
if (c.cmdType == commandKnob || c.text == "None") {
knobEvent->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.dev == currentDevice) {
b.onText = new QGraphicsTextItem(b.onCommand->text);
b.onText->setDefaultTextColor(b.textColour);
scene->addItem(b.onText);
b.onText->setPos(b.pos.center().x() - b.onText->boundingRect().width() / 2,
(b.pos.center().y() - b.onText->boundingRect().height() / 2) - 6);
emit programButton(b.num, b.onCommand->text); // Program the button with ontext if supported
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.dev == currentDevice) {
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));
}
}
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
ui->graphicsView->resize(ui->graphicsView->sizeHint());
//this->resize(this->sizeHint());
this->adjustSize();
// Add comboboxes to scene after everything else.
offEventProxy = scene->addWidget(offEvent);
connect(offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
onEventProxy = scene->addWidget(onEvent);
connect(onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
knobEventProxy = scene->addWidget(knobEvent);
connect(knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
if (currentDevice == QuickKeys) {
// Finally update the device with the default values
emit programBrightness((quint8)ui->qkBrightCombo->currentIndex() - 1);
emit programOrientation((quint8)ui->qkOrientCombo->currentIndex());
emit programSpeed((quint8)ui->qkSpeedCombo->currentIndex());
emit programTimeout((quint8)ui->qkTimeoutSpin->value());
emit programWheelColour((quint8)initialColor.red(), (quint8)initialColor.green(), (quint8)initialColor.blue());
}
}
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
ui->graphicsView->resize(ui->graphicsView->sizeHint());
//this->resize(this->sizeHint());
this->adjustSize();
}
void controllerSetup::receiveSensitivity(int val)
@ -199,4 +382,79 @@ void controllerSetup::receiveSensitivity(int val)
void controllerSetup::on_sensitivitySlider_valueChanged(int val)
{
emit sendSensitivity(val);
}
void controllerSetup::on_qkBrightCombo_currentIndexChanged(int index)
{
if (index) {
emit programBrightness((quint8)index - 1);
}
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
}
void controllerSetup::on_qkOrientCombo_currentIndexChanged(int index)
{
if (index) {
emit programOrientation((quint8)index);
emit programOverlay(3, QString("Orientation set to %0").arg(ui->qkOrientCombo->currentText()));
}
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
}
void controllerSetup::on_qkSpeedCombo_currentIndexChanged(int index)
{
if (index) {
emit programSpeed((quint8)index);
emit programOverlay(3, QString("Dial speed set to %0").arg(ui->qkSpeedCombo->currentText()));
}
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
}
void controllerSetup::on_qkColorButton_clicked()
{
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())
{
selColor = initialColor;
}
initialColor = selColor;
emit programWheelColour((quint8)selColor.red(), (quint8)selColor.green(), (quint8)initialColor.blue());
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
}
void controllerSetup::on_qkTimeoutSpin_valueChanged(int arg1)
{
emit programTimeout((quint8)arg1);
emit programOverlay(3, QString("Sleep timeout set to %0 minutes").arg(arg1));
emit updateSettings((quint8)ui->qkBrightCombo->currentIndex(), (quint8)ui->qkOrientCombo->currentIndex(),
(quint8)ui->qkSpeedCombo->currentIndex(), (quint8)ui->qkTimeoutSpin->value(), initialColor);
}
void controllerSetup::setDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color)
{
ui->qkBrightCombo->blockSignals(true);
ui->qkSpeedCombo->blockSignals(true);
ui->qkOrientCombo->blockSignals(true);
ui->qkTimeoutSpin->blockSignals(true);
ui->qkBrightCombo->setCurrentIndex((int)bright);
ui->qkOrientCombo->setCurrentIndex((int)orient);
ui->qkSpeedCombo->setCurrentIndex((int)speed);
ui->qkTimeoutSpin->setValue((int)timeout);
initialColor = color;
ui->qkBrightCombo->blockSignals(false);
ui->qkSpeedCombo->blockSignals(false);
ui->qkOrientCombo->blockSignals(false);
ui->qkTimeoutSpin->blockSignals(false);
}

Wyświetl plik

@ -17,6 +17,7 @@
#include <QDebug>
#include <QObject>
#include <QColorDialog>
#include "usbcontroller.h"
@ -36,14 +37,29 @@ public:
signals:
void sendSensitivity(int val);
void programButton(quint8 but, QString text);
void programBrightness(quint8 level);
void programWheelColour(quint8 r, quint8 g, quint8 b);
void programOverlay(quint8 duration, QString text);
void programOrientation(quint8 value);
void programSpeed(quint8 value);
void programTimeout(quint8 value);
void updateSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
public slots:
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<COMMAND>* cmd);
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
void mousePressed(QPoint p);
void onEventIndexChanged(int index);
void offEventIndexChanged(int index);
void knobEventIndexChanged(int index);
void receiveSensitivity(int val);
void on_sensitivitySlider_valueChanged(int val);
void on_qkBrightCombo_currentIndexChanged(int index);
void on_qkOrientCombo_currentIndexChanged(int index);
void on_qkSpeedCombo_currentIndexChanged(int index);
void on_qkColorButton_clicked();
void on_qkTimeoutSpin_valueChanged(int arg1);
void setDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
private:
@ -55,14 +71,21 @@ private:
QLabel* imgLabel;
unsigned char currentDevice = 0;
QVector<BUTTON>* buttons;
QVector<KNOB>* knobs;
QVector<COMMAND>* commands;
BUTTON* currentButton=Q_NULLPTR;
QComboBox onEvent;
QComboBox offEvent;
QGraphicsProxyWidget* onEventProxy=Q_NULLPTR;
QGraphicsProxyWidget* offEventProxy=Q_NULLPTR;
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;
QString deviceName;
QMutex* mutex;
QColor initialColor = Qt::white;
};
@ -86,17 +109,6 @@ protected:
QGraphicsScene::mousePressEvent(event);
}
}
/*
void mouseMoveEvent(QGraphicsSceneMouseEvent* event) {
}
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) {
}
*/
};

Wyświetl plik

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<width>442</width>
<height>343</height>
</rect>
</property>
@ -14,24 +14,7 @@
<string>Controller setup</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Button configuration: &lt;/span&gt;Right-click on each button to configure it.&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;Top selection is command to send when button is pressed and bottom is (optional) command to send when button is released.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<item row="7" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
@ -77,7 +60,134 @@
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="qkBrightCombo">
<property name="enabled">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Brightness</string>
</property>
</item>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>Low</string>
</property>
</item>
<item>
<property name="text">
<string>Medium</string>
</property>
</item>
<item>
<property name="text">
<string>High</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="qkSpeedCombo">
<item>
<property name="text">
<string>Speed</string>
</property>
</item>
<item>
<property name="text">
<string>Fastest</string>
</property>
</item>
<item>
<property name="text">
<string>Faster</string>
</property>
</item>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Slower</string>
</property>
</item>
<item>
<property name="text">
<string>Slowest</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="qkOrientCombo">
<item>
<property name="text">
<string>Orientation</string>
</property>
</item>
<item>
<property name="text">
<string>Rotate 0</string>
</property>
</item>
<item>
<property name="text">
<string>Rotate 90</string>
</property>
</item>
<item>
<property name="text">
<string>Rotate 180</string>
</property>
</item>
<item>
<property name="text">
<string>Rotate 270</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="qkColorButton">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qkTimeoutLabel">
<property name="text">
<string>Timeout</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="qkTimeoutSpin">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
@ -104,6 +214,23 @@
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Button configuration: &lt;/span&gt;Right-click on each button to configure it.&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;Top selection is command to send when button is pressed and bottom is (optional) command to send when button is released.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>

Wyświetl plik

@ -47,6 +47,11 @@ struct preferences {
bool automaticSidebandSwitching = true;
bool enableUSBControllers;
int usbSensitivity;
quint8 usbSpeed;
quint8 usbTimeout;
quint8 usbBrightness;
quint8 usbOrientation;
QColor usbColor;
// LAN:
bool enableLAN;
@ -63,8 +68,8 @@ struct preferences {
QString clusterTcpServerName;
QString clusterTcpUserName;
QString clusterTcpPassword;
int clusterTimeout; // used?
bool clusterSkimmerSpotsEnable; // where is this used?
int clusterTimeout;
bool clusterSkimmerSpotsEnable;
};
#endif // PREFS_H

Plik binarny nie jest wyświetlany.

Po

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

Plik binarny nie jest wyświetlany.

Po

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

Wyświetl plik

@ -4,6 +4,8 @@
<file>shuttlexpress.png</file>
<file>shuttlepro.png</file>
<file>rc28.png</file>
<file>ecoder.png</file>
<file>quickkeys.png</file>
<file>xbox.png</file>
</qresource>
</RCC>

Wyświetl plik

@ -12,6 +12,7 @@
usbController::usbController()
{
// As this is run in it's own thread, don't do anything in the constructor
qInfo(logUsbControl()) << "Starting usbController()";
}
@ -20,6 +21,7 @@ usbController::~usbController()
qInfo(logUsbControl) << "Ending usbController()";
if (handle) {
programOverlay(60, "Goodbye from wfview");
if (usbDevice == RC28) {
ledControl(false, 3);
@ -38,9 +40,10 @@ usbController::~usbController()
#endif
}
void usbController::init(int sens)
void usbController::init(int sens, QMutex* mut)
{
sensitivity = sens;
this->mutex = mut;
this->sensitivity = sens;
emit sendSensitivity(sensitivity);
#ifdef HID_API_VERSION_MAJOR
if (HID_API_VERSION == HID_API_MAKE_VERSION(hid_version()->major, hid_version()->minor, hid_version()->patch)) {
@ -75,10 +78,14 @@ void usbController::init(int sens)
struct hid_device_info* devs;
devs = hid_enumerate(0x0, 0x0);
while (devs) {
qInfo(logUsbControl()) << QString("Manufacturer: %0 Product: %1 Path: %2")
.arg(QString::fromWCharArray(devs->manufacturer_string))
qInfo(logUsbControl()) << QString("Device found: (%0:%1) %2 manufacturer: (%3)%4 usage: 0x%5 usage_page 0x%6")
.arg(devs->vendor_id, 4, 16, QChar('0'))
.arg(devs->product_id, 4, 16, QChar('0'))
.arg(QString::fromWCharArray(devs->product_string))
.arg(QString::fromLocal8Bit(devs->path));
.arg(QString::fromWCharArray(devs->product_string))
.arg(QString::fromWCharArray(devs->manufacturer_string))
.arg(devs->usage, 4, 16, QChar('0'))
.arg(devs->usage_page, 4, 16, QChar('0'));
devs = devs->next;
}
hid_free_enumeration(devs);
@ -86,19 +93,7 @@ void usbController::init(int sens)
}
}
void usbController::receiveCommands(QVector<COMMAND>* cmds)
{
qDebug(logUsbControl()) << "Receiving commands";
commands = cmds;
}
void usbController::receiveButtons(QVector<BUTTON>* buts)
{
qDebug(logUsbControl()) << "Receiving buttons";
buttonList = buts;
}
/* run() is called every 2s and attempts to connect to a supported controller */
void usbController::run()
{
if (commands == Q_NULLPTR || hidStatus) {
@ -203,7 +198,7 @@ void usbController::run()
qInfo(logUsbControl()) << "Button Guide" << pressed;
});
emit newDevice(usbDevice, buttonList, commands); // Let the UI know we have a new controller
emit newDevice(usbDevice, buttonList, knobList, commands, mutex); // Let the UI know we have a new controller
return;
}
}
@ -223,12 +218,18 @@ void usbController::run()
while (devs) {
for (int i = 0; i < (int)sizeof knownUsbDevices / (int)sizeof knownUsbDevices[0]; i++) {
if (devs->vendor_id == knownUsbDevices[i][1] && devs->product_id == knownUsbDevices[i][2]) {
if (devs->vendor_id == knownUsbDevices[i][1] && devs->product_id == knownUsbDevices[i][2]
&& (knownUsbDevices[i][3] == 0x00 || devs->usage == knownUsbDevices[i][3])
&& (knownUsbDevices[i][4] == 0x00 || devs->usage_page == knownUsbDevices[i][4]))
{
this->manufacturer = QString::fromWCharArray(devs->manufacturer_string);
this->vendorId = devs->vendor_id;
this->productId = devs->product_id;
this->product = QString::fromWCharArray(devs->product_string);
this->serial = QString::fromWCharArray(devs->serial_number);
usbDevice = (usbDeviceType)knownUsbDevices[i][0];
this->path = QString::fromLocal8Bit(devs->path);
this->deviceId = QString("0x%1").arg(this->productId, 4, 16, QChar('0'));
this->usbDevice = (usbDeviceType)knownUsbDevices[i][0];
break;
}
}
@ -255,9 +256,35 @@ void usbController::run()
ledControl(false, 2);
ledControl(true, 3);
}
else if (usbDevice == eCoderPlus)
{
knobValues.clear();
knobSend.clear();
knobValues.append({ 0,0,0 });
knobSend.append({ 0,0,0 });
}
else if (usbDevice == QuickKeys) {
// Subscribe to event streams
QByteArray b(32,0x0);
b[0] = (qint8)0x02;
b[1] = (qint8)0xb0;
b[2] = (qint8)0x04;
b.replace(10, sizeof(this->deviceId), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)b.constData(), b.size());
b[0] = (qint8)0x02;
b[1] = (qint8)0xb4;
b[2] = (qint8)0x10;
b.replace(10, sizeof(this->deviceId), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)b.constData(), b.size());
}
// Let the UI know we have a new controller
emit newDevice(usbDevice, buttonList, commands);
emit newDevice(usbDevice, buttonList, knobList, commands, mutex);
// Run the periodic timer to get data
QTimer::singleShot(25, this, SLOT(runTimer()));
}
@ -277,17 +304,26 @@ void usbController::run()
}
/* runTimer is called every 25ms once a connection to a supported controller is established */
void usbController::runTimer()
{
int res=1;
if (!this->handle) {
// Something bad happened!
QTimer::singleShot(25, this, SLOT(runTimer()));
res = 0;
}
QMutexLocker locker(mutex);
while (res > 0) {
QByteArray data(HIDDATALENGTH, 0x0);
res = hid_read(this->handle, (unsigned char*)data.data(), HIDDATALENGTH);
if (res < 0)
{
qInfo(logUsbControl()) << "USB Device disconnected" << this->product;
emit newDevice(0, buttonList, commands);
emit newDevice(0, buttonList, knobList, commands, mutex);
this->product = "";
this->manufacturer = "";
this->serial = "<none>";
@ -306,7 +342,7 @@ void usbController::runTimer()
<< hex << (unsigned char)data[3] << ":"
<< hex << (unsigned char)data[4];
*/
unsigned int tempButtons = (unsigned int)((unsigned char)data[3] | (unsigned char)data[4] << 8);
quint32 tempButtons = ((quint8)data[4] << 8) | ((quint8)data[3] & 0xff);
unsigned char tempJogpos = (unsigned char)data[1];
unsigned char tempShutpos = (unsigned char)data[0];
@ -341,23 +377,22 @@ void usbController::runTimer()
if (buttons != tempButtons)
{
// Step through all buttons and emit ones that have been pressed.
for (unsigned char i = 0; i < 16; i++)
{
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
if (but->dev == usbDevice && but->num == i) {
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
{
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
emit button(but->onCommand);
}
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
{
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
emit button(but->offCommand);
}
auto but = std::find_if(buttonList->begin(), buttonList->end(), [this, i](const BUTTON& b)
{ return (b.dev == this->usbDevice && b.num == i); });
if (but != buttonList->end()) {
if ((tempButtons >> i & 1) && !(buttons >> i & 1))
{
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
emit button(but->onCommand);
}
else if ((buttons >> i & 1) && !(tempButtons >> i & 1))
{
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
emit button(but->offCommand);
}
}
}
@ -384,9 +419,6 @@ void usbController::runTimer()
BUTTON* butf1 = Q_NULLPTR;
BUTTON* butf2 = Q_NULLPTR;;
//delayedCmdQue.erase(std::remove_if(delayedCmdQue.begin() + 1, delayedCmdQue.end(), [cmd](const commandtype& c) { return (c.cmd == cmd); }),
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
if (but->dev == usbDevice) {
@ -477,6 +509,115 @@ void usbController::runTimer()
lastData = data;
}
}
else if (usbDevice == eCoderPlus && data.length() > 0x0f && (quint8)data[0] == 0xff) {
/* Button matrix:
DATA3 DATA2 DATA 1
765432107654321076543210
001000000000000000000000 = Left CW
000100000000000000000000 = Right CW
000010000000000000000000 = PTT
000001000000000000000000 = Knob 3 Press
000000100000000000000000 = Knob 2 Press
000000010000000000000000 = Knob 1 Press
000000000100000000000000 = button14
000000000010000000000000 = button13
000000000001000000000000 = button12
000000000000100000000000 = button11
000000000000010000000000 = button10
000000000000001000000000 = button9
000000000000000100000000 = button8
000000000000000010000000 = button7
000000000000000001000000 = button6
000000000000000000100000 = button5
000000000000000000010000 = button4
000000000000000000001000 = button3
000000000000000000000100 = button2
000000000000000000000010 = button1
*/
quint32 tempButtons = ((quint8)data[3] << 16) | ((quint8)data[2] << 8) | ((quint8)data[1] & 0xff);
quint32 tempKnobs = ((quint8)data[16] << 16) | ((quint8)data[15] << 8) | ((quint8)data[14] & 0xff);
if (buttons != tempButtons)
{
// Step through all buttons and emit ones that have been pressed.
for (unsigned char i = 1; i < 23; i++)
{
auto but = std::find_if(buttonList->begin(), buttonList->end(), [this, i](const BUTTON& b)
{ return (b.dev == this->usbDevice && b.num == i); });
if (but != buttonList->end()) {
if ((tempButtons >> i & 1) && !(buttons >> i & 1))
{
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
emit button(but->onCommand);
}
else if ((buttons >> i & 1) && !(tempButtons >> i & 1))
{
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
emit button(but->offCommand);
}
}
}
}
buttons = tempButtons;
if (knobs != tempKnobs) {
// One of the knobs has moved
for (unsigned char i = 0; i < 3; i++) {
if ((tempKnobs >> (i * 8) & 0xff) != (knobs >> (i * 8) & 0xff)) {
knobValues[i] = knobValues[i] + (qint8)((knobs >> (i * 8)) & 0xff);
}
}
}
knobs = tempKnobs;
// Tuning knob
jogCounter = jogCounter + (qint8)data[13];
} else if (usbDevice == QuickKeys && (quint8)data[0] == 0x02) {
if ((quint8)data[1] == 0xf0) {
//qInfo(logUsbControl()) << "Received:" << data;
quint32 tempButtons = (data[3] << 8) | (data[2] & 0xff);
// Step through all buttons and emit ones that have been pressed.
for (unsigned char i = 0; i < 10; i++)
{
auto but = std::find_if(buttonList->begin(), buttonList->end(), [this, i](const BUTTON& b)
{ return (b.dev == this->usbDevice && b.num == i); });
if (but != buttonList->end()) {
if ((tempButtons >> i & 1) && !(buttons >> i & 1))
{
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
emit button(but->onCommand);
programButton(but->num, but->offCommand->text);
}
else if ((buttons >> i & 1) && !(tempButtons >> i & 1))
{
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
emit button(but->offCommand);
programButton(but->num, but->onCommand->text);
}
}
}
buttons = tempButtons;
// Tuning knob
if (data[7] & 0x01) {
jogCounter++;
}
else if (data[7] & 0x02) {
jogCounter--;
}
}
else if ((quint8)data[1] == 0xf2 && (quint8)data[2] == 0x01)
{
// Battery level
quint8 battery = (quint8)data[3];
qDebug(logUsbControl()) << QString("Battery level %1 %").arg(battery);
}
}
if (lastusbController.msecsTo(QTime::currentTime()) >= 100 || lastusbController > QTime::currentTime())
{
@ -495,6 +636,33 @@ void usbController::runTimer()
qDebug(logUsbControl()) << "Shuttle MINUS" << shutMult;
}
}
if (usbDevice == eCoderPlus) {
for (unsigned char i = 0; i < 3; i++) {
for (KNOB* kb = knobList->begin(); kb != knobList->end(); kb++) {
if (kb && kb->dev == usbDevice && kb->num == i + 1 && knobValues[i]) {
COMMAND cmd;
cmd.command = kb->command->command;
if (knobSend[i] + (knobValues[i] * 10) <= 0)
{
knobSend[i] = 0;
}
else if (knobSend[i] + (knobValues[i] * 10) >= 255)
{
knobSend[i] = 255;
}
else {
knobSend[i] = knobSend[i] + (knobValues[i] * 10);
}
cmd.suffix = knobSend[i];
qInfo(logUsbControl()) << "Sending Knob:" << kb->num << "Command:" << cmd.command << " Value:" << cmd.suffix << "Raw value:" << knobValues[i];
emit button(&cmd);
knobValues[i] = 0;
}
}
}
}
if (jogCounter != 0) {
emit sendJog(jogCounter/sensitivity);
qDebug(logUsbControl()) << "Change Frequency by" << jogCounter << "hz";
@ -505,10 +673,55 @@ void usbController::runTimer()
}
}
// Run every 25ms
QTimer::singleShot(25, this, SLOT(runTimer()));
}
/* Functions below receive various settings from other classes/threads */
void usbController::receiveCommands(QVector<COMMAND>* cmds)
{
qDebug(logUsbControl()) << "Receiving commands";
commands = cmds;
}
void usbController::receiveButtons(QVector<BUTTON>* buts)
{
qDebug(logUsbControl()) << "Receiving buttons";
buttonList = buts;
}
void usbController::receiveKnobs(QVector<KNOB>* kbs)
{
qDebug(logUsbControl()) << "Receiving knobs";
knobList = kbs;
}
void usbController::receiveSensitivity(int val)
{
sensitivity = val;
}
void usbController::receivePTTStatus(bool on) {
static QColor lastColour = currentColour;
static bool ptt;
if (on && !ptt) {
lastColour = currentColour;
programWheelColour(255, 0, 0);
}
else {
programWheelColour((quint8)lastColour.red(), (quint8)lastColour.green(), (quint8)lastColour.blue());
}
ptt = on;
}
/*
* All functions below here are for specific controllers
*/
/* Functions below are for RC28 */
void usbController::ledControl(bool on, unsigned char num)
{
if (usbDevice == RC28) {
@ -544,6 +757,10 @@ void usbController::getVersion()
qDebug(logUsbControl()) << "Unable to write(), Error:" << hid_error(handle);
}
}
/* End of RC28 functions*/
/* Functions below are for Gamepad controllers */
void usbController::buttonState(QString name, bool val)
{
for (BUTTON* but = buttonList->begin(); but != buttonList->end(); but++) {
@ -560,6 +777,7 @@ void usbController::buttonState(QString name, bool val)
}
}
}
void usbController::buttonState(QString name, double val)
{
@ -585,9 +803,133 @@ void usbController::buttonState(QString name, double val)
*/
}
void usbController::receiveSensitivity(int val)
/* End of Gamepad functions*/
/* Functions below are for Xencelabs QuickKeys*/
void usbController::programButton(quint8 val, QString text)
{
sensitivity = val;
if (handle && usbDevice == QuickKeys && val < 8) {
text = text.mid(0, 10); // Make sure text is no more than 10 characters.
qDebug(logUsbControl()) << QString("Programming button %0 with %1").arg(val).arg(text);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb1;
data[3] = val + 1;
data[5] = text.length() * 2;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
QByteArray le = qToLittleEndian(QByteArray::fromRawData(reinterpret_cast<const char*>(text.constData()), text.size() * 2));
data.replace(16, le.size(), le);
int res = hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
if (res < 0) {
qDebug(logUsbControl()) << "Unable to write(), Error:" << hid_error(this->handle);
return;
}
}
}
void usbController::programBrightness(quint8 val) {
if (handle && usbDevice == QuickKeys) {
qDebug(logUsbControl()) << QString("Programming brightness to %0").arg(val);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb1;
data[2] = (qint8)0x0a;
data[3] = (qint8)0x01;
data[4] = val;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
}
}
void usbController::programOrientation(quint8 val) {
if (handle && usbDevice == QuickKeys) {
qDebug(logUsbControl()) << QString("Programming orientation to %0").arg(val);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb1;
data[2] = (qint8)val;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
}
}
void usbController::programSpeed(quint8 val) {
if (handle && usbDevice == QuickKeys) {
qDebug(logUsbControl()) << QString("Programming speed to %0").arg(val);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb4;
data[2] = (qint8)0x04;
data[3] = (qint8)0x01;
data[4] = (qint8)0x01;
data[5] = val;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
}
}
void usbController::programWheelColour(quint8 r, quint8 g, quint8 b)
{
if (handle && usbDevice == QuickKeys) {
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb4;
data[2] = (qint8)0x01;
data[3] = (qint8)0x01;
data[6] = (qint8)r;
data[7] = (qint8)g;
data[8] = (qint8)b;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
currentColour.setRed(r);
currentColour.setGreen(g);
currentColour.setBlue(b);
}
}
void usbController::programOverlay(quint8 duration, QString text)
{
if (handle && usbDevice == QuickKeys) {
text = text.mid(0, 32);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb1;
data[3] = (qint8)duration;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
for (int i = 0; i < text.length(); i = i + 8)
{
data[2] = (i == 0) ? 0x05 : 0x06;
QByteArray le = qToLittleEndian(QByteArray::fromRawData(reinterpret_cast<const char*>(text.mid(i, 8).constData()), text.mid(i, 8).size() * 2));
data.replace(16, le.size(), le);
data[5] = text.mid(i, 8).length() * 2;
data[6] = (i > 0 && text.mid(i).size() > 8) ? 0x01 : 0x00;
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
}
//qInfo(logUsbControl()) << "Sent overlay" << text;
}
}
void usbController::programTimeout(quint8 val)
{
if (handle && usbDevice == QuickKeys) {
qInfo(logUsbControl()) << QString("Programming timeout to %0 minutes").arg(val);
QByteArray data(32, 0x0);
data[0] = (qint8)0x02;
data[1] = (qint8)0xb4;
data[2] = (qint8)0x08;
data[3] = (qint8)0x01;
data[4] = val;
data.replace(10, this->deviceId.size(), this->deviceId.toLocal8Bit());
hid_write(this->handle, (const unsigned char*)data.constData(), data.size());
}
}
/* End of functions for Xencelabs QuickKeys*/
#endif

Wyświetl plik

@ -10,6 +10,10 @@
#include <QGraphicsTextItem>
#include <QColor>
#include <QVector>
#include <QList>
#include <QMutex>
#include <QIODevice>
#include <QtEndian>
#if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0)
#include <QGamepad>
@ -56,15 +60,16 @@ using namespace std;
struct COMMAND {
COMMAND() {}
COMMAND(int index, QString text, int command, char suffix) :
index(index), text(text), command(command), suffix(suffix) {}
COMMAND(int index, QString text, int command, availableBands band) :
index(index), text(text), command(command), band(band) {}
COMMAND(int index, QString text, int command, mode_kind mode) :
index(index), text(text), command(command), mode(mode) {}
COMMAND(int index, QString text, usbCommandType cmdType, int command, unsigned char suffix) :
index(index), text(text), cmdType(cmdType), command(command), suffix(suffix) {}
COMMAND(int index, QString text, usbCommandType cmdType, int command, availableBands band) :
index(index), text(text), cmdType(cmdType), command(command), band(band) {}
COMMAND(int index, QString text, usbCommandType cmdType, int command, mode_kind mode) :
index(index), text(text), cmdType(cmdType), command(command), mode(mode) {}
int index=0;
QString text;
usbCommandType cmdType = commandButton;
int command=0;
unsigned char suffix=0x0;
availableBands band=bandGen;
@ -74,25 +79,40 @@ struct COMMAND {
struct BUTTON {
BUTTON() {}
BUTTON(quint8 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) {}
BUTTON(quint8 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) {}
quint8 dev;
usbDeviceType dev;
int num;
QString name;
QRect pos;
QColor textColour;
int onEvent = 0;
int offEvent = 0;
const COMMAND* onCommand=Q_NULLPTR;
const COMMAND* offCommand=Q_NULLPTR;
const COMMAND* onCommand = Q_NULLPTR;
const COMMAND* offCommand = Q_NULLPTR;
QGraphicsTextItem* onText;
QGraphicsTextItem* offText;
};
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) {}
usbDeviceType dev;
int num;
QString name;
QRect pos;
QColor textColour;
const COMMAND* command = Q_NULLPTR;
QGraphicsTextItem* text;
};
#if defined(USB_CONTROLLER)
class usbController : public QObject
{
@ -103,14 +123,23 @@ public:
~usbController();
public slots:
void init(int sens);
void init(int sens, QMutex *mut);
void run();
void runTimer();
void ledControl(bool on, unsigned char num);
void receiveCommands(QVector<COMMAND>*);
void receiveButtons(QVector<BUTTON>*);
void receiveKnobs(QVector<KNOB>*);
void receivePTTStatus(bool on);
void getVersion();
void receiveSensitivity(int val);
void programButton(quint8 val, QString text);
void programBrightness(quint8 val);
void programOrientation(quint8 val);
void programSpeed(quint8 val);
void programWheelColour(quint8 r, quint8 g, quint8 b);
void programOverlay(quint8 duration, QString text);
void programTimeout(quint8 val);
signals:
void jogPlus();
@ -119,14 +148,15 @@ signals:
void doShuttle(bool plus, quint8 level);
void setBand(int band);
void button(const COMMAND* cmd);
void newDevice(unsigned char devType, QVector<BUTTON>* but,QVector<COMMAND>* cmd);
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd, QMutex* mut);
void sendSensitivity(int val);
private:
hid_device* handle=NULL;
int hidStatus = 1;
bool isOpen=false;
unsigned int buttons=0;
quint32 buttons = 0;
quint32 knobs = 0;
unsigned char jogpos=0;
unsigned char shutpos=0;
unsigned char shutMult = 0;
@ -135,12 +165,20 @@ private:
QByteArray lastData = QByteArray(8,0x0);
unsigned char lastDialPos=0;
QVector<BUTTON>* buttonList;
QVector<KNOB>* knobList;
QVector<COMMAND>* commands = Q_NULLPTR;
QString product="";
QString manufacturer="";
QString serial="<none>";
QString deviceId = "";
QString path = "";
quint16 vendorId = 0;
quint16 productId = 0;
int sensitivity = 1;
QList<int> knobValues;
QList<quint8> knobSend;
QMutex* mutex=Q_NULLPTR;
QColor currentColour;
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QGamepad* gamepad=Q_NULLPTR;
#endif
@ -148,11 +186,15 @@ private:
void buttonState(QString but, double val);
usbDeviceType usbDevice = usbNone;
unsigned short knownUsbDevices[3][3] = {
{shuttleXpress,0x0b33,0x0020},
{shuttlePro2,0x0b33,0x0030},
{RC28,0x0c26,0x001e} };
unsigned short knownUsbDevices[6][5] = {
{shuttleXpress,0x0b33,0x0020,0x0001,0x000c},
{shuttlePro2,0x0b33,0x0030,0x0001,0x000c},
//{eCoderPlus,0x0c26,0x001e}, // Only enable for testing!
{RC28,0x0c26,0x001e,0x0004,0x0004},
{eCoderPlus, 0x1fc9, 0x0003,0x0000,0x0000},
{QuickKeys, 0x28bd, 0x5202,0x0001,0xff0a},
{QuickKeys, 0x28bd, 0x5203,0x0001,0xff0a}
};
protected:
};

Wyświetl plik

@ -74,6 +74,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
qRegisterMetaType<rigstate*>();
qRegisterMetaType<QList<radio_cap_packet>>();
qRegisterMetaType<QVector<BUTTON>*>();
qRegisterMetaType<QVector<KNOB>*>();
qRegisterMetaType<QVector<COMMAND>*>();
qRegisterMetaType<const COMMAND*>();
qRegisterMetaType<QList<radio_cap_packet>>();
@ -1677,15 +1678,27 @@ void wfmain::setupUsbControllerDevice()
connect(usbControllerDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char)));
connect(usbControllerDev, SIGNAL(button(const COMMAND*)), this, SLOT(buttonControl(const COMMAND*)));
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
connect(usbControllerDev, SIGNAL(newDevice(unsigned char, QVector<BUTTON>*, QVector<COMMAND>*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*, QVector<COMMAND>*)));
connect(usbControllerDev, SIGNAL(newDevice(unsigned char, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*, QMutex*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*,QMutex*)));
usbControllerThread->start(QThread::LowestPriority);
connect(this, SIGNAL(sendUsbControllerCommands(QVector<COMMAND>*)), usbControllerDev, SLOT(receiveCommands(QVector<COMMAND>*)));
connect(this, SIGNAL(sendUsbControllerButtons(QVector<BUTTON>*)), usbControllerDev, SLOT(receiveButtons(QVector<BUTTON>*)));
connect(this, SIGNAL(sendUsbControllerKnobs(QVector<KNOB>*)), usbControllerDev, SLOT(receiveKnobs(QVector<KNOB>*)));
connect(shut, SIGNAL(sendSensitivity(int)), usbControllerDev, SLOT(receiveSensitivity(int)));
connect(shut, SIGNAL(sendSensitivity(int)), this, SLOT(receiveUsbSensitivity(int)));
connect(usbControllerDev, SIGNAL(sendSensitivity(int)), shut, SLOT(receiveSensitivity(int)));
connect(this, SIGNAL(initUsbController(int)), usbControllerDev, SLOT(init(int)));
connect(shut, SIGNAL(programButton(quint8, QString)), usbControllerDev, SLOT(programButton(quint8, QString)));
connect(shut, SIGNAL(programBrightness(quint8)), usbControllerDev, SLOT(programBrightness(quint8)));
connect(shut, SIGNAL(programOrientation(quint8)), usbControllerDev, SLOT(programOrientation(quint8)));
connect(shut, SIGNAL(programSpeed(quint8)), usbControllerDev, SLOT(programSpeed(quint8)));
connect(shut, SIGNAL(programWheelColour(quint8, quint8, quint8)), usbControllerDev, SLOT(programWheelColour(quint8, quint8, quint8)));
connect(shut, SIGNAL(programOverlay(quint8, QString)), usbControllerDev, SLOT(programOverlay(quint8, QString)));
connect(shut, SIGNAL(programTimeout(quint8)), usbControllerDev, SLOT(programTimeout(quint8)));
connect(shut, SIGNAL(updateSettings(quint8, quint8, quint8, quint8, QColor)), this, SLOT(receiveUsbSettings(quint8, quint8, quint8, quint8, QColor)));
connect(this, SIGNAL(setPTT(bool)), usbControllerDev, SLOT(receivePTTStatus(bool)));
connect(this, SIGNAL(initUsbController(int, QMutex*)), usbControllerDev, SLOT(init(int, QMutex*)));
connect(this, SIGNAL(initUsbDefaults(quint8, quint8, quint8, quint8, QColor)), shut, SLOT(setDefaults(quint8, quint8, quint8, quint8, QColor)));
#endif
}
@ -1892,6 +1905,11 @@ void wfmain::setDefPrefs()
defPrefs.audioSystem = qtAudio;
defPrefs.enableUSBControllers = false;
defPrefs.usbSensitivity = 1;
defPrefs.usbSpeed = 3;
defPrefs.usbTimeout = 30;
defPrefs.usbBrightness = 3;
defPrefs.usbOrientation = 3;
defPrefs.usbColor = Qt::white;
udpDefPrefs.ipAddress = QString("");
udpDefPrefs.controlLANPort = 50001;
@ -2445,13 +2463,24 @@ void wfmain::loadSettings()
ui->usbButtonsResetBtn->setEnabled(prefs.enableUSBControllers);
ui->usbCommandsResetBtn->setEnabled(prefs.enableUSBControllers);
ui->usbResetLbl->setVisible(prefs.enableUSBControllers);
prefs.usbBrightness = (quint8)settings->value("USBBrightness", defPrefs.usbBrightness).toInt();
prefs.usbOrientation = (quint8)settings->value("USBOrientation", defPrefs.usbOrientation).toInt();
prefs.usbSpeed = (quint8)settings->value("USBSpeed", defPrefs.usbSpeed).toInt();
prefs.usbTimeout = (quint8)settings->value("USBBTimeout", defPrefs.usbTimeout).toInt();
prefs.usbColor.setNamedColor(settings->value("USBColor", defPrefs.usbColor.name(QColor::HexArgb)).toString());
/*Ensure that no operations on the usb commands/buttons/knobs take place*/
QMutexLocker locker(&usbMutex);
if (prefs.enableUSBControllers) {
// Setup USB Controller
setupUsbControllerDevice();
emit initUsbController(prefs.usbSensitivity);
emit initUsbController(prefs.usbSensitivity, &usbMutex);
emit sendUsbControllerCommands(&usbCommands);
emit sendUsbControllerButtons(&usbButtons);
emit sendUsbControllerKnobs(&usbKnobs);
emit initUsbDefaults(prefs.usbBrightness, prefs.usbOrientation, prefs.usbSpeed, prefs.usbTimeout, prefs.usbColor);
}
int numCommands = settings->beginReadArray("Commands");
@ -2472,6 +2501,7 @@ void wfmain::loadSettings()
comm.band = (availableBands)settings->value("Band", 0).toInt();
comm.mode = (mode_kind)settings->value("Mode", 0).toInt();
comm.suffix = (unsigned char)settings->value("Suffix", 0).toInt();
comm.cmdType = (usbCommandType)settings->value("CommandType", 0).toInt();
usbCommands.append(comm);
}
settings->endArray();
@ -2490,7 +2520,7 @@ void wfmain::loadSettings()
{
settings->setArrayIndex(nb);
BUTTON butt;
butt.dev = settings->value("Dev", 0).toInt();
butt.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
butt.num = settings->value("Num", 0).toInt();
butt.name = settings->value("Name", "").toString();
butt.pos = QRect(settings->value("Left", 0).toInt(),
@ -2518,6 +2548,44 @@ void wfmain::loadSettings()
settings->endArray();
}
int numKnobs = settings->beginReadArray("Knobs");
// This is the last time the knobs were changed, (v1.58)
if (numKnobs == 0 || priorVersionFloat < 1.58) {
settings->endArray();
// We have no knobs so create defaults
resetUsbKnobs();
}
else {
usbKnobs.clear();
for (int nk = 0; nk < numKnobs; nk++)
{
settings->setArrayIndex(nk);
KNOB kb;
kb.dev = (usbDeviceType)settings->value("Dev", 0).toInt();
kb.num = settings->value("Num", 0).toInt();
kb.name = settings->value("Name", "").toString();
kb.pos = QRect(settings->value("Left", 0).toInt(),
settings->value("Top", 0).toInt(),
settings->value("Width", 0).toInt(),
settings->value("Height", 0).toInt());
kb.textColour = QColor((settings->value("Colour", "Green").toString()));
QString cmd = settings->value("Command", "None").toString();
QVector<COMMAND>::iterator usbc = usbCommands.begin();
while (usbc != usbCommands.end())
{
if (cmd == usbc->text) {
kb.command = usbc;
}
++usbc;
}
usbKnobs.append(kb);
}
settings->endArray();
}
settings->endGroup();
#endif
}
@ -2917,7 +2985,14 @@ void wfmain::saveSettings()
// Store USB Controller
settings->setValue("EnableUSBControllers", prefs.enableUSBControllers);
settings->setValue("USBSensitivity", prefs.usbSensitivity);
settings->setValue("USBBrightness", prefs.usbBrightness);
settings->setValue("USBOrientation", prefs.usbOrientation);
settings->setValue("USBSpeed", prefs.usbSpeed);
settings->setValue("USBTimeout", prefs.usbTimeout);
settings->setValue("USBColor", prefs.usbColor.name(QColor::HexArgb));
QMutexLocker locker(&usbMutex);
settings->beginWriteArray("Buttons");
for (int nb = 0; nb < usbButtons.count(); nb++)
{
@ -2938,6 +3013,23 @@ void wfmain::saveSettings()
settings->endArray();
settings->beginWriteArray("Knobs");
for (int nk = 0; nk < usbKnobs.count(); nk++)
{
settings->setArrayIndex(nk);
settings->setValue("Dev", usbKnobs[nk].dev);
settings->setValue("Num", usbKnobs[nk].num);
settings->setValue("Left", usbKnobs[nk].pos.left());
settings->setValue("Top", usbKnobs[nk].pos.top());
settings->setValue("Width", usbKnobs[nk].pos.width());
settings->setValue("Height", usbKnobs[nk].pos.height());
settings->setValue("Colour", usbKnobs[nk].textColour.name());
if (usbKnobs[nk].command != Q_NULLPTR)
settings->setValue("Command", usbKnobs[nk].command->text);
}
settings->endArray();
settings->beginWriteArray("Commands");
for (int nc = 0; nc < usbCommands.count(); nc++)
{
@ -2949,6 +3041,7 @@ void wfmain::saveSettings()
settings->setValue("Band", usbCommands[nc].band);
settings->setValue("Mode", usbCommands[nc].mode);
settings->setValue("Suffix", usbCommands[nc].suffix);
settings->setValue("CommandType", usbCommands[nc].cmdType);
}
settings->endArray();
@ -7997,17 +8090,18 @@ QColor wfmain::getColorFromPicker(QColor initialColor)
int alphaVal = 0;
bool ok = false;
if(selColor.isValid())
if (selColor.isValid())
{
if(selColor.alpha() == 0)
if (selColor.alpha() == 0)
{
alphaVal = QInputDialog::getInt(this, tr("Specify Opacity"),
tr("You specified an opacity value of 0. \nDo you want to change it? (0=transparent, 255=opaque)"), 0, 0, 255, 1,
&ok);
if(!ok)
tr("You specified an opacity value of 0. \nDo you want to change it? (0=transparent, 255=opaque)"), 0, 0, 255, 1,
&ok);
if (!ok)
{
return selColor;
} else {
}
else {
selColor.setAlpha(alphaVal);
return selColor;
}
@ -9072,9 +9166,18 @@ void wfmain::on_enableUsbChk_clicked(bool checked)
if (checked) {
// Setup USB Controller
setupUsbControllerDevice();
emit initUsbController(prefs.usbSensitivity);
emit initUsbController(prefs.usbSensitivity, &usbMutex);
emit sendUsbControllerCommands(&usbCommands);
emit sendUsbControllerButtons(&usbButtons);
emit sendUsbControllerKnobs(&usbKnobs);
emit initUsbDefaults(prefs.usbBrightness, prefs.usbOrientation, prefs.usbSpeed, prefs.usbTimeout, prefs.usbColor);
}
else {
if (shut != Q_NULLPTR) {
if (shut->isVisible()) {
shut->hide();
}
}
}
#endif
}
@ -9102,6 +9205,7 @@ void wfmain::on_usbButtonsResetBtn_clicked()
if (ret == QMessageBox::Ok) {
qInfo(logUsbControl()) << "Resetting USB buttons to default values";
resetUsbButtons();
resetUsbKnobs();
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
}
}
@ -9209,122 +9313,194 @@ void wfmain::on_cwButton_clicked()
void wfmain::resetUsbButtons()
{
#ifdef USB_CONTROLLER
qInfo(logUsbControl) << "Resetting USB Buttons to defaults";
usbButtons.clear();
// ShuttleXpress
usbButtons.append(BUTTON(1, 4, QRect(25, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(1, 5, QRect(101, 72, 83, 88), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(1, 6, QRect(238, 26, 134, 69), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(1, 7, QRect(452, 72, 77, 86), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(1, 8, QRect(504, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttleXpress, 4, QRect(25, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttleXpress, 5, QRect(101, 72, 83, 88), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttleXpress, 6, QRect(238, 26, 134, 69), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttleXpress, 7, QRect(452, 72, 77, 86), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttleXpress, 8, QRect(504, 199, 89, 169), Qt::red, &usbCommands[0], &usbCommands[0]));
// ShuttlePro2
usbButtons.append(BUTTON(2, 0, QRect(60, 66, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 1, QRect(114, 50, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 2, QRect(169, 47, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 3, QRect(225, 59, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 4, QRect(41, 132, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 5, QRect(91, 105, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 6, QRect(144, 93, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 7, QRect(204, 99, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 8, QRect(253, 124, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 9, QRect(50, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 10, QRect(210, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 11, QRect(50, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 12, QRect(210, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 13, QRect(30, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(2, 14, QRect(280, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 0, QRect(60, 66, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 1, QRect(114, 50, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 2, QRect(169, 47, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 3, QRect(225, 59, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 4, QRect(41, 132, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 5, QRect(91, 105, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 6, QRect(144, 93, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 7, QRect(204, 99, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 8, QRect(253, 124, 40, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 9, QRect(50, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 10, QRect(210, 270, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 11, QRect(50, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 12, QRect(210, 335, 70, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 13, QRect(30, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(shuttlePro2, 14, QRect(280, 195, 25, 80), Qt::red, &usbCommands[0], &usbCommands[0]));
// RC28
usbButtons.append(BUTTON(3, 0, QRect(52, 445, 238, 64), Qt::red, &usbCommands[1], &usbCommands[2])); // PTT On/OFF
usbButtons.append(BUTTON(3, 1, QRect(52, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(3, 2, QRect(193, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(RC28, 0, QRect(52, 445, 238, 64), Qt::red, &usbCommands[1], &usbCommands[2])); // PTT On/OFF
usbButtons.append(BUTTON(RC28, 1, QRect(52, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(RC28, 2, QRect(193, 373, 98, 46), Qt::red, &usbCommands[0], &usbCommands[0]));
// Xbox Gamepad
usbButtons.append(BUTTON(4, "UP", QRect(256, 229, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "DOWN", QRect(256, 316, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "LEFT", QRect(203, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "RIGHT", QRect(303, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "SELECT", QRect(302, 160, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "START", QRect(412, 163, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "Y", QRect(534, 104, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "X", QRect(485, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "B", QRect(590, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "A", QRect(534, 202, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "L1", QRect(123, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "R1", QRect(562, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "LEFTX", QRect(143, 119, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "LEFTY", QRect(162, 132, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "RIGHTX", QRect(430, 298, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(4, "RIGHTY", QRect(453, 233, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "UP", QRect(256, 229, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "DOWN", QRect(256, 316, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "LEFT", QRect(203, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "RIGHT", QRect(303, 273, 50, 50), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "SELECT", QRect(302, 160, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "START", QRect(412, 163, 40, 40), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "Y", QRect(534, 104, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "X", QRect(485, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "B", QRect(590, 152, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "A", QRect(534, 202, 53, 53), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "L1", QRect(123, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "R1", QRect(562, 40, 70, 45), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "LEFTX", QRect(143, 119, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "LEFTY", QRect(162, 132, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "RIGHTX", QRect(430, 298, 83, 35), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(xBoxGamepad, "RIGHTY", QRect(453, 233, 50, 57), Qt::red, &usbCommands[0], &usbCommands[0]));
// eCoder
usbButtons.append(BUTTON(eCoderPlus, 1, QRect(87, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 2, QRect(168, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 3, QRect(249, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 4, QRect(329, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 5, QRect(410, 190, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 6, QRect(87, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 7, QRect(168, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 8, QRect(249, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 9, QRect(329, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 10, QRect(410, 270, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 11, QRect(87, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 12, QRect(410, 351, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 13, QRect(87, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 14, QRect(410, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 16, QRect(128, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 17, QRect(256, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 18, QRect(380, 104, 45, 47), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 19, QRect(124, 2, 55, 30), Qt::red, &usbCommands[1], &usbCommands[2]));
usbButtons.append(BUTTON(eCoderPlus, 20, QRect(290, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(eCoderPlus, 21, QRect(404, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
// QuickKeys
usbButtons.append(BUTTON(QuickKeys, 0, QRect(77, 204, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 1, QRect(77, 276, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 2, QRect(77, 348, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 3, QRect(77, 422, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 4, QRect(230, 204, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 5, QRect(230, 276, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 6, QRect(230, 348, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 7, QRect(230, 422, 39, 63), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 8, QRect(143, 515, 55, 40), Qt::white, &usbCommands[0], &usbCommands[0]));
usbButtons.append(BUTTON(QuickKeys, 9, QRect(139, 68, 65, 65), Qt::white, &usbCommands[0], &usbCommands[0]));
emit sendUsbControllerButtons(&usbButtons);
#endif
}
void wfmain::resetUsbKnobs()
{
#ifdef USB_CONTROLLER
qInfo(logUsbControl) << "Resetting USB Knobs to defaults";
usbKnobs.clear();
// eCoder
usbKnobs.append(KNOB(eCoderPlus, 1, QRect(120, 153, 72, 27), Qt::green, &usbCommands[0]));
usbKnobs.append(KNOB(eCoderPlus, 2, QRect(242, 153, 72, 27), Qt::green, &usbCommands[0]));
usbKnobs.append(KNOB(eCoderPlus, 3, QRect(362, 153, 72, 27), Qt::green, &usbCommands[0]));
emit sendUsbControllerKnobs(&usbKnobs);
#endif
}
void wfmain::resetUsbCommands()
{
#ifdef USB_CONTROLLER
qInfo(logUsbControl) << "Resetting USB Commands to defaults";
usbCommands.clear();
int num = 0;
usbCommands.append(COMMAND(num++, "None", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "PTT On", cmdSetPTT, 0x1));
usbCommands.append(COMMAND(num++, "PTT Off", cmdSetPTT, 0x0));
usbCommands.append(COMMAND(num++, "PTT Toggle", cmdPTTToggle, 0x0));
usbCommands.append(COMMAND(num++, "Tune", cmdStartATU, 0x0));
usbCommands.append(COMMAND(num++, "Step+", cmdSetStepUp, 0x0));
usbCommands.append(COMMAND(num++, "Step-", cmdSetStepDown, 0x0));
usbCommands.append(COMMAND(num++, "Span+", cmdSetSpanUp, 0x0));
usbCommands.append(COMMAND(num++, "Span-", cmdSetSpanDown, 0x0));
usbCommands.append(COMMAND(num++, "Mode+", cmdSetModeUp, 0x0));
usbCommands.append(COMMAND(num++, "Mode-", cmdSetModeDown, 0x0));
usbCommands.append(COMMAND(num++, "Mode LSB", cmdSetMode, modeLSB));
usbCommands.append(COMMAND(num++, "Mode USB", cmdSetMode, modeUSB));
usbCommands.append(COMMAND(num++, "Mode LSBD", cmdSetMode, modeLSB_D));
usbCommands.append(COMMAND(num++, "Mode USBD", cmdSetMode, modeUSB_D));
usbCommands.append(COMMAND(num++, "Mode CW", cmdSetMode, modeCW));
usbCommands.append(COMMAND(num++, "Mode CWR", cmdSetMode, modeCW_R));
usbCommands.append(COMMAND(num++, "Mode FM", cmdSetMode, modeFM));
usbCommands.append(COMMAND(num++, "Mode AM", cmdSetMode, modeAM));
usbCommands.append(COMMAND(num++, "Mode RTTY", cmdSetMode, modeRTTY));
usbCommands.append(COMMAND(num++, "Mode RTTYR", cmdSetMode, modeRTTY_R));
usbCommands.append(COMMAND(num++, "Mode PSK", cmdSetMode, modePSK));
usbCommands.append(COMMAND(num++, "Mode PSKR", cmdSetMode, modePSK_R));
usbCommands.append(COMMAND(num++, "Mode DV", cmdSetMode, modeDV));
usbCommands.append(COMMAND(num++, "Mode DD", cmdSetMode, modeDD));
usbCommands.append(COMMAND(num++, "Band+", cmdSetBandUp, 0x0));
usbCommands.append(COMMAND(num++, "Band-", cmdSetBandDown, 0x0));
usbCommands.append(COMMAND(num++, "23cm", cmdGetBandStackReg, band23cm));
usbCommands.append(COMMAND(num++, "70cm", cmdGetBandStackReg, band70cm));
usbCommands.append(COMMAND(num++, "2m", cmdGetBandStackReg, band2m));
usbCommands.append(COMMAND(num++, "AIR", cmdGetBandStackReg, bandAir));
usbCommands.append(COMMAND(num++, "WFM", cmdGetBandStackReg, bandWFM));
usbCommands.append(COMMAND(num++, "4m", cmdGetBandStackReg, band4m));
usbCommands.append(COMMAND(num++, "6m", cmdGetBandStackReg, band6m));
usbCommands.append(COMMAND(num++, "10m", cmdGetBandStackReg, band10m));
usbCommands.append(COMMAND(num++, "12m", cmdGetBandStackReg, band12m));
usbCommands.append(COMMAND(num++, "15m", cmdGetBandStackReg, band15m));
usbCommands.append(COMMAND(num++, "17m", cmdGetBandStackReg, band17m));
usbCommands.append(COMMAND(num++, "20m", cmdGetBandStackReg, band20m));
usbCommands.append(COMMAND(num++, "30m", cmdGetBandStackReg, band30m));
usbCommands.append(COMMAND(num++, "40m", cmdGetBandStackReg, band40m));
usbCommands.append(COMMAND(num++, "60m", cmdGetBandStackReg, band60m));
usbCommands.append(COMMAND(num++, "80m", cmdGetBandStackReg, band80m));
usbCommands.append(COMMAND(num++, "160m", cmdGetBandStackReg, band160m));
usbCommands.append(COMMAND(num++, "630m", cmdGetBandStackReg, band630m));
usbCommands.append(COMMAND(num++, "2200m", cmdGetBandStackReg, band2200m));
usbCommands.append(COMMAND(num++, "GEN", cmdGetBandStackReg, bandGen));
usbCommands.append(COMMAND(num++, "NR On", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NR Off", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NB On", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NB Off", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "Split On", cmdNone, 0x01));
usbCommands.append(COMMAND(num++, "Split Off", cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "Swap VFOs", cmdVFOSwap, 0x0));
usbCommands.append(COMMAND(num++, "None", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "PTT On", commandButton, cmdSetPTT, 0x1));
usbCommands.append(COMMAND(num++, "PTT Off", commandButton, cmdSetPTT, 0x0));
usbCommands.append(COMMAND(num++, "PTT Toggle", commandButton, cmdPTTToggle, 0x0));
usbCommands.append(COMMAND(num++, "Tune", commandButton, cmdStartATU, 0x0));
usbCommands.append(COMMAND(num++, "Step+", commandButton, cmdSetStepUp, 0x0));
usbCommands.append(COMMAND(num++, "Step-", commandButton, cmdSetStepDown, 0x0));
usbCommands.append(COMMAND(num++, "Span+", commandButton, cmdSetSpanUp, 0x0));
usbCommands.append(COMMAND(num++, "Span-", commandButton, cmdSetSpanDown, 0x0));
usbCommands.append(COMMAND(num++, "Mode+", commandButton, cmdSetModeUp, 0x0));
usbCommands.append(COMMAND(num++, "Mode-", commandButton, cmdSetModeDown, 0x0));
usbCommands.append(COMMAND(num++, "Mode LSB", commandButton, cmdSetMode, modeLSB));
usbCommands.append(COMMAND(num++, "Mode USB", commandButton, cmdSetMode, modeUSB));
usbCommands.append(COMMAND(num++, "Mode LSBD", commandButton, cmdSetMode, modeLSB_D));
usbCommands.append(COMMAND(num++, "Mode USBD", commandButton, cmdSetMode, modeUSB_D));
usbCommands.append(COMMAND(num++, "Mode CW", commandButton, cmdSetMode, modeCW));
usbCommands.append(COMMAND(num++, "Mode CWR", commandButton, cmdSetMode, modeCW_R));
usbCommands.append(COMMAND(num++, "Mode FM", commandButton, cmdSetMode, modeFM));
usbCommands.append(COMMAND(num++, "Mode AM", commandButton, cmdSetMode, modeAM));
usbCommands.append(COMMAND(num++, "Mode RTTY", commandButton, cmdSetMode, modeRTTY));
usbCommands.append(COMMAND(num++, "Mode RTTYR", commandButton, cmdSetMode, modeRTTY_R));
usbCommands.append(COMMAND(num++, "Mode PSK", commandButton, cmdSetMode, modePSK));
usbCommands.append(COMMAND(num++, "Mode PSKR", commandButton, cmdSetMode, modePSK_R));
usbCommands.append(COMMAND(num++, "Mode DV", commandButton, cmdSetMode, modeDV));
usbCommands.append(COMMAND(num++, "Mode DD", commandButton, cmdSetMode, modeDD));
usbCommands.append(COMMAND(num++, "Band+", commandButton, cmdSetBandUp, 0x0));
usbCommands.append(COMMAND(num++, "Band-", commandButton, cmdSetBandDown, 0x0));
usbCommands.append(COMMAND(num++, "Band 23cm", commandButton, cmdGetBandStackReg, band23cm));
usbCommands.append(COMMAND(num++, "Band 70cm", commandButton, cmdGetBandStackReg, band70cm));
usbCommands.append(COMMAND(num++, "Band 2m", commandButton, cmdGetBandStackReg, band2m));
usbCommands.append(COMMAND(num++, "Band AIR", commandButton, cmdGetBandStackReg, bandAir));
usbCommands.append(COMMAND(num++, "Band WFM", commandButton, cmdGetBandStackReg, bandWFM));
usbCommands.append(COMMAND(num++, "Band 4m", commandButton, cmdGetBandStackReg, band4m));
usbCommands.append(COMMAND(num++, "Band 6m", commandButton, cmdGetBandStackReg, band6m));
usbCommands.append(COMMAND(num++, "Band 10m", commandButton, cmdGetBandStackReg, band10m));
usbCommands.append(COMMAND(num++, "Band 12m", commandButton, cmdGetBandStackReg, band12m));
usbCommands.append(COMMAND(num++, "Band 15m", commandButton, cmdGetBandStackReg, band15m));
usbCommands.append(COMMAND(num++, "Band 17m", commandButton, cmdGetBandStackReg, band17m));
usbCommands.append(COMMAND(num++, "Band 20m", commandButton, cmdGetBandStackReg, band20m));
usbCommands.append(COMMAND(num++, "Band 30m", commandButton, cmdGetBandStackReg, band30m));
usbCommands.append(COMMAND(num++, "Band 40m", commandButton, cmdGetBandStackReg, band40m));
usbCommands.append(COMMAND(num++, "Band 60m", commandButton, cmdGetBandStackReg, band60m));
usbCommands.append(COMMAND(num++, "Band 80m", commandButton, cmdGetBandStackReg, band80m));
usbCommands.append(COMMAND(num++, "Band 160m", commandButton, cmdGetBandStackReg, band160m));
usbCommands.append(COMMAND(num++, "Band 630m", commandButton, cmdGetBandStackReg, band630m));
usbCommands.append(COMMAND(num++, "Band 2200m", commandButton, cmdGetBandStackReg, band2200m));
usbCommands.append(COMMAND(num++, "Band GEN", commandButton, cmdGetBandStackReg, bandGen));
usbCommands.append(COMMAND(num++, "NR On", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NR Off", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NB On", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "NB Off", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "Split On", commandButton, cmdNone, 0x01));
usbCommands.append(COMMAND(num++, "Split Off", commandButton, cmdNone, 0x0));
usbCommands.append(COMMAND(num++, "Swap VFO", commandButton, cmdVFOSwap, 0x0));
usbCommands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, 0xff));
usbCommands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, 0xff));
usbCommands.append(COMMAND(num++, "TX Power", commandKnob, cmdSetTxPower, 0xff));
usbCommands.append(COMMAND(num++, "Mic Gain", commandKnob, cmdSetMicGain, 0xff));
usbCommands.append(COMMAND(num++, "Mod Level", commandKnob, cmdSetModLevel, 0xff));
usbCommands.append(COMMAND(num++, "Squelch", commandKnob, cmdSetSql, 0xff));
usbCommands.append(COMMAND(num++, "IF Shift", commandKnob, cmdSetIFShift, 0xff));
usbCommands.append(COMMAND(num++, "In PBT", commandKnob, cmdSetTPBFInner, 0xff));
usbCommands.append(COMMAND(num++, "Out PBT", commandKnob, cmdSetTPBFOuter, 0xff));
usbCommands.append(COMMAND(num++, "CW Pitch", commandKnob, cmdSetCwPitch, 0xff));
usbCommands.append(COMMAND(num++, "CW Speed", commandKnob, cmdSetKeySpeed, 0xff));
emit sendUsbControllerCommands(&usbCommands);
#endif
}
void wfmain::receiveUsbSensitivity(int val) {
prefs.usbSensitivity = val;
}
void wfmain::receiveUsbSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color)
{
qInfo(logUsbControl()) << QString("USB brightness: %0 orentation: %1 speed: %2 timeout: %3 color: %4").arg(bright).arg(orient).arg(speed).arg(timeout).arg(color.name());
prefs.usbBrightness = bright;
prefs.usbOrientation = orient;
prefs.usbSpeed = speed;
prefs.usbTimeout = timeout;
prefs.usbColor = color;
}

Wyświetl plik

@ -225,9 +225,11 @@ signals:
void openShuttle();
void requestRigState();
void stateUpdated();
void initUsbController(int sens);
void initUsbController(int sens, QMutex* mutex);
void sendUsbControllerCommands(QVector<COMMAND>* cmds);
void sendUsbControllerButtons(QVector<BUTTON>* buts);
void sendUsbControllerKnobs(QVector<KNOB>* kbs);
void initUsbDefaults(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
void setClusterUdpPort(int port);
void setClusterEnableUdp(bool udp);
void setClusterEnableTcp(bool tcp);
@ -353,6 +355,8 @@ private slots:
void receiveBaudRate(quint32 baudrate);
void radioSelection(QList<radio_cap_packet> radios);
void receiveUsbSensitivity(int val);
void receiveUsbSettings(quint8 bright, quint8 orient, quint8 speed, quint8 timeout, QColor color);
// Added for RC28/Shuttle support
void pttToggle(bool);
@ -1070,8 +1074,8 @@ private:
void updateUsbButtons();
void resetUsbButtons();
void resetUsbKnobs();
void resetUsbCommands();
int oldFreqDialVal;
rigCapabilities rigCaps;
@ -1149,6 +1153,8 @@ private:
QString usbDeviceName;
QVector<COMMAND> usbCommands;
QVector<BUTTON> usbButtons;
QVector<KNOB> usbKnobs;
QMutex usbMutex;
#endif
dxClusterClient* cluster = Q_NULLPTR;
@ -1183,7 +1189,7 @@ Q_DECLARE_METATYPE(QList<radio_cap_packet>)
Q_DECLARE_METATYPE(QList<spotData>)
Q_DECLARE_METATYPE(rigstate*)
Q_DECLARE_METATYPE(QVector <BUTTON>*)
Q_DECLARE_METATYPE(struct BUTTON*)
Q_DECLARE_METATYPE(QVector <KNOB>*)
Q_DECLARE_METATYPE(QVector <COMMAND>*)
Q_DECLARE_METATYPE(const COMMAND*)
Q_DECLARE_METATYPE(codecType)

Wyświetl plik

@ -112,7 +112,7 @@
<QtModules>core;network;gui;multimedia;widgets;serialport;printsupport</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
<QtInstall>msvc2019_64_v62</QtInstall>
<QtInstall>msvc2016_64_v640</QtInstall>
<QtModules>core;network;gui;multimedia;widgets;serialport;printsupport</QtModules>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -120,7 +120,7 @@
<QtModules>core;network;gui;multimedia;widgets;serialport;printsupport</QtModules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings">
<QtInstall>msvc2019_64_v62</QtInstall>
<QtInstall>msvc2016_64_v640</QtInstall>
<QtModules>core;network;gui;multimedia;widgets;serialport;printsupport</QtModules>
</PropertyGroup>
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.props')">

Wyświetl plik

@ -2,15 +2,15 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="QtSettings">
<QtLastBackgroundBuild>2022-08-21T18:45:22.2052009Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-06T15:26:00.1276665Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="QtSettings">
<QtLastBackgroundBuild>2022-08-21T18:45:22.2052009Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-06T15:25:59.8598138Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="QtSettings">
<QtLastBackgroundBuild>2023-01-02T19:56:38.8798452Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-06T15:26:00.7293349Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="QtSettings">
<QtLastBackgroundBuild>2022-04-13T11:33:53.0745117Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-02-06T15:26:00.3825270Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

Wyświetl plik

@ -194,6 +194,7 @@ enum codecType { LPCM, PCMU, OPUS };
enum passbandActions {passbandStatic, pbtInnerMove, pbtOuterMove, pbtMoving, passbandResizing};
enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2, RC28, xBoxGamepad, unknownGamepad };
enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2, RC28, xBoxGamepad, unknownGamepad, eCoderPlus, QuickKeys};
enum usbCommandType{ commandButton, commandKnob };
#endif // WFVIEWTYPES_H