feat: New advanced joystick mode on radio, improvements to Companion and Simulator joystick support (#3111)
* Allow switches on the connected radio to control switches in the simulator via the joystick interface. * Merge configurable radio joystick interface from banyaszg. * Add two more 'axis' channels to companion. * Fix 6POS from USB joystick to simulator. * Reduce data size. * Fix build error on B&W radios. * Add 'Companion' button mode to work with the button logic in the Companion app. * Build Companion joystick setup layout at runtime. Change #define names for simulator joystick. Allow 15 axes and 32 buttons. Initial support for trim sliders. * Remove custom joystick button type for companion - use 3 buttons per switch in companion to control simulator switch state. * Fix joystick constructor calls parameters. Connect some radio joystick trims to simulator widgets. * Restore 'companion' button type to reduce number of buttons needed. Make trims work via buttons in USB joystick. * Connect joystick trim buttons to simulator widgets. * Use companion source names for trims. * Add encode / decode of usb joystick custom settings to Companion. * Convert to lvgl layouts. Update language files. * Fix generated YAML storage files. * Fix initialisation error when editing button channel. Cleanup code. * Fix rebase. * Fix refresh of joystick channel list view after editing an entry. Companion joystick config window uses two columns. * Fix vertical joystick inversion bug. Change stick axis labels. --------- Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
This commit is contained in:
@@ -65,7 +65,7 @@ class RadioTrimWidget : public RadioWidget
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
void setValue(const int & value)
|
||||
void setValue(const int & value) override
|
||||
{
|
||||
if (sender() && qobject_cast<SliderWidget *>(sender())) {
|
||||
RadioWidget::setValue(value);
|
||||
@@ -75,6 +75,12 @@ class RadioTrimWidget : public RadioWidget
|
||||
}
|
||||
}
|
||||
|
||||
void chgValueQual(const RadioWidgetType & type, const int & index, const int offset, const bool state) override {
|
||||
if (type == m_type && index == m_index) {
|
||||
emit valueChange(m_type, (offset < 0) ? m_btnDecIndex : m_btnIncIndex, state ? RADIO_TRIM_BTN_ON : RADIO_TRIM_BTN_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
protected slots:
|
||||
|
||||
void init(Qt::Orientation orientation)
|
||||
|
||||
@@ -88,6 +88,7 @@ class RadioWidget : public QWidget
|
||||
virtual void setType(const RadioWidgetType & type);
|
||||
virtual void setValue(const int & value);
|
||||
virtual void setValueQual(const RadioWidgetType & type, const int & index, const int & value);
|
||||
virtual void chgValueQual(const RadioWidgetType & type, const int & index, const int offset, const bool state) {}
|
||||
virtual void setFlags(const quint16 & flags);
|
||||
virtual void setShowLabel(const bool show);
|
||||
virtual void setLabelText(const QString & labelText, bool showLabel = true);
|
||||
|
||||
@@ -323,7 +323,7 @@ void VirtualJoystickWidget::onNodeXChanged()
|
||||
|
||||
void VirtualJoystickWidget::onNodeYChanged()
|
||||
{
|
||||
emit valueChange(RadioWidget::RADIO_WIDGET_STICK, m_yIndex, int(-m_stickScale * getStickY()));
|
||||
emit valueChange(RadioWidget::RADIO_WIDGET_STICK, m_yIndex, int(m_stickScale * getStickY()));
|
||||
updateNodeValueLabels();
|
||||
}
|
||||
|
||||
@@ -564,9 +564,9 @@ void VirtualJoystickWidget::onButtonChange(bool checked)
|
||||
void VirtualJoystickWidget::updateNodeValueLabels()
|
||||
{
|
||||
if (nodeLabelX)
|
||||
nodeLabelX->setText(QString("%1").arg(node->getX() * 100.0f, 2, 'f', 0));
|
||||
nodeLabelX->setText(QString("%1").arg(getStickX() * 100.0f, 2, 'f', 0));
|
||||
if (nodeLabelY)
|
||||
nodeLabelY->setText(QString("%1").arg(node->getY() * -100.0f, 2, 'f', 0));
|
||||
nodeLabelY->setText(QString("%1").arg(getStickY() * 100.0f, 2, 'f', 0));
|
||||
}
|
||||
|
||||
void VirtualJoystickWidget::onGsMouseEvent(QGraphicsSceneMouseEvent * event)
|
||||
|
||||
@@ -61,6 +61,9 @@ class VirtualJoystickWidget : public QWidget
|
||||
int getStickScale() const;
|
||||
void setStickScale(int stickScale);
|
||||
|
||||
const RadioTrimWidget *horizontalTrim() { return hTrimWidget; }
|
||||
const RadioTrimWidget *verticalTrim() { return vTrimWidget; }
|
||||
|
||||
public slots:
|
||||
void setStickX(qreal x);
|
||||
void setStickY(qreal y);
|
||||
|
||||
Reference in New Issue
Block a user