From ef6788840568a831c54baa6be4167cec2767fb62 Mon Sep 17 00:00:00 2001 From: ykeara Date: Sat, 27 Apr 2019 17:47:46 -0500 Subject: [PATCH] WMR default binding, Toggle Chaperone Action, frame timing graph, prox sensor back-end (#182) * perf graph overlay/checkbox added * added toggle Chaperone action * toggle chaperone non-functional * fixed chaperone toggle action const to once * Added Proximity Sensor Action back-end, not implemented via logic Until fixed by valve * added default WMR controller profile * formated * formated steamvrtabcontroller.h * fixed un-intended change --- installer/installer.nsi | 4 +- src/openvr/ivrinput.cpp | 12 ++ src/openvr/ivrinput.h | 11 ++ src/overlaycontroller.cpp | 11 ++ src/overlaycontroller.h | 1 + src/package_files/action_manifest.json | 24 +++- ...ras-team.advancedsettings_default_hmd.json | 23 ++++ ...ras-team.advancedsettings_default_wmr.json | 114 ++++++++++++++++++ src/res/qml/SteamVRPage.qml | 12 ++ src/tabcontrollers/SteamVRTabController.cpp | 51 ++++++++ src/tabcontrollers/SteamVRTabController.h | 7 ++ src/tabcontrollers/VideoTabController.cpp | 2 +- 12 files changed, 268 insertions(+), 4 deletions(-) create mode 100644 src/package_files/default_action_manifests/ovras-team.advancedsettings_default_hmd.json create mode 100644 src/package_files/default_action_manifests/ovras-team.advancedsettings_default_wmr.json diff --git a/installer/installer.nsi b/installer/installer.nsi index 69d5fd9..e44b6e8 100644 --- a/installer/installer.nsi +++ b/installer/installer.nsi @@ -116,9 +116,9 @@ Section "Install" SecInstall File "${BASEDIR}\*.exe" ;Any action manifests - File "${BASEDIR}\*.json" + File "${PACKAGEDIR}\*.json" ;And their defaults - File /r "${BASEDIR}\default_action_manifests" + File /r "${PACKAGEDIR}\default_action_manifests" File "${THIRDDIR}\openvr\bin\win64\*.dll" File "${BASEDIR}\*.dll" diff --git a/src/openvr/ivrinput.cpp b/src/openvr/ivrinput.cpp index 13138f0..be89508 100644 --- a/src/openvr/ivrinput.cpp +++ b/src/openvr/ivrinput.cpp @@ -131,9 +131,11 @@ SteamIVRInput::SteamIVRInput() m_xAxisLockToggle( action_keys::xAxisLockToggle ), m_yAxisLockToggle( action_keys::yAxisLockToggle ), m_zAxisLockToggle( action_keys::zAxisLockToggle ), + m_chaperoneToggle( action_keys::chaperoneToggle ), m_pushToTalk( action_keys::pushToTalk ), m_leftHaptic( action_keys::hapticsLeft ), m_rightHaptic( action_keys::hapticsRight ), + m_proxSensor( action_keys::proxSensor ), m_leftHand( input_keys::leftHand ), m_rightHand( input_keys::rightHand ), m_sets( { m_mainSet.activeActionSet(), m_music.activeActionSet(), @@ -290,6 +292,16 @@ bool SteamIVRInput::pushToTalk() return isDigitalActionActivatedConstant( m_pushToTalk ); } +bool SteamIVRInput::chaperoneToggle() +{ + return isDigitalActionActivatedOnce( m_chaperoneToggle ); +} + +bool SteamIVRInput::proxState() +{ + return isDigitalActionActivatedConstant( m_pushToTalk ); +} + /*! Returns the action handle of the Left Haptic Action */ diff --git a/src/openvr/ivrinput.h b/src/openvr/ivrinput.h index 1399166..13b3f3b 100644 --- a/src/openvr/ivrinput.h +++ b/src/openvr/ivrinput.h @@ -51,6 +51,9 @@ namespace action_keys constexpr auto hapticsLeft = "/actions/haptic/out/HapticsLeft"; constexpr auto hapticsRight = "/actions/haptic/out/HapticsRight"; + constexpr auto proxSensor = "/actions/misc/in/ProxSensor"; + + constexpr auto chaperoneToggle = "/actions/misc/in/ChaperoneToggle"; } // namespace action_keys @@ -131,6 +134,8 @@ public: bool xAxisLockToggle(); bool yAxisLockToggle(); bool zAxisLockToggle(); + bool chaperoneToggle(); + bool proxState(); bool pushToTalk(); @@ -192,6 +197,9 @@ private: DigitalAction m_yAxisLockToggle; DigitalAction m_zAxisLockToggle; + // Misc Bindings + DigitalAction m_chaperoneToggle; + // Push To Talk DigitalAction m_pushToTalk; @@ -199,6 +207,9 @@ private: DigitalAction m_leftHaptic; DigitalAction m_rightHaptic; + // prox Sensor + DigitalAction m_proxSensor; + // input sources InputSource m_leftHand; InputSource m_rightHand; diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index 94a1754..dddf612 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -558,6 +558,15 @@ void OverlayController::processMotionBindings() m_actions.swapSpaceDragToRightHandOverride() ); } +void OverlayController::processChaperoneBindings() +{ + if ( m_actions.chaperoneToggle() ) + { + m_chaperoneTabController.setDisableChaperone( + !( m_chaperoneTabController.disableChaperone() ), true ); + } +} + void OverlayController::processPushToTalkBindings() { const auto pushToTalkCannotChange = !m_audioTabController.pttChangeValid(); @@ -590,6 +599,8 @@ void OverlayController::processInputBindings() processMotionBindings(); processPushToTalkBindings(); + + processChaperoneBindings(); } // vsync implementation: diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index a33119b..8b3f752 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -134,6 +134,7 @@ private: void processMediaKeyBindings(); void processMotionBindings(); void processPushToTalkBindings(); + void processChaperoneBindings(); public: OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine ); diff --git a/src/package_files/action_manifest.json b/src/package_files/action_manifest.json index 19d93c6..4bcf9a6 100644 --- a/src/package_files/action_manifest.json +++ b/src/package_files/action_manifest.json @@ -4,10 +4,19 @@ "controller_type": "vive_controller", "binding_url": "default_action_manifests/ovras-team.advancedsettings_default_vive_controller.json" }, + { + "controller_type": "holographic_controller", + "binding_url": "default_action_manifests/ovras-team.advancedsettings_default_wmr.json" + }, { "controller_type": "knuckles", "binding_url": "default_action_manifests/ovras-team.advancedsettings_default_knuckles.json" + }, + { + "controller_type": "generic_hmd", + "binding_url": "default_action_manifests/ovras-team.advancedsettings_default_hmd.json" } + ], "actions": [ { @@ -141,7 +150,18 @@ "name": "/actions/misc/in/PushToTalk", "requirement": "optional", "type": "boolean" + }, + { + "name": "/actions/misc/in/ChaperoneToggle", + "requirement": "optional", + "type": "boolean" + }, + { + "name": "/actions/misc/in/ProxSensor", + "requirement": "optional", + "type": "boolean" } + ], "action_sets": [ { @@ -198,7 +218,9 @@ "/actions/misc/in/XAxisLockToggle" : "X-Axis Lock Toggle", "/actions/misc/in/YAxisLockToggle" : "Y-Axis Lock Toggle", "/actions/misc/in/ZAxisLockToggle" : "Z-Axis Lock Toggle", - "/actions/misc/in/PushToTalk" : "Push To Talk" + "/actions/misc/in/PushToTalk" : "Push To Talk", + "/actions/misc/in/ChaperoneToggle" : "Chaperone Toggle", + "/actions/misc/in/ProxSensor" : "Proximity Sensor" } ] } \ No newline at end of file diff --git a/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_hmd.json b/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_hmd.json new file mode 100644 index 0000000..d615f09 --- /dev/null +++ b/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_hmd.json @@ -0,0 +1,23 @@ +{ + "name": "OVRAS HMD default", + "controller_type": "generic_hmd", + "alias_info" : {}, + "app_key" : "ovras-team.advancedsettings", + "bindings": + { + "/actions/misc" : { + "sources" : [ + { + "inputs" : { + "click" : { + "output" : "/actions/misc/in/ProxSensor" + } + }, + "mode" : "button", + "path" : "/user/head/proximity" + } + ] + } + }, + "description": "" +} \ No newline at end of file diff --git a/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_wmr.json b/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_wmr.json new file mode 100644 index 0000000..865463e --- /dev/null +++ b/src/package_files/default_action_manifests/ovras-team.advancedsettings_default_wmr.json @@ -0,0 +1,114 @@ +{ + "alias_info" : {}, + "app_key" : "ovras-team.advancedsettings", + "bindings" : { + "/actions/haptic": { + "haptics": [ + { + "path": "/user/hand/left/output/haptic", + "output": "/actions/haptic/out/hapticsleft" + }, + { + "path": "/user/hand/right/output/haptic", + "output": "/actions/haptic/out/hapticsright" + } + ], + "sources": [ + { + "path": "/user/hand/right/input/trigger", + "mode": "none", + "inputs": {} + }, + { + "path": "/user/hand/left/input/application_menu", + "mode": "none", + "inputs": {} + }, + { + "path": "/user/hand/right/input/application_menu", + "mode": "none", + "inputs": {} + } + ] + }, + "/actions/motion": { + "sources": [ + { + "path": "/user/hand/left/input/application_menu", + "mode": "button", + "inputs": { + "click": { + "output": "/actions/motion/in/lefthandspaceturn" + } + } + }, + { + "path": "/user/hand/right/input/application_menu", + "mode": "button", + "inputs": { + "click": { + "output": "/actions/motion/in/righthandspaceturn" + } + } + }, + { + "path": "/user/hand/left/input/application_menu", + "mode": "button", + "inputs": { + "double": { + "output": "/actions/motion/in/lefthandspacedrag" + } + } + }, + { + "path": "/user/hand/left/input/application_menu", + "mode": "button", + "inputs": { + "click": { + "output": "/actions/motion/in/swapspacedragtolefthandoverride" + } + } + }, + { + "path": "/user/hand/right/input/application_menu", + "mode": "button", + "inputs": { + "double": { + "output": "/actions/motion/in/righthandspacedrag" + } + } + }, + { + "path": "/user/hand/right/input/application_menu", + "mode": "button", + "inputs": { + "click": { + "output": "/actions/motion/in/swapspacedragtorighthandoverride" + } + } + } + ] + }, + "/actions/misc": { + "sources": [ + { + "path": "/user/hand/right/input/trackpad", + "mode": "dpad", + "parameters": { + "sub_mode": "click" + }, + "inputs": { + "south": { + "output": "/actions/misc/in/pushtotalk" + } + } + } + ] + } +}, + "controller_type" : "holographic_controller", + "description" : "", + "name" : "OVRAS WMR Default", + "options" : {}, + "simulated_actions" : [] +} diff --git a/src/res/qml/SteamVRPage.qml b/src/res/qml/SteamVRPage.qml index 6eda7b7..6eaab28 100644 --- a/src/res/qml/SteamVRPage.qml +++ b/src/res/qml/SteamVRPage.qml @@ -276,6 +276,14 @@ MyStackViewPage { } } + MyToggleButton { + id: steamvrPerformanceGraphToggle + text: "Enable timing overlay" + onCheckedChanged: { + SteamVRTabController.setPerformanceGraph(this.checked, false) + } + } + Item { Layout.fillHeight: true; Layout.fillWidth: true} RowLayout { @@ -310,6 +318,7 @@ MyStackViewPage { steamvrAllowSupersampleOverrideToggle.checked = SteamVRTabController.allowSupersampleOverride steamvrAllowSupersampleFilteringToggle.checked = SteamVRTabController.allowSupersampleFiltering steamvrMotionSmoothingToggle.checked = SteamVRTabController.motionSmoothing + steamvrPerformanceGraphToggle.checked = SteamVRTabController.performanceGraph if(!steamvrAllowSupersampleOverrideToggle.checked){ steamvrSupersamplingText.enabled = false steamvrSupersamplingSlider.enabled = false @@ -339,6 +348,9 @@ MyStackViewPage { onMotionSmoothingChanged: { steamvrMotionSmoothingToggle.checked = SteamVRTabController.motionSmoothing } + onPerformanceGraphChanged:{ + steamvrPerformanceGraphToggle.checked = SteamVRTabController.performanceGraph + } onSteamVRProfilesUpdated: { reloadSteamVRProfiles() diff --git a/src/tabcontrollers/SteamVRTabController.cpp b/src/tabcontrollers/SteamVRTabController.cpp index d7912de..c655ffc 100644 --- a/src/tabcontrollers/SteamVRTabController.cpp +++ b/src/tabcontrollers/SteamVRTabController.cpp @@ -103,6 +103,21 @@ void SteamVRTabController::eventLoopTick() vrSettingsError ); } setMotionSmoothing( ms ); + + // Checks and synchs performance graph + auto pg + = vr::VRSettings()->GetBool( vr::k_pch_Perf_Section, + vr::k_pch_Perf_PerfGraphInHMD_Bool, + &vrSettingsError ); + if ( vrSettingsError != vr::VRSettingsError_None ) + { + LOG( WARNING ) + << "Could not read \"" << vr::k_pch_Perf_PerfGraphInHMD_Bool + << "\" setting: " + << vr::VRSettings()->GetSettingsErrorNameFromEnum( + vrSettingsError ); + } + setPerformanceGraph( pg ); } settingsUpdateCounter = 0; } @@ -447,6 +462,31 @@ void SteamVRTabController::initSupersampleOverride() /*------------------------------------------*/ /* -----------------------------------------*/ +bool SteamVRTabController::performanceGraph() const +{ + return m_performanceGraphToggle; +} + +void SteamVRTabController::setPerformanceGraph( const bool value, + const bool notify ) +{ + if ( m_performanceGraphToggle != value ) + { + m_performanceGraphToggle = value; + vr::VRSettings()->SetBool( vr::k_pch_Perf_Section, + vr::k_pch_Perf_PerfGraphInHMD_Bool, + m_performanceGraphToggle ); + vr::VRSettings()->Sync(); + if ( notify ) + { + emit performanceGraphChanged( m_performanceGraphToggle ); + } + } +} + +/*------------------------------------------*/ +/* -----------------------------------------*/ + void SteamVRTabController::reset() { vr::EVRSettingsError vrSettingsError; @@ -516,6 +556,17 @@ void SteamVRTabController::reset() vrSettingsError ); } + vr::VRSettings()->RemoveKeyInSection( vr::k_pch_Perf_Section, + vr::k_pch_Perf_PerfGraphInHMD_Bool, + &vrSettingsError ); + if ( vrSettingsError != vr::VRSettingsError_None ) + { + LOG( WARNING ) << "Could not remove \"" + << vr::k_pch_Perf_PerfGraphInHMD_Bool << "\" setting: " + << vr::VRSettings()->GetSettingsErrorNameFromEnum( + vrSettingsError ); + } + vr::VRSettings()->Sync(); settingsUpdateCounter = 999; // Easiest way to get default values } diff --git a/src/tabcontrollers/SteamVRTabController.h b/src/tabcontrollers/SteamVRTabController.h index 1974bc6..c6d78ec 100644 --- a/src/tabcontrollers/SteamVRTabController.h +++ b/src/tabcontrollers/SteamVRTabController.h @@ -39,6 +39,9 @@ class SteamVRTabController : public QObject bool allowSupersampleOverride READ allowSupersampleOverride WRITE setAllowSupersampleOverride NOTIFY allowSupersampleOverrideChanged ) + Q_PROPERTY( bool performanceGraph READ performanceGraph WRITE + setPerformanceGraph NOTIFY performanceGraphChanged ) + private: OverlayController* parent; QQuickWindow* widget; @@ -47,6 +50,7 @@ private: bool m_motionSmoothing = true; bool m_allowSupersampleFiltering = true; bool m_allowSupersampleOverride = false; + bool m_performanceGraphToggle = false; void initMotionSmoothing(); void initSupersampleOverride(); @@ -65,6 +69,7 @@ public: bool motionSmoothing() const; bool allowSupersampleFiltering() const; bool allowSupersampleOverride() const; + bool performanceGraph() const; void reloadSteamVRProfiles(); void saveSteamVRProfiles(); @@ -77,6 +82,7 @@ public slots: void setMotionSmoothing( bool value, bool notify = true ); void setAllowSupersampleFiltering( bool value, bool notify = true ); void setAllowSupersampleOverride( bool value, bool notify = true ); + void setPerformanceGraph( bool value, bool notify = true ); void addSteamVRProfile( QString name, bool includeSupersampling, @@ -93,6 +99,7 @@ signals: void motionSmoothingChanged( bool value ); void allowSupersampleFilteringChanged( bool value ); void allowSupersampleOverrideChanged( bool value ); + void performanceGraphChanged( bool value ); void steamVRProfilesUpdated(); void steamVRProfileAdded(); diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp index 162653e..dadb48a 100644 --- a/src/tabcontrollers/VideoTabController.cpp +++ b/src/tabcontrollers/VideoTabController.cpp @@ -172,4 +172,4 @@ void VideoTabController::setOpacityValue() } emit brightnessValueChanged( m_brightnessValue ); } -} // namespace advsettings \ No newline at end of file +} // namespace advsettings