Refactor out duplicate PTT logic into a shared controller.
This commit is contained in:
@@ -30,147 +30,9 @@ MyStackViewPage {
|
||||
}
|
||||
}
|
||||
|
||||
MyDialogOkCancelPopup {
|
||||
PttControllerConfigDialog {
|
||||
id: pttControllerConfigDialog
|
||||
property int controllerIndex: -1
|
||||
dialogTitle: "Controller Configuration"
|
||||
dialogWidth: 600
|
||||
dialogHeight: 620
|
||||
dialogContentItem: ColumnLayout {
|
||||
MyText {
|
||||
text: "Buttons"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigGripButtonToggle
|
||||
text: "Grip"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigMenuButtonToggle
|
||||
text: "Menu"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigTriggerButtonToggle
|
||||
text: "Trigger"
|
||||
}
|
||||
|
||||
MyText {
|
||||
Layout.topMargin: 32
|
||||
text: "Touchpad"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadLeftToggle
|
||||
text: "Left"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadRightToggle
|
||||
text: "Right"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadTopToggle
|
||||
text: "Top"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadBottomToggle
|
||||
text: "Bottom"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
MyText {
|
||||
text: "Mode:"
|
||||
}
|
||||
MyComboBox {
|
||||
id: pttControllerConfigPadModeCombo
|
||||
Layout.preferredWidth: 250
|
||||
model: ["Disabled", "Touched", "Pressed"]
|
||||
}
|
||||
}
|
||||
}
|
||||
onClosed: {
|
||||
if (okClicked) {
|
||||
var buttons = []
|
||||
if (pttControllerConfigGripButtonToggle.checked) {
|
||||
buttons.push(2)
|
||||
}
|
||||
if (pttControllerConfigMenuButtonToggle.checked) {
|
||||
buttons.push(1)
|
||||
}
|
||||
var triggerMode = 0
|
||||
if (pttControllerConfigTriggerButtonToggle.checked) {
|
||||
triggerMode = 1
|
||||
}
|
||||
var padAreas = 0
|
||||
if (pttControllerConfigPadLeftToggle.checked) {
|
||||
padAreas |= (1 << 0)
|
||||
}
|
||||
if (pttControllerConfigPadTopToggle.checked) {
|
||||
padAreas |= (1 << 1)
|
||||
}
|
||||
if (pttControllerConfigPadRightToggle.checked) {
|
||||
padAreas |= (1 << 2)
|
||||
}
|
||||
if (pttControllerConfigPadBottomToggle.checked) {
|
||||
padAreas |= (1 << 3)
|
||||
}
|
||||
AudioTabController.setPttControllerConfig(controllerIndex, buttons, triggerMode, pttControllerConfigPadModeCombo.currentIndex, padAreas);
|
||||
}
|
||||
}
|
||||
function openPopup(controller) {
|
||||
if (controller === 0) {
|
||||
dialogTitle = "Left Controller Configuration"
|
||||
controllerIndex = 0
|
||||
} else {
|
||||
dialogTitle = "Right Controller Configuration"
|
||||
controllerIndex = 1
|
||||
}
|
||||
pttControllerConfigGripButtonToggle.checked = false
|
||||
pttControllerConfigMenuButtonToggle.checked = false
|
||||
pttControllerConfigTriggerButtonToggle.checked = false
|
||||
pttControllerConfigPadLeftToggle.checked = false
|
||||
pttControllerConfigPadTopToggle.checked = false
|
||||
pttControllerConfigPadRightToggle.checked = false
|
||||
pttControllerConfigPadBottomToggle.checked = false
|
||||
pttControllerConfigPadModeCombo.currentIndex = AudioTabController.pttTouchpadMode(controllerIndex)
|
||||
var buttons = AudioTabController.pttDigitalButtons(controllerIndex)
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] == 1) {
|
||||
pttControllerConfigMenuButtonToggle.checked = true
|
||||
} else if (buttons[i] == 2) {
|
||||
pttControllerConfigGripButtonToggle.checked = true
|
||||
}
|
||||
}
|
||||
if (AudioTabController.pttTriggerMode(controllerIndex) > 0) {
|
||||
pttControllerConfigTriggerButtonToggle.checked = true
|
||||
}
|
||||
var padAreas = AudioTabController.pttTouchpadArea(controllerIndex)
|
||||
if (padAreas & (1 << 0)) {
|
||||
pttControllerConfigPadLeftToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 1)) {
|
||||
pttControllerConfigPadTopToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 2)) {
|
||||
pttControllerConfigPadRightToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 3)) {
|
||||
pttControllerConfigPadBottomToggle.checked = true
|
||||
}
|
||||
open()
|
||||
}
|
||||
pttControllerConfigClass: AudioTabController
|
||||
}
|
||||
|
||||
MyDialogOkCancelPopup {
|
||||
|
||||
@@ -8,147 +8,9 @@ import matzman666.advsettings 1.0
|
||||
MyStackViewPage {
|
||||
headerText: "Play Space Settings"
|
||||
|
||||
MyDialogOkCancelPopup {
|
||||
PttControllerConfigDialog {
|
||||
id: pttControllerConfigDialog
|
||||
property int controllerIndex: -1
|
||||
dialogTitle: "Controller Configuration"
|
||||
dialogWidth: 600
|
||||
dialogHeight: 620
|
||||
dialogContentItem: ColumnLayout {
|
||||
MyText {
|
||||
text: "Buttons"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigGripButtonToggle
|
||||
text: "Grip"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigMenuButtonToggle
|
||||
text: "Menu"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigTriggerButtonToggle
|
||||
text: "Trigger"
|
||||
}
|
||||
|
||||
MyText {
|
||||
Layout.topMargin: 32
|
||||
text: "Touchpad"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadLeftToggle
|
||||
text: "Left"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadRightToggle
|
||||
text: "Right"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadTopToggle
|
||||
text: "Top"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadBottomToggle
|
||||
text: "Bottom"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
MyText {
|
||||
text: "Mode:"
|
||||
}
|
||||
MyComboBox {
|
||||
id: pttControllerConfigPadModeCombo
|
||||
Layout.preferredWidth: 250
|
||||
model: ["Disabled", "Touched", "Pressed"]
|
||||
}
|
||||
}
|
||||
}
|
||||
onClosed: {
|
||||
if (okClicked) {
|
||||
var buttons = []
|
||||
if (pttControllerConfigGripButtonToggle.checked) {
|
||||
buttons.push(2)
|
||||
}
|
||||
if (pttControllerConfigMenuButtonToggle.checked) {
|
||||
buttons.push(1)
|
||||
}
|
||||
var triggerMode = 0
|
||||
if (pttControllerConfigTriggerButtonToggle.checked) {
|
||||
triggerMode = 1
|
||||
}
|
||||
var padAreas = 0
|
||||
if (pttControllerConfigPadLeftToggle.checked) {
|
||||
padAreas |= (1 << 0)
|
||||
}
|
||||
if (pttControllerConfigPadTopToggle.checked) {
|
||||
padAreas |= (1 << 1)
|
||||
}
|
||||
if (pttControllerConfigPadRightToggle.checked) {
|
||||
padAreas |= (1 << 2)
|
||||
}
|
||||
if (pttControllerConfigPadBottomToggle.checked) {
|
||||
padAreas |= (1 << 3)
|
||||
}
|
||||
MoveCenterTabController.setPttControllerConfig(controllerIndex, buttons, triggerMode, pttControllerConfigPadModeCombo.currentIndex, padAreas);
|
||||
}
|
||||
}
|
||||
function openPopup(controller) {
|
||||
if (controller === 0) {
|
||||
dialogTitle = "Left Controller Configuration"
|
||||
controllerIndex = 0
|
||||
} else {
|
||||
dialogTitle = "Right Controller Configuration"
|
||||
controllerIndex = 1
|
||||
}
|
||||
pttControllerConfigGripButtonToggle.checked = false
|
||||
pttControllerConfigMenuButtonToggle.checked = false
|
||||
pttControllerConfigTriggerButtonToggle.checked = false
|
||||
pttControllerConfigPadLeftToggle.checked = false
|
||||
pttControllerConfigPadTopToggle.checked = false
|
||||
pttControllerConfigPadRightToggle.checked = false
|
||||
pttControllerConfigPadBottomToggle.checked = false
|
||||
pttControllerConfigPadModeCombo.currentIndex = MoveCenterTabController.pttTouchpadMode(controllerIndex)
|
||||
var buttons = MoveCenterTabController.pttDigitalButtons(controllerIndex)
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] == 1) {
|
||||
pttControllerConfigMenuButtonToggle.checked = true
|
||||
} else if (buttons[i] == 2) {
|
||||
pttControllerConfigGripButtonToggle.checked = true
|
||||
}
|
||||
}
|
||||
if (MoveCenterTabController.pttTriggerMode(controllerIndex) > 0) {
|
||||
pttControllerConfigTriggerButtonToggle.checked = true
|
||||
}
|
||||
var padAreas = MoveCenterTabController.pttTouchpadArea(controllerIndex)
|
||||
if (padAreas & (1 << 0)) {
|
||||
pttControllerConfigPadLeftToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 1)) {
|
||||
pttControllerConfigPadTopToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 2)) {
|
||||
pttControllerConfigPadRightToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 3)) {
|
||||
pttControllerConfigPadBottomToggle.checked = true
|
||||
}
|
||||
open()
|
||||
}
|
||||
pttControllerConfigClass: MoveCenterTabController
|
||||
}
|
||||
|
||||
content: ColumnLayout {
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.3
|
||||
import matzman666.advsettings 1.0
|
||||
|
||||
MyDialogOkCancelPopup {
|
||||
id: pttControllerConfigDialog
|
||||
property var pttControllerConfigClass
|
||||
property int controllerIndex: -1
|
||||
dialogTitle: "Controller Configuration"
|
||||
dialogWidth: 600
|
||||
dialogHeight: 620
|
||||
dialogContentItem: ColumnLayout {
|
||||
MyText {
|
||||
text: "Buttons"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigGripButtonToggle
|
||||
text: "Grip"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigMenuButtonToggle
|
||||
text: "Menu"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigTriggerButtonToggle
|
||||
text: "Trigger"
|
||||
}
|
||||
|
||||
MyText {
|
||||
Layout.topMargin: 32
|
||||
text: "Touchpad"
|
||||
}
|
||||
Rectangle {
|
||||
color: "#cccccc"
|
||||
height: 1
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadLeftToggle
|
||||
text: "Left"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadRightToggle
|
||||
text: "Right"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 64
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadTopToggle
|
||||
text: "Top"
|
||||
}
|
||||
MyToggleButton {
|
||||
id: pttControllerConfigPadBottomToggle
|
||||
text: "Bottom"
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
MyText {
|
||||
text: "Mode:"
|
||||
}
|
||||
MyComboBox {
|
||||
id: pttControllerConfigPadModeCombo
|
||||
Layout.preferredWidth: 250
|
||||
model: ["Disabled", "Touched", "Pressed"]
|
||||
}
|
||||
}
|
||||
}
|
||||
onClosed: {
|
||||
if (okClicked) {
|
||||
var buttons = []
|
||||
if (pttControllerConfigGripButtonToggle.checked) {
|
||||
buttons.push(2)
|
||||
}
|
||||
if (pttControllerConfigMenuButtonToggle.checked) {
|
||||
buttons.push(1)
|
||||
}
|
||||
var triggerMode = 0
|
||||
if (pttControllerConfigTriggerButtonToggle.checked) {
|
||||
triggerMode = 1
|
||||
}
|
||||
var padAreas = 0
|
||||
if (pttControllerConfigPadLeftToggle.checked) {
|
||||
padAreas |= (1 << 0)
|
||||
}
|
||||
if (pttControllerConfigPadTopToggle.checked) {
|
||||
padAreas |= (1 << 1)
|
||||
}
|
||||
if (pttControllerConfigPadRightToggle.checked) {
|
||||
padAreas |= (1 << 2)
|
||||
}
|
||||
if (pttControllerConfigPadBottomToggle.checked) {
|
||||
padAreas |= (1 << 3)
|
||||
}
|
||||
pttControllerConfigClass.setPttControllerConfig(controllerIndex, buttons, triggerMode, pttControllerConfigPadModeCombo.currentIndex, padAreas);
|
||||
}
|
||||
}
|
||||
function openPopup(controller) {
|
||||
if (controller === 0) {
|
||||
dialogTitle = "Left Controller Configuration"
|
||||
controllerIndex = 0
|
||||
} else {
|
||||
dialogTitle = "Right Controller Configuration"
|
||||
controllerIndex = 1
|
||||
}
|
||||
pttControllerConfigGripButtonToggle.checked = false
|
||||
pttControllerConfigMenuButtonToggle.checked = false
|
||||
pttControllerConfigTriggerButtonToggle.checked = false
|
||||
pttControllerConfigPadLeftToggle.checked = false
|
||||
pttControllerConfigPadTopToggle.checked = false
|
||||
pttControllerConfigPadRightToggle.checked = false
|
||||
pttControllerConfigPadBottomToggle.checked = false
|
||||
pttControllerConfigPadModeCombo.currentIndex = pttControllerConfigClass.pttTouchpadMode(controllerIndex)
|
||||
var buttons = pttControllerConfigClass.pttDigitalButtons(controllerIndex)
|
||||
for (var i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] == 1) {
|
||||
pttControllerConfigMenuButtonToggle.checked = true
|
||||
} else if (buttons[i] == 2) {
|
||||
pttControllerConfigGripButtonToggle.checked = true
|
||||
}
|
||||
}
|
||||
if (pttControllerConfigClass.pttTriggerMode(controllerIndex) > 0) {
|
||||
pttControllerConfigTriggerButtonToggle.checked = true
|
||||
}
|
||||
var padAreas = pttControllerConfigClass.pttTouchpadArea(controllerIndex)
|
||||
if (padAreas & (1 << 0)) {
|
||||
pttControllerConfigPadLeftToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 1)) {
|
||||
pttControllerConfigPadTopToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 2)) {
|
||||
pttControllerConfigPadRightToggle.checked = true
|
||||
}
|
||||
if (padAreas & (1 << 3)) {
|
||||
pttControllerConfigPadBottomToggle.checked = true
|
||||
}
|
||||
open()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user