Skip to content

Commit

Permalink
Improved input remapping GUI.
Browse files Browse the repository at this point in the history
Added support for keyboard layout dependend keys.
Added immediate key release feature to long/double press.
  • Loading branch information
matzman666 committed Sep 26, 2017
1 parent 15dbe7c commit 2c99d3e
Show file tree
Hide file tree
Showing 20 changed files with 560 additions and 415 deletions.
388 changes: 133 additions & 255 deletions client_overlay/Debug/moc_DigitalInputRemappingController.cpp

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions client_overlay/bin/win64/res/qml/DeviceAnalogAxisEntry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ RowLayout {
Layout.preferredWidth: 270
text: axisName
}
MyText {
id: axisStatusText
Layout.preferredWidth: 650
text: axisStatus
}
MyPushButton {
Layout.preferredWidth: 150
text: "Configure"
id: configButton
Layout.preferredWidth: 840
text: axisStatus
onClicked: {
DeviceManipulationTabController.startConfigureAnalogInputRemapping(deviceIndex, axisId)
deviceAnalogInputRemappingPage.setDeviceIndex(deviceIndex, axisId)
Expand All @@ -33,8 +29,8 @@ RowLayout {
Connections {
target: DeviceManipulationTabController
onConfigureAnalogInputRemappingFinished: {
var axisStatus = DeviceManipulationTabController.getAnalogAxisName(deviceIndex, axisId);
axisStatusText.text = axisStatus
axisStatus = DeviceManipulationTabController.getAnalogAxisName(deviceIndex, axisId);
configButton.text = axisStatus
}
}
}
52 changes: 31 additions & 21 deletions client_overlay/bin/win64/res/qml/DeviceAnalogInputRemappingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@ MyStackViewPage {
}
}

onPageBackButtonClicked: {
if (bindingTypeComboBox.currentIndex == 0) {
AnalogInputRemappingController.finishConfigure_Original()
} else if (bindingTypeComboBox.currentIndex == 1) {
AnalogInputRemappingController.finishConfigure_Disabled()
} else if (bindingTypeComboBox.currentIndex == 2) {
var controllerId = -1
if (openVRControllerComboBox.currentIndex > 0) {
var controllerId = _controllerIds[openVRControllerComboBox.currentIndex - 1]
}
var mappedAxisId = openvrAxisComboBox.currentIndex
var invertXAxis = openvrXAxisInvertToggle.checked
var invertYAxis = openvrYAxisInvertToggle.checked
var swapAxes = openvrAxisSwapToggle.checked
var lowerDeadzone = deadzonesRangeSlider.first.value
var upperDeadzone = deadzonesRangeSlider.second.value
AnalogInputRemappingController.finishConfigure_OpenVR(controllerId, mappedAxisId, invertXAxis, invertYAxis, swapAxes, lowerDeadzone, upperDeadzone)
}
}

content: ColumnLayout {
spacing: 64

Expand Down Expand Up @@ -180,7 +160,7 @@ MyStackViewPage {
spacing: 16

MyText {
text: "Deadzones:"
text: "Active Zone:"
Layout.preferredWidth: 180
Layout.rightMargin: 12
}
Expand Down Expand Up @@ -252,6 +232,36 @@ MyStackViewPage {
Layout.fillHeight: true
}

RowLayout {
Item {
Layout.fillWidth: true
}
MyPushButton {
Layout.preferredWidth: 200
text: "Save"
onClicked: {
if (bindingTypeComboBox.currentIndex == 0) {
AnalogInputRemappingController.finishConfigure_Original()
} else if (bindingTypeComboBox.currentIndex == 1) {
AnalogInputRemappingController.finishConfigure_Disabled()
} else if (bindingTypeComboBox.currentIndex == 2) {
var controllerId = -1
if (openVRControllerComboBox.currentIndex > 0) {
var controllerId = _controllerIds[openVRControllerComboBox.currentIndex - 1]
}
var mappedAxisId = openvrAxisComboBox.currentIndex
var invertXAxis = openvrXAxisInvertToggle.checked
var invertYAxis = openvrYAxisInvertToggle.checked
var swapAxes = openvrAxisSwapToggle.checked
var lowerDeadzone = deadzonesRangeSlider.first.value
var upperDeadzone = deadzonesRangeSlider.second.value
AnalogInputRemappingController.finishConfigure_OpenVR(controllerId, mappedAxisId, invertXAxis, invertYAxis, swapAxes, lowerDeadzone, upperDeadzone)
}
goBack()
}
}
}


Component.onCompleted: {
}
Expand Down
114 changes: 80 additions & 34 deletions client_overlay/bin/win64/res/qml/DeviceDigitalBindingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ MyStackViewPage {
var _controllerNames = ["<No Change>"]
_controllerIds = []
for (var i = 0; i < DeviceManipulationTabController.getDeviceCount(); i++) {
_controllerNames.push(DeviceManipulationTabController.getDeviceSerial(i))
_controllerIds.push(DeviceManipulationTabController.getDeviceId(i))
var deviceId = DeviceManipulationTabController.getDeviceId(i)
var deviceName = deviceId.toString() + ": " + DeviceManipulationTabController.getDeviceSerial(i)
_controllerNames.push(deviceName)
_controllerIds.push(deviceId)
}
openVRControllerComboBox.model = _controllerNames
var _buttonNames = []
Expand Down Expand Up @@ -64,42 +66,18 @@ MyStackViewPage {
} else {
openVRControllerComboBox.currentIndex = 0
openvrButtonComboBox.currentIndex = 0
keyboardKeyComboBox.currentIndex = 0
keyboardShiftToggle.checked = false
keyboardCtrlToggle.checked = false
keyboardAltToggle.checked = false
toggleModeToggle.checked = false
toggleThresholdSlider.value = 300
autoTriggerToggle.checked = false
triggerFrequencySlider.value = 10
}
}

onPageBackButtonClicked: {
var toggleMode = toggleModeToggle.checked
var toggleDelay = toggleThresholdSlider.value
var autoTrigger = autoTriggerToggle.checked
var autoTriggerFreq = Math.round(triggerFrequencySlider.value * 100)
if (bindingTypeComboBox.currentIndex == 0) {
DigitalInputRemappingController.finishConfigureBinding_Original()
} else if (bindingTypeComboBox.currentIndex == 1) {
DigitalInputRemappingController.finishConfigureBinding_Disabled()
} else if (bindingTypeComboBox.currentIndex == 2) {
var controllerId = -1
if (openVRControllerComboBox.currentIndex > 0) {
var controllerId = _controllerIds[openVRControllerComboBox.currentIndex - 1]
}
var buttonId = openvrButtonComboBox.currentIndex
DigitalInputRemappingController.finishConfigureBinding_OpenVR(controllerId, buttonId, toggleMode, toggleDelay, autoTrigger, autoTriggerFreq)
} else if (bindingTypeComboBox.currentIndex == 3) {
var shift = keyboardShiftToggle.checked
var ctrl = keyboardCtrlToggle.checked
var alt = keyboardAltToggle.checked
var keyIndex = keyboardKeyComboBox.currentIndex
DigitalInputRemappingController.finishConfigureBinding_keyboard(shift, ctrl, alt, keyIndex, toggleMode, toggleDelay, autoTrigger, autoTriggerFreq)
} else if (bindingTypeComboBox.currentIndex == 4) {
DigitalInputRemappingController.finishConfigureBinding_suspendRedirectMode()
}
}

content: ColumnLayout {
spacing: 64

RowLayout {
MyText {
Expand Down Expand Up @@ -142,8 +120,9 @@ MyStackViewPage {

ColumnLayout {
id: openvrConfigContainer
Layout.topMargin: 48
visible: false
spacing: 18
spacing: 8

RowLayout {
MyText {
Expand Down Expand Up @@ -184,8 +163,9 @@ MyStackViewPage {

ColumnLayout {
id: keyboardConfigContainer
Layout.topMargin: 48
visible: false
spacing: 18
spacing: 8
RowLayout {
MyText {
Layout.preferredWidth: 200
Expand Down Expand Up @@ -226,26 +206,38 @@ MyStackViewPage {

ColumnLayout {
id: toggleModeContainer
Layout.topMargin: 48
visible: false
spacing: 18
spacing: 8

MyToggleButton {
id: toggleModeToggle
text: "Enable Toggle Mode"
onCheckedChanged: {
toggleThresholdLabel.enabled = checked
toggleThresholdMinusButton.enabled = checked
toggleThresholdPlusButton.enabled = checked
toggleThresholdSlider.enabled = checked
toggleThresholdText.enabled = checked
}
}

RowLayout {
spacing: 16

MyText {
id: toggleThresholdLabel
text: "Toggle Threshold:"
Layout.preferredWidth: 350
Layout.rightMargin: 12
enabled: false
}

MyPushButton2 {
id: toggleThresholdMinusButton
text: "-"
Layout.preferredWidth: 40
enabled: false
onClicked: {
toggleThresholdSlider.value -= 100
}
Expand All @@ -259,6 +251,7 @@ MyStackViewPage {
value: 300
snapMode: Slider.SnapAlways
Layout.fillWidth: true
enabled: false
onPositionChanged: {
var val = this.from + ( this.position * (this.to - this.from))
toggleThresholdText.text = val.toFixed(0) + " ms"
Expand All @@ -269,8 +262,10 @@ MyStackViewPage {
}

MyPushButton2 {
id: toggleThresholdPlusButton
text: "+"
Layout.preferredWidth: 40
enabled: false
onClicked: {
toggleThresholdSlider.value += 100
}
Expand All @@ -282,6 +277,7 @@ MyStackViewPage {
Layout.preferredWidth: 150
Layout.leftMargin: 10
horizontalAlignment: Text.AlignHCenter
enabled: false
function onInputEvent(input) {
var val = parseFloat(input)
if (!isNaN(val)) {
Expand All @@ -300,26 +296,38 @@ MyStackViewPage {

ColumnLayout {
id: autoTriggerContainer
Layout.topMargin: 48
visible: false
spacing: 18
spacing: 8

MyToggleButton {
id: autoTriggerToggle
text: "Enable Auto-Trigger"
onCheckedChanged: {
triggerFrequencyLabel.enabled = checked
triggerFrequencyMinusButton.enabled = checked
triggerFrequencyPlusButton.enabled = checked
triggerFrequencySlider.enabled = checked
triggerFrequencyText.enabled = checked
}
}

RowLayout {
spacing: 16

MyText {
id: triggerFrequencyLabel
text: "Trigger Frequency:"
Layout.preferredWidth: 350
Layout.rightMargin: 12
enabled: false
}

MyPushButton2 {
id: triggerFrequencyMinusButton
text: "-"
Layout.preferredWidth: 40
enabled: false
onClicked: {
triggerFrequencySlider.value -= 0.1
}
Expand All @@ -343,8 +351,10 @@ MyStackViewPage {
}

MyPushButton2 {
id: triggerFrequencyPlusButton
text: "+"
Layout.preferredWidth: 40
enabled: false
onClicked: {
triggerFrequencySlider.value += 0.1
}
Expand Down Expand Up @@ -378,6 +388,42 @@ MyStackViewPage {
Layout.fillHeight: true
}

RowLayout {
Item {
Layout.fillWidth: true
}
MyPushButton {
Layout.preferredWidth: 200
text: "Save"
onClicked: {
var toggleMode = toggleModeToggle.checked
var toggleDelay = toggleThresholdSlider.value
var autoTrigger = autoTriggerToggle.checked
var autoTriggerFreq = Math.round(triggerFrequencySlider.value * 100)
if (bindingTypeComboBox.currentIndex == 0) {
DigitalInputRemappingController.finishConfigureBinding_Original()
} else if (bindingTypeComboBox.currentIndex == 1) {
DigitalInputRemappingController.finishConfigureBinding_Disabled()
} else if (bindingTypeComboBox.currentIndex == 2) {
var controllerId = -1
if (openVRControllerComboBox.currentIndex > 0) {
var controllerId = _controllerIds[openVRControllerComboBox.currentIndex - 1]
}
var buttonId = openvrButtonComboBox.currentIndex
DigitalInputRemappingController.finishConfigureBinding_OpenVR(controllerId, buttonId, toggleMode, toggleDelay, autoTrigger, autoTriggerFreq)
} else if (bindingTypeComboBox.currentIndex == 3) {
var shift = keyboardShiftToggle.checked
var ctrl = keyboardCtrlToggle.checked
var alt = keyboardAltToggle.checked
var keyIndex = keyboardKeyComboBox.currentIndex
DigitalInputRemappingController.finishConfigureBinding_keyboard(shift, ctrl, alt, keyIndex, toggleMode, toggleDelay, autoTrigger, autoTriggerFreq)
} else if (bindingTypeComboBox.currentIndex == 4) {
DigitalInputRemappingController.finishConfigureBinding_suspendRedirectMode()
}
goBack()
}
}
}

Component.onCompleted: {
}
Expand Down
14 changes: 5 additions & 9 deletions client_overlay/bin/win64/res/qml/DeviceDigitalButtonEntry.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ RowLayout {
Layout.preferredWidth: 270
text: buttonName
}
MyText {
id: buttonStatusText
Layout.preferredWidth: 650
text: buttonStatus
}
MyPushButton {
Layout.preferredWidth: 150
text: "Configure"
id: configButton
Layout.preferredWidth: 840
text: buttonStatus
onClicked: {
DeviceManipulationTabController.startConfigureDigitalInputRemapping(deviceIndex, buttonId)
deviceDigitalInputRemappingPage.setDeviceIndex(deviceIndex, buttonId)
Expand All @@ -33,8 +29,8 @@ RowLayout {
Connections {
target: DeviceManipulationTabController
onConfigureDigitalInputRemappingFinished: {
var buttonStatus = DeviceManipulationTabController.getDigitalButtonStatus(deviceIndex, buttonId);
buttonStatusText.text = buttonStatus
buttonStatus = DeviceManipulationTabController.getDigitalButtonStatus(deviceIndex, buttonId);
configButton.text = buttonStatus
}
}
}
Loading

0 comments on commit 2c99d3e

Please sign in to comment.