The open source OpenXR runtime
0
fork

Configure Feed

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

t/libmonado: add function for getting a device's battery status information

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
8e407e96 f5b9ed31

+46
+1
doc/changes/misc_features/mr.2292.md
··· 1 + t/libmonado: Add a function for getting a device's battery status information.
+1
src/xrt/targets/libmonado/libmonado.def
··· 20 20 mnd_root_set_tracking_origin_offset 21 21 mnd_root_get_tracking_origin_count 22 22 mnd_root_get_tracking_origin_name 23 + mnd_root_get_device_battery_status
+29
src/xrt/targets/libmonado/monado.c
··· 546 546 547 547 return MND_SUCCESS; 548 548 } 549 + 550 + mnd_result_t 551 + mnd_root_get_device_battery_status( 552 + mnd_root_t *root, uint32_t device_index, bool *out_present, bool *out_charging, float *out_charge) 553 + { 554 + CHECK_NOT_NULL(root); 555 + CHECK_NOT_NULL(out_present); 556 + CHECK_NOT_NULL(out_charging); 557 + CHECK_NOT_NULL(out_charge); 558 + 559 + if (device_index >= root->ipc_c.ism->isdev_count) { 560 + PE("Invalid device index (%u)", device_index); 561 + return MND_ERROR_INVALID_VALUE; 562 + } 563 + 564 + const struct ipc_shared_device *shared_device = &root->ipc_c.ism->isdevs[device_index]; 565 + 566 + if (!shared_device->battery_status_supported) { 567 + return MND_ERROR_OPERATION_FAILED; 568 + } 569 + 570 + xrt_result_t xret = 571 + ipc_call_device_get_battery_status(&root->ipc_c, device_index, out_present, out_charging, out_charge); 572 + switch (xret) { 573 + case XRT_SUCCESS: return MND_SUCCESS; 574 + case XRT_ERROR_IPC_FAILURE: PE("Connection error!"); return MND_ERROR_OPERATION_FAILED; 575 + default: PE("Internal error, shouldn't get here"); return MND_ERROR_OPERATION_FAILED; 576 + } 577 + }
+15
src/xrt/targets/libmonado/monado.h
··· 460 460 mnd_result_t 461 461 mnd_root_get_tracking_origin_name(mnd_root_t *root, uint32_t origin_id, const char **out_string); 462 462 463 + /*! 464 + * Get battery status of a device. 465 + * 466 + * @param root The libmonado state. 467 + * @param device_index Index of device to retrieve battery info from. 468 + * @param[out] out_present Pointer to value to populate with whether the device provides battery status info. 469 + * @param[out] out_charging Pointer to value to populate with whether the device is currently being charged. 470 + * @param[out] out_charge Pointer to value to populate with the battery charge as a value between 0 and 1. 471 + * 472 + * @return MND_SUCCESS on success 473 + */ 474 + mnd_result_t 475 + mnd_root_get_device_battery_status( 476 + mnd_root_t *root, uint32_t device_index, bool *out_present, bool *out_charging, float *out_charge); 477 + 463 478 #ifdef __cplusplus 464 479 } 465 480 #endif