Option to enable desktop notifications while AFK

This commit is contained in:
Natsumi
2023-11-13 21:29:13 +13:00
parent 928422e5b9
commit 25f47f9a1e
6 changed files with 130 additions and 93 deletions
+3 -1
View File
@@ -34,9 +34,11 @@ namespace VRCX
isSteamVRRunning = true; isSteamVRRunning = true;
} }
var isHmdAfk = VRCXVR.Instance.IsHmdAfk;
// TODO: fix this throwing an exception for being called before the browser is ready. somehow it gets past the checks // TODO: fix this throwing an exception for being called before the browser is ready. somehow it gets past the checks
if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame)
MainForm.Instance.Browser.ExecuteScriptAsync("$app.updateIsGameRunning", isGameRunning, isSteamVRRunning); MainForm.Instance.Browser.ExecuteScriptAsync("$app.updateIsGameRunning", isGameRunning, isSteamVRRunning, isHmdAfk);
} }
/// <summary> /// <summary>
+24 -3
View File
@@ -42,6 +42,7 @@ namespace VRCX
private Texture2D _texture2; private Texture2D _texture2;
private Thread _thread; private Thread _thread;
private bool _wristOverlayActive; private bool _wristOverlayActive;
public bool IsHmdAfk { get; private set; }
static VRCXVR() static VRCXVR()
{ {
@@ -190,6 +191,7 @@ namespace VRCX
if (type == EVREventType.VREvent_Quit) if (type == EVREventType.VREvent_Quit)
{ {
active = false; active = false;
IsHmdAfk = false;
OpenVR.Shutdown(); OpenVR.Shutdown();
nextInit = DateTime.UtcNow.AddSeconds(10); nextInit = DateTime.UtcNow.AddSeconds(10);
system = null; system = null;
@@ -247,6 +249,7 @@ namespace VRCX
else if (active) else if (active)
{ {
active = false; active = false;
IsHmdAfk = false;
OpenVR.Shutdown(); OpenVR.Shutdown();
_deviceListLock.EnterWriteLock(); _deviceListLock.EnterWriteLock();
try try
@@ -314,9 +317,24 @@ namespace VRCX
for (var i = 0u; i < OpenVR.k_unMaxTrackedDeviceCount; ++i) for (var i = 0u; i < OpenVR.k_unMaxTrackedDeviceCount; ++i)
{ {
var devClass = system.GetTrackedDeviceClass(i); var devClass = system.GetTrackedDeviceClass(i);
if (devClass == ETrackedDeviceClass.Controller || switch (devClass)
devClass == ETrackedDeviceClass.GenericTracker || {
devClass == ETrackedDeviceClass.TrackingReference) case ETrackedDeviceClass.HMD:
var success = system.GetControllerState(i, ref state, (uint)Marshal.SizeOf(state));
if (!success)
break; // this fails while SteamVR overlay is open
var prox = state.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_ProximitySensor));
var isHmdAfk = prox == 0;
if (isHmdAfk != IsHmdAfk)
{
IsHmdAfk = isHmdAfk;
AppApi.Instance.CheckGameRunning();
}
break;
case ETrackedDeviceClass.Controller:
case ETrackedDeviceClass.GenericTracker:
case ETrackedDeviceClass.TrackingReference:
{ {
var err = ETrackedPropertyError.TrackedProp_Success; var err = ETrackedPropertyError.TrackedProp_Success;
var batteryPercentage = system.GetFloatTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref err); var batteryPercentage = system.GetFloatTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref err);
@@ -411,6 +429,9 @@ namespace VRCX
{ {
_deviceListLock.ExitWriteLock(); _deviceListLock.ExitWriteLock();
} }
break;
}
} }
} }
} }
+18 -2
View File
@@ -5231,6 +5231,7 @@ speechSynthesis.getVoices();
isGameRunning: false, isGameRunning: false,
isGameNoVR: configRepository.getBool('isGameNoVR'), isGameNoVR: configRepository.getBool('isGameNoVR'),
isSteamVRRunning: false, isSteamVRRunning: false,
isHmdAfk: false,
appVersion: '', appVersion: '',
latestAppVersion: '', latestAppVersion: '',
ossDialog: false ossDialog: false
@@ -5455,7 +5456,8 @@ speechSynthesis.getVoices();
$app.methods.updateIsGameRunning = function ( $app.methods.updateIsGameRunning = function (
isGameRunning, isGameRunning,
isSteamVRRunning isSteamVRRunning,
isHmdAfk
) { ) {
if (isGameRunning !== this.isGameRunning) { if (isGameRunning !== this.isGameRunning) {
this.isGameRunning = isGameRunning; this.isGameRunning = isGameRunning;
@@ -5485,6 +5487,10 @@ speechSynthesis.getVoices();
this.isSteamVRRunning = isSteamVRRunning; this.isSteamVRRunning = isSteamVRRunning;
console.log('isSteamVRRunning:', isSteamVRRunning); console.log('isSteamVRRunning:', isSteamVRRunning);
} }
if (isHmdAfk !== this.isHmdAfk) {
this.isHmdAfk = isHmdAfk;
console.log('isHmdAfk:', isHmdAfk);
}
this.updateOpenVR(); this.updateOpenVR();
}; };
@@ -6227,8 +6233,13 @@ speechSynthesis.getVoices();
(this.desktopToast === 'Game Running' && this.isGameRunning) || (this.desktopToast === 'Game Running' && this.isGameRunning) ||
(this.desktopToast === 'Desktop Mode' && (this.desktopToast === 'Desktop Mode' &&
this.isGameNoVR && this.isGameNoVR &&
this.isGameRunning) this.isGameRunning) ||
(this.afkDesktopToast &&
this.isHmdAfk &&
this.isGameRunning &&
!this.isGameNoVR)
) { ) {
// this if statement looks like it has seen better days
playDesktopToast = true; playDesktopToast = true;
} }
var playXSNotification = this.xsNotifications; var playXSNotification = this.xsNotifications;
@@ -14212,6 +14223,10 @@ speechSynthesis.getVoices();
'VRCX_desktopToast', 'VRCX_desktopToast',
'Never' 'Never'
); );
$app.data.afkDesktopToast = configRepository.getBool(
'VRCX_afkDesktopToast',
false
);
$app.data.minimalFeed = configRepository.getBool('VRCX_minimalFeed', false); $app.data.minimalFeed = configRepository.getBool('VRCX_minimalFeed', false);
$app.data.displayVRCPlusIconsAsAvatar = configRepository.getBool( $app.data.displayVRCPlusIconsAsAvatar = configRepository.getBool(
'displayVRCPlusIconsAsAvatar', 'displayVRCPlusIconsAsAvatar',
@@ -14366,6 +14381,7 @@ speechSynthesis.getVoices();
this.imageNotifications this.imageNotifications
); );
configRepository.setString('VRCX_desktopToast', this.desktopToast); configRepository.setString('VRCX_desktopToast', this.desktopToast);
configRepository.setBool('VRCX_afkDesktopToast', this.afkDesktopToast);
configRepository.setBool('VRCX_minimalFeed', this.minimalFeed); configRepository.setBool('VRCX_minimalFeed', this.minimalFeed);
configRepository.setBool( configRepository.setBool(
'displayVRCPlusIconsAsAvatar', 'displayVRCPlusIconsAsAvatar',
+2 -1
View File
@@ -322,7 +322,8 @@
"when_to_display_outside_vr": "Outside VR", "when_to_display_outside_vr": "Outside VR",
"when_to_display_game_closed": "Game Closed", "when_to_display_game_closed": "Game Closed",
"when_to_display_game_running": "Game Running", "when_to_display_game_running": "Game Running",
"when_to_display_always": "Always" "when_to_display_always": "Always",
"desktop_notification_while_afk": "Desktop Notification While AFK"
}, },
"text_to_speech": { "text_to_speech": {
"header": "Text-To-Speech Options", "header": "Text-To-Speech Options",
+3
View File
@@ -273,6 +273,9 @@ mixin settingsTab()
el-radio-button(label="Game Closed") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_game_closed') }} el-radio-button(label="Game Closed") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_game_closed') }}
el-radio-button(label="Game Running") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_game_running') }} el-radio-button(label="Game Running") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_game_running') }}
el-radio-button(label="Always") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_always') }} el-radio-button(label="Always") {{ $t('view.settings.notifications.notifications.desktop_notifications.when_to_display_always') }}
div.options-container-item
span.name(style="min-width:225px") {{ $t('view.settings.notifications.notifications.desktop_notifications.desktop_notification_while_afk') }}
el-switch(v-model="afkDesktopToast" @change="saveOpenVROption")
//- Notifications | Notifications | Text-to-Speech Options //- Notifications | Notifications | Text-to-Speech Options
div.options-container div.options-container
span.sub-header {{ $t('view.settings.notifications.notifications.text_to_speech.header') }} span.sub-header {{ $t('view.settings.notifications.notifications.text_to_speech.header') }}
-6
View File
@@ -462,12 +462,6 @@ html
img(v-if="device[1] !== 'connected'" src="images/base_status_off.png") img(v-if="device[1] !== 'connected'" src="images/base_status_off.png")
img(v-else src="images/base_status_ready.png") img(v-else src="images/base_status_ready.png")
span(v-if="device[3] !== 100") {{ device[3] }}x span(v-if="device[3] !== 100") {{ device[3] }}x
div(v-else class="tracker-device" :class="trackingResultToClass(device[4])")
img(v-if="device[1] !== 'connected'" src="images/other_status_off.png")
img(v-else-if="device[2] === 'charging'" src="images/other_status_ready_charging.png")
img(v-else-if="device[3] < 20" src="images/other_status_ready_low.png")
img(v-else src="images/other_status_ready.png")
span {{ device[3] }}%
.x-containerbottom .x-containerbottom
template(v-if="nowPlaying.playing") template(v-if="nowPlaying.playing")
span(style="float:right;padding-left:10px") {{ nowPlaying.remainingText }} span(style="float:right;padding-left:10px") {{ nowPlaying.remainingText }}