Unverified Commit 124f9ec9 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7622 from mavlink/joystickButtons

Joystick Work
parents e71da845 4d3620dc
......@@ -6,6 +6,7 @@ Note: This file only contains high level features or important fixes.
### 3.6.0 - Daily Build
* Added ability to set a joystick button to be single action or repeated action while the button is held down.
* Rework joysticks. Fixed several issues and updated setup UI.
* Adding support for UDP RTP h.265 video streams
* For text to speech engine on Linux to English (all messages are in English)
......
This diff is collapsed.
This diff is collapsed.
......@@ -32,6 +32,14 @@ QmlObjectListModel::~QmlObjectListModel()
}
QObject* QmlObjectListModel::get(int index)
{
if (index < 0 || index >= _objectList.count()) {
return nullptr;
}
return _objectList[index];
}
int QmlObjectListModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
......@@ -160,19 +168,17 @@ void QmlObjectListModel::insert(int i, QObject* object)
if (i < 0 || i > _objectList.count()) {
qWarning() << "Invalid index index:count" << i << _objectList.count();
}
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
// Look for a dirtyChanged signal on the object
if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) {
if (!_skipDirtyFirstItem || i != 0) {
QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool)));
if(object) {
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
// Look for a dirtyChanged signal on the object
if (object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("dirtyChanged(bool)")) != -1) {
if (!_skipDirtyFirstItem || i != 0) {
QObject::connect(object, SIGNAL(dirtyChanged(bool)), this, SLOT(_childDirtyChanged(bool)));
}
}
}
_objectList.insert(i, object);
insertRows(i, 1);
setDirty(true);
}
......
......@@ -27,7 +27,7 @@ public:
/// a dirty property and dirtyChanged signal.
Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
Q_INVOKABLE QObject* get(int index) { return _objectList[index]; }
Q_INVOKABLE QObject* get(int index);
// Property accessors
......
......@@ -61,6 +61,9 @@ SetupPage {
QGCTabBar {
id: bar
width: parent.width
Component.onCompleted: {
currentIndex = _activeJoystick && _activeJoystick.calibrated ? 0 : 2
}
anchors.top: parent.top
QGCTabButton {
text: qsTr("General")
......
......@@ -144,20 +144,38 @@ Item {
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Message Frequency
//-- Axis Message Frequency
QGCLabel {
text: qsTr("Message frequency (Hz):")
text: qsTr("Axis frequency (Hz):")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCTextField {
text: _activeJoystick.frequency
text: _activeJoystick.axisFrequency
enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 100.0; }
validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter
onEditingFinished: {
_activeJoystick.frequency = parseFloat(text)
_activeJoystick.axisFrequency = parseFloat(text)
}
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Button Repeat Frequency
QGCLabel {
text: qsTr("Button repeat frequency (Hz):")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCTextField {
text: _activeJoystick.buttonFrequency
enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 50.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter
onEditingFinished: {
_activeJoystick.buttonFrequency = parseFloat(text)
}
visible: advancedSettings.checked
}
......
......@@ -46,11 +46,7 @@ Item {
Row {
spacing: ScreenTools.defaultFontPixelWidth
property bool pressed
QGCCheckBox {
anchors.verticalCenter: parent.verticalCenter
checked: _activeJoystick ? _activeJoystick.buttonActions[modelData] !== "" : false
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
}
property var currentAssignableAction: _activeJoystick ? _activeJoystick.assignableActions.get(buttonActionCombo.currentIndex) : null
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
......@@ -69,9 +65,35 @@ Item {
QGCComboBox {
id: buttonActionCombo
width: ScreenTools.defaultFontPixelWidth * 26
model: _activeJoystick ? _activeJoystick.actions : 0
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index))
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData])
model: _activeJoystick ? _activeJoystick.assignableActionTitles : []
onActivated: {
_activeJoystick.setButtonAction(modelData, textAt(index))
}
Component.onCompleted: {
if(_activeJoystick) {
var i = find(_activeJoystick.buttonActions[modelData])
if(i < 0) i = 0
currentIndex = i
}
}
}
QGCCheckBox {
id: repeatCheck
text: qsTr("Repeat")
enabled: currentAssignableAction && _activeJoystick.calibrated && currentAssignableAction.canRepeat
onClicked: {
_activeJoystick.setButtonRepeat(modelData, checked)
}
Component.onCompleted: {
if(_activeJoystick) {
checked = _activeJoystick.getButtonRepeat(modelData)
}
}
anchors.verticalCenter: parent.verticalCenter
}
Item {
width: ScreenTools.defaultFontPixelWidth * 2
height: 1
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment