expose battery on hmd xdev

This commit is contained in:
galister
2024-08-10 22:54:41 +02:00
committed by xytovl
parent 2a50237142
commit 225bf9d30f
7 changed files with 146 additions and 1 deletions
+34
View File
@@ -70,6 +70,11 @@ static void wivrn_hmd_get_view_poses(xrt_device * xdev,
xrt_fov * out_fovs,
xrt_pose * out_poses);
static xrt_result_t wivrn_hmd_get_battery_status(struct xrt_device * xdev,
bool * out_present,
bool * out_charging,
float * out_charge);
static double foveate(double a, double b, double λ, double c, double x)
{
// In order to save encoding, transmit and decoding time, only a portion of the image is encoded in full resolution.
@@ -190,11 +195,13 @@ wivrn_hmd::wivrn_hmd(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx,
base->update_inputs = wivrn_hmd_update_inputs;
base->get_tracked_pose = wivrn_hmd_get_tracked_pose;
base->get_view_poses = wivrn_hmd_get_view_poses;
base->get_battery_status = wivrn_hmd_get_battery_status;
base->destroy = wivrn_hmd_destroy;
name = XRT_DEVICE_GENERIC_HMD;
device_type = XRT_DEVICE_TYPE_HMD;
orientation_tracking_supported = true;
// hand_tracking_supported = true;
battery_status_supported = true;
position_tracking_supported = true;
// Print name.
@@ -261,6 +268,12 @@ void wivrn_hmd::update_tracking(const from_headset::tracking & tracking, const c
views.update_tracking(tracking, offset);
}
void wivrn_hmd::update_battery(const from_headset::battery & new_battery)
{
std::lock_guard lock(mutex);
battery = new_battery;
}
void wivrn_hmd::get_view_poses(const xrt_vec3 * default_eye_relation,
uint64_t at_timestamp_ns,
uint32_t view_count,
@@ -296,6 +309,19 @@ void wivrn_hmd::get_view_poses(const xrt_vec3 * default_eye_relation,
}
}
xrt_result_t wivrn_hmd::get_battery_status(struct xrt_device * xdev,
bool * out_present,
bool * out_charging,
float * out_charge)
{
std::lock_guard lock(mutex);
*out_present = battery.present;
*out_charging = battery.charging;
*out_charge = battery.charge;
return XRT_SUCCESS;
}
decltype(wivrn_hmd::foveation_parameters) wivrn_hmd::set_foveated_size(uint32_t width, uint32_t height)
{
assert(width % 2 == 0);
@@ -384,3 +410,11 @@ static void wivrn_hmd_get_view_poses(xrt_device * xdev,
{
static_cast<wivrn_hmd *>(xdev)->get_view_poses(default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs, out_poses);
}
static xrt_result_t wivrn_hmd_get_battery_status(struct xrt_device * xdev,
bool * out_present,
bool * out_charging,
float * out_charge)
{
return static_cast<wivrn_hmd *>(xdev)->get_battery_status(xdev, out_present, out_charging, out_charge);
}
+6
View File
@@ -48,6 +48,7 @@ class wivrn_hmd : public xrt_device
view_list views;
std::array<to_headset::video_stream_description::foveation_parameter, 2> foveation_parameters{};
from_headset::battery battery{};
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
@@ -70,7 +71,12 @@ public:
xrt_space_relation * out_head_relation,
xrt_fov * out_fovs,
xrt_pose * out_poses);
xrt_result_t get_battery_status(struct xrt_device * xdev,
bool * out_present,
bool * out_charging,
float * out_charge);
void update_battery(const from_headset::battery &);
void update_tracking(const from_headset::tracking &, const clock_offset &);
decltype(foveation_parameters) set_foveated_size(uint32_t width, uint32_t height);
+5
View File
@@ -304,6 +304,11 @@ void wivrn_session::operator()(from_headset::feedback && feedback)
dump_time("display", feedback.frame_index, o.from_headset(feedback.displayed), feedback.stream_index);
}
void wivrn_session::operator()(from_headset::battery && battery)
{
hmd->update_battery(battery);
}
void wivrn_session::operator()(audio_data && data)
{
if (audio_handle)
+1
View File
@@ -117,6 +117,7 @@ public:
void operator()(from_headset::inputs &&);
void operator()(from_headset::timesync_response &&);
void operator()(from_headset::feedback &&);
void operator()(from_headset::battery &&);
void operator()(audio_data &&);
template <typename T>