Skip to content

Commit

Permalink
Merge pull request #1103 from ditcheshurt/master
Browse files Browse the repository at this point in the history
Completed adding button monitor feedback for midi controllers
  • Loading branch information
mcallegari authored Feb 5, 2024
2 parents fa51c43 + 863c0ae commit 29dfa14
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 31 deletions.
10 changes: 10 additions & 0 deletions engine/src/qlcinputsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ void QLCInputSource::setRange(uchar lower, uchar upper)
m_upper = upper;
}

void QLCInputSource::setMonitor(uchar monitor)
{
m_monitor = monitor;
}

uchar QLCInputSource::lowerValue() const
{
return m_lower;
Expand All @@ -136,6 +141,11 @@ uchar QLCInputSource::upperValue() const
return m_upper;
}

uchar QLCInputSource::monitorValue() const
{
return m_monitor;
}

/*********************************************************************
* Working mode
*********************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion engine/src/qlcinputsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ class QLCInputSource: public QThread
void setRange(uchar lower, uchar upper);
uchar lowerValue() const;
uchar upperValue() const;
void setMonitor(uchar monitor);
uchar monitorValue() const;

protected:
uchar m_lower, m_upper;
uchar m_lower, m_upper, m_monitor;

/*********************************************************************
* Working mode
Expand Down
15 changes: 14 additions & 1 deletion ui/src/inputselectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ InputSelectionWidget::InputSelectionWidget(Doc *doc, QWidget *parent)
m_feedbackGroup->setVisible(false);
m_lowerSpin->setEnabled(false);
m_upperSpin->setEnabled(false);
m_monitorSpin->setEnabled(false);

connect(m_attachKey, SIGNAL(clicked()), this, SLOT(slotAttachKey()));
connect(m_detachKey, SIGNAL(clicked()), this, SLOT(slotDetachKey()));
Expand All @@ -57,6 +58,8 @@ InputSelectionWidget::InputSelectionWidget(Doc *doc, QWidget *parent)
this, SLOT(slotLowerSpinValueChanged(int)));
connect(m_upperSpin, SIGNAL(valueChanged(int)),
this, SLOT(slotUpperSpinValueChanged(int)));
connect(m_monitorSpin, SIGNAL(valueChanged(int)),
this, SLOT(slotMonitorSpinValueChanged(int)));
}

InputSelectionWidget::~InputSelectionWidget()
Expand Down Expand Up @@ -197,6 +200,11 @@ void InputSelectionWidget::slotUpperSpinValueChanged(int value)
m_inputSource->setRange(uchar(m_lowerSpin->value()), uchar(value));
}

void InputSelectionWidget::slotMonitorSpinValueChanged(int value)
{
m_inputSource->setMonitor(uchar(value));
}

void InputSelectionWidget::updateInputSource()
{
QString uniName;
Expand All @@ -208,15 +216,17 @@ void InputSelectionWidget::updateInputSource()
chName = KInputNone;
m_lowerSpin->setEnabled(false);
m_upperSpin->setEnabled(false);
m_monitorSpin->setEnabled(false);
m_customFbButton->setChecked(false);
m_feedbackGroup->setVisible(false);
}
else
{
m_lowerSpin->blockSignals(true);
m_upperSpin->blockSignals(true);
m_monitorSpin->blockSignals(true);

uchar min = 0, max = UCHAR_MAX;
uchar min = 0, max = UCHAR_MAX, mon = UCHAR_MAX;

InputPatch *ip = m_doc->inputOutputMap()->inputPatch(m_inputSource->universe());
if (ip != NULL && ip->profile() != NULL)
Expand All @@ -230,6 +240,7 @@ void InputSelectionWidget::updateInputSource()
}
m_lowerSpin->setValue((m_inputSource->lowerValue() != 0) ? m_inputSource->lowerValue() : min);
m_upperSpin->setValue((m_inputSource->upperValue() != UCHAR_MAX) ? m_inputSource->upperValue() : max);
m_monitorSpin->setValue((m_inputSource->monitorValue() != UCHAR_MAX) ? m_inputSource->monitorValue() : mon);
if (m_lowerSpin->value() != 0 || m_upperSpin->value() != UCHAR_MAX)
{
m_customFbButton->setChecked(true);
Expand All @@ -241,8 +252,10 @@ void InputSelectionWidget::updateInputSource()
}
m_lowerSpin->blockSignals(false);
m_upperSpin->blockSignals(false);
m_monitorSpin->blockSignals(false);
m_lowerSpin->setEnabled(true);
m_upperSpin->setEnabled(true);
m_monitorSpin->setEnabled(true);
}

m_inputUniverseEdit->setText(uniName);
Expand Down
1 change: 1 addition & 0 deletions ui/src/inputselectionwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected slots:
void slotCustomFeedbackToggled(bool checked);
void slotLowerSpinValueChanged(int value);
void slotUpperSpinValueChanged(int value);
void slotMonitorSpinValueChanged(int value);

signals:
void autoDetectToggled(bool checked);
Expand Down
66 changes: 48 additions & 18 deletions ui/src/inputselectionwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,39 @@
<property name="title">
<string>Custom feedback</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Lower</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_lowerSpin">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Lower value</string>
<string>Upper</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item>
<widget class="QSpinBox" name="m_upperSpin">
<property name="minimum">
<number>0</number>
Expand All @@ -198,21 +216,33 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="m_lowerSpin">
<property name="maximum">
<number>255</number>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Monitor</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Upper value</string>
<item>
<widget class="QSpinBox" name="m_monitorSpin">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
</layout>
<zorder>m_upperSpin</zorder>
<zorder>m_lowerSpin</zorder>
<zorder>label_2</zorder>
<zorder>label</zorder>
<zorder>m_monitorSpin</zorder>
<zorder>label_3</zorder>
<zorder>m_keyInputGroup</zorder>
</widget>
</item>
<item row="1" column="1" colspan="4">
Expand Down
11 changes: 7 additions & 4 deletions ui/src/virtualconsole/vcbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,19 @@ void VCButton::slotKeyReleased(const QKeySequence& keySequence)

void VCButton::updateFeedback()
{
if (m_state == Monitoring)
return;
//if (m_state == Monitoring)
// return;

QSharedPointer<QLCInputSource> src = inputSource();
if (!src.isNull() && src->isValid() == true)
{
if (m_state == Inactive)
if (m_state == Inactive) {
sendFeedback(src->lowerValue());
else
} else if (m_state == Monitoring) {
sendFeedback(src->monitorValue());
} else {
sendFeedback(src->upperValue());
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion ui/src/virtualconsole/vcwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,15 +885,18 @@ QSharedPointer<QLCInputSource> VCWidget::getXMLInput(QXmlStreamReader &root)

quint32 uni = attrs.value(KXMLQLCVCWidgetInputUniverse).toString().toUInt();
quint32 ch = attrs.value(KXMLQLCVCWidgetInputChannel).toString().toUInt();
uchar min = 0, max = UCHAR_MAX;
uchar min = 0, max = UCHAR_MAX, mon = UCHAR_MAX;

QSharedPointer<QLCInputSource>newSrc = QSharedPointer<QLCInputSource>(new QLCInputSource(uni, ch));
if (attrs.hasAttribute(KXMLQLCVCWidgetInputLowerValue))
min = uchar(attrs.value(KXMLQLCVCWidgetInputLowerValue).toString().toUInt());
if (attrs.hasAttribute(KXMLQLCVCWidgetInputUpperValue))
max = uchar(attrs.value(KXMLQLCVCWidgetInputUpperValue).toString().toUInt());
if (attrs.hasAttribute(KXMLQLCVCWidgetInputMonitorValue))
mon = uchar(attrs.value(KXMLQLCVCWidgetInputMonitorValue).toString().toUInt());

newSrc->setRange(min, max);
newSrc->setMonitor(mon);

return newSrc;
}
Expand Down Expand Up @@ -1041,6 +1044,9 @@ bool VCWidget::saveXMLInput(QXmlStreamWriter *doc,
doc->writeAttribute(KXMLQLCVCWidgetInputLowerValue, QString::number(src->lowerValue()));
if (src->upperValue() != UCHAR_MAX)
doc->writeAttribute(KXMLQLCVCWidgetInputUpperValue, QString::number(src->upperValue()));
if (src->monitorValue() != UCHAR_MAX)
doc->writeAttribute(KXMLQLCVCWidgetInputMonitorValue, QString::number(src->monitorValue()));

doc->writeEndElement();
}

Expand Down
13 changes: 7 additions & 6 deletions ui/src/virtualconsole/vcwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ class QFile;
#define KVCFrameStyleRaised (QFrame::Panel | QFrame::Raised)
#define KVCFrameStyleNone (QFrame::NoFrame)

#define KXMLQLCVCWidgetKey QString("Key")
#define KXMLQLCVCWidgetInput QString("Input")
#define KXMLQLCVCWidgetInputUniverse QString("Universe")
#define KXMLQLCVCWidgetInputChannel QString("Channel")
#define KXMLQLCVCWidgetInputLowerValue QString("LowerValue")
#define KXMLQLCVCWidgetInputUpperValue QString("UpperValue")
#define KXMLQLCVCWidgetKey QString("Key")
#define KXMLQLCVCWidgetInput QString("Input")
#define KXMLQLCVCWidgetInputUniverse QString("Universe")
#define KXMLQLCVCWidgetInputChannel QString("Channel")
#define KXMLQLCVCWidgetInputLowerValue QString("LowerValue")
#define KXMLQLCVCWidgetInputUpperValue QString("UpperValue")
#define KXMLQLCVCWidgetInputMonitorValue QString("MonitorValue")

#define KXMLQLCWindowState QString("WindowState")
#define KXMLQLCWindowStateVisible QString("Visible")
Expand Down

0 comments on commit 29dfa14

Please sign in to comment.