diff --git a/Dotnet/Overlay/VRCXVR.cs b/Dotnet/Overlay/VRCXVR.cs index 96bbcf52..5711a6a0 100644 --- a/Dotnet/Overlay/VRCXVR.cs +++ b/Dotnet/Overlay/VRCXVR.cs @@ -331,6 +331,36 @@ namespace VRCX IsHmdAfk = isHmdAfk; AppApi.Instance.CheckGameRunning(); } + + var headsetErr = ETrackedPropertyError.TrackedProp_Success; + var headsetBatteryPercentage = system.GetFloatTrackedDeviceProperty(i, ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref headsetErr); + if (headsetErr != ETrackedPropertyError.TrackedProp_Success) + { + // Headset has no battery, skip displaying it + break; + } + + var headset = new[] + { + "headset", + system.IsTrackedDeviceConnected(i) + ? "connected" + : "disconnected", + // Currently neither VD or SteamLink report charging state + "discharging", + (headsetBatteryPercentage * 100).ToString(), + poses[i].eTrackingResult.ToString() + }; + _deviceListLock.EnterWriteLock(); + try + { + _deviceList.Add(headset); + } + finally + { + _deviceListLock.ExitWriteLock(); + } + break; case ETrackedDeviceClass.Controller: case ETrackedDeviceClass.GenericTracker: diff --git a/html/images/headset_quest_status_off.png b/html/images/headset_quest_status_off.png new file mode 100644 index 00000000..bc24bd97 Binary files /dev/null and b/html/images/headset_quest_status_off.png differ diff --git a/html/images/headset_quest_status_ready.png b/html/images/headset_quest_status_ready.png new file mode 100644 index 00000000..8a1b1f39 Binary files /dev/null and b/html/images/headset_quest_status_ready.png differ diff --git a/html/images/headset_quest_status_ready_charging.png b/html/images/headset_quest_status_ready_charging.png new file mode 100644 index 00000000..7aa497a0 Binary files /dev/null and b/html/images/headset_quest_status_ready_charging.png differ diff --git a/html/images/headset_quest_status_ready_low.png b/html/images/headset_quest_status_ready_low.png new file mode 100644 index 00000000..349b2f53 Binary files /dev/null and b/html/images/headset_quest_status_ready_low.png differ diff --git a/html/src/vr.js b/html/src/vr.js index 7cd615e3..fbf10596 100644 --- a/html/src/vr.js +++ b/html/src/vr.js @@ -446,22 +446,19 @@ Vue.component('marquee-text', MarqueeText); if (device[0] === 'base' && device[1] === 'connected') { baseStations++; } else { - deviceList.unshift(device); + deviceList.push(device); } }); this.deviceCount = deviceList.length; - deviceList.sort((a, b) => { - if (a[0] === b[0]) { - return 0; - } - if (a[0] === 'tracker' || a[0] === 'base') { - return 1; - } - if (a[0].toLowerCase().includes('controller')) { - return -1; - } - return 0; - }); + const deviceValue = (dev) => { + if (dev[0] === 'headset') return 0; + if (dev[0] === 'leftController') return 1; + if (dev[0] === 'rightController') return 2; + if (dev[0].toLowerCase().includes('controller')) return 3; + if (dev[0] === 'tracker' || dev[0] === 'base') return 4; + return 5; + } + deviceList.sort((a, b) => deviceValue(a) - deviceValue(b)); deviceList.sort((a, b) => { if (a[1] === b[1]) { return 0; diff --git a/html/src/vr.pug b/html/src/vr.pug index d03a0199..ca1ef0b6 100644 --- a/html/src/vr.pug +++ b/html/src/vr.pug @@ -434,6 +434,12 @@ html .x-containerbottom div(style="display:flex;flex-direction:row;flex-wrap:wrap") div(v-for="device in devices" class="tracker-container") + div(v-if="device[0] === 'headset'" class="tracker-device" :class="trackingResultToClass(device[4])") + img(v-if="device[1] !== 'connected'" src="images/headset_quest_status_off.png" class="tracker-device" :class="trackingResultToClass(device[4])") + img(v-else-if="device[2] === 'charging'" src="images/headset_quest_status_ready_charging.png") + img(v-else-if="device[3] < 20" src="images/headset_quest_status_ready_low.png") + img(v-else src="images/headset_quest_status_ready.png") + span {{ device[3] }}% div(v-if="device[0] === 'leftController'" class="tracker-device" :class="trackingResultToClass(device[4])") img(v-if="device[1] !== 'connected'" src="images/left_controller_status_off.png" class="tracker-device" :class="trackingResultToClass(device[4])") img(v-else-if="device[2] === 'charging'" src="images/left_controller_status_ready_charging.png") diff --git a/html/src/vr.scss b/html/src/vr.scss index dcdb25ea..5216ebc6 100644 --- a/html/src/vr.scss +++ b/html/src/vr.scss @@ -414,7 +414,6 @@ i.x-user-status.busy { } .tracker-device img { - width: 32px; height: 32px; transition: all 0.25s linear; }