JoystickConfig.qml 33 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11 12 13 14


import QtQuick          2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs  1.2

15
import QGroundControl               1.0
16 17 18 19
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
20
import QGroundControl.FactSystem    1.0
21
import QGroundControl.FactControls  1.0
22 23

/// Joystick Config
Don Gagne's avatar
Don Gagne committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
SetupPage {
    id:                 joystickPage
    pageComponent:      pageComponent
    pageName:           qsTr("Joystick")
    pageDescription:    qsTr("Joystick Setup is used to configure a calibrate joysticks.")

    Component {
        id: pageComponent

        Item {
            width:  availableWidth
            height: Math.max(leftColumn.height, rightColumn.height)

            property bool controllerCompleted:      false
            property bool controllerAndViewReady:   false

            readonly property real labelToMonitorMargin: defaultTextWidth * 3

            property var _activeVehicle:    QGroundControl.multiVehicleManager.activeVehicle
            property var _activeJoystick:   joystickManager.activeJoystick

            JoystickConfigController {
                id:             controller
                factPanel:      joystickPage.viewPanel
                statusText:     statusText
                cancelButton:   cancelButton
                nextButton:     nextButton
                skipButton:     skipButton

                Component.onCompleted: {
                    controllerCompleted = true
                    if (joystickPage.completedSignalled) {
                        controllerAndViewReady = true
                        controller.start()
                    }
                }
60 61
            }

Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67
            Component.onCompleted: {
                if (controllerCompleted) {
                    controllerAndViewReady = true
                    controller.start()
                }
            }
68

Don Gagne's avatar
Don Gagne committed
69 70 71
            // Live axis monitor control component
            Component {
                id: axisMonitorDisplayComponent
72

Don Gagne's avatar
Don Gagne committed
73 74
                Item {
                    property int axisValue: 0
Gregory Dymarek's avatar
Gregory Dymarek committed
75
                    property int deadbandValue: 0
76

Don Gagne's avatar
Don Gagne committed
77 78 79
                    property int            __lastAxisValue:        0
                    readonly property int   __axisValueMaxJitter:   100
                    property color          __barColor:             qgcPal.windowShade
80

Don Gagne's avatar
Don Gagne committed
81 82 83 84 85 86 87 88
                    // Bar
                    Rectangle {
                        id:                     bar
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.width
                        height:                 parent.height / 2
                        color:                  __barColor
                    }
89

Gregory Dymarek's avatar
Gregory Dymarek committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103
                    // Deadband
                    Rectangle {
                        id:                     deadbandBar
                        anchors.verticalCenter: parent.verticalCenter
                        x:                      _deadbandPosition
                        width:                  _deadbandWidth
                        height:                 parent.height / 2
                        color:                  "#8c161a"

                        property real _percentDeadband:    ((2 * deadbandValue) / (32768.0 * 2))
                        property real _deadbandWidth:   parent.width * _percentDeadband
                        property real _deadbandPosition:   (parent.width - _deadbandWidth) / 2
                    }

Don Gagne's avatar
Don Gagne committed
104 105 106 107 108 109 110
                    // Center point
                    Rectangle {
                        anchors.horizontalCenter:   parent.horizontalCenter
                        width:                      defaultTextWidth / 2
                        height:                     parent.height
                        color:                      qgcPal.window
                    }
111

Don Gagne's avatar
Don Gagne committed
112 113 114 115 116 117 118 119 120 121 122 123 124
                    // Indicator
                    Rectangle {
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.height * 0.75
                        height:                 width
                        x:                      (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2)
                        radius:                 width / 2
                        color:                  qgcPal.text
                        visible:                mapped

                        property real _percentAxisValue:    ((axisValue + 32768.0) / (32768.0 * 2))
                        property real _indicatorPosition:   parent.width * _percentAxisValue
                    }
125

Don Gagne's avatar
Don Gagne committed
126 127 128 129 130 131 132
                    QGCLabel {
                        anchors.fill:           parent
                        horizontalAlignment:    Text.AlignHCenter
                        verticalAlignment:      Text.AlignVCenter
                        text:                   qsTr("Not Mapped")
                        visible:                !mapped
                    }
133

Don Gagne's avatar
Don Gagne committed
134 135 136 137 138 139 140 141
                    ColorAnimation {
                        id:         barAnimation
                        target:     bar
                        property:   "color"
                        from:       "yellow"
                        to:         __barColor
                        duration:   1500
                    }
142

Gregory Dymarek's avatar
Gregory Dymarek committed
143

Don Gagne's avatar
Don Gagne committed
144
                    // Axis value debugger
Gregory Dymarek's avatar
Gregory Dymarek committed
145
                    /*
Don Gagne's avatar
Don Gagne committed
146 147 148 149 150
                    QGCLabel {
                        anchors.fill: parent
                        text: axisValue
                    }
                    */
Gregory Dymarek's avatar
Gregory Dymarek committed
151

152
                }
Don Gagne's avatar
Don Gagne committed
153
            } // Component - axisMonitorDisplayComponent
154

Don Gagne's avatar
Don Gagne committed
155 156 157 158 159 160 161 162 163
            // Main view Qml starts here

            // Left side column
            Column {
                id:                     leftColumn
                anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.right:          rightColumn.left
                spacing:                10
164

Don Gagne's avatar
Don Gagne committed
165 166 167 168
                // Attitude Controls
                Column {
                    width:      parent.width
                    spacing:    5
169

Don Gagne's avatar
Don Gagne committed
170
                    QGCLabel { text: qsTr("Attitude Controls") }
171

Don Gagne's avatar
Don Gagne committed
172 173 174
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
175

Don Gagne's avatar
Don Gagne committed
176 177 178 179 180
                        QGCLabel {
                            id:     rollLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Roll")
                        }
181

Don Gagne's avatar
Don Gagne committed
182 183 184 185 186 187 188 189 190 191 192 193
                        Loader {
                            id:                 rollLoader
                            anchors.left:       rollLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.rollAxisMapped
                            property bool reversed:         controller.rollAxisReversed
                        }
194

Don Gagne's avatar
Don Gagne committed
195 196
                        Connections {
                            target: controller
197

Don Gagne's avatar
Don Gagne committed
198
                            onRollAxisValueChanged: rollLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
199 200

                            onRollAxisDeadbandChanged: rollLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
201
                        }
202 203
                    }

Don Gagne's avatar
Don Gagne committed
204 205 206
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
207

Don Gagne's avatar
Don Gagne committed
208 209 210 211 212
                        QGCLabel {
                            id:     pitchLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Pitch")
                        }
213

Don Gagne's avatar
Don Gagne committed
214 215 216 217 218 219 220 221 222 223 224 225
                        Loader {
                            id:                 pitchLoader
                            anchors.left:       pitchLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.pitchAxisMapped
                            property bool reversed:         controller.pitchAxisReversed
                        }
226

Don Gagne's avatar
Don Gagne committed
227 228
                        Connections {
                            target: controller
229

Don Gagne's avatar
Don Gagne committed
230
                            onPitchAxisValueChanged: pitchLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
231 232 233

                            onPitchAxisDeadbandChanged: pitchLoader.item.deadbandValue = value

Don Gagne's avatar
Don Gagne committed
234
                        }
235 236
                    }

Don Gagne's avatar
Don Gagne committed
237 238 239
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
240

Don Gagne's avatar
Don Gagne committed
241 242 243 244 245
                        QGCLabel {
                            id:     yawLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Yaw")
                        }
246

Don Gagne's avatar
Don Gagne committed
247 248 249 250 251 252 253 254 255 256 257 258
                        Loader {
                            id:                 yawLoader
                            anchors.left:       yawLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.yawAxisMapped
                            property bool reversed:         controller.yawAxisReversed
                        }
259

Don Gagne's avatar
Don Gagne committed
260 261
                        Connections {
                            target: controller
262

Don Gagne's avatar
Don Gagne committed
263
                            onYawAxisValueChanged: yawLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
264 265

                            onYawAxisDeadbandChanged: yawLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
266
                        }
267 268
                    }

Don Gagne's avatar
Don Gagne committed
269 270 271
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
272

Don Gagne's avatar
Don Gagne committed
273 274 275 276 277
                        QGCLabel {
                            id:     throttleLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Throttle")
                        }
278

Don Gagne's avatar
Don Gagne committed
279 280 281 282 283 284 285 286 287 288 289 290
                        Loader {
                            id:                 throttleLoader
                            anchors.left:       throttleLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.throttleAxisMapped
                            property bool reversed:         controller.throttleAxisReversed
                        }
291

Don Gagne's avatar
Don Gagne committed
292 293
                        Connections {
                            target: controller
294

Don Gagne's avatar
Don Gagne committed
295
                            onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
Gregory Dymarek's avatar
Gregory Dymarek committed
296 297

                            onThrottleAxisDeadbandChanged: throttleLoader.item.deadbandValue = value
Don Gagne's avatar
Don Gagne committed
298
                        }
299
                    }
Don Gagne's avatar
Don Gagne committed
300
                } // Column - Attitude Control labels
301

Don Gagne's avatar
Don Gagne committed
302 303 304 305 306 307 308
                // Command Buttons
                Row {
                    spacing: 10

                    QGCButton {
                        id:     skipButton
                        text:   qsTr("Skip")
309

Don Gagne's avatar
Don Gagne committed
310
                        onClicked: controller.skipButtonClicked()
311 312
                    }

Don Gagne's avatar
Don Gagne committed
313 314 315
                    QGCButton {
                        id:     cancelButton
                        text:   qsTr("Cancel")
316

Don Gagne's avatar
Don Gagne committed
317 318
                        onClicked: controller.cancelButtonClicked()
                    }
319

Don Gagne's avatar
Don Gagne committed
320 321 322 323
                    QGCButton {
                        id:         nextButton
                        primary:    true
                        text:       qsTr("Calibrate")
324

Don Gagne's avatar
Don Gagne committed
325 326 327
                        onClicked: controller.nextButtonClicked()
                    }
                } // Row - Buttons
328

Don Gagne's avatar
Don Gagne committed
329 330 331 332 333
                // Status Text
                QGCLabel {
                    id:         statusText
                    width:      parent.width
                    wrapMode:   Text.WordWrap
334 335
                }

Don Gagne's avatar
Don Gagne committed
336 337 338 339 340
                Rectangle {
                    width:          parent.width
                    height:         1
                    border.color:   qgcPal.text
                    border.width:   1
341 342
                }

