mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-14 10:55:23 +00:00
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>
This commit is contained in:
parent
ad39ec054b
commit
59d9d832d6
1
doc/changes/auxiliary/mr.2292.md
Normal file
1
doc/changes/auxiliary/mr.2292.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
a/util: Add not-implemented fallback function for `xrd_device::get_battery_status`.
|
1
doc/changes/xrt/mr.2292.md
Normal file
1
doc/changes/xrt/mr.2292.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add a `get_battery_status` function to `xrt_device` for getting the device's battery status info.
|
|
@ -539,3 +539,10 @@ u_device_ni_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_fact
|
||||||
E(is_form_factor_available);
|
E(is_form_factor_available);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xrt_result_t
|
||||||
|
u_device_ni_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
|
||||||
|
{
|
||||||
|
E(get_battery_status);
|
||||||
|
return XRT_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
|
@ -259,6 +259,14 @@ u_device_ni_get_visibility_mask(struct xrt_device *xdev,
|
||||||
bool
|
bool
|
||||||
u_device_ni_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor);
|
u_device_ni_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not implemented function for @ref xrt_device::get_battery_status.
|
||||||
|
*
|
||||||
|
* @ingroup aux_util
|
||||||
|
*/
|
||||||
|
xrt_result_t
|
||||||
|
u_device_ni_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,6 +269,7 @@ struct xrt_device
|
||||||
bool stage_supported;
|
bool stage_supported;
|
||||||
bool face_tracking_supported;
|
bool face_tracking_supported;
|
||||||
bool body_tracking_supported;
|
bool body_tracking_supported;
|
||||||
|
bool battery_status_supported;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -502,6 +503,19 @@ struct xrt_device
|
||||||
*/
|
*/
|
||||||
bool (*is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor);
|
bool (*is_form_factor_available)(struct xrt_device *xdev, enum xrt_form_factor form_factor);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Get battery status information.
|
||||||
|
*
|
||||||
|
* @param[in] xdev The device.
|
||||||
|
* @param[out] out_present Whether battery status information exist for this device.
|
||||||
|
* @param[out] out_charging Whether the device's battery is being charged.
|
||||||
|
* @param[out] out_charge Battery charge as a value between 0 and 1.
|
||||||
|
*/
|
||||||
|
xrt_result_t (*get_battery_status)(struct xrt_device *xdev,
|
||||||
|
bool *out_present,
|
||||||
|
bool *out_charging,
|
||||||
|
float *out_charge);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroy device.
|
* Destroy device.
|
||||||
*/
|
*/
|
||||||
|
@ -702,6 +716,22 @@ xrt_device_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_facto
|
||||||
return xdev->is_form_factor_available(xdev, form_factor);
|
return xdev->is_form_factor_available(xdev, form_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Helper function for @ref xrt_device::get_battery_status.
|
||||||
|
*
|
||||||
|
* @copydoc xrt_device::get_battery_status
|
||||||
|
*
|
||||||
|
* @public @memberof xrt_device
|
||||||
|
*/
|
||||||
|
static inline xrt_result_t
|
||||||
|
xrt_device_get_battery_status(struct xrt_device *xdev, bool *out_present, bool *out_charging, float *out_charge)
|
||||||
|
{
|
||||||
|
if (xdev->get_battery_status == NULL) {
|
||||||
|
return XRT_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
return xdev->get_battery_status(xdev, out_present, out_charging, out_charge);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Helper function for @ref xrt_device::destroy.
|
* Helper function for @ref xrt_device::destroy.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue