Skip to content

Commit 1cfd9ff

Browse files
feilenykeara
andauthored
Option to gently fade chaperone to disabled below a certain height (#622)
* Option to fade out chaperone when HMD goes below a configured height Useful for setups in which you have a seat just outside your VR space, or like to sit in the middle of your space for any amount of time. Will fade out the boundaries to 0% opacity over 5 seconds, 5 seconds after you sit down. Standing back up to the configured height will make them pop back in immediately. Can be found under Chaperone -> Additional Settings. * Update format.sh to require clang-format v10 * Use fade distance instead of opacity, opacity inconsistently applied * Bugfixes (#624) * stop crashing on HMD Init Errors, as well as bypass force quit on all steamvr Init Errors * add qtc clang to gitignore * add app volume adjustment * adjust app volume placement in menu * fix type error * increment version * fix version number --------- Co-authored-by: ykeara <[email protected]>
1 parent 65b5aac commit 1cfd9ff

File tree

14 files changed

+339
-13
lines changed

14 files changed

+339
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ installer/*.exe
1515
build_scripts/win/__pycache__
1616
build_scripts/win/current_build.bat
1717
AdvancedSettings_resource.rc
18+
.qtc_clangd/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.6.2-release
1+
5.7.0-release

build_scripts/linux/format.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
clang-format --version
4+
if [ -x /usr/bin/clang-format-10 ]; then
5+
CLANG_FORMAT_EXE=clang-format-10
6+
else
7+
CLANG_FORMAT_EXE=clang-format
8+
fi
9+
10+
CLANG_VERSION="$($CLANG_FORMAT_EXE --version)"
11+
echo $CLANG_VERSION
12+
if [[ "$CLANG_VERSION" != *"clang-format version 10"* ]]; then
13+
echo "Wrong clang-format version found! Install version 10"
14+
exit 1
15+
fi
516

617
if [ $? -eq 0 ]; then
718
echo "Clang-format found."
819
build_path="`dirname \"$0\"`"
920
project_path=$build_path/../..
1021

11-
find $project_path/src/ -regex '.*\.\(cpp\|h\)' -exec clang-format -style=file -i {} \; -exec echo "Iteration 1: {}" \;
12-
find $project_path/src/ -regex '.*\.\(cpp\|h\)' -exec clang-format -style=file -i {} \; -exec echo "Iteration 2: {}" \;
22+
find $project_path/src/ -regex '.*\.\(cpp\|h\)' -exec $CLANG_FORMAT_EXE -style=file -i {} \; -exec echo "Iteration 1: {}" \;
23+
find $project_path/src/ -regex '.*\.\(cpp\|h\)' -exec $CLANG_FORMAT_EXE -style=file -i {} \; -exec echo "Iteration 2: {}" \;
1324
echo "DONE"
1425
else
15-
echo "Could not find clang-format."
26+
echo "Could not find clang-format-10."
1627
fi
1728

src/openvr/openvr_init.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,25 @@ void initializeProperly( const OpenVrInitializationType initType )
2626
if ( initError == vr::VRInitError_Init_HmdNotFound
2727
|| initError == vr::VRInitError_Init_HmdNotFoundPresenceFailed )
2828
{
29-
QMessageBox::critical( nullptr,
30-
"OpenVR Advanced Settings Overlay",
31-
"Could not find HMD!" );
29+
// In particular in some setups these errors are thrown while
30+
// nothing is wrong with their setup presumably this is some sort of
31+
// race condition
32+
LOG( WARNING ) << "HMD not Found During Startup";
33+
LOG( WARNING ) << "steamvr error: "
34+
+ std::string(
35+
vr::VR_GetVRInitErrorAsEnglishDescription(
36+
initError ) );
37+
return;
3238
}
3339
LOG( ERROR ) << "Failed to initialize OpenVR: "
3440
+ std::string(
3541
vr::VR_GetVRInitErrorAsEnglishDescription(
3642
initError ) );
37-
exit( EXIT_FAILURE );
43+
// Going to stop Exiting App, This may lead to crashes if OpenVR
44+
// actually fails to start, HOWEVER based on the HMD errors we are
45+
// probably pre-maturely killing ourselves from some sort of OpenVR race
46+
// condition
47+
// exit( EXIT_FAILURE );
3848
}
3949
else
4050
{

src/overlaycontroller.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ OverlayController::OverlayController( bool desktopMode,
6969
m_runtimePathUrl = QUrl::fromLocalFile( tempRuntimePath );
7070
LOG( INFO ) << "VR Runtime Path: " << m_runtimePathUrl.toLocalFile();
7171

72+
const double initVol = soundVolume();
7273
constexpr auto clickSoundURL = "res/sounds/click.wav";
7374
const auto activationSoundFile
7475
= paths::binaryDirectoryFindFile( clickSoundURL );
@@ -77,7 +78,7 @@ OverlayController::OverlayController( bool desktopMode,
7778
{
7879
m_activationSoundEffect.setSource( QUrl::fromLocalFile(
7980
QString::fromStdString( ( *activationSoundFile ) ) ) );
80-
m_activationSoundEffect.setVolume( 0.7 );
81+
m_activationSoundEffect.setVolume( initVol );
8182
}
8283
else
8384
{
@@ -92,7 +93,7 @@ OverlayController::OverlayController( bool desktopMode,
9293
{
9394
m_focusChangedSoundEffect.setSource( QUrl::fromLocalFile(
9495
QString::fromStdString( ( *focusChangedSoundFile ) ) ) );
95-
m_focusChangedSoundEffect.setVolume( 0.7 );
96+
m_focusChangedSoundEffect.setVolume( initVol );
9697
}
9798
else
9899
{
@@ -1648,6 +1649,26 @@ void OverlayController::setKeyboardPos()
16481649
vr::VROverlay()->SetKeyboardPositionForOverlay( m_ulOverlayHandle, empty );
16491650
}
16501651

1652+
void OverlayController::setSoundVolume( double value, bool notify )
1653+
{
1654+
m_activationSoundEffect.setVolume( value );
1655+
m_focusChangedSoundEffect.setVolume( value );
1656+
// leaving alarm sound alone for now as chaperone warning setting effects it
1657+
// m_alarm01SoundEffect.setVolume( value);
1658+
settings::setSetting( settings::DoubleSetting::APPLICATION_appVolume,
1659+
value );
1660+
if ( notify )
1661+
{
1662+
emit soundVolumeChanged( value );
1663+
}
1664+
}
1665+
1666+
double OverlayController::soundVolume() const
1667+
{
1668+
return settings::getSetting(
1669+
settings::DoubleSetting::APPLICATION_appVolume );
1670+
}
1671+
16511672
void OverlayController::playActivationSound()
16521673
{
16531674
if ( !m_noSound )

src/overlaycontroller.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class OverlayController : public QObject
9696
Q_PROPERTY( bool autoApplyChaperoneEnabled READ autoApplyChaperoneEnabled
9797
WRITE setAutoApplyChaperoneEnabled NOTIFY
9898
autoApplyChaperoneEnabledChanged )
99+
Q_PROPERTY( double soundVolume READ soundVolume WRITE setSoundVolume NOTIFY
100+
soundVolumeChanged )
99101

100102
private:
101103
vr::VROverlayHandle_t m_ulOverlayHandle = vr::k_ulOverlayHandleInvalid;
@@ -252,6 +254,8 @@ class OverlayController : public QObject
252254
int debugState() const;
253255
std::string autoApplyChaperoneName();
254256

257+
double soundVolume() const;
258+
255259
public slots:
256260
void renderOverlay();
257261
void OnRenderRequest();
@@ -277,6 +281,7 @@ public slots:
277281
void setCustomTickRateMs( int value, bool notify = true );
278282
void setDebugState( int value, bool notify = true );
279283
void setAutoApplyChaperoneEnabled( bool value, bool notify = true );
284+
void setSoundVolume( double value, bool notify = true );
280285

281286
signals:
282287
void keyBoardInputSignal( QString input, unsigned long userValue = 0 );
@@ -290,6 +295,7 @@ public slots:
290295
void customTickRateMsChanged( int value );
291296
void debugStateChanged( int value );
292297
void autoApplyChaperoneEnabledChanged( bool value );
298+
void soundVolumeChanged( double value );
293299
};
294300

295301
} // namespace advsettings

src/res/qml/SettingsPage.qml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,73 @@ MyStackViewPage {
1818
ColumnLayout {
1919
spacing: 18
2020

21+
RowLayout{
22+
MyText {
23+
text: "Application Volume:"
24+
Layout.rightMargin: 12
25+
}
26+
27+
MyPushButton2 {
28+
text: "-"
29+
Layout.preferredWidth: 40
30+
onClicked: {
31+
volumeSlider.value -= 0.05
32+
}
33+
}
34+
35+
MySlider {
36+
id: volumeSlider
37+
from: 0.0
38+
to: 1.0
39+
stepSize: 0.01
40+
value: 0.7
41+
Layout.fillWidth: true
42+
onPositionChanged: {
43+
var val = (this.value * 100)
44+
volumeText.text = Math.round(val) + "%"
45+
}
46+
onValueChanged: {
47+
OverlayController.setSoundVolume(value, false)
48+
}
49+
}
50+
51+
MyPushButton2 {
52+
text: "+"
53+
Layout.preferredWidth: 40
54+
onClicked: {
55+
volumeSlider.value += 0.05
56+
}
57+
}
58+
59+
60+
MyTextField {
61+
id: volumeText
62+
text: "70%"
63+
keyBoardUID: 503
64+
Layout.preferredWidth: 100
65+
Layout.leftMargin: 10
66+
horizontalAlignment: Text.AlignHCenter
67+
function onInputEvent(input) {
68+
var val = parseFloat(input)
69+
if (!isNaN(val)) {
70+
if (val < 0) {
71+
val = 0
72+
} else if (val > 100.0) {
73+
val = 100.0
74+
}
75+
76+
var v = (val/100).toFixed(0)
77+
if (v <= volumeSlider.to) {
78+
chaperoneVisibilitySlider.value = v
79+
} else {
80+
ChaperoneTabController.setBoundsVisibility(v, false)
81+
}
82+
}
83+
text = Math.round(ChaperoneTabController.boundsVisibility * 100) + "%"
84+
}
85+
}
86+
}
87+
2188
MyToggleButton {
2289
id: settingsAutoStartToggle
2390
text: "Autostart"
@@ -295,6 +362,7 @@ MyStackViewPage {
295362

296363
seatedOldExternalWarning.visible = MoveCenterTabController.allowExternalEdits && MoveCenterTabController.oldStyleMotion
297364
reloadChaperoneProfiles()
365+
volumeSlider.value = OverlayController.soundVolume
298366
}
299367

300368
Connections {
@@ -357,6 +425,9 @@ MyStackViewPage {
357425
onAutoApplyChaperoneEnabledChanged: {
358426
autoApplyChaperoneToggleButton.checked = OverlayController.autoApplyChaperoneEnabled
359427
}
428+
onSoundVolumeChanged:{
429+
volumeSlider.value = OverlayController.soundVolume
430+
}
360431
}
361432
Connections{
362433
target: ChaperoneTabController

src/res/qml/chaperone_page/ChaperonePage.qml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ MyStackViewPage {
244244
}
245245

246246
MyPushButton2 {
247+
id: chaperoneVisibilityMinus
247248
text: "-"
248249
Layout.preferredWidth: 40
249250
onClicked: {
@@ -268,6 +269,7 @@ MyStackViewPage {
268269
}
269270

270271
MyPushButton2 {
272+
id: chaperoneVisibilityPlus
271273
text: "+"
272274
Layout.preferredWidth: 40
273275
onClicked: {
@@ -561,7 +563,13 @@ MyStackViewPage {
561563
chaperonePlaySpaceToggle.checked = ChaperoneTabController.playSpaceMarker
562564
chaperoneForceBoundsToggle.checked = ChaperoneTabController.forceBounds
563565
chaperoneDisableChaperone.checked = ChaperoneTabController.disableChaperone
564-
if(chaperoneDisableChaperone.checked){
566+
var dim = ChaperoneTabController.chaperoneDimHeight
567+
if(dim > 0.0){
568+
chaperoneDisableChaperone.enabled = false;
569+
}else{
570+
chaperoneDisableChaperone.enabled = true;
571+
}
572+
if(dim > 0.0 || chaperoneDisableChaperone.checked){
565573
chaperoneFadeDistanceMinus.enabled = false;
566574
chaperoneFadeDistancePlus.enabled = false;
567575
chaperoneFadeDistanceSlider.enabled = false;
@@ -597,7 +605,26 @@ MyStackViewPage {
597605
}
598606
chaperoneHeightText.text = h
599607
}
608+
onChaperoneDimHeightChanged: {
609+
var dim = ChaperoneTabController.chaperoneDimHeight
610+
if(dim > 0.0){
611+
chaperoneDisableChaperone.enabled = false;
612+
}else{
613+
chaperoneDisableChaperone.enabled = true;
614+
}
615+
if(dim > 0.0 || chaperoneDisableChaperone.checked){
616+
chaperoneFadeDistanceMinus.enabled = false;
617+
chaperoneFadeDistancePlus.enabled = false;
618+
chaperoneFadeDistanceSlider.enabled = false;
619+
chaperoneFadeDistanceText.enabled = false;
600620

621+
}else{
622+
chaperoneFadeDistanceMinus.enabled = true;
623+
chaperoneFadeDistancePlus.enabled = true;
624+
chaperoneFadeDistanceSlider.enabled = true;
625+
chaperoneFadeDistanceText.enabled = true;
626+
}
627+
}
601628
onCenterMarkerNewChanged: {
602629
chaperoneCenterMarkerToggle.checked = ChaperoneTabController.centerMarkerNew
603630
}

0 commit comments

Comments
 (0)