kopia lustrzana https://gitlab.com/eliggett/wfview
Provisional support for knobs
rodzic
17a6547264
commit
a8951813f5
|
@ -16,6 +16,7 @@ controllerSetup::controllerSetup(QWidget* parent) :
|
||||||
|
|
||||||
connect(&onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
|
connect(&onEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(onEventIndexChanged(int)));
|
||||||
connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
|
connect(&offEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(offEventIndexChanged(int)));
|
||||||
|
connect(&knobEvent, SIGNAL(currentIndexChanged(int)), this, SLOT(knobEventIndexChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerSetup::~controllerSetup()
|
controllerSetup::~controllerSetup()
|
||||||
|
@ -50,48 +51,80 @@ void controllerSetup::mousePressed(QPoint p)
|
||||||
}
|
}
|
||||||
onEvent.blockSignals(true);
|
onEvent.blockSignals(true);
|
||||||
onEvent.move(p);
|
onEvent.move(p);
|
||||||
onEvent.setCurrentIndex(currentButton->onCommand->index);
|
onEvent.setCurrentIndex(onEvent.findData(currentButton->onCommand->index));
|
||||||
onEvent.show();
|
onEvent.show();
|
||||||
onEvent.blockSignals(false);
|
onEvent.blockSignals(false);
|
||||||
|
|
||||||
p.setY(p.y() + 40);
|
p.setY(p.y() + 40);
|
||||||
offEvent.blockSignals(true);
|
offEvent.blockSignals(true);
|
||||||
offEvent.move(p);
|
offEvent.move(p);
|
||||||
offEvent.setCurrentIndex(currentButton->offCommand->index);
|
offEvent.setCurrentIndex(offEvent.findData(currentButton->offCommand->index));
|
||||||
offEvent.show();
|
offEvent.show();
|
||||||
offEvent.blockSignals(false);
|
offEvent.blockSignals(false);
|
||||||
|
knobEvent.hide();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
for (KNOB& k : *knobs)
|
||||||
|
{
|
||||||
|
if (k.dev == currentDevice && k.pos.contains(p))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
currentKnob = &k;
|
||||||
|
qDebug() << "Knob" << currentKnob->num << "Event" << currentKnob->command->text;
|
||||||
|
if (knobEventProxy == Q_NULLPTR) {
|
||||||
|
knobEventProxy = scene->addWidget(&knobEvent);
|
||||||
|
}
|
||||||
|
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) {
|
if (!found) {
|
||||||
onEvent.hide();
|
onEvent.hide();
|
||||||
offEvent.hide();
|
offEvent.hide();
|
||||||
|
knobEvent.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void controllerSetup::onEventIndexChanged(int index) {
|
void controllerSetup::onEventIndexChanged(int index) {
|
||||||
qDebug() << "On Event for button" << currentButton->num << "Event" << index;
|
Q_UNUSED(index);
|
||||||
if (currentButton != Q_NULLPTR && index < commands->size()) {
|
if (currentButton != Q_NULLPTR && onEvent.currentData().toInt() < commands->size()) {
|
||||||
currentButton->onCommand = &commands->at(index);
|
currentButton->onCommand = &commands->at(onEvent.currentData().toInt());
|
||||||
currentButton->onText->setPlainText(currentButton->onCommand->text);
|
currentButton->onText->setPlainText(currentButton->onCommand->text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void controllerSetup::offEventIndexChanged(int index) {
|
void controllerSetup::offEventIndexChanged(int index) {
|
||||||
qDebug() << "Off Event for button" << currentButton->num << "Event" << index;
|
Q_UNUSED(index);
|
||||||
if (currentButton != Q_NULLPTR && index < commands->size()) {
|
if (currentButton != Q_NULLPTR && offEvent.currentData().toInt() < commands->size()) {
|
||||||
currentButton->offCommand = &commands->at(index);
|
currentButton->offCommand = &commands->at(offEvent.currentData().toInt());
|
||||||
currentButton->offText->setPlainText(currentButton->offCommand->text);
|
currentButton->offText->setPlainText(currentButton->offCommand->text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void controllerSetup::knobEventIndexChanged(int index) {
|
||||||
|
Q_UNUSED(index);
|
||||||
|
if (currentKnob != Q_NULLPTR && knobEvent.currentData().toInt() < commands->size()) {
|
||||||
|
currentKnob->command = &commands->at(knobEvent.currentData().toInt());
|
||||||
|
currentKnob->text->setPlainText(currentKnob->command->text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
buttons = but;
|
buttons = but;
|
||||||
|
knobs = kb;
|
||||||
commands = cmd;
|
commands = cmd;
|
||||||
|
|
||||||
// Remove any existing button text:
|
// Remove any existing button text:
|
||||||
|
@ -107,10 +140,18 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
||||||
scene->removeItem(bgImage);
|
scene->removeItem(bgImage);
|
||||||
delete bgImage;
|
delete bgImage;
|
||||||
bgImage = Q_NULLPTR;
|
bgImage = Q_NULLPTR;
|
||||||
if (onEventProxy != Q_NULLPTR)
|
if (onEventProxy != Q_NULLPTR) {
|
||||||
scene->removeItem(onEventProxy);
|
scene->removeItem(onEventProxy);
|
||||||
if (offEventProxy != Q_NULLPTR)
|
onEventProxy = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
if (offEventProxy != Q_NULLPTR) {
|
||||||
scene->removeItem(offEventProxy);
|
scene->removeItem(offEventProxy);
|
||||||
|
offEventProxy = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
if (knobEventProxy != Q_NULLPTR) {
|
||||||
|
scene->removeItem(knobEventProxy);
|
||||||
|
knobEventProxy = Q_NULLPTR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QImage image;
|
QImage image;
|
||||||
|
|
||||||
|
@ -151,35 +192,46 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
||||||
|
|
||||||
onEvent.blockSignals(true);
|
onEvent.blockSignals(true);
|
||||||
offEvent.blockSignals(true);
|
offEvent.blockSignals(true);
|
||||||
|
knobEvent.blockSignals(true);
|
||||||
onEvent.clear();
|
onEvent.clear();
|
||||||
offEvent.clear();
|
offEvent.clear();
|
||||||
|
knobEvent.clear();
|
||||||
|
|
||||||
onEvent.setMaxVisibleItems(5);
|
onEvent.setMaxVisibleItems(5);
|
||||||
offEvent.setMaxVisibleItems(5);
|
offEvent.setMaxVisibleItems(5);
|
||||||
|
knobEvent.setMaxVisibleItems(5);
|
||||||
onEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
onEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
offEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
offEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
knobEvent.view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
onEvent.setStyleSheet("combobox-popup: 0;");
|
onEvent.setStyleSheet("combobox-popup: 0;");
|
||||||
offEvent.setStyleSheet("combobox-popup: 0;");
|
offEvent.setStyleSheet("combobox-popup: 0;");
|
||||||
|
knobEvent.setStyleSheet("combobox-popup: 0;");
|
||||||
|
|
||||||
for (COMMAND &c : *commands) {
|
for (COMMAND &c : *commands) {
|
||||||
onEvent.addItem(c.text);
|
if (c.cmdType == commandButton || c.text == "None") {
|
||||||
offEvent.addItem(c.text);
|
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);
|
onEvent.blockSignals(false);
|
||||||
offEvent.blockSignals(false);
|
offEvent.blockSignals(false);
|
||||||
|
knobEvent.blockSignals(false);
|
||||||
|
|
||||||
// Set button text
|
// Set button text
|
||||||
for (BUTTON& b : *buttons)
|
for (BUTTON& b : *buttons)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (b.dev == currentDevice) {
|
if (b.dev == currentDevice) {
|
||||||
//b.onCommand = &commands->at(0);
|
|
||||||
b.onText = new QGraphicsTextItem(b.onCommand->text);
|
b.onText = new QGraphicsTextItem(b.onCommand->text);
|
||||||
b.onText->setDefaultTextColor(b.textColour);
|
b.onText->setDefaultTextColor(b.textColour);
|
||||||
scene->addItem(b.onText);
|
scene->addItem(b.onText);
|
||||||
b.onText->setPos(b.pos.x(), b.pos.y());
|
b.onText->setPos(b.pos.x(), b.pos.y());
|
||||||
|
|
||||||
//b.offCommand = &commands->at(0);
|
|
||||||
b.offText = new QGraphicsTextItem(b.offCommand->text);
|
b.offText = new QGraphicsTextItem(b.offCommand->text);
|
||||||
b.offText->setDefaultTextColor(b.textColour);
|
b.offText->setDefaultTextColor(b.textColour);
|
||||||
scene->addItem(b.offText);
|
scene->addItem(b.offText);
|
||||||
|
@ -187,6 +239,18 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.x(), k.pos.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
|
ui->graphicsView->setSceneRect(scene->itemsBoundingRect());
|
||||||
ui->graphicsView->resize(ui->graphicsView->sizeHint());
|
ui->graphicsView->resize(ui->graphicsView->sizeHint());
|
||||||
//this->resize(this->sizeHint());
|
//this->resize(this->sizeHint());
|
||||||
|
|
|
@ -38,10 +38,11 @@ signals:
|
||||||
void sendSensitivity(int val);
|
void sendSensitivity(int val);
|
||||||
|
|
||||||
public slots:
|
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);
|
||||||
void mousePressed(QPoint p);
|
void mousePressed(QPoint p);
|
||||||
void onEventIndexChanged(int index);
|
void onEventIndexChanged(int index);
|
||||||
void offEventIndexChanged(int index);
|
void offEventIndexChanged(int index);
|
||||||
|
void knobEventIndexChanged(int index);
|
||||||
void receiveSensitivity(int val);
|
void receiveSensitivity(int val);
|
||||||
void on_sensitivitySlider_valueChanged(int val);
|
void on_sensitivitySlider_valueChanged(int val);
|
||||||
|
|
||||||
|
@ -55,12 +56,16 @@ private:
|
||||||
QLabel* imgLabel;
|
QLabel* imgLabel;
|
||||||
unsigned char currentDevice = 0;
|
unsigned char currentDevice = 0;
|
||||||
QVector<BUTTON>* buttons;
|
QVector<BUTTON>* buttons;
|
||||||
|
QVector<KNOB>* knobs;
|
||||||
QVector<COMMAND>* commands;
|
QVector<COMMAND>* commands;
|
||||||
BUTTON* currentButton=Q_NULLPTR;
|
BUTTON* currentButton = Q_NULLPTR;
|
||||||
|
KNOB* currentKnob = Q_NULLPTR;
|
||||||
QComboBox onEvent;
|
QComboBox onEvent;
|
||||||
QComboBox offEvent;
|
QComboBox offEvent;
|
||||||
QGraphicsProxyWidget* onEventProxy=Q_NULLPTR;
|
QComboBox knobEvent;
|
||||||
QGraphicsProxyWidget* offEventProxy=Q_NULLPTR;
|
QGraphicsProxyWidget* onEventProxy = Q_NULLPTR;
|
||||||
|
QGraphicsProxyWidget* offEventProxy = Q_NULLPTR;
|
||||||
|
QGraphicsProxyWidget* knobEventProxy = Q_NULLPTR;
|
||||||
QString deviceName;
|
QString deviceName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,6 +96,11 @@ void usbController::receiveButtons(QVector<BUTTON>* buts)
|
||||||
buttonList = buts;
|
buttonList = buts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usbController::receiveKnobs(QVector<KNOB>* kbs)
|
||||||
|
{
|
||||||
|
qDebug(logUsbControl()) << "Receiving knobs";
|
||||||
|
knobList = kbs;
|
||||||
|
}
|
||||||
|
|
||||||
void usbController::run()
|
void usbController::run()
|
||||||
{
|
{
|
||||||
|
@ -201,7 +206,7 @@ void usbController::run()
|
||||||
qInfo(logUsbControl()) << "Button Guide" << pressed;
|
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); // Let the UI know we have a new controller
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,6 +245,19 @@ void usbController::run()
|
||||||
this->handle = hid_open_path(this->path.toLocal8Bit());
|
this->handle = hid_open_path(this->path.toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ADDED FOR DEBUGGING ONLY MUST BE REMOVED!*/
|
||||||
|
//this->manufacturer = "EESDR";
|
||||||
|
//this->product = "ecoderplus";
|
||||||
|
//this->serial = "1";
|
||||||
|
//usbDevice = eCoderPlus;
|
||||||
|
// Let the UI know we have a new controller
|
||||||
|
//emit newDevice(usbDevice, buttonList, knobList, commands);
|
||||||
|
// Run the periodic timer to get data
|
||||||
|
//QTimer::singleShot(25, this, SLOT(runTimer()));
|
||||||
|
//return;
|
||||||
|
/********************************************/
|
||||||
|
|
||||||
if (this->handle)
|
if (this->handle)
|
||||||
{
|
{
|
||||||
qInfo(logUsbControl()) << QString("Connected to device: %0 from %1 S/N %2").arg(this->product).arg(this->manufacturer).arg(this->serial);
|
qInfo(logUsbControl()) << QString("Connected to device: %0 from %1 S/N %2").arg(this->product).arg(this->manufacturer).arg(this->serial);
|
||||||
|
@ -255,7 +273,7 @@ void usbController::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the UI know we have a new controller
|
// Let the UI know we have a new controller
|
||||||
emit newDevice(usbDevice, buttonList, commands);
|
emit newDevice(usbDevice, buttonList, knobList, commands);
|
||||||
// Run the periodic timer to get data
|
// Run the periodic timer to get data
|
||||||
QTimer::singleShot(25, this, SLOT(runTimer()));
|
QTimer::singleShot(25, this, SLOT(runTimer()));
|
||||||
}
|
}
|
||||||
|
@ -278,6 +296,11 @@ void usbController::run()
|
||||||
void usbController::runTimer()
|
void usbController::runTimer()
|
||||||
{
|
{
|
||||||
int res=1;
|
int res=1;
|
||||||
|
if (!this->handle) {
|
||||||
|
// Something bad happened!
|
||||||
|
QTimer::singleShot(25, this, SLOT(runTimer()));
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (res > 0) {
|
while (res > 0) {
|
||||||
QByteArray data(HIDDATALENGTH, 0x0);
|
QByteArray data(HIDDATALENGTH, 0x0);
|
||||||
|
@ -285,7 +308,7 @@ void usbController::runTimer()
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
qInfo(logUsbControl()) << "USB Device disconnected" << this->product;
|
qInfo(logUsbControl()) << "USB Device disconnected" << this->product;
|
||||||
emit newDevice(0, buttonList, commands);
|
emit newDevice(0, buttonList, knobList, commands);
|
||||||
this->product = "";
|
this->product = "";
|
||||||
this->manufacturer = "";
|
this->manufacturer = "";
|
||||||
this->serial = "<none>";
|
this->serial = "<none>";
|
||||||
|
@ -361,6 +384,8 @@ void usbController::runTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buttons = tempButtons;
|
buttons = tempButtons;
|
||||||
jogpos = tempJogpos;
|
jogpos = tempJogpos;
|
||||||
shutpos = tempShutpos;
|
shutpos = tempShutpos;
|
||||||
|
@ -475,7 +500,7 @@ void usbController::runTimer()
|
||||||
lastData = data;
|
lastData = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (usbDevice == eCoderPlus && data.length() >= 0x0f && (quint8)data[0] == 0xff) {
|
else if (usbDevice == eCoderPlus && data.length() > 0x0f && (quint8)data[0] == 0xff) {
|
||||||
/* Button matrix:
|
/* Button matrix:
|
||||||
DATA3 DATA2 DATA 1
|
DATA3 DATA2 DATA 1
|
||||||
765432107654321076543210
|
765432107654321076543210
|
||||||
|
@ -501,6 +526,7 @@ void usbController::runTimer()
|
||||||
000000000000000000000010 = button1
|
000000000000000000000010 = button1
|
||||||
*/
|
*/
|
||||||
quint32 tempButtons = ((quint8)data[3] << 16) | ((quint8)data[2] << 8) | ((quint8)data[1] & 0xff);
|
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)
|
if (buttons != tempButtons)
|
||||||
{
|
{
|
||||||
|
@ -512,12 +538,14 @@ void usbController::runTimer()
|
||||||
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
if ((tempButtons >> i & 1) && !(buttons >> i & 1) && but->onCommand->index > 0)
|
||||||
{
|
{
|
||||||
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
qDebug(logUsbControl()) << "On Button event:" << but->onCommand->text;
|
||||||
emit button(but->onCommand);
|
COMMAND cmd = *but->onCommand;
|
||||||
|
emit button(&cmd);
|
||||||
}
|
}
|
||||||
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
else if ((buttons >> i & 1) && !(tempButtons >> i & 1) && but->offCommand->index > 0)
|
||||||
{
|
{
|
||||||
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
qDebug(logUsbControl()) << "Off Button event:" << but->offCommand->text;
|
||||||
emit button(but->offCommand);
|
COMMAND cmd = *but->offCommand;
|
||||||
|
emit button(&cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -525,7 +553,26 @@ void usbController::runTimer()
|
||||||
}
|
}
|
||||||
buttons = tempButtons;
|
buttons = tempButtons;
|
||||||
|
|
||||||
// Will this work for the tuning knob?
|
if (knobs != tempKnobs) {
|
||||||
|
// One of the knobs has moved
|
||||||
|
for (unsigned char i = 0; i < 3; i = i++) {
|
||||||
|
for (KNOB* kb = knobList->begin(); kb != knobList->end(); kb++) {
|
||||||
|
if (kb->dev == usbDevice && kb->num == i+1) {
|
||||||
|
if ((tempKnobs >> (i*8) & 0xff) != (knobs >> (i*8) & 0xff) && kb->command->index > 0)
|
||||||
|
{
|
||||||
|
COMMAND cmd = *kb->command;
|
||||||
|
cmd.suffix = (unsigned char)(knobs >> (i * 8) & 0xff);
|
||||||
|
qDebug(logUsbControl()) << "Knob event:" << cmd.command << "Value:" << cmd.suffix;
|
||||||
|
emit button(&cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
knobs = tempKnobs;
|
||||||
|
|
||||||
|
// Tuning knob
|
||||||
jogCounter = jogCounter + (qint8)data[13];
|
jogCounter = jogCounter + (qint8)data[13];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,12 @@ using namespace std;
|
||||||
struct COMMAND {
|
struct COMMAND {
|
||||||
COMMAND() {}
|
COMMAND() {}
|
||||||
|
|
||||||
COMMAND(int index, QString text, int command, char suffix) :
|
COMMAND(int index, QString text, usbCommandType cmdType, int command, unsigned char suffix) :
|
||||||
index(index), text(text), command(command), suffix(suffix) {}
|
index(index), text(text), cmdType(cmdType), command(command), suffix(suffix) {}
|
||||||
COMMAND(int index, QString text, int command, availableBands band) :
|
COMMAND(int index, QString text, usbCommandType cmdType, int command, availableBands band) :
|
||||||
index(index), text(text), command(command), band(band) {}
|
index(index), text(text), cmdType(cmdType), command(command), band(band) {}
|
||||||
COMMAND(int index, QString text, int command, mode_kind mode) :
|
COMMAND(int index, QString text, usbCommandType cmdType, int command, mode_kind mode) :
|
||||||
index(index), text(text), command(command), mode(mode) {}
|
index(index), text(text), cmdType(cmdType), command(command), mode(mode) {}
|
||||||
|
|
||||||
int index=0;
|
int index=0;
|
||||||
QString text;
|
QString text;
|
||||||
|
@ -69,30 +69,46 @@ struct COMMAND {
|
||||||
unsigned char suffix=0x0;
|
unsigned char suffix=0x0;
|
||||||
availableBands band=bandGen;
|
availableBands band=bandGen;
|
||||||
mode_kind mode=modeLSB;
|
mode_kind mode=modeLSB;
|
||||||
|
usbCommandType cmdType = commandButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BUTTON {
|
struct BUTTON {
|
||||||
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) {}
|
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) {}
|
dev(dev), num(-1), name(name), pos(pos), textColour(textColour), onCommand(on), offCommand(off) {}
|
||||||
|
|
||||||
quint8 dev;
|
usbDeviceType dev;
|
||||||
int num;
|
int num;
|
||||||
QString name;
|
QString name;
|
||||||
QRect pos;
|
QRect pos;
|
||||||
QColor textColour;
|
QColor textColour;
|
||||||
int onEvent = 0;
|
const COMMAND* onCommand = Q_NULLPTR;
|
||||||
int offEvent = 0;
|
const COMMAND* offCommand = Q_NULLPTR;
|
||||||
const COMMAND* onCommand=Q_NULLPTR;
|
|
||||||
const COMMAND* offCommand=Q_NULLPTR;
|
|
||||||
QGraphicsTextItem* onText;
|
QGraphicsTextItem* onText;
|
||||||
QGraphicsTextItem* offText;
|
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)
|
#if defined(USB_CONTROLLER)
|
||||||
class usbController : public QObject
|
class usbController : public QObject
|
||||||
{
|
{
|
||||||
|
@ -109,6 +125,7 @@ public slots:
|
||||||
void ledControl(bool on, unsigned char num);
|
void ledControl(bool on, unsigned char num);
|
||||||
void receiveCommands(QVector<COMMAND>*);
|
void receiveCommands(QVector<COMMAND>*);
|
||||||
void receiveButtons(QVector<BUTTON>*);
|
void receiveButtons(QVector<BUTTON>*);
|
||||||
|
void receiveKnobs(QVector<KNOB>*);
|
||||||
void getVersion();
|
void getVersion();
|
||||||
void receiveSensitivity(int val);
|
void receiveSensitivity(int val);
|
||||||
|
|
||||||
|
@ -119,14 +136,15 @@ signals:
|
||||||
void doShuttle(bool plus, quint8 level);
|
void doShuttle(bool plus, quint8 level);
|
||||||
void setBand(int band);
|
void setBand(int band);
|
||||||
void button(const COMMAND* cmd);
|
void button(const COMMAND* cmd);
|
||||||
void newDevice(unsigned char devType, QVector<BUTTON>* but,QVector<COMMAND>* cmd);
|
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<KNOB>* kb, QVector<COMMAND>* cmd);
|
||||||
void sendSensitivity(int val);
|
void sendSensitivity(int val);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hid_device* handle=NULL;
|
hid_device* handle=NULL;
|
||||||
int hidStatus = 1;
|
int hidStatus = 1;
|
||||||
bool isOpen=false;
|
bool isOpen=false;
|
||||||
quint32 buttons=0;
|
quint32 buttons = 0;
|
||||||
|
quint32 knobs = 0;
|
||||||
unsigned char jogpos=0;
|
unsigned char jogpos=0;
|
||||||
unsigned char shutpos=0;
|
unsigned char shutpos=0;
|
||||||
unsigned char shutMult = 0;
|
unsigned char shutMult = 0;
|
||||||
|
@ -135,6 +153,7 @@ private:
|
||||||
QByteArray lastData = QByteArray(8,0x0);
|
QByteArray lastData = QByteArray(8,0x0);
|
||||||
unsigned char lastDialPos=0;
|
unsigned char lastDialPos=0;
|
||||||
QVector<BUTTON>* buttonList;
|
QVector<BUTTON>* buttonList;
|
||||||
|
QVector<KNOB>* knobList;
|
||||||
QVector<COMMAND>* commands = Q_NULLPTR;
|
QVector<COMMAND>* commands = Q_NULLPTR;
|
||||||
QString product="";
|
QString product="";
|
||||||
QString manufacturer="";
|
QString manufacturer="";
|
||||||
|
@ -151,8 +170,9 @@ private:
|
||||||
unsigned short knownUsbDevices[4][3] = {
|
unsigned short knownUsbDevices[4][3] = {
|
||||||
{shuttleXpress,0x0b33,0x0020},
|
{shuttleXpress,0x0b33,0x0020},
|
||||||
{shuttlePro2,0x0b33,0x0030},
|
{shuttlePro2,0x0b33,0x0030},
|
||||||
{RC28,0x0c26,0x001e},
|
{eCoderPlus,0x0c26,0x001e},
|
||||||
{eCoderPlus, 0x1fc9, 0x0003}
|
//{RC28,0x0c26,0x001e},
|
||||||
|
//{eCoderPlus, 0x1fc9, 0x0003}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
196
wfmain.cpp
196
wfmain.cpp
|
@ -74,6 +74,7 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode
|
||||||
qRegisterMetaType<rigstate*>();
|
qRegisterMetaType<rigstate*>();
|
||||||
qRegisterMetaType<QList<radio_cap_packet>>();
|
qRegisterMetaType<QList<radio_cap_packet>>();
|
||||||
qRegisterMetaType<QVector<BUTTON>*>();
|
qRegisterMetaType<QVector<BUTTON>*>();
|
||||||
|
qRegisterMetaType<QVector<KNOB>*>();
|
||||||
qRegisterMetaType<QVector<COMMAND>*>();
|
qRegisterMetaType<QVector<COMMAND>*>();
|
||||||
qRegisterMetaType<const COMMAND*>();
|
qRegisterMetaType<const COMMAND*>();
|
||||||
qRegisterMetaType<QList<radio_cap_packet>>();
|
qRegisterMetaType<QList<radio_cap_packet>>();
|
||||||
|
@ -1670,11 +1671,12 @@ void wfmain::setupUsbControllerDevice()
|
||||||
connect(usbControllerDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char)));
|
connect(usbControllerDev, SIGNAL(doShuttle(bool, unsigned char)), this, SLOT(doShuttle(bool, unsigned char)));
|
||||||
connect(usbControllerDev, SIGNAL(button(const COMMAND*)), this, SLOT(buttonControl(const COMMAND*)));
|
connect(usbControllerDev, SIGNAL(button(const COMMAND*)), this, SLOT(buttonControl(const COMMAND*)));
|
||||||
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
|
connect(usbControllerDev, SIGNAL(setBand(int)), this, SLOT(setBand(int)));
|
||||||
connect(usbControllerDev, SIGNAL(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>*)), shut, SLOT(newDevice(unsigned char, QVector<BUTTON>*, QVector<KNOB>*, QVector<COMMAND>*)));
|
||||||
usbControllerThread->start(QThread::LowestPriority);
|
usbControllerThread->start(QThread::LowestPriority);
|
||||||
|
|
||||||
connect(this, SIGNAL(sendUsbControllerCommands(QVector<COMMAND>*)), usbControllerDev, SLOT(receiveCommands(QVector<COMMAND>*)));
|
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(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)), usbControllerDev, SLOT(receiveSensitivity(int)));
|
||||||
connect(shut, SIGNAL(sendSensitivity(int)), this, SLOT(receiveUsbSensitivity(int)));
|
connect(shut, SIGNAL(sendSensitivity(int)), this, SLOT(receiveUsbSensitivity(int)));
|
||||||
connect(usbControllerDev, SIGNAL(sendSensitivity(int)), shut, SLOT(receiveSensitivity(int)));
|
connect(usbControllerDev, SIGNAL(sendSensitivity(int)), shut, SLOT(receiveSensitivity(int)));
|
||||||
|
@ -2445,6 +2447,7 @@ void wfmain::loadSettings()
|
||||||
emit initUsbController(prefs.usbSensitivity);
|
emit initUsbController(prefs.usbSensitivity);
|
||||||
emit sendUsbControllerCommands(&usbCommands);
|
emit sendUsbControllerCommands(&usbCommands);
|
||||||
emit sendUsbControllerButtons(&usbButtons);
|
emit sendUsbControllerButtons(&usbButtons);
|
||||||
|
emit sendUsbControllerKnobs(&usbKnobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int numCommands = settings->beginReadArray("Commands");
|
int numCommands = settings->beginReadArray("Commands");
|
||||||
|
@ -2465,6 +2468,7 @@ void wfmain::loadSettings()
|
||||||
comm.band = (availableBands)settings->value("Band", 0).toInt();
|
comm.band = (availableBands)settings->value("Band", 0).toInt();
|
||||||
comm.mode = (mode_kind)settings->value("Mode", 0).toInt();
|
comm.mode = (mode_kind)settings->value("Mode", 0).toInt();
|
||||||
comm.suffix = (unsigned char)settings->value("Suffix", 0).toInt();
|
comm.suffix = (unsigned char)settings->value("Suffix", 0).toInt();
|
||||||
|
comm.cmdType = (usbCommandType)settings->value("CommandType", 0).toInt();
|
||||||
usbCommands.append(comm);
|
usbCommands.append(comm);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
|
@ -2483,7 +2487,7 @@ void wfmain::loadSettings()
|
||||||
{
|
{
|
||||||
settings->setArrayIndex(nb);
|
settings->setArrayIndex(nb);
|
||||||
BUTTON butt;
|
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.num = settings->value("Num", 0).toInt();
|
||||||
butt.name = settings->value("Name", "").toString();
|
butt.name = settings->value("Name", "").toString();
|
||||||
butt.pos = QRect(settings->value("Left", 0).toInt(),
|
butt.pos = QRect(settings->value("Left", 0).toInt(),
|
||||||
|
@ -2511,6 +2515,45 @@ void wfmain::loadSettings()
|
||||||
settings->endArray();
|
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();
|
settings->endGroup();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2931,6 +2974,23 @@ void wfmain::saveSettings()
|
||||||
|
|
||||||
settings->endArray();
|
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");
|
settings->beginWriteArray("Commands");
|
||||||
for (int nc = 0; nc < usbCommands.count(); nc++)
|
for (int nc = 0; nc < usbCommands.count(); nc++)
|
||||||
{
|
{
|
||||||
|
@ -2942,6 +3002,7 @@ void wfmain::saveSettings()
|
||||||
settings->setValue("Band", usbCommands[nc].band);
|
settings->setValue("Band", usbCommands[nc].band);
|
||||||
settings->setValue("Mode", usbCommands[nc].mode);
|
settings->setValue("Mode", usbCommands[nc].mode);
|
||||||
settings->setValue("Suffix", usbCommands[nc].suffix);
|
settings->setValue("Suffix", usbCommands[nc].suffix);
|
||||||
|
settings->setValue("CommandType", usbCommands[nc].cmdType);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
|
@ -9059,6 +9120,7 @@ void wfmain::on_enableUsbChk_clicked(bool checked)
|
||||||
emit initUsbController(prefs.usbSensitivity);
|
emit initUsbController(prefs.usbSensitivity);
|
||||||
emit sendUsbControllerCommands(&usbCommands);
|
emit sendUsbControllerCommands(&usbCommands);
|
||||||
emit sendUsbControllerButtons(&usbButtons);
|
emit sendUsbControllerButtons(&usbButtons);
|
||||||
|
emit sendUsbControllerKnobs(&usbKnobs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -9086,6 +9148,7 @@ void wfmain::on_usbButtonsResetBtn_clicked()
|
||||||
if (ret == QMessageBox::Ok) {
|
if (ret == QMessageBox::Ok) {
|
||||||
qInfo(logUsbControl()) << "Resetting USB buttons to default values";
|
qInfo(logUsbControl()) << "Resetting USB buttons to default values";
|
||||||
resetUsbButtons();
|
resetUsbButtons();
|
||||||
|
resetUsbKnobs();
|
||||||
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
on_enableUsbChk_clicked(true); // Force disconnect/reconnect of USB controller.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9257,9 +9320,9 @@ void wfmain::resetUsbButtons()
|
||||||
usbButtons.append(BUTTON(eCoderPlus, 12, QRect(410, 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, 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, 14, QRect(410, 512, 55, 55), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||||
usbButtons.append(BUTTON(eCoderPlus, 16, QRect(121, 102, 68, 73), 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(242, 102, 68, 73), 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(362, 102, 68, 73), 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, 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, 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]));
|
usbButtons.append(BUTTON(eCoderPlus, 21, QRect(404, 2, 55, 30), Qt::red, &usbCommands[0], &usbCommands[0]));
|
||||||
|
@ -9269,65 +9332,80 @@ void wfmain::resetUsbButtons()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wfmain::resetUsbKnobs()
|
||||||
|
{
|
||||||
|
#ifdef USB_CONTROLLER
|
||||||
|
usbKnobs.clear();
|
||||||
|
// eCoder
|
||||||
|
usbKnobs.append(KNOB(eCoderPlus, 1, QRect(120, 153, 72, 27), Qt::red, &usbCommands[0]));
|
||||||
|
usbKnobs.append(KNOB(eCoderPlus, 2, QRect(242, 153, 72, 27), Qt::red, &usbCommands[0]));
|
||||||
|
usbKnobs.append(KNOB(eCoderPlus, 3, QRect(362, 153, 72, 27), Qt::red, &usbCommands[0]));
|
||||||
|
emit sendUsbControllerKnobs(&usbKnobs);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void wfmain::resetUsbCommands()
|
void wfmain::resetUsbCommands()
|
||||||
{
|
{
|
||||||
#ifdef USB_CONTROLLER
|
#ifdef USB_CONTROLLER
|
||||||
usbCommands.clear();
|
usbCommands.clear();
|
||||||
int num = 0;
|
int num = 0;
|
||||||
usbCommands.append(COMMAND(num++, "None", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "None", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "PTT On", cmdSetPTT, 0x1));
|
usbCommands.append(COMMAND(num++, "PTT On", commandButton, cmdSetPTT, 0x1));
|
||||||
usbCommands.append(COMMAND(num++, "PTT Off", cmdSetPTT, 0x0));
|
usbCommands.append(COMMAND(num++, "PTT Off", commandButton, cmdSetPTT, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "PTT Toggle", cmdPTTToggle, 0x0));
|
usbCommands.append(COMMAND(num++, "PTT Toggle", commandButton, cmdPTTToggle, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Tune", cmdStartATU, 0x0));
|
usbCommands.append(COMMAND(num++, "Tune", commandButton, cmdStartATU, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Step+", cmdSetStepUp, 0x0));
|
usbCommands.append(COMMAND(num++, "Step+", commandButton, cmdSetStepUp, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Step-", cmdSetStepDown, 0x0));
|
usbCommands.append(COMMAND(num++, "Step-", commandButton, cmdSetStepDown, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Span+", cmdSetSpanUp, 0x0));
|
usbCommands.append(COMMAND(num++, "Span+", commandButton, cmdSetSpanUp, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Span-", cmdSetSpanDown, 0x0));
|
usbCommands.append(COMMAND(num++, "Span-", commandButton, cmdSetSpanDown, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Mode+", cmdSetModeUp, 0x0));
|
usbCommands.append(COMMAND(num++, "Mode+", commandButton, cmdSetModeUp, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Mode-", cmdSetModeDown, 0x0));
|
usbCommands.append(COMMAND(num++, "Mode-", commandButton, cmdSetModeDown, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Mode LSB", cmdSetMode, modeLSB));
|
usbCommands.append(COMMAND(num++, "Mode LSB", commandButton, cmdSetMode, modeLSB));
|
||||||
usbCommands.append(COMMAND(num++, "Mode USB", cmdSetMode, modeUSB));
|
usbCommands.append(COMMAND(num++, "Mode USB", commandButton, cmdSetMode, modeUSB));
|
||||||
usbCommands.append(COMMAND(num++, "Mode LSBD", cmdSetMode, modeLSB_D));
|
usbCommands.append(COMMAND(num++, "Mode LSBD", commandButton, cmdSetMode, modeLSB_D));
|
||||||
usbCommands.append(COMMAND(num++, "Mode USBD", cmdSetMode, modeUSB_D));
|
usbCommands.append(COMMAND(num++, "Mode USBD", commandButton, cmdSetMode, modeUSB_D));
|
||||||
usbCommands.append(COMMAND(num++, "Mode CW", cmdSetMode, modeCW));
|
usbCommands.append(COMMAND(num++, "Mode CW", commandButton, cmdSetMode, modeCW));
|
||||||
usbCommands.append(COMMAND(num++, "Mode CWR", cmdSetMode, modeCW_R));
|
usbCommands.append(COMMAND(num++, "Mode CWR", commandButton, cmdSetMode, modeCW_R));
|
||||||
usbCommands.append(COMMAND(num++, "Mode FM", cmdSetMode, modeFM));
|
usbCommands.append(COMMAND(num++, "Mode FM", commandButton, cmdSetMode, modeFM));
|
||||||
usbCommands.append(COMMAND(num++, "Mode AM", cmdSetMode, modeAM));
|
usbCommands.append(COMMAND(num++, "Mode AM", commandButton, cmdSetMode, modeAM));
|
||||||
usbCommands.append(COMMAND(num++, "Mode RTTY", cmdSetMode, modeRTTY));
|
usbCommands.append(COMMAND(num++, "Mode RTTY", commandButton, cmdSetMode, modeRTTY));
|
||||||
usbCommands.append(COMMAND(num++, "Mode RTTYR", cmdSetMode, modeRTTY_R));
|
usbCommands.append(COMMAND(num++, "Mode RTTYR", commandButton, cmdSetMode, modeRTTY_R));
|
||||||
usbCommands.append(COMMAND(num++, "Mode PSK", cmdSetMode, modePSK));
|
usbCommands.append(COMMAND(num++, "Mode PSK", commandButton, cmdSetMode, modePSK));
|
||||||
usbCommands.append(COMMAND(num++, "Mode PSKR", cmdSetMode, modePSK_R));
|
usbCommands.append(COMMAND(num++, "Mode PSKR", commandButton, cmdSetMode, modePSK_R));
|
||||||
usbCommands.append(COMMAND(num++, "Mode DV", cmdSetMode, modeDV));
|
usbCommands.append(COMMAND(num++, "Mode DV", commandButton, cmdSetMode, modeDV));
|
||||||
usbCommands.append(COMMAND(num++, "Mode DD", cmdSetMode, modeDD));
|
usbCommands.append(COMMAND(num++, "Mode DD", commandButton, cmdSetMode, modeDD));
|
||||||
usbCommands.append(COMMAND(num++, "Band+", cmdSetBandUp, 0x0));
|
usbCommands.append(COMMAND(num++, "Band+", commandButton, cmdSetBandUp, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Band-", cmdSetBandDown, 0x0));
|
usbCommands.append(COMMAND(num++, "Band-", commandButton, cmdSetBandDown, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "23cm", cmdGetBandStackReg, band23cm));
|
usbCommands.append(COMMAND(num++, "23cm", commandButton, cmdGetBandStackReg, band23cm));
|
||||||
usbCommands.append(COMMAND(num++, "70cm", cmdGetBandStackReg, band70cm));
|
usbCommands.append(COMMAND(num++, "70cm", commandButton, cmdGetBandStackReg, band70cm));
|
||||||
usbCommands.append(COMMAND(num++, "2m", cmdGetBandStackReg, band2m));
|
usbCommands.append(COMMAND(num++, "2m", commandButton, cmdGetBandStackReg, band2m));
|
||||||
usbCommands.append(COMMAND(num++, "AIR", cmdGetBandStackReg, bandAir));
|
usbCommands.append(COMMAND(num++, "AIR", commandButton, cmdGetBandStackReg, bandAir));
|
||||||
usbCommands.append(COMMAND(num++, "WFM", cmdGetBandStackReg, bandWFM));
|
usbCommands.append(COMMAND(num++, "WFM", commandButton, cmdGetBandStackReg, bandWFM));
|
||||||
usbCommands.append(COMMAND(num++, "4m", cmdGetBandStackReg, band4m));
|
usbCommands.append(COMMAND(num++, "4m", commandButton, cmdGetBandStackReg, band4m));
|
||||||
usbCommands.append(COMMAND(num++, "6m", cmdGetBandStackReg, band6m));
|
usbCommands.append(COMMAND(num++, "6m", commandButton, cmdGetBandStackReg, band6m));
|
||||||
usbCommands.append(COMMAND(num++, "10m", cmdGetBandStackReg, band10m));
|
usbCommands.append(COMMAND(num++, "10m", commandButton, cmdGetBandStackReg, band10m));
|
||||||
usbCommands.append(COMMAND(num++, "12m", cmdGetBandStackReg, band12m));
|
usbCommands.append(COMMAND(num++, "12m", commandButton, cmdGetBandStackReg, band12m));
|
||||||
usbCommands.append(COMMAND(num++, "15m", cmdGetBandStackReg, band15m));
|
usbCommands.append(COMMAND(num++, "15m", commandButton, cmdGetBandStackReg, band15m));
|
||||||
usbCommands.append(COMMAND(num++, "17m", cmdGetBandStackReg, band17m));
|
usbCommands.append(COMMAND(num++, "17m", commandButton, cmdGetBandStackReg, band17m));
|
||||||
usbCommands.append(COMMAND(num++, "20m", cmdGetBandStackReg, band20m));
|
usbCommands.append(COMMAND(num++, "20m", commandButton, cmdGetBandStackReg, band20m));
|
||||||
usbCommands.append(COMMAND(num++, "30m", cmdGetBandStackReg, band30m));
|
usbCommands.append(COMMAND(num++, "30m", commandButton, cmdGetBandStackReg, band30m));
|
||||||
usbCommands.append(COMMAND(num++, "40m", cmdGetBandStackReg, band40m));
|
usbCommands.append(COMMAND(num++, "40m", commandButton, cmdGetBandStackReg, band40m));
|
||||||
usbCommands.append(COMMAND(num++, "60m", cmdGetBandStackReg, band60m));
|
usbCommands.append(COMMAND(num++, "60m", commandButton, cmdGetBandStackReg, band60m));
|
||||||
usbCommands.append(COMMAND(num++, "80m", cmdGetBandStackReg, band80m));
|
usbCommands.append(COMMAND(num++, "80m", commandButton, cmdGetBandStackReg, band80m));
|
||||||
usbCommands.append(COMMAND(num++, "160m", cmdGetBandStackReg, band160m));
|
usbCommands.append(COMMAND(num++, "160m", commandButton, cmdGetBandStackReg, band160m));
|
||||||
usbCommands.append(COMMAND(num++, "630m", cmdGetBandStackReg, band630m));
|
usbCommands.append(COMMAND(num++, "630m", commandButton, cmdGetBandStackReg, band630m));
|
||||||
usbCommands.append(COMMAND(num++, "2200m", cmdGetBandStackReg, band2200m));
|
usbCommands.append(COMMAND(num++, "2200m", commandButton, cmdGetBandStackReg, band2200m));
|
||||||
usbCommands.append(COMMAND(num++, "GEN", cmdGetBandStackReg, bandGen));
|
usbCommands.append(COMMAND(num++, "GEN", commandButton, cmdGetBandStackReg, bandGen));
|
||||||
usbCommands.append(COMMAND(num++, "NR On", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "NR On", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "NR Off", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "NR Off", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "NB On", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "NB On", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "NB Off", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "NB Off", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Split On", cmdNone, 0x01));
|
usbCommands.append(COMMAND(num++, "Split On", commandButton, cmdNone, 0x01));
|
||||||
usbCommands.append(COMMAND(num++, "Split Off", cmdNone, 0x0));
|
usbCommands.append(COMMAND(num++, "Split Off", commandButton, cmdNone, 0x0));
|
||||||
usbCommands.append(COMMAND(num++, "Swap VFOs", cmdVFOSwap, 0x0));
|
usbCommands.append(COMMAND(num++, "Swap VFOs", commandButton, cmdVFOSwap, 0x0));
|
||||||
|
usbCommands.append(COMMAND(num++, "AF Gain", commandKnob, cmdSetAfGain, 0xff));
|
||||||
|
usbCommands.append(COMMAND(num++, "RF Gain", commandKnob, cmdSetRxRfGain, 0xff));
|
||||||
emit sendUsbControllerCommands(&usbCommands);
|
emit sendUsbControllerCommands(&usbCommands);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
5
wfmain.h
5
wfmain.h
|
@ -226,6 +226,7 @@ signals:
|
||||||
void initUsbController(int sens);
|
void initUsbController(int sens);
|
||||||
void sendUsbControllerCommands(QVector<COMMAND>* cmds);
|
void sendUsbControllerCommands(QVector<COMMAND>* cmds);
|
||||||
void sendUsbControllerButtons(QVector<BUTTON>* buts);
|
void sendUsbControllerButtons(QVector<BUTTON>* buts);
|
||||||
|
void sendUsbControllerKnobs(QVector<KNOB>* kbs);
|
||||||
void setClusterUdpPort(int port);
|
void setClusterUdpPort(int port);
|
||||||
void setClusterEnableUdp(bool udp);
|
void setClusterEnableUdp(bool udp);
|
||||||
void setClusterEnableTcp(bool tcp);
|
void setClusterEnableTcp(bool tcp);
|
||||||
|
@ -1068,6 +1069,7 @@ private:
|
||||||
void updateUsbButtons();
|
void updateUsbButtons();
|
||||||
|
|
||||||
void resetUsbButtons();
|
void resetUsbButtons();
|
||||||
|
void resetUsbKnobs();
|
||||||
void resetUsbCommands();
|
void resetUsbCommands();
|
||||||
|
|
||||||
int oldFreqDialVal;
|
int oldFreqDialVal;
|
||||||
|
@ -1147,6 +1149,7 @@ private:
|
||||||
QString usbDeviceName;
|
QString usbDeviceName;
|
||||||
QVector<COMMAND> usbCommands;
|
QVector<COMMAND> usbCommands;
|
||||||
QVector<BUTTON> usbButtons;
|
QVector<BUTTON> usbButtons;
|
||||||
|
QVector<KNOB> usbKnobs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dxClusterClient* cluster = Q_NULLPTR;
|
dxClusterClient* cluster = Q_NULLPTR;
|
||||||
|
@ -1181,7 +1184,7 @@ Q_DECLARE_METATYPE(QList<radio_cap_packet>)
|
||||||
Q_DECLARE_METATYPE(QList<spotData>)
|
Q_DECLARE_METATYPE(QList<spotData>)
|
||||||
Q_DECLARE_METATYPE(rigstate*)
|
Q_DECLARE_METATYPE(rigstate*)
|
||||||
Q_DECLARE_METATYPE(QVector <BUTTON>*)
|
Q_DECLARE_METATYPE(QVector <BUTTON>*)
|
||||||
Q_DECLARE_METATYPE(struct BUTTON*)
|
Q_DECLARE_METATYPE(QVector <KNOB>*)
|
||||||
Q_DECLARE_METATYPE(QVector <COMMAND>*)
|
Q_DECLARE_METATYPE(QVector <COMMAND>*)
|
||||||
Q_DECLARE_METATYPE(const COMMAND*)
|
Q_DECLARE_METATYPE(const COMMAND*)
|
||||||
Q_DECLARE_METATYPE(codecType)
|
Q_DECLARE_METATYPE(codecType)
|
||||||
|
|
|
@ -195,5 +195,6 @@ enum codecType { LPCM, PCMU, OPUS };
|
||||||
enum passbandActions {passbandStatic, pbtInnerMove, pbtOuterMove, pbtMoving, passbandResizing};
|
enum passbandActions {passbandStatic, pbtInnerMove, pbtOuterMove, pbtMoving, passbandResizing};
|
||||||
|
|
||||||
enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2, RC28, xBoxGamepad, unknownGamepad, eCoderPlus};
|
enum usbDeviceType { usbNone = 0, shuttleXpress, shuttlePro2, RC28, xBoxGamepad, unknownGamepad, eCoderPlus};
|
||||||
|
enum usbCommandType{ commandButton, commandKnob };
|
||||||
|
|
||||||
#endif // WFVIEWTYPES_H
|
#endif // WFVIEWTYPES_H
|
||||||
|
|
Ładowanie…
Reference in New Issue