Don Gagne's avatar
Don Gagne committed
343 344 345 346
                // Settings
                Row {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelWidth
347

Don Gagne's avatar
Don Gagne committed
348
                    // Left column settings
349
                    Column {
Don Gagne's avatar
Don Gagne committed
350
                        width:      parent.width / 2
351 352
                        spacing:    ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
353
                        QGCLabel { text: qsTr("Additional Joystick settings:") }
354

Don Gagne's avatar
Don Gagne committed
355 356 357
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight
358 359


Don Gagne's avatar
Don Gagne committed
360 361 362 363
                            QGCCheckBox {
                                enabled:    checked || _activeJoystick.calibrated
                                text:       _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)")
                                checked:    _activeVehicle.joystickEnabled
364

Don Gagne's avatar
Don Gagne committed
365
                                onClicked:  _activeVehicle.joystickEnabled = checked
366 367
                            }

Don Gagne's avatar
Don Gagne committed
368 369 370
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
371

Don Gagne's avatar
Don Gagne committed
372 373 374 375 376
                                QGCLabel {
                                    id:                 activeJoystickLabel
                                    anchors.baseline:   joystickCombo.baseline
                                    text:               qsTr("Active joystick:")
                                }
377

Don Gagne's avatar
Don Gagne committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391
                                QGCComboBox {
                                    id:                 joystickCombo
                                    width:              parent.width - activeJoystickLabel.width - parent.spacing
                                    model:              joystickManager.joystickNames

                                    onActivated: joystickManager.activeJoystickName = textAt(index)

                                    Component.onCompleted: {
                                        var index = joystickCombo.find(joystickManager.activeJoystickName)
                                        if (index == -1) {
                                            console.warn(qsTr("Active joystick name not in combo"), joystickManager.activeJoystickName)
                                        } else {
                                            joystickCombo.currentIndex = index
                                        }
392 393
                                    }
                                }
394 395
                            }

Don Gagne's avatar
Don Gagne committed
396 397 398
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
                                visible: _activeVehicle.supportsThrottleModeCenterZero
399

Don Gagne's avatar
Don Gagne committed
400
                                ExclusiveGroup { id: throttleModeExclusiveGroup }
401

Don Gagne's avatar
Don Gagne committed
402 403 404 405
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Center stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 0
406

Don Gagne's avatar
Don Gagne committed
407 408
                                    onClicked: _activeJoystick.throttleMode = 0
                                }
409

410
                                Row {
Gregory Dymarek's avatar
Gregory Dymarek committed
411
                                    x:          20
412 413 414 415 416 417 418
                                    width:      parent.width
                                    spacing:    ScreenTools.defaultFontPixelWidth
                                    visible:    _activeJoystick.throttleMode == 0

                                    QGCCheckBox {
                                        id:         accumulator
                                        checked:    _activeJoystick.accumulator
Gregory Dymarek's avatar
Gregory Dymarek committed
419
                                        text:       qsTr("Spring loaded throttle smoothing")
420 421 422 423 424

                                        onClicked:  _activeJoystick.accumulator = checked
                                    }
                                }

Don Gagne's avatar
Don Gagne committed
425 426 427 428
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Full down stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 1
429

Don Gagne's avatar
Don Gagne committed
430 431
                                    onClicked: _activeJoystick.throttleMode = 1
                                }
432 433
                            }

Don Gagne's avatar
Don Gagne committed
434 435
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
436

Don Gagne's avatar
Don Gagne committed
437 438 439 440
                                QGCCheckBox {
                                    id:         exponential
                                    checked:    _activeJoystick.exponential
                                    text:       qsTr("Use exponential curve on roll, pitch, yaw")
441

Don Gagne's avatar
Don Gagne committed
442 443
                                    onClicked:  _activeJoystick.exponential = checked
                                }
444 445
                            }

Don Gagne's avatar
Don Gagne committed
446 447 448 449
                            QGCCheckBox {
                                id:         advancedSettings
                                checked:    _activeVehicle.joystickMode != 0
                                text:       qsTr("Advanced settings (careful!)")
450

Don Gagne's avatar
Don Gagne committed
451 452 453 454
                                onClicked: {
                                    if (!checked) {
                                        _activeVehicle.joystickMode = 0
                                    }
455 456 457
                                }
                            }

Don Gagne's avatar
Don Gagne committed
458 459 460 461 462 463 464 465 466 467
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
                                visible:    advancedSettings.checked

                                QGCLabel {
                                    id:                 joystickModeLabel
                                    anchors.baseline:   joystickModeCombo.baseline
                                    text:               qsTr("Joystick mode:")
                                }
468

Don Gagne's avatar
Don Gagne committed
469 470 471 472 473
                                QGCComboBox {
                                    id:             joystickModeCombo
                                    currentIndex:   _activeVehicle.joystickMode
                                    width:          ScreenTools.defaultFontPixelWidth * 20
                                    model:          _activeVehicle.joystickModes
474

Don Gagne's avatar
Don Gagne committed
475 476
                                    onActivated: _activeVehicle.joystickMode = index
                                }
477
                            }
478 479 480 481 482 483 484 485 486 487 488 489 490 491

                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
                                visible:    advancedSettings.checked

                                QGCCheckBox {
                                    id:         deadband
                                    checked:    controller.deadbandToggle
                                    text:       qsTr("Deadbands")

                                    onClicked:  controller.deadbandToggle = checked
                                }
                            }
492
                        }
Don Gagne's avatar
Don Gagne committed
493
                    } // Column - left column
494

