The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: add device battery status query

Co-authored-by: Gabriele Musco <gabmus@disroot.org>
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2292>

authored by

Torge Matthies
Gabriele Musco
and committed by
Marge Bot
59d9d832 ad39ec05

+47
+1
doc/changes/auxiliary/mr.2292.md
··· 1 + a/util: Add not-implemented fallback function for `xrd_device::get_battery_status`.
+1
doc/changes/xrt/mr.2292.md
··· 1 + Add a `get_battery_status` function to `xrt_device` for getting the device's battery status info.
+7
src/xrt/auxiliary/util/u_device.c
··· 539 539 E(is_form_factor_available); 540 540 return false; 541 541 } 542 + 543 + xrt_result_t 544 + u_device_ni_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge) 545 + { 546 + E(get_battery_status); 547 + return XRT_ERROR_NOT_IMPLEMENTED; 548 + }
+8
src/xrt/auxiliary/util/u_device.h
··· 259 259 bool 260 260 u_device_ni_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor); 261 261 262 + /*! 263 + * Not implemented function for @ref xrt_device::get_battery_status. 264 + * 265 + * @ingroup aux_util 266 + */ 267 + xrt_result_t 268 + u_device_ni_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge); 269 + 262 270 263 271 #ifdef __cplusplus 264 272 }
+30
src/xrt/include/xrt/xrt_device.h
··· 269 269 bool stage_supported; 270 270 bool face_tracking_supported; 271 271 bool body_tracking_supported; 272 + bool battery_status_supported; 272 273 273 274 /* 274 275 * ··· 503 504 bool (*is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor); 504 505 505 506 /*! 507 + * @brief Get battery status information. 508 + * 509 + * @param[in] xdev The device. 510 + * @param[out] out_present Whether battery status information exist for this device. 511 + * @param[out] out_charging Whether the device's battery is being charged. 512 + * @param[out] out_charge Battery charge as a value between 0 and 1. 513 + */ 514 + xrt_result_t (*get_battery_status)(struct xrt_device *xdev, 515 + bool *out_present, 516 + bool *out_charging, 517 + float *out_charge); 518 + 519 + /*! 506 520 * Destroy device. 507 521 */ 508 522 void (*destroy)(struct xrt_device *xdev); ··· 700 714 xrt_device_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor) 701 715 { 702 716 return xdev->is_form_factor_available(xdev, form_factor); 717 + } 718 + 719 + /*! 720 + * Helper function for @ref xrt_device::get_battery_status. 721 + * 722 + * @copydoc xrt_device::get_battery_status 723 + * 724 + * @public @memberof xrt_device 725 + */ 726 + static inline xrt_result_t 727 + xrt_device_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge) 728 + { 729 + if (xdev->get_battery_status == NULL) { 730 + return XRT_ERROR_NOT_IMPLEMENTED; 731 + } 732 + return xdev->get_battery_status(xdev, out_present, out_charging, out_charge); 703 733 } 704 734 705 735 /*!