From 7f536528d0977ba488ed7e9d18871851594452f9 Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sat, 13 Dec 2025 19:04:44 -0600 Subject: [PATCH 1/9] Parse runtime from HID tracker --- .../dev/slimevr/protocol/datafeed/DataFeedBuilder.java | 3 +++ .../main/java/dev/slimevr/tracking/trackers/Tracker.kt | 1 + .../java/dev/slimevr/tracking/trackers/hid/HIDCommon.kt | 9 +++++++++ solarxr-protocol | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/server/core/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java b/server/core/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java index 3c256ff2f..78d2e3dd0 100644 --- a/server/core/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java +++ b/server/core/src/main/java/dev/slimevr/protocol/datafeed/DataFeedBuilder.java @@ -310,6 +310,9 @@ public class DataFeedBuilder { HardwareStatus.addRssi(fbb, (short) tracker.getSignalStrength().floatValue()); } + if (tracker.getBatteryRemainingRuntime() != null) { + HardwareStatus.addBatteryRuntimeEstimate(fbb, tracker.getBatteryRemainingRuntime()); + } int hardwareDataOffset = HardwareStatus.endHardwareStatus(fbb); int hardwareInfoOffset = DataFeedBuilder.createHardwareInfo(fbb, device); diff --git a/server/core/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt b/server/core/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt index 6392d2f7c..0212b1982 100644 --- a/server/core/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt +++ b/server/core/src/main/java/dev/slimevr/tracking/trackers/Tracker.kt @@ -112,6 +112,7 @@ class Tracker @JvmOverloads constructor( val trackerFlexHandler: TrackerFlexHandler = TrackerFlexHandler(this) var batteryVoltage: Float? = null var batteryLevel: Float? = null + var batteryRemainingRuntime: Long? = null var ping: Int? = null var signalStrength: Int? = null var temperature: Float? = null diff --git a/server/core/src/main/java/dev/slimevr/tracking/trackers/hid/HIDCommon.kt b/server/core/src/main/java/dev/slimevr/tracking/trackers/hid/HIDCommon.kt index 23d0a27ba..584af8604 100644 --- a/server/core/src/main/java/dev/slimevr/tracking/trackers/hid/HIDCommon.kt +++ b/server/core/src/main/java/dev/slimevr/tracking/trackers/hid/HIDCommon.kt @@ -138,6 +138,7 @@ class HIDCommon { } // Packet data + var runtime: Long? = null var batt: Int? = null var batt_v: Int? = null var temp: Int? = null @@ -221,6 +222,11 @@ class HIDCommon { } } + 5 -> { // runtime + // ulong as little endian + runtime = (dataReceived[i + 9].toUByte().toLong() shl 56) or (dataReceived[i + 8].toUByte().toLong() shl 48) or (dataReceived[i + 7].toUByte().toLong() shl 40) or (dataReceived[i + 6].toUByte().toLong() shl 32) or (dataReceived[i + 5].toUByte().toLong() shl 24) or (dataReceived[i + 4].toUByte().toLong() shl 16) or (dataReceived[i + 3].toUByte().toLong() shl 8) or dataReceived[i + 2].toUByte().toLong() + } + 6 -> { // data button = dataReceived[i + 2].toUByte().toInt() rssi = dataReceived[i + 15].toUByte().toInt() @@ -248,6 +254,9 @@ class HIDCommon { } // Assign data + if (runtime != null) { + tracker.batteryRemainingRuntime = runtime + } if (batt != null) { tracker.batteryLevel = if (batt == 128) 1f else (batt and 127).toFloat() } diff --git a/solarxr-protocol b/solarxr-protocol index b0147eeff..d386d56d7 160000 --- a/solarxr-protocol +++ b/solarxr-protocol @@ -1 +1 @@ -Subproject commit b0147eeffaa97a16400de174383c91be2ec31ab5 +Subproject commit d386d56d74325c603b1a2eddb53e37ca7e71cb89 From 122efacc52a41ade8484133d953877d048ec2907 Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sat, 13 Dec 2025 21:00:23 -0600 Subject: [PATCH 2/9] show runtime in gui --- gui/src/components/tracker/TrackerBattery.tsx | 26 ++++++++++++++++--- gui/src/components/tracker/TrackerCard.tsx | 2 ++ gui/src/components/tracker/TrackersTable.tsx | 3 ++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index 0bf775a82..1f4c232ab 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -6,6 +6,7 @@ import { Typography } from '@/components/commons/Typography'; export function TrackerBattery({ value, voltage, + runtime, disabled, textColor = 'primary', }: { @@ -14,6 +15,7 @@ export function TrackerBattery({ */ value: number; voltage?: number | null; + runtime?: BigInt | null disabled?: boolean; textColor?: string; }) { @@ -33,11 +35,27 @@ export function TrackerBattery({ return (
- +
{((!charging || showVoltage) && ( -
- {!charging && ( +
+ {!charging && runtime && ( + + {(( + runtime.valueOf() / + BigInt(3600000000) + ).toString() + + 'h ' + + ( + (runtime.valueOf() % + BigInt(3600000000)) / + BigInt(60000000) + ).toString() + + 'min') || + 'N/A'} + + )} + {!charging && (!runtime || showVoltage) && ( {percentFormatter.format(value)} @@ -49,7 +67,7 @@ export function TrackerBattery({ )}
)) || ( -
+
)} diff --git a/gui/src/components/tracker/TrackerCard.tsx b/gui/src/components/tracker/TrackerCard.tsx index 00dafabe0..a016f65dc 100644 --- a/gui/src/components/tracker/TrackerCard.tsx +++ b/gui/src/components/tracker/TrackerCard.tsx @@ -51,6 +51,7 @@ function TrackerBig({ )} @@ -119,6 +120,7 @@ function TrackerSmol({ )} diff --git a/gui/src/components/tracker/TrackersTable.tsx b/gui/src/components/tracker/TrackersTable.tsx index 1a4fdb022..55967fda4 100644 --- a/gui/src/components/tracker/TrackersTable.tsx +++ b/gui/src/components/tracker/TrackersTable.tsx @@ -229,6 +229,7 @@ function Row({ @@ -329,7 +330,7 @@ export function TrackersTable({ const cols = [ 'minmax(150px, 1.5fr)', // Name 'minmax(100px, 1fr)', // Type - 'minmax(60px, 1fr)', // Battery + 'minmax(110px, 1fr)', // Battery '6rem', // Ping (w-24) 'minmax(60px, 1fr)', // TPS config?.devSettings?.preciseRotation ? '11rem' : '8rem', // Rotation From cf357e71f5e7d670110add3e96c412720ee38d3c Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sat, 13 Dec 2025 21:02:30 -0600 Subject: [PATCH 3/9] lint --- gui/src/components/tracker/TrackerBattery.tsx | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index 1f4c232ab..e7617de92 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -15,7 +15,7 @@ export function TrackerBattery({ */ value: number; voltage?: number | null; - runtime?: BigInt | null + runtime?: bigint | null; disabled?: boolean; textColor?: string; }) { @@ -35,24 +35,19 @@ export function TrackerBattery({ return (
- +
{((!charging || showVoltage) && (
{!charging && runtime && ( - {(( - runtime.valueOf() / - BigInt(3600000000) - ).toString() + - 'h ' + - ( - (runtime.valueOf() % - BigInt(3600000000)) / - BigInt(60000000) - ).toString() + - 'min') || - 'N/A'} + {(runtime.valueOf() / BigInt(3600000000)).toString() + + 'h ' + + ( + (runtime.valueOf() % BigInt(3600000000)) / + BigInt(60000000) + ).toString() + + 'min' || 'N/A'} )} {!charging && (!runtime || showVoltage) && ( From 09d44b51d6a35f2eb020e16dd89df3dfebad4d9b Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sat, 13 Dec 2025 21:09:23 -0600 Subject: [PATCH 4/9] linter borked it --- gui/src/components/tracker/TrackerBattery.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index e7617de92..20f7bbada 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -39,14 +39,11 @@ export function TrackerBattery({
{((!charging || showVoltage) && (
- {!charging && runtime && ( + {!charging && runtime != null && ( - {(runtime.valueOf() / BigInt(3600000000)).toString() + + {(runtime / BigInt(3600000000)).toString() + 'h ' + - ( - (runtime.valueOf() % BigInt(3600000000)) / - BigInt(60000000) - ).toString() + + ((runtime % BigInt(3600000000)) / BigInt(60000000)).toString() + 'min' || 'N/A'} )} From d3eafb8d06d52bd71b339da86a3975f400eaf9ab Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sat, 13 Dec 2025 21:11:23 -0600 Subject: [PATCH 5/9] only show runtime if nonzero --- gui/src/components/tracker/TrackerBattery.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index 20f7bbada..b839abb94 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -39,12 +39,12 @@ export function TrackerBattery({
{((!charging || showVoltage) && (
- {!charging && runtime != null && ( + {!charging && runtime != null && runtime > 0 && ( {(runtime / BigInt(3600000000)).toString() + 'h ' + ((runtime % BigInt(3600000000)) / BigInt(60000000)).toString() + - 'min' || 'N/A'} + 'min'} )} {!charging && (!runtime || showVoltage) && ( From c9783d097b03bdac095439b3b5ccafead7bcf26b Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Sun, 14 Dec 2025 14:17:03 -0600 Subject: [PATCH 6/9] show voltage in less situations --- gui/src/components/tracker/TrackerBattery.tsx | 7 +++++-- gui/src/components/tracker/TrackerCard.tsx | 1 + gui/src/components/tracker/TrackersTable.tsx | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index b839abb94..d867f63e3 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -8,6 +8,7 @@ export function TrackerBattery({ voltage, runtime, disabled, + moreInfo = false, textColor = 'primary', }: { /** @@ -17,6 +18,7 @@ export function TrackerBattery({ voltage?: number | null; runtime?: bigint | null; disabled?: boolean; + moreInfo?: boolean; textColor?: string; }) { const { currentLocales } = useLocaleConfig(); @@ -30,7 +32,8 @@ export function TrackerBattery({ }); const charging = (voltage || 0) > 4.3; - const showVoltage = voltage && config?.debug; + const debug = config?.debug || config?.devSettings.moreInfo; + const showVoltage = moreInfo && voltage && debug; return (
@@ -47,7 +50,7 @@ export function TrackerBattery({ 'min'} )} - {!charging && (!runtime || showVoltage) && ( + {!charging && (!runtime || debug) && ( {percentFormatter.format(value)} diff --git a/gui/src/components/tracker/TrackerCard.tsx b/gui/src/components/tracker/TrackerCard.tsx index a016f65dc..a5e63d0a1 100644 --- a/gui/src/components/tracker/TrackerCard.tsx +++ b/gui/src/components/tracker/TrackerCard.tsx @@ -53,6 +53,7 @@ function TrackerBig({ value={device.hardwareStatus.batteryPctEstimate / 100} runtime={device.hardwareStatus.batteryRuntimeEstimate} disabled={tracker.status === TrackerStatusEnum.DISCONNECTED} + moreInfo={true} /> )}
diff --git a/gui/src/components/tracker/TrackersTable.tsx b/gui/src/components/tracker/TrackersTable.tsx index 55967fda4..de165246c 100644 --- a/gui/src/components/tracker/TrackersTable.tsx +++ b/gui/src/components/tracker/TrackersTable.tsx @@ -231,6 +231,7 @@ function Row({ voltage={device.hardwareStatus.batteryVoltage} runtime={device.hardwareStatus.batteryRuntimeEstimate} disabled={tracker.status === TrackerStatusEnum.DISCONNECTED} + moreInfo={config?.devSettings.moreInfo} textColor={fontColor} /> )} From 6208979ce9d94d0434a374d00f577dd4074722b8 Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:48:00 -0600 Subject: [PATCH 7/9] TrackerBattery battery level tooltip if not shown --- gui/src/components/tracker/TrackerBattery.tsx | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index d867f63e3..68dcf2a5d 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -2,6 +2,7 @@ import { useConfig } from '@/hooks/config'; import { useLocaleConfig } from '@/i18n/config'; import { BatteryIcon } from '@/components/commons/icon/BatteryIcon'; import { Typography } from '@/components/commons/Typography'; +import { Tooltip } from '@/components/commons/Tooltip'; export function TrackerBattery({ value, @@ -36,36 +37,49 @@ export function TrackerBattery({ const showVoltage = moreInfo && voltage && debug; return ( -
-
- + + {percentFormatter.format(value)} +
+ } + > +
+
+ +
+ {((!charging || showVoltage) && ( +
+ {!charging && runtime != null && runtime > 0 && ( + + {(runtime / BigInt(3600000000)).toString() + + 'h ' + + ( + (runtime % BigInt(3600000000)) / + BigInt(60000000) + ).toString() + + 'min'} + + )} + {!charging && (!runtime || debug) && ( + + {percentFormatter.format(value)} + + )} + {showVoltage && ( + + {voltageFormatter.format(voltage)}V + + )} +
+ )) || ( +
+
+
+ )}
- {((!charging || showVoltage) && ( -
- {!charging && runtime != null && runtime > 0 && ( - - {(runtime / BigInt(3600000000)).toString() + - 'h ' + - ((runtime % BigInt(3600000000)) / BigInt(60000000)).toString() + - 'min'} - - )} - {!charging && (!runtime || debug) && ( - - {percentFormatter.format(value)} - - )} - {showVoltage && ( - - {voltageFormatter.format(voltage)}V - - )} -
- )) || ( -
-
-
- )} -
+ ); } From 87940ddd03e078ad5cfd7fd93725ff5651d5aef7 Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Thu, 18 Dec 2025 00:04:07 -0600 Subject: [PATCH 8/9] TrackerBattery tooltip remove classes --- gui/src/components/tracker/TrackerBattery.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gui/src/components/tracker/TrackerBattery.tsx b/gui/src/components/tracker/TrackerBattery.tsx index 68dcf2a5d..a9ccaa6f4 100644 --- a/gui/src/components/tracker/TrackerBattery.tsx +++ b/gui/src/components/tracker/TrackerBattery.tsx @@ -40,11 +40,7 @@ export function TrackerBattery({ - {percentFormatter.format(value)} -
- } + content={percentFormatter.format(value)} >
From 2e8bfa5373919a59ebd9c11518e731f9eefd8988 Mon Sep 17 00:00:00 2001 From: sctanf <36978460+sctanf@users.noreply.github.com> Date: Thu, 18 Dec 2025 02:35:33 -0600 Subject: [PATCH 9/9] Update solarxr-protocol --- solarxr-protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solarxr-protocol b/solarxr-protocol index d386d56d7..3400a6e6d 160000 --- a/solarxr-protocol +++ b/solarxr-protocol @@ -1 +1 @@ -Subproject commit d386d56d74325c603b1a2eddb53e37ca7e71cb89 +Subproject commit 3400a6e6dd4c66a0924b46b77445699d44a120e2