@@ -79,6 +79,32 @@ void SlimeVRDriver::TrackerDevice::PositionMessage(messages::Position &position)
7979 this ->last_pose_ = pose;
8080}
8181
82+ void SlimeVRDriver::TrackerDevice::BatteryMessage (messages::Battery &battery)
83+ {
84+ if (this ->device_index_ == vr::k_unTrackedDeviceIndexInvalid)
85+ return ;
86+
87+ // Get the properties handle
88+ auto props = GetDriver ()->GetProperties ()->TrackedDeviceToPropertyContainer (this ->device_index_ );
89+
90+ vr::ETrackedPropertyError err;
91+
92+ // Set that the tracker reports battery level in case it has not already been set to true
93+ // It's a given that the tracker supports reporting battery life because otherwise a BatteryMessage would not be received
94+ if (vr::VRProperties ()->GetBoolProperty (props, vr::Prop_DeviceProvidesBatteryStatus_Bool, &err) != true ) {
95+ vr::VRProperties ()->SetBoolProperty (props, vr::Prop_DeviceProvidesBatteryStatus_Bool, true );
96+ }
97+
98+ if (battery.is_charging ()) {
99+ vr::VRProperties ()->SetBoolProperty (props, vr::Prop_DeviceIsCharging_Bool, true );
100+ } else {
101+ vr::VRProperties ()->SetBoolProperty (props, vr::Prop_DeviceIsCharging_Bool, false );
102+ }
103+
104+ // Set the battery Level; 0 = 0%, 1 = 100%
105+ vr::VRProperties ()->SetFloatProperty (props, vr::Prop_DeviceBatteryPercentage_Float, battery.battery_level ());
106+ }
107+
82108void SlimeVRDriver::TrackerDevice::StatusMessage (messages::TrackerStatus &status)
83109{
84110 auto pose = this ->last_pose_ ;
@@ -141,15 +167,15 @@ vr::EVRInitError SlimeVRDriver::TrackerDevice::Activate(uint32_t unObjectId)
141167 GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_RenderModelName_String, " {htc}/rendermodels/vr_tracker_vive_1_0" );
142168
143169 // Set the icon
144- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceReady_String, " {slimevr}/icons/tracker_status_ready.b4bfb144. png" );
170+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceReady_String, " {slimevr}/icons/tracker_status_ready.png" );
145171
146172 GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceOff_String, " {slimevr}/icons/tracker_status_off.png" );
147- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceSearching_String, " {slimevr}/icons/tracker_status_ready.b4bfb144. png" );
148- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceSearchingAlert_String, " {slimevr}/icons/tracker_status_ready_alert.b4bfb144. png" );
149- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceReadyAlert_String, " {slimevr}/icons/tracker_status_ready_alert.b4bfb144. png" );
150- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceNotReady_String, " {slimevr}/icons/tracker_status_off .png" );
151- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceStandby_String, " {slimevr}/icons/tracker_status_standby.b4bfb144. png" );
152- GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceAlertLow_String, " {slimevr}/icons/tracker_status_ready_low.b4bfb144. png" );
173+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceSearching_String, " {slimevr}/icons/tracker_status_ready.png" );
174+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceSearchingAlert_String, " {slimevr}/icons/tracker_status_ready_alert.png" );
175+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceReadyAlert_String, " {slimevr}/icons/tracker_status_ready_alert.png" );
176+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceNotReady_String, " {slimevr}/icons/tracker_status_error .png" );
177+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceStandby_String, " {slimevr}/icons/tracker_status_standby.png" );
178+ GetDriver ()->GetProperties ()->SetStringProperty (props, vr::Prop_NamedIconPathDeviceAlertLow_String, " {slimevr}/icons/tracker_status_ready_low.png" );
153179
154180 // Automatically select vive tracker roles and set hints for games that need it (Beat Saber avatar mod, for example)
155181 auto roleHint = getViveRoleHint (trackerRole);
0 commit comments