Don Gagne's avatar
Don Gagne committed
495 496 497 498
                    // Right column settings
                    Column {
                        width:      parent.width / 2
                        spacing:    ScreenTools.defaultFontPixelHeight
499

Don Gagne's avatar
Don Gagne committed
500 501
                        Connections {
                            target: _activeJoystick
502

Don Gagne's avatar
Don Gagne committed
503 504 505 506 507 508 509
                            onRawButtonPressedChanged: {
                                if (buttonActionRepeater.itemAt(index)) {
                                    buttonActionRepeater.itemAt(index).pressed = pressed
                                }
                                if (jsButtonActionRepeater.itemAt(index)) {
                                    jsButtonActionRepeater.itemAt(index).pressed = pressed
                                }
510
                            }
511 512
                        }

Don Gagne's avatar
Don Gagne committed
513
                        QGCLabel { text: qsTr("Button actions:") }
514

Don Gagne's avatar
Don Gagne committed
515 516 517
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight / 3
518

Don Gagne's avatar
Don Gagne committed
519 520 521
                            QGCLabel {
                                visible: _activeVehicle.manualControlReservedButtonCount != 0
                                text: qsTr("Buttons 0-%1 reserved for firmware use").arg(reservedButtonCount)
522

Don Gagne's avatar
Don Gagne committed
523 524
                                property int reservedButtonCount: _activeVehicle.manualControlReservedButtonCount == -1 ? _activeJoystick.totalButtonCount : _activeVehicle.manualControlReservedButtonCount
                            }
525

Don Gagne's avatar
Don Gagne committed
526 527 528
                            Repeater {
                                id:     buttonActionRepeater
                                model:  _activeJoystick.totalButtonCount
529

Don Gagne's avatar
Don Gagne committed
530 531 532
                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
                                    visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
533

Don Gagne's avatar
Don Gagne committed
534
                                    property bool pressed
535

Don Gagne's avatar
Don Gagne committed
536 537 538
                                    QGCCheckBox {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        checked:                    _activeJoystick.buttonActions[modelData] != ""
539

Don Gagne's avatar
Don Gagne committed
540 541
                                        onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
                                    }
542

Don Gagne's avatar
Don Gagne committed
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
                                    Rectangle {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        width:                      ScreenTools.defaultFontPixelHeight * 1.5
                                        height:                     width
                                        border.width:               1
                                        border.color:               qgcPal.text
                                        color:                      pressed ? qgcPal.buttonHighlight : qgcPal.button


                                        QGCLabel {
                                            anchors.fill:           parent
                                            color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                            horizontalAlignment:    Text.AlignHCenter
                                            verticalAlignment:      Text.AlignVCenter
                                            text:                   modelData
                                        }
559 560
                                    }

Don Gagne's avatar
Don Gagne committed
561 562 563 564
                                    QGCComboBox {
                                        id:             buttonActionCombo
                                        width:          ScreenTools.defaultFontPixelWidth * 20
                                        model:          _activeJoystick.actions
565

Don Gagne's avatar
Don Gagne committed
566 567 568
                                        onActivated:            _activeJoystick.setButtonAction(modelData, textAt(index))
                                        Component.onCompleted:  currentIndex = find(_activeJoystick.buttonActions[modelData])
                                    }
569
                                }
Don Gagne's avatar
Don Gagne committed
570
                            } // Repeater
571 572 573

                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth
574
                                visible: _activeVehicle.supportsJSButton
575

Don Gagne's avatar
Don Gagne committed
576 577 578 579
                                QGCLabel {
                                    horizontalAlignment:    Text.AlignHCenter
                                    width:                  ScreenTools.defaultFontPixelHeight * 1.5
                                    text:                   qsTr("#")
580 581
                                }

Don Gagne's avatar
Don Gagne committed
582 583 584
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Function: ")
585 586
                                }

Don Gagne's avatar
Don Gagne committed
587 588 589
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Shift Function: ")
590 591
                                }
                            } // Row
592

Don Gagne's avatar
Don Gagne committed
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
                            Repeater {
                                id:     jsButtonActionRepeater
                                model:  _activeJoystick.totalButtonCount

                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
                                    visible: _activeVehicle.supportsJSButton

                                    property bool pressed

                                    Rectangle {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        width:                      ScreenTools.defaultFontPixelHeight * 1.5
                                        height:                     width
                                        border.width:               1
                                        border.color:               qgcPal.text
                                        color:                      pressed ? qgcPal.buttonHighlight : qgcPal.button


                                        QGCLabel {
                                            anchors.fill:           parent
                                            color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                            horizontalAlignment:    Text.AlignHCenter
                                            verticalAlignment:      Text.AlignVCenter
                                            text:                   modelData
                                        }
                                    }

                                    FactComboBox {
                                        id:         mainJSButtonActionCombo
                                        width:      ScreenTools.defaultFontPixelWidth * 15
                                        fact:       controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
                                        indexModel: false
                                    }

                                    FactComboBox {
                                        id:         shiftJSButtonActionCombo
                                        width:      ScreenTools.defaultFontPixelWidth * 15
                                        fact:       controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
                                        indexModel: false
                                    }
                                } // Row
                            } // Repeater
                        } // Column
                    } // Column - right setting column
                } // Row - Settings
            } // Column - Left Main Column

            // Right side column
642
            Column {
Don Gagne's avatar
Don Gagne committed
643 644 645 646 647 648 649 650 651 652 653 654 655
                id:             rightColumn
                anchors.top:    parent.top
                anchors.right:  parent.right
                width:          defaultTextWidth * 35
                spacing:        10

                Image {
                    //width:      parent.width
                    height:     defaultTextHeight * 15
                    fillMode:   Image.PreserveAspectFit
                    smooth:     true
                    source:     controller.imageHelp
                }
656

Don Gagne's avatar
Don Gagne committed
657 658 659 660
                // Axis monitor
                Column {
                    width:      parent.width
                    spacing:    5
661

Don Gagne's avatar
Don Gagne committed
662
                    QGCLabel { text: qsTr("Axis Monitor") }
663

Don Gagne's avatar
Don Gagne committed
664 665 666 667 668 669 670
                    Connections {
                        target: controller

                        onAxisValueChanged: {
                            if (axisMonitorRepeater.itemAt(axis)) {
                                axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
                            }
671 672 673
                        }
                    }

Don Gagne's avatar
Don Gagne committed
674 675 676 677
                    Repeater {
                        id:     axisMonitorRepeater
                        model:  _activeJoystick.axisCount
                        width:  parent.width
678

Don Gagne's avatar
Don Gagne committed
679 680
                        Row {
                            spacing:    5
681

Don Gagne's avatar
Don Gagne committed
682 683
                            // Need this to get to loader from Connections above
                            property Item loader: theLoader
684

Don Gagne's avatar
Don Gagne committed
685 686 687 688
                            QGCLabel {
                                id:     axisLabel
                                text:   modelData
                            }
689

Don Gagne's avatar
Don Gagne committed
690 691 692 693 694 695 696 697 698 699 700
                            Loader {
                                id:                     theLoader
                                anchors.verticalCenter: axisLabel.verticalCenter
                                height:                 ScreenTools.defaultFontPixelHeight
                                width:                  200
                                sourceComponent:        axisMonitorDisplayComponent

                                property real defaultTextWidth:     ScreenTools.defaultFontPixelWidth
                                property bool mapped:               true
                                readonly property bool reversed:    false
                            }
701 702
                        }
                    }
Don Gagne's avatar
Don Gagne committed
703
                } // Column - Axis Monitor
704

Don Gagne's avatar
Don Gagne committed
705 706 707 708
                // Button monitor
                Column {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelHeight
709

Don Gagne's avatar
Don Gagne committed
710
                    QGCLabel { text: qsTr("Button Monitor") }
711

Don Gagne's avatar
Don Gagne committed
712 713
                    Connections {
                        target: _activeJoystick
714

Don Gagne's avatar
Don Gagne committed
715 716 717 718
                        onRawButtonPressedChanged: {
                            if (buttonMonitorRepeater.itemAt(index)) {
                                buttonMonitorRepeater.itemAt(index).pressed = pressed
                            }
719 720 721
                        }
                    }

Don Gagne's avatar
Don Gagne committed
722 723 724
                    Flow {
                        width:      parent.width
                        spacing:    -1
725

Don Gagne's avatar
Don Gagne committed
726 727 728
                        Repeater {
                            id:     buttonMonitorRepeater
                            model:  _activeJoystick.totalButtonCount
729

Don Gagne's avatar
Don Gagne committed
730 731 732 733 734 735
                            Rectangle {
                                width:          ScreenTools.defaultFontPixelHeight * 1.2
                                height:         width
                                border.width:   1
                                border.color:   qgcPal.text
                                color:          pressed ? qgcPal.buttonHighlight : qgcPal.button
736

Don Gagne's avatar
Don Gagne committed
737
                                property bool pressed
738

Don Gagne's avatar
Don Gagne committed
739 740 741 742 743 744 745
                                QGCLabel {
                                    anchors.fill:           parent
                                    color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                    horizontalAlignment:    Text.AlignHCenter
                                    verticalAlignment:      Text.AlignVCenter
                                    text:                   modelData
                                }
746
                            }
Don Gagne's avatar
Don Gagne committed
747 748 749 750 751 752 753
                        } // Repeater
                    } // Row
                } // Column - Axis Monitor
            } // Column - Right Column
        } // Item
    } // Component - pageComponent
} // SetupPage
Gregory Dymarek's avatar
Gregory Dymarek committed
754 755