diff --git a/doc/changes/ipc/mr.2292.md b/doc/changes/ipc/mr.2292.md new file mode 100644 index 000000000..cb6c8ad4d --- /dev/null +++ b/doc/changes/ipc/mr.2292.md @@ -0,0 +1 @@ +all: Add device battery status query. diff --git a/src/xrt/ipc/client/ipc_client_hmd.c b/src/xrt/ipc/client/ipc_client_hmd.c index 5c5081106..b6e93b9d7 100644 --- a/src/xrt/ipc/client/ipc_client_hmd.c +++ b/src/xrt/ipc/client/ipc_client_hmd.c @@ -377,6 +377,7 @@ ipc_client_hmd_create(struct ipc_connection *ipc_c, struct xrt_tracking_origin * ich->base.force_feedback_supported = isdev->force_feedback_supported; ich->base.form_factor_check_supported = isdev->form_factor_check_supported; ich->base.stage_supported = isdev->stage_supported; + ich->base.battery_status_supported = isdev->battery_status_supported; return &ich->base; } diff --git a/src/xrt/ipc/server/ipc_server_handler.c b/src/xrt/ipc/server/ipc_server_handler.c index 01246fa96..c871bbd03 100644 --- a/src/xrt/ipc/server/ipc_server_handler.c +++ b/src/xrt/ipc/server/ipc_server_handler.c @@ -2140,3 +2140,11 @@ ipc_handle_device_get_body_joints(volatile struct ipc_client_state *ics, struct xrt_device *xdev = get_xdev(ics, id); return xrt_device_get_body_joints(xdev, body_tracking_type, desired_timestamp_ns, out_value); } + +xrt_result_t +ipc_handle_device_get_battery_status( + volatile struct ipc_client_state *ics, uint32_t id, bool *out_present, bool *out_charging, float *out_charge) +{ + struct xrt_device *xdev = get_xdev(ics, id); + return xrt_device_get_battery_status(xdev, out_present, out_charging, out_charge); +} diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c index cfcfa1419..732703408 100644 --- a/src/xrt/ipc/server/ipc_server_process.c +++ b/src/xrt/ipc/server/ipc_server_process.c @@ -356,6 +356,7 @@ init_shm(struct ipc_server *s) isdev->face_tracking_supported = xdev->face_tracking_supported; isdev->body_tracking_supported = xdev->body_tracking_supported; isdev->stage_supported = xdev->stage_supported; + isdev->battery_status_supported = xdev->battery_status_supported; // Is this a HMD? if (xdev->hmd != NULL) { diff --git a/src/xrt/ipc/shared/ipc_protocol.h b/src/xrt/ipc/shared/ipc_protocol.h index b589d4d6e..682a5bde4 100644 --- a/src/xrt/ipc/shared/ipc_protocol.h +++ b/src/xrt/ipc/shared/ipc_protocol.h @@ -137,6 +137,7 @@ struct ipc_shared_device bool force_feedback_supported; bool form_factor_check_supported; bool stage_supported; + bool battery_status_supported; }; /*! diff --git a/src/xrt/ipc/shared/proto.json b/src/xrt/ipc/shared/proto.json index b5c1107ab..e63bef753 100644 --- a/src/xrt/ipc/shared/proto.json +++ b/src/xrt/ipc/shared/proto.json @@ -512,6 +512,17 @@ "out": [ {"name": "value", "type": "struct xrt_body_joint_set"} ] + }, + + "device_get_battery_status": { + "in": [ + {"name": "id", "type": "uint32_t"} + ], + "out": [ + {"name": "present", "type": "bool"}, + {"name": "charging", "type": "bool"}, + {"name": "charge", "type": "float"} + ] } }