Add sensitivity control to USB controllers.

failbranch
Phil Taylor 2023-02-07 09:32:33 +00:00
rodzic b619be3e2a
commit 0e28f288ff
9 zmienionych plików z 98 dodań i 33 usunięć

Wyświetl plik

@ -187,5 +187,16 @@ void controllerSetup::newDevice(unsigned char devType, QVector<BUTTON>* but, QVe
ui->graphicsView->resize(ui->graphicsView->sizeHint());
//this->resize(this->sizeHint());
this->adjustSize();
}
void controllerSetup::receiveSensitivity(int val)
{
ui->sensitivitySlider->blockSignals(true);
ui->sensitivitySlider->setValue(val);
ui->sensitivitySlider->blockSignals(false);
}
void controllerSetup::on_sensitivitySlider_valueChanged(int val)
{
emit sendSensitivity(val);
}

Wyświetl plik

@ -35,13 +35,15 @@ public:
~controllerSetup();
signals:
void sendSensitivity(int val);
public slots:
void newDevice(unsigned char devType, QVector<BUTTON>* but, QVector<COMMAND>* cmd);
void mousePressed(QPoint p);
void onEventIndexChanged(int index);
void offEventIndexChanged(int index);
void receiveSensitivity(int val);
void on_sensitivitySlider_valueChanged(int val);
private:

Wyświetl plik

@ -14,31 +14,7 @@
<string>Controller setup</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</item>
<item row="1" 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="3" column="0">
<item row="4" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
@ -84,6 +60,57 @@
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Sensitivity</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="sensitivitySlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>21</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" 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>
<widget class="QGraphicsView" name="graphicsView"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>

Wyświetl plik

@ -46,6 +46,7 @@ struct preferences {
bool niceTS;
bool automaticSidebandSwitching = true;
bool enableUSBControllers;
int usbSensitivity;
// LAN:
bool enableLAN;

Wyświetl plik

@ -440,6 +440,7 @@ void servermain::setDefPrefs()
udpDefPrefs.username = QString("");
udpDefPrefs.password = QString("");
udpDefPrefs.clientName = QHostInfo::localHostName();
}
void servermain::loadSettings()

Wyświetl plik

@ -38,8 +38,11 @@ usbController::~usbController()
#endif
}
void usbController::init()
void usbController::init(int sens)
{
sensitivity = sens;
emit sendSensitivity(sensitivity);
if (HID_API_VERSION == HID_API_MAKE_VERSION(hid_version()->major, hid_version()->minor, hid_version()->patch)) {
qInfo(logUsbControl) << QString("Compile-time version matches runtime version of hidapi: %0.%1.%2")
.arg(hid_version()->major)
@ -503,7 +506,7 @@ void usbController::runTimer()
}
}
if (jogCounter != 0) {
emit sendJog(jogCounter);
emit sendJog(jogCounter/sensitivity);
qDebug(logUsbControl()) << "Change Frequency by" << jogCounter << "hz";
jogCounter = 0;
}
@ -591,4 +594,10 @@ void usbController::buttonState(QString name, double val)
}
*/
}
void usbController::receiveSensitivity(int val)
{
sensitivity = val;
}
#endif

Wyświetl plik

@ -103,13 +103,14 @@ public:
~usbController();
public slots:
void init();
void init(int sens);
void run();
void runTimer();
void ledControl(bool on, unsigned char num);
void receiveCommands(QVector<COMMAND>*);
void receiveButtons(QVector<BUTTON>*);
void getVersion();
void receiveSensitivity(int val);
signals:
void jogPlus();
@ -119,6 +120,7 @@ signals:
void setBand(int band);
void button(const COMMAND* cmd);
void newDevice(unsigned char devType, QVector<BUTTON>* but,QVector<COMMAND>* cmd);
void sendSensitivity(int val);
private:
hid_device* handle=NULL;
@ -138,6 +140,7 @@ private:
QString manufacturer="";
QString serial="<none>";
QString path = "";
int sensitivity = 1;
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
QGamepad* gamepad=Q_NULLPTR;
#endif

Wyświetl plik

@ -1675,8 +1675,10 @@ void wfmain::setupUsbControllerDevice()
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(initUsbController()), usbControllerDev, SLOT(init()));
emit initUsbController();
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)));
#endif
}
@ -1882,6 +1884,7 @@ void wfmain::setDefPrefs()
defPrefs.waterfallFormat = 0;
defPrefs.audioSystem = qtAudio;
defPrefs.enableUSBControllers = false;
defPrefs.usbSensitivity = 1;
udpDefPrefs.ipAddress = QString("");
udpDefPrefs.controlLANPort = 50001;
@ -2427,6 +2430,7 @@ void wfmain::loadSettings()
settings->beginGroup("USB");
/* Load USB buttons*/
prefs.enableUSBControllers = settings->value("EnableUSBControllers", defPrefs.enableUSBControllers).toBool();
prefs.usbSensitivity = settings->value("USBSensitivity", defPrefs.usbSensitivity).toInt();
ui->enableUsbChk->blockSignals(true);
ui->enableUsbChk->setChecked(prefs.enableUSBControllers);
ui->enableUsbChk->blockSignals(false);
@ -2438,6 +2442,7 @@ void wfmain::loadSettings()
if (prefs.enableUSBControllers) {
// Setup USB Controller
setupUsbControllerDevice();
emit initUsbController(prefs.usbSensitivity);
emit sendUsbControllerCommands(&usbCommands);
emit sendUsbControllerButtons(&usbButtons);
}
@ -2904,6 +2909,7 @@ void wfmain::saveSettings()
settings->beginGroup("USB");
// Store USB Controller
settings->setValue("EnableUSBControllers", prefs.enableUSBControllers);
settings->setValue("USBSensitivity", prefs.usbSensitivity);
settings->beginWriteArray("Buttons");
for (int nb = 0; nb < usbButtons.count(); nb++)
@ -9050,6 +9056,7 @@ void wfmain::on_enableUsbChk_clicked(bool checked)
if (checked) {
// Setup USB Controller
setupUsbControllerDevice();
emit initUsbController(prefs.usbSensitivity);
emit sendUsbControllerCommands(&usbCommands);
emit sendUsbControllerButtons(&usbButtons);
}
@ -9299,3 +9306,6 @@ void wfmain::resetUsbCommands()
emit sendUsbControllerCommands(&usbCommands);
}
void wfmain::receiveUsbSensitivity(int val) {
prefs.usbSensitivity = val;
}

Wyświetl plik

@ -223,7 +223,7 @@ signals:
void openShuttle();
void requestRigState();
void stateUpdated();
void initUsbController();
void initUsbController(int sens);
void sendUsbControllerCommands(QVector<COMMAND>* cmds);
void sendUsbControllerButtons(QVector<BUTTON>* buts);
void setClusterUdpPort(int port);
@ -350,6 +350,7 @@ private slots:
void showStatusBarText(QString text);
void receiveBaudRate(quint32 baudrate);
void radioSelection(QList<radio_cap_packet> radios);
void receiveUsbSensitivity(int val);
// Added for RC28/Shuttle support
void pttToggle(bool);