diff --git a/advancedSettings.pro b/advancedSettings.pro index 09fb8d3..05d4ff1 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -21,6 +21,7 @@ SOURCES += src/main.cpp\ src/tabcontrollers/SettingsTabController.cpp \ src/tabcontrollers/StatisticsTabController.cpp \ src/tabcontrollers/SteamVRTabController.cpp \ + src/tabcontrollers/ReviveTabController.cpp \ src/tabcontrollers/audiomanager/AudioManagerWindows.cpp HEADERS += src/overlaycontroller.h \ @@ -32,6 +33,7 @@ HEADERS += src/overlaycontroller.h \ src/tabcontrollers/SettingsTabController.h \ src/tabcontrollers/StatisticsTabController.h \ src/tabcontrollers/SteamVRTabController.h \ + src/tabcontrollers/ReviveTabController.h \ src/tabcontrollers/AudioManager.h \ src/tabcontrollers/audiomanager/AudioManagerWindows.h diff --git a/bin/win64/res/qml/RevivePage.qml b/bin/win64/res/qml/RevivePage.qml index bce0a67..5463b24 100644 --- a/bin/win64/res/qml/RevivePage.qml +++ b/bin/win64/res/qml/RevivePage.qml @@ -12,8 +12,12 @@ MyStackViewPage { RowLayout { MyToggleButton { + id: pixelsPerDisplayPixelToggle text: "Render Target Override:" - Layout.rightMargin: 12 + Layout.preferredWidth: 350 + onCheckedChanged: { + ReviveTabController.setPixelsPerDisplayPixelOverrideEnabled(checked, false) + } } MyPushButton2 { @@ -36,6 +40,7 @@ MyStackViewPage { pixelsPerDisplayPixelText.text = val.toFixed(1) } onValueChanged: { + ReviveTabController.setPixelsPerDisplayPixelOverride(value) } } @@ -47,11 +52,27 @@ MyStackViewPage { } } - MyText { + MyTextField { id: pixelsPerDisplayPixelText - text: "1.0" - horizontalAlignment: Text.AlignRight - Layout.minimumWidth: 85 + text: "0.00" + keyBoardUID: 221 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.1) { + val = 0.1 + } + var v = val.toFixed(1) + pixelsPerDisplayPixelSlider.value = v + ReviveTabController.setPixelsPerDisplayPixelOverride(v, false) + text = v + } else { + text = ReviveTabController.pixelsPerDisplayPixelOverride.toFixed(1) + } + } } } @@ -59,17 +80,15 @@ MyStackViewPage { RowLayout { MyText { text: "Grip Button Mode:" - Layout.rightMargin: 12 + Layout.preferredWidth: 350 } MyComboBox { id: gripButtonModeComboBox - Layout.maximumWidth: 300 - Layout.minimumWidth: 300 - Layout.preferredWidth: 300 Layout.fillWidth: true model: ["Normal Mode", "Toggle Mode", "Hybrid Mode"] onCurrentIndexChanged: { + ReviveTabController.setGripButtonMode(currentIndex, false) } } } @@ -118,12 +137,15 @@ MyStackViewPage { id: thumbDeadzoneSlider from: 0.0 to: 1.0 - stepSize: 0.1 + stepSize: 0.01 value: 0.5 Layout.fillWidth: true onPositionChanged: { var val = this.from + ( this.position * (this.to - this.from)) - thumbDeadzoneText.text = val.toFixed(1) + thumbDeadzoneText.text = val.toFixed(2) + } + onValueChanged: { + ReviveTabController.setThumbDeadzone(value.toFixed(2)) } } @@ -136,11 +158,29 @@ MyStackViewPage { } } - MyText { + MyTextField { id: thumbDeadzoneText - Layout.preferredWidth: 85 - horizontalAlignment: Text.AlignRight - text: "1.0" + text: "0.00" + keyBoardUID: 222 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.0) { + val = 0.0 + } else if (val > 1.0) { + val = 1.0 + } + var v = val.toFixed(2) + thumbDeadzoneSlider.value = v + ReviveTabController.setThumbDeadzone(v, false) + text = v + } else { + text = ReviveTabController.thumbDeadzone.toFixed(2) + } + } } } @@ -161,14 +201,17 @@ MyStackViewPage { MySlider { id: thumbRangeSlider - from: 0.0 - to: 1.0 - stepSize: 0.1 - value: 0.5 + from: 1.0 + to: 5.0 + stepSize: 0.01 + value: 2.0 Layout.fillWidth: true onPositionChanged: { var val = this.from + ( this.position * (this.to - this.from)) - thumbRangeText.text = val.toFixed(1) + thumbRangeText.text = val.toFixed(2) + } + onValueChanged: { + ReviveTabController.setThumbRange(value.toFixed(2)) } } @@ -181,11 +224,27 @@ MyStackViewPage { } } - MyText { + MyTextField { id: thumbRangeText - Layout.preferredWidth: 85 - horizontalAlignment: Text.AlignRight - text: "1.0" + text: "0.00" + keyBoardUID: 223 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.01) { + val = 0.01 + } + var v = val.toFixed(2) + thumbRangeSlider.value = v + ReviveTabController.setThumbRange(v, false) + text = v + } else { + text = ReviveTabController.thumbRange.toFixed(2) + } + } } } } @@ -230,27 +289,35 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + var val = ReviveTabController.touchPitch - 0.1 + if (val < -180.0) { + val = -180.0 + } + ReviveTabController.setTouchPitch(val.toFixed(1)) } } - TextField { + MyTextField { id: touchPitchInputField + text: "0.00" + keyBoardUID: 201 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 201) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 201) { - touchPitchInputField.text = input + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < -180.0) { + val = -180.0 + } else if (val > 180.0) { + val = 180.0 } + var v = val.toFixed(1) + ReviveTabController.setTouchPitch(v, false) + text = v + "°" + } else { + text = ReviveTabController.touchPitch.toFixed(1) + "°" } } } @@ -260,6 +327,11 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + var val = ReviveTabController.touchPitch + 0.1 + if (val > 180.0) { + val = 180.0 + } + ReviveTabController.setTouchPitch(val.toFixed(1)) } } @@ -276,27 +348,35 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + var val = ReviveTabController.touchYaw - 0.1 + if (val < -180.0) { + val = -180.0 + } + ReviveTabController.setTouchYaw(val.toFixed(1)) } } - TextField { + MyTextField { id: touchYawInputField + text: "0.00" + keyBoardUID: 202 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 202) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 202) { - touchYawInputField.text = input + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < -180.0) { + val = -180.0 + } else if (val > 180.0) { + val = 180.0 } + var v = val.toFixed(1) + ReviveTabController.setTouchYaw(v, false) + text = v + "°" + } else { + text = ReviveTabController.touchYaw.toFixed(1) + "°" } } } @@ -306,6 +386,11 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + var val = ReviveTabController.touchYaw + 0.1 + if (val > 180.0) { + val = 180.0 + } + ReviveTabController.setTouchYaw(val.toFixed(1)) } } @@ -322,27 +407,35 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + var val = ReviveTabController.touchRoll - 0.1 + if (val < -180.0) { + val = -180.0 + } + ReviveTabController.setTouchRoll(val.toFixed(1)) } } - TextField { + MyTextField { id: touchRollInputField + text: "0.00" + keyBoardUID: 203 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 203) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 203) { - touchRollInputField.text = input + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < -180.0) { + val = -180.0 + } else if (val > 180.0) { + val = 180.0 } + var v = val.toFixed(1) + ReviveTabController.setTouchRoll(v, false) + text = v + "°" + } else { + text = ReviveTabController.touchRoll.toFixed(1) + "°" } } } @@ -352,6 +445,11 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + var val = ReviveTabController.touchRoll + 0.1 + if (val > 180.0) { + val = 180.0 + } + ReviveTabController.setTouchRoll(val.toFixed(1)) } } @@ -367,27 +465,26 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + ReviveTabController.setTouchX((ReviveTabController.touchX - 0.001).toFixed(3)) } } - TextField { + MyTextField { id: touchXInputField + text: "0.00" + keyBoardUID: 204 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 204) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 204) { - touchXInputField.text = input - } + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + var v = val.toFixed(3) + ReviveTabController.setTouchX(v, false) + text = v + } else { + text = ReviveTabController.touchX.toFixed(3) } } } @@ -397,6 +494,7 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + ReviveTabController.setTouchX((ReviveTabController.touchX + 0.001).toFixed(3)) } } @@ -413,27 +511,26 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + ReviveTabController.setTouchY((ReviveTabController.touchY - 0.001).toFixed(3)) } } - TextField { + MyTextField { id: touchYInputField + text: "0.00" + keyBoardUID: 205 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 205) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 205) { - touchYInputField.text = input - } + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + var v = val.toFixed(3) + ReviveTabController.setTouchY(v, false) + text = v + } else { + text = ReviveTabController.touchY.toFixed(3) } } } @@ -443,6 +540,7 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + ReviveTabController.setTouchY((ReviveTabController.touchY + 0.001).toFixed(3)) } } @@ -459,27 +557,26 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "-" onClicked: { + ReviveTabController.setTouchZ((ReviveTabController.touchZ - 0.001).toFixed(3)) } } - TextField { + MyTextField { id: touchZInputField + text: "0.00" + keyBoardUID: 206 + Layout.preferredWidth: 140 + Layout.leftMargin: 10 + Layout.rightMargin: 10 horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" - Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 206) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 206) { - touchZInputField.text = input - } + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + var v = val.toFixed(3) + ReviveTabController.setTouchZ(v, false) + text = v + } else { + text = ReviveTabController.touchZ.toFixed(3) } } } @@ -489,6 +586,7 @@ MyStackViewPage { Layout.preferredWidth: 40 text: "+" onClicked: { + ReviveTabController.setTouchZ((ReviveTabController.touchZ + 0.001).toFixed(3)) } } } @@ -498,164 +596,171 @@ MyStackViewPage { MyDialogOkCancelPopup { id: revivePersonalInfoDialog + property double playerHeight: 0.0 + property double eyeHeight: 0.0 dialogWidth: 600 - dialogHeight: 400 + dialogHeight: 440 dialogTitle: "Personal Information" dialogContentItem: GridLayout { + rowSpacing: 6 + columnSpacing: 18 columns: 2 MyText { text: "Username:" } - TextField { + MyTextField { id: rpidUsername - horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "Username" - Layout.preferredWidth: 250 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 211) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 211) { - rpidUsername.text = input - } - } + text: "0.00" + keyBoardUID: 211 + Layout.fillWidth: true + function onInputEvent(input) { + rpidUsername.text = input } } MyText { text: "Name:" } - - TextField { + MyTextField { id: rpidName - horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "Name" - Layout.preferredWidth: 250 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 212) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 212) { - rpidName.text = input - } - } + text: "0.00" + keyBoardUID: 212 + Layout.fillWidth: true + function onInputEvent(input) { + rpidName.text = input } } MyText { text: "Gender:" } - MyComboBox { id: rpidGender - Layout.maximumWidth: 300 - Layout.minimumWidth: 300 - Layout.preferredWidth: 300 Layout.fillWidth: true currentIndex: 2 - model: ["Male", "Female", "Unknown"] - onCurrentIndexChanged: { - } + model: ["Unknown", "Male", "Female"] } MyText { text: "Player Height:" } RowLayout { + Item { + Layout.fillWidth: true + } MyPushButton2 { id: pridPlayerHeighMinusButton Layout.preferredWidth: 40 text: "-" onClicked: { + if (revivePersonalInfoDialog.playerHeight > 0.01) { + revivePersonalInfoDialog.playerHeight = (revivePersonalInfoDialog.playerHeight - 0.01).toFixed(2) + } + pridPlayerHeighInputField.text = revivePersonalInfoDialog.playerHeight.toFixed(2) } } - - TextField { + MyTextField { id: pridPlayerHeighInputField - horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" + text: "0.00" + keyBoardUID: 213 Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 213) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 213) { - pridPlayerHeighInputField.text = input + Layout.leftMargin: 10 + Layout.rightMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.01) { + val = 0.01 } + revivePersonalInfoDialog.playerHeight = val.toFixed(2) + text = val.toFixed(2) + } else { + text = val.toFixed(2) } } } - MyPushButton2 { id: pridPlayerHeighPlusButton Layout.preferredWidth: 40 text: "+" onClicked: { + revivePersonalInfoDialog.playerHeight = (revivePersonalInfoDialog.playerHeight + 0.01).toFixed(2) + pridPlayerHeighInputField.text = revivePersonalInfoDialog.playerHeight.toFixed(2) } } + Item { + Layout.fillWidth: true + } } MyText { text: "Eye Height:" } RowLayout { + Item { + Layout.fillWidth: true + } MyPushButton2 { id: pridEyeHeighMinusButton Layout.preferredWidth: 40 text: "-" onClicked: { + if (revivePersonalInfoDialog.eyeHeight > 0.01) { + revivePersonalInfoDialog.eyeHeight = (revivePersonalInfoDialog.eyeHeight - 0.01).toFixed(2) + } + pridEyeHeighInputField.text = revivePersonalInfoDialog.eyeHeight.toFixed(2) } } - - TextField { + MyTextField { id: pridEyeHeighInputField - horizontalAlignment: Text.AlignHCenter - color: "#cccccc" - text: "0.0" + text: "0.00" + keyBoardUID: 214 Layout.preferredWidth: 120 - font.pointSize: 20 - onActiveFocusChanged: { - if (activeFocus) { - OverlayController.showKeyboard(text, 214) - } - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 214) { - pridEyeHeighInputField.text = input + Layout.leftMargin: 10 + Layout.rightMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.01) { + val = 0.01 } + revivePersonalInfoDialog.eyeHeight = val.toFixed(2) + text = val.toFixed(2) + } else { + text = val.toFixed(2) } } } - MyPushButton2 { id: pridEyeHeighPlusButton Layout.preferredWidth: 40 text: "+" onClicked: { + revivePersonalInfoDialog.eyeHeight = (revivePersonalInfoDialog.eyeHeight + 0.01).toFixed(2) + pridEyeHeighInputField.text = revivePersonalInfoDialog.eyeHeight.toFixed(2) } } + Item { + Layout.fillWidth: true + } } } function openPopup() { + rpidUsername.text = ReviveTabController.piUsername + rpidName.text = ReviveTabController.piName + rpidGender.currentIndex = ReviveTabController.piGender + playerHeight = ReviveTabController.piPlayerHeight + pridPlayerHeighInputField.text = playerHeight.toFixed(2) + eyeHeight = ReviveTabController.piEyeHeight + pridEyeHeighInputField.text = eyeHeight.toFixed(2) open() } onClosed: { + if (okClicked) { + ReviveTabController.setPiUsername(rpidUsername.text, false) + ReviveTabController.setPiName(rpidName.text, false) + ReviveTabController.setPiGender(rpidGender.currentIndex, false) + ReviveTabController.setPiPlayerHeight(playerHeight, false) + ReviveTabController.setPiEyeHeight(eyeHeight, false) + } } } @@ -672,10 +777,71 @@ MyStackViewPage { Layout.fillHeight: true } - /*Component.onCompleted: { - }*/ + Component.onCompleted: { + pixelsPerDisplayPixelToggle.checked = ReviveTabController.pixelsPerDisplayPixelOverrideEnabled + var v = ReviveTabController.pixelsPerDisplayPixelOverride.toFixed(1) + pixelsPerDisplayPixelSlider.value = v + pixelsPerDisplayPixelText.text = v - /*Connections { - }*/ + gripButtonModeComboBox.currentIndex = ReviveTabController.gripButtonMode + + v = ReviveTabController.thumbDeadzone.toFixed(2) + thumbDeadzoneSlider.value = v + thumbDeadzoneText.text = v + + v = ReviveTabController.thumbRange.toFixed(2) + thumbRangeSlider.value = v + thumbRangeText.text = v + + touchPitchInputField.text = ReviveTabController.touchPitch.toFixed(1) + "°" + touchYawInputField.text = ReviveTabController.touchYaw.toFixed(1) + "°" + touchRollInputField.text = ReviveTabController.touchRoll.toFixed(1) + "°" + touchXInputField.text = ReviveTabController.touchX.toFixed(3) + touchYInputField.text = ReviveTabController.touchY.toFixed(3) + touchZInputField.text = ReviveTabController.touchZ.toFixed(3) + } + + Connections { + target: ReviveTabController + onGripButtonModeChanged : { + gripButtonModeComboBox.currentIndex = ReviveTabController.gripButtonMode + } + onPixelsPerDisplayPixelOverrideEnabledChanged : { + pixelsPerDisplayPixelToggle.checked = ReviveTabController.pixelsPerDisplayPixelOverrideEnabled + } + onPixelsPerDisplayPixelOverrideChanged : { + var v = ReviveTabController.pixelsPerDisplayPixelOverride.toFixed(1) + pixelsPerDisplayPixelSlider.value = v + pixelsPerDisplayPixelText.text = v + } + onThumbDeadzoneChanged : { + var v = ReviveTabController.thumbDeadzone.toFixed(2) + thumbDeadzoneSlider.value = v + thumbDeadzoneText.text = v + } + onThumbRangeChanged : { + var v = ReviveTabController.thumbRange.toFixed(2) + thumbRangeSlider.value = v + thumbRangeText.text = v + } + onTouchPitchChanged : { + touchPitchInputField.text = ReviveTabController.touchPitch.toFixed(1) + "°" + } + onTouchYawChanged : { + touchYawInputField.text = ReviveTabController.touchYaw.toFixed(1) + "°" + } + onTouchRollChanged : { + touchRollInputField.text = ReviveTabController.touchRoll.toFixed(1) + "°" + } + onTouchXChanged : { + touchXInputField.text = ReviveTabController.touchX.toFixed(3) + } + onTouchYChanged : { + touchYInputField.text = ReviveTabController.touchY.toFixed(3) + } + onTouchZChanged : { + touchZInputField.text = ReviveTabController.touchZ.toFixed(3) + } + } } } diff --git a/bin/win64/res/qml/RootPage.qml b/bin/win64/res/qml/RootPage.qml index fd11fa2..5746443 100644 --- a/bin/win64/res/qml/RootPage.qml +++ b/bin/win64/res/qml/RootPage.qml @@ -81,6 +81,7 @@ MyStackViewPage { activationSoundEnabled: false text: "Revive" Layout.fillWidth: true + visible: ReviveTabController.isOverlayInstalled onClicked: { MyResources.playFocusChangedSound() mainView.push(revivePage) diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index 3721301..b56eb91 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -84,6 +84,7 @@ void OverlayController::Init(QQmlEngine* qmlEngine) { audioTabController.initStage1(); statisticsTabController.initStage1(); settingsTabController.initStage1(); + reviveTabController.initStage1(); // Set qml context qmlEngine->rootContext()->setContextProperty("applicationVersion", getVersionString()); @@ -130,6 +131,11 @@ void OverlayController::Init(QQmlEngine* qmlEngine) { QQmlEngine::setObjectOwnership(obj, QQmlEngine::CppOwnership); return obj; }); + qmlRegisterSingletonType("matzman666.advsettings", 1, 0, "ReviveTabController", [](QQmlEngine*, QJSEngine*) { + QObject* obj = &getInstance()->reviveTabController; + QQmlEngine::setObjectOwnership(obj, QQmlEngine::CppOwnership); + return obj; + }); } void OverlayController::Shutdown() { @@ -213,6 +219,7 @@ void OverlayController::SetWidget(QQuickItem* quickItem, const std::string& name audioTabController.initStage2(this, m_pWindow.get()); statisticsTabController.initStage2(this, m_pWindow.get()); settingsTabController.initStage2(this, m_pWindow.get()); + reviveTabController.initStage2(this, m_pWindow.get()); } @@ -265,6 +272,7 @@ void OverlayController::OnTimeoutPumpEvents() { steamVRTabController.eventLoopTick(); chaperoneTabController.eventLoopTick(); settingsTabController.eventLoopTick(); + reviveTabController.eventLoopTick(); audioTabController.eventLoopTick(); vr::VREvent_t vrEvent; diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 83e8f2c..3fcc629 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -29,6 +29,7 @@ #include "tabcontrollers/AudioTabController.h" #include "tabcontrollers/StatisticsTabController.h" #include "tabcontrollers/SettingsTabController.h" +#include "tabcontrollers/ReviveTabController.h" @@ -42,7 +43,7 @@ class OverlayController : public QObject { public: static constexpr const char* applicationKey = "matzman666.AdvancedSettings"; static constexpr const char* applicationName = "Advanced Settings"; - static constexpr const char* applicationVersionString = "v2.1"; + static constexpr const char* applicationVersionString = "v2.2a"; private: vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid; @@ -73,6 +74,7 @@ private: AudioTabController audioTabController; StatisticsTabController statisticsTabController; SettingsTabController settingsTabController; + ReviveTabController reviveTabController; private: OverlayController(bool desktopMode, bool noSound) : QObject(), desktopMode(desktopMode), noSound(noSound) {} diff --git a/src/tabcontrollers/ReviveTabController.cpp b/src/tabcontrollers/ReviveTabController.cpp new file mode 100644 index 0000000..731a27a --- /dev/null +++ b/src/tabcontrollers/ReviveTabController.cpp @@ -0,0 +1,585 @@ +#include "ReviveTabController.h" +#include +#include "../overlaycontroller.h" + +// application namespace +namespace advsettings { + + const char* appkey_overlay = "revive.dashboard.overlay"; + const char* section_revive = "revive"; + const char* key_pixelsPerDisplayPixel = "pixelsPerDisplayPixel"; + const char* key_toggleGrip = "ToggleGrip"; + const char* key_thumbDeadzone = "ThumbDeadzone"; + const char* key_thumbSensitivity = "ThumbSensitivity"; + const char* key_touchPitch = "TouchPitch"; + const char* key_touchYaw = "TouchYaw"; + const char* key_touchRoll = "TouchRoll"; + const char* key_touchX = "TouchX"; + const char* key_touchY = "TouchY"; + const char* key_touchZ = "TouchZ"; + const char* key_playerHeight = "PlayerHeight"; + const char* key_eyeHeight = "EyeHeight"; + const char* key_piUser = "User"; + const char* key_piName = "Name"; + const char* key_piGender = "Gender"; + + + void ReviveTabController::initStage1() { + m_isOverlayInstalled = vr::VRApplications()->IsApplicationInstalled(appkey_overlay); + if (m_isOverlayInstalled) { + vr::EVRSettingsError vrSettingsError; + + float valuef = vr::VRSettings()->GetFloat(section_revive, key_pixelsPerDisplayPixel, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_pixelsPerDisplayPixel << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + if (m_pixelsPerDisplayPixelOverride == 0.0) { + m_pixelsPerDisplayPixelOverrideEnabled = false; + m_pixelsPerDisplayPixelOverride = 1.0; + } else { + m_pixelsPerDisplayPixelOverrideEnabled = true; + m_pixelsPerDisplayPixelOverride = valuef; + } + } + + int valuei = vr::VRSettings()->GetInt32(section_revive, key_toggleGrip, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_toggleGrip << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_gripButtonMode = valuei; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_thumbDeadzone, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_thumbDeadzone << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_thumbDeadzone = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_thumbSensitivity, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_thumbSensitivity << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_thumbRange = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchPitch, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchPitch << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchPitch = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchYaw, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchYaw << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchYaw = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchRoll, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchRoll << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchRoll = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchX, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchX << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchX = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchY, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchY << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchY = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchZ, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_touchZ << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_touchZ = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_playerHeight, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_playerHeight << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_piPlayerHeight = valuef; + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_eyeHeight, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_eyeHeight << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_piEyeHeight = valuef; + } + + char buffer[1024]; + vr::VRSettings()->GetString(section_revive, key_piUser, buffer, 1024, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_piUser << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_piUsername = buffer; + } + + vr::VRSettings()->GetString(section_revive, key_piName, buffer, 1024, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_piName << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + m_piName = buffer; + } + + vr::VRSettings()->GetString(section_revive, key_piGender, buffer, 1024, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not read \"revive::" << key_piGender << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } else { + if (QString(buffer).compare("male", Qt::CaseInsensitive) == 0) { + m_piGender = 1; + } else if (QString(buffer).compare("female", Qt::CaseInsensitive) == 0) { + m_piGender = 2; + } else { + m_piGender = 0; + } + } + } + } + + void ReviveTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { + this->parent = parent; + this->widget = widget; + } + + void ReviveTabController::eventLoopTick() { + if (m_isOverlayInstalled) { + if (settingsUpdateCounter >= 50) { + settingsUpdateCounter = 0; + vr::EVRSettingsError vrSettingsError; + + float valuef = vr::VRSettings()->GetFloat(section_revive, key_pixelsPerDisplayPixel, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + if (valuef == 0.0) { + setPixelsPerDisplayPixelOverrideEnabled(false); + } else { + setPixelsPerDisplayPixelOverride(valuef); + } + } + + int valuei = vr::VRSettings()->GetInt32(section_revive, key_toggleGrip, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setGripButtonMode(valuei); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_thumbDeadzone, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setThumbDeadzone(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_thumbSensitivity, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setThumbRange(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchPitch, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchPitch(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchYaw, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchYaw(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchRoll, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchRoll(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchX, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchX(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchY, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchY(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_touchZ, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setTouchZ(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_playerHeight, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setPiPlayerHeight(valuef); + } + + valuef = vr::VRSettings()->GetFloat(section_revive, key_eyeHeight, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setPiEyeHeight(valuef); + } + + char buffer[1024]; + vr::VRSettings()->GetString(section_revive, key_piUser, buffer, 1024, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setPiUsername(buffer); + } + + vr::VRSettings()->GetString(section_revive, key_piName, buffer, 1024, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + setPiName(buffer); + } + + vr::VRSettings()->GetString(section_revive, key_piGender, buffer, 1024, &vrSettingsError); + if (vrSettingsError == vr::VRSettingsError_None) { + if (QString(buffer).compare("male", Qt::CaseInsensitive) == 0) { + valuei = 1; + } else if (QString(buffer).compare("female", Qt::CaseInsensitive) == 0) { + valuei = 2; + } else { + valuei = 0; + } + setPiGender(valuei); + } + } else { + settingsUpdateCounter++; + } + } + } + + bool ReviveTabController::isOverlayInstalled() const { + return m_isOverlayInstalled; + } + + int ReviveTabController::gripButtonMode() const { + return m_gripButtonMode; + } + + bool ReviveTabController::isPixelsPerDisplayPixelOverrideEnabled() const { + return m_pixelsPerDisplayPixelOverrideEnabled; + } + + float ReviveTabController::pixelsPerDisplayPixelOverride() const { + return m_pixelsPerDisplayPixelOverride; + } + + float ReviveTabController::thumbDeadzone() const { + return m_thumbDeadzone; + } + + float ReviveTabController::thumbRange() const { + return m_thumbRange; + } + + float ReviveTabController::touchPitch() const { + return m_touchPitch; + } + + float ReviveTabController::touchYaw() const { + return m_touchYaw; + } + + float ReviveTabController::touchRoll() const { + return m_touchRoll; + } + + float ReviveTabController::touchX() const { + return m_touchX; + } + + float ReviveTabController::touchY() const { + return m_touchY; + } + + float ReviveTabController::touchZ() const { + return m_touchZ; + } + + float ReviveTabController::piPlayerHeight() const { + return m_piPlayerHeight; + } + + float ReviveTabController::piEyeHeight() const { + return m_piEyeHeight; + } + + const QString& ReviveTabController::piUsername() const { + return m_piUsername; + } + + const QString& ReviveTabController::piName() const { + return m_piName; + } + + int ReviveTabController::piGender() const { + return m_piGender; + } + + void ReviveTabController::setGripButtonMode(int value, bool notify) { + if (m_gripButtonMode != value) { + m_gripButtonMode = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetInt32(section_revive, key_toggleGrip, m_gripButtonMode, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_toggleGrip << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit gripButtonModeChanged(m_gripButtonMode); + } + } + } + + void ReviveTabController::setPixelsPerDisplayPixelOverrideEnabled(bool value, bool notify) { + if (m_pixelsPerDisplayPixelOverrideEnabled != value) { + m_pixelsPerDisplayPixelOverrideEnabled = value; + if (m_pixelsPerDisplayPixelOverrideEnabled) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_pixelsPerDisplayPixel, m_pixelsPerDisplayPixelOverride, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_pixelsPerDisplayPixel << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + } else { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->RemoveKeyInSection(section_revive, key_pixelsPerDisplayPixel, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not remove \"revive::" << key_pixelsPerDisplayPixel << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + } + vr::VRSettings()->Sync(); + if (notify) { + emit pixelsPerDisplayPixelOverrideEnabledChanged(m_pixelsPerDisplayPixelOverrideEnabled); + } + } + } + + void ReviveTabController::setPixelsPerDisplayPixelOverride(float value, bool notify) { + if (m_pixelsPerDisplayPixelOverride != value) { + m_pixelsPerDisplayPixelOverride = value; + if (m_pixelsPerDisplayPixelOverrideEnabled) { + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_pixelsPerDisplayPixel, m_pixelsPerDisplayPixelOverride, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_pixelsPerDisplayPixel << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + } + if (notify) { + emit pixelsPerDisplayPixelOverrideChanged(m_pixelsPerDisplayPixelOverride); + } + } + } + + void ReviveTabController::setThumbDeadzone(float value, bool notify) { + if (m_thumbDeadzone != value) { + m_thumbDeadzone = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_thumbDeadzone, m_thumbDeadzone, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_thumbDeadzone << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit thumbDeadzoneChanged(m_thumbDeadzone); + } + } + } + + void ReviveTabController::setThumbRange(float value, bool notify) { + if (m_thumbRange != value) { + m_thumbRange = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_thumbSensitivity, m_thumbRange, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_thumbSensitivity << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit thumbRangeChanged(m_thumbRange); + } + } + } + + void ReviveTabController::setTouchPitch(float value, bool notify) { + if (m_touchPitch != value) { + m_touchPitch = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchPitch, m_touchPitch, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchPitch << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchPitchChanged(m_touchPitch); + } + } + } + + void ReviveTabController::setTouchYaw(float value, bool notify) { + if (m_touchYaw != value) { + m_touchYaw = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchYaw, m_touchYaw, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchYaw << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchYawChanged(m_touchYaw); + } + } + } + + void ReviveTabController::setTouchRoll(float value, bool notify) { + if (m_touchRoll != value) { + m_touchRoll = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchRoll, m_touchRoll, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchRoll << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchRollChanged(m_touchRoll); + } + } + } + + void ReviveTabController::setTouchX(float value, bool notify) { + if (m_touchX != value) { + m_touchX = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchX, m_touchX, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchX << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchXChanged(m_touchX); + } + } + } + + void ReviveTabController::setTouchY(float value, bool notify) { + if (m_touchY != value) { + m_touchY = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchY, m_touchY, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchY << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchYChanged(m_touchY); + } + } + } + + void ReviveTabController::setTouchZ(float value, bool notify) { + if (m_touchZ != value) { + m_touchZ = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_touchZ, m_touchZ, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_touchZ << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit touchZChanged(m_touchZ); + } + } + } + + void ReviveTabController::setPiPlayerHeight(float value, bool notify) { + if (m_piPlayerHeight != value) { + m_piPlayerHeight = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_playerHeight, m_piPlayerHeight, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_playerHeight << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit piPlayerHeightChanged(m_piPlayerHeight); + } + } + } + + void ReviveTabController::setPiEyeHeight(float value, bool notify) { + if (m_piEyeHeight != value) { + m_piEyeHeight = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetFloat(section_revive, key_eyeHeight, m_piEyeHeight, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_eyeHeight << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit piEyeHeightChanged(m_piEyeHeight); + } + } + } + + void ReviveTabController::setPiUsername(const QString& value, bool notify) { + if (m_piUsername.compare(value) != 0) { + m_piUsername = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(section_revive, key_piUser, m_piUsername.toStdString().c_str(), &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_piUser << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit piUsernameChanged(m_piUsername); + } + } + } + + void ReviveTabController::setPiName(const QString& value, bool notify) { + if (m_piName.compare(value) != 0) { + m_piName = value; + vr::EVRSettingsError vrSettingsError; + vr::VRSettings()->SetString(section_revive, key_piName, m_piName.toStdString().c_str(), &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_piName << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit piNameChanged(m_piName); + } + } + } + + void ReviveTabController::setPiGender(int value, bool notify) { + if (m_piGender != value) { + m_piGender = value; + vr::EVRSettingsError vrSettingsError; + char* txt; + switch (value) { + case 1: + txt = (char*)"Male"; + break; + case 2: + txt = (char*)"Female"; + break; + default: + txt = (char*)"Unknown"; + break; + } + vr::VRSettings()->SetString(section_revive, key_piGender, txt, &vrSettingsError); + if (vrSettingsError != vr::VRSettingsError_None) { + LOG(WARNING) << "Could not set \"revive::" << key_piGender << "\" setting: " << vr::VRSettings()->GetSettingsErrorNameFromEnum(vrSettingsError); + } + vr::VRSettings()->Sync(); + if (notify) { + emit piGenderChanged(m_piGender); + } + } + } + +} // namespace advconfig diff --git a/src/tabcontrollers/ReviveTabController.h b/src/tabcontrollers/ReviveTabController.h new file mode 100644 index 0000000..e2bda1b --- /dev/null +++ b/src/tabcontrollers/ReviveTabController.h @@ -0,0 +1,135 @@ + +#pragma once + +#include + +class QQuickWindow; +// application namespace +namespace advsettings { + + + // forward declaration + class OverlayController; + + + class ReviveTabController : public QObject { + Q_OBJECT + Q_PROPERTY(int isOverlayInstalled READ isOverlayInstalled NOTIFY isOverlayInstalledChanged) + Q_PROPERTY(int gripButtonMode READ gripButtonMode WRITE setGripButtonMode NOTIFY gripButtonModeChanged) + Q_PROPERTY(bool pixelsPerDisplayPixelOverrideEnabled READ isPixelsPerDisplayPixelOverrideEnabled WRITE setPixelsPerDisplayPixelOverrideEnabled NOTIFY pixelsPerDisplayPixelOverrideEnabledChanged) + Q_PROPERTY(float pixelsPerDisplayPixelOverride READ pixelsPerDisplayPixelOverride WRITE setPixelsPerDisplayPixelOverride NOTIFY pixelsPerDisplayPixelOverrideChanged) + Q_PROPERTY(float thumbDeadzone READ thumbDeadzone WRITE setThumbDeadzone NOTIFY thumbDeadzoneChanged) + Q_PROPERTY(float thumbRange READ thumbRange WRITE setThumbRange NOTIFY thumbRangeChanged) + Q_PROPERTY(float touchPitch READ touchPitch WRITE setTouchPitch NOTIFY touchPitchChanged) + Q_PROPERTY(float touchYaw READ touchYaw WRITE setTouchYaw NOTIFY touchYawChanged) + Q_PROPERTY(float touchRoll READ touchRoll WRITE setTouchRoll NOTIFY touchRollChanged) + Q_PROPERTY(float touchX READ touchX WRITE setTouchX NOTIFY touchXChanged) + Q_PROPERTY(float touchY READ touchY WRITE setTouchY NOTIFY touchYChanged) + Q_PROPERTY(float touchZ READ touchZ WRITE setTouchZ NOTIFY touchZChanged) + Q_PROPERTY(float piPlayerHeight READ piPlayerHeight WRITE setPiPlayerHeight NOTIFY piPlayerHeightChanged) + Q_PROPERTY(float piEyeHeight READ piEyeHeight WRITE setPiEyeHeight NOTIFY piEyeHeightChanged) + Q_PROPERTY(QString piUsername READ piUsername WRITE setPiUsername NOTIFY piUsernameChanged) + Q_PROPERTY(QString piName READ piName WRITE setPiName NOTIFY piNameChanged) + Q_PROPERTY(int piGender READ piGender WRITE setPiGender NOTIFY piGenderChanged) + + private: + OverlayController* parent; + QQuickWindow* widget; + + bool m_isOverlayInstalled = false; + int m_gripButtonMode = 0; + bool m_pixelsPerDisplayPixelOverrideEnabled = false; + float m_pixelsPerDisplayPixelOverride = 1.0; + float m_thumbDeadzone = 0.3f; + float m_thumbRange = 2.0f; + float m_touchPitch = -28.0f; + float m_touchYaw = 0.0f; + float m_touchRoll = -14.0f; + float m_touchX = 0.016f; + float m_touchY = 0.0f; + float m_touchZ = 0.016f; + float m_piPlayerHeight = 1.778f; + float m_piEyeHeight = 1.675f; + QString m_piUsername = ""; + QString m_piName = ""; + int m_piGender = 0; // 0 .. Unknown, 1 .. Male, 2 .. Female + + unsigned settingsUpdateCounter = 0; + + public: + void initStage1(); + void initStage2(OverlayController* parent, QQuickWindow* widget); + + void eventLoopTick(); + + bool isOverlayInstalled() const; + + int gripButtonMode() const; + + bool isPixelsPerDisplayPixelOverrideEnabled() const; + float pixelsPerDisplayPixelOverride() const; + + float thumbDeadzone() const; + float thumbRange() const; + + float touchPitch() const; + float touchYaw() const; + float touchRoll() const; + float touchX() const; + float touchY() const; + float touchZ() const; + + float piPlayerHeight() const; + float piEyeHeight() const; + const QString& piUsername() const; + const QString& piName() const; + int piGender() const; // 0 .. Unknown, 1 .. Male, 2 .. Female + + public slots: + void setGripButtonMode(int value, bool notify = true); + + void setPixelsPerDisplayPixelOverrideEnabled(bool value, bool notify = true); + void setPixelsPerDisplayPixelOverride(float value, bool notify = true); + + void setThumbDeadzone(float value, bool notify = true); + void setThumbRange(float value, bool notify = true); + + void setTouchPitch(float value, bool notify = true); + void setTouchYaw(float value, bool notify = true); + void setTouchRoll(float value, bool notify = true); + void setTouchX(float value, bool notify = true); + void setTouchY(float value, bool notify = true); + void setTouchZ(float value, bool notify = true); + + void setPiPlayerHeight(float value, bool notify = true); + void setPiEyeHeight(float value, bool notify = true); + void setPiUsername(const QString& value, bool notify = true); + void setPiName(const QString& value, bool notify = true); + void setPiGender(int value, bool notify = true); // 0 .. Unknown, 1 .. Male, 2 .. Female + + signals: + void isOverlayInstalledChanged(bool value); + + void gripButtonModeChanged(int value); + + void pixelsPerDisplayPixelOverrideEnabledChanged(bool value); + void pixelsPerDisplayPixelOverrideChanged(float value); + + void thumbDeadzoneChanged(float value); + void thumbRangeChanged(float value); + + void touchPitchChanged(float value); + void touchYawChanged(float value); + void touchRollChanged(float value); + void touchXChanged(float value); + void touchYChanged(float value); + void touchZChanged(float value); + + void piPlayerHeightChanged(float value); + void piEyeHeightChanged(float value); + void piUsernameChanged(const QString& value); + void piNameChanged(const QString& value); + void piGenderChanged(int value); + }; + +} // namespace advsettings