t/libmonado: Tidy mnd_root_get_device_from_role [NFC]

Tidy both documentation and code.
This commit is contained in:
Jakob Bornecrantz 2023-12-28 22:59:01 +00:00
parent 9e9bbe47b9
commit 1f60853d6e
2 changed files with 16 additions and 15 deletions

View file

@ -314,11 +314,11 @@ mnd_root_get_device_info(mnd_root_t *root, uint32_t device_index, uint32_t *out_
} }
mnd_result_t mnd_result_t
mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *out_device_id) mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *out_index)
{ {
CHECK_NOT_NULL(root); CHECK_NOT_NULL(root);
CHECK_NOT_NULL(role_name); CHECK_NOT_NULL(role_name);
CHECK_NOT_NULL(out_device_id); CHECK_NOT_NULL(out_index);
enum role_enum role; enum role_enum role;
@ -341,10 +341,10 @@ mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *
#undef TO_ENUM #undef TO_ENUM
switch (role) { switch (role) {
case ROLE_HEAD: *out_device_id = root->ipc_c.ism->roles.head; return MND_SUCCESS; case ROLE_HEAD: *out_index = root->ipc_c.ism->roles.head; return MND_SUCCESS;
case ROLE_EYES: *out_device_id = root->ipc_c.ism->roles.eyes; return MND_SUCCESS; case ROLE_EYES: *out_index = root->ipc_c.ism->roles.eyes; return MND_SUCCESS;
case ROLE_HAND_LEFT: *out_device_id = root->ipc_c.ism->roles.hand_tracking.left; return MND_SUCCESS; case ROLE_HAND_LEFT: *out_index = root->ipc_c.ism->roles.hand_tracking.left; return MND_SUCCESS;
case ROLE_HAND_RIGHT: *out_device_id = root->ipc_c.ism->roles.hand_tracking.right; return MND_SUCCESS; case ROLE_HAND_RIGHT: *out_index = root->ipc_c.ism->roles.hand_tracking.right; return MND_SUCCESS;
case ROLE_LEFT: case ROLE_LEFT:
case ROLE_RIGHT: case ROLE_RIGHT:
case ROLE_GAMEPAD: break; case ROLE_GAMEPAD: break;
@ -359,9 +359,9 @@ mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *
// Assumes roles index match device id. // Assumes roles index match device id.
switch (role) { switch (role) {
case ROLE_LEFT: *out_device_id = roles.left; return MND_SUCCESS; case ROLE_LEFT: *out_index = roles.left; return MND_SUCCESS;
case ROLE_RIGHT: *out_device_id = roles.right; return MND_SUCCESS; case ROLE_RIGHT: *out_index = roles.right; return MND_SUCCESS;
case ROLE_GAMEPAD: *out_device_id = roles.gamepad; return MND_SUCCESS; case ROLE_GAMEPAD: *out_index = roles.gamepad; return MND_SUCCESS;
default: PE("Internal error, shouldn't get here"); return MND_ERROR_OPERATION_FAILED; default: PE("Internal error, shouldn't get here"); return MND_ERROR_OPERATION_FAILED;
} }
} }

View file

@ -232,16 +232,17 @@ mnd_root_get_device_info(mnd_root_t *root, uint32_t device_index, uint32_t *out_
/*! /*!
* Get the device index associated for a given role name. * Get the device index associated for a given role name.
* *
* @param root The libmonado state. * @param root The libmonado state.
* @param role_name Name of the role, one-of * @param role_name Name of the role, one-of: "head", "left", "right",
* "head","left","right"."gamepad","eyes","hand-tracking-left","hand-tracking-right" * "gamepad", "eyes", "hand-tracking-left", and,
* @param[out] out_device_id Pointer to value to populate with the device id associated with given role name, -1 if not * "hand-tracking-right":
* role is set. * @param[out] out_index Pointer to value to populate with the device index
* associated with given role name, -1 if not role is set.
* *
* @return MND_SUCCESS on success * @return MND_SUCCESS on success
*/ */
mnd_result_t mnd_result_t
mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *out_device_id); mnd_root_get_device_from_role(mnd_root_t *root, const char *role_name, int32_t *out_index);
/*! /*!
* Trigger a recenter of the local spaces. * Trigger a recenter of the local spaces.