ipc: Add support for xrt_device::is_form_factor_available

This commit is contained in:
Jarvis Huang 2023-02-07 11:48:36 +08:00 committed by Jakob Bornecrantz
parent b93d1ea8b8
commit 693641b70b
5 changed files with 38 additions and 0 deletions

View file

@ -139,6 +139,17 @@ ipc_client_hmd_get_view_poses(struct xrt_device *xdev,
}
}
static bool
ipc_client_hmd_is_form_factor_available(struct xrt_device *xdev, enum xrt_form_factor form_factor)
{
struct ipc_client_hmd *ich = ipc_client_hmd(xdev);
bool available = false;
xrt_result_t r = ipc_call_device_is_form_factor_available(ich->ipc_c, ich->device_id, form_factor, &available);
if (r != XRT_SUCCESS) {
IPC_ERROR(ich->ipc_c, "Error calling is available!");
}
return available;
}
/*!
* @public @memberof ipc_client_hmd
@ -159,6 +170,7 @@ ipc_client_hmd_create(struct ipc_connection *ipc_c, struct xrt_tracking_origin *
ich->base.get_tracked_pose = ipc_client_hmd_get_tracked_pose;
ich->base.get_view_poses = ipc_client_hmd_get_view_poses;
ich->base.destroy = ipc_client_hmd_destroy;
ich->base.is_form_factor_available = ipc_client_hmd_is_form_factor_available;
// Start copying the information from the isdev.
ich->base.tracking_origin = xtrack;
@ -213,6 +225,7 @@ ipc_client_hmd_create(struct ipc_connection *ipc_c, struct xrt_tracking_origin *
ich->base.device_type = isdev->device_type;
ich->base.hand_tracking_supported = isdev->hand_tracking_supported;
ich->base.force_feedback_supported = isdev->force_feedback_supported;
ich->base.form_factor_check_supported = isdev->form_factor_check_supported;
return &ich->base;
}

View file

@ -1155,3 +1155,16 @@ ipc_handle_device_set_output(volatile struct ipc_client_state *ics,
return XRT_SUCCESS;
}
xrt_result_t
ipc_handle_device_is_form_factor_available(volatile struct ipc_client_state *ics,
uint32_t id,
enum xrt_form_factor form_factor,
bool *out_available)
{
// To make the code a bit more readable.
uint32_t device_id = id;
struct xrt_device *xdev = get_xdev(ics, device_id);
*out_available = xrt_device_is_form_factor_available(xdev, form_factor);
return XRT_SUCCESS;
}

View file

@ -288,6 +288,7 @@ init_shm(struct ipc_server *s)
isdev->device_type = xdev->device_type;
isdev->hand_tracking_supported = xdev->hand_tracking_supported;
isdev->force_feedback_supported = xdev->force_feedback_supported;
isdev->form_factor_check_supported = xdev->form_factor_check_supported;
// Is this a HMD?
if (xdev->hmd != NULL) {

View file

@ -125,6 +125,7 @@ struct ipc_shared_device
bool position_tracking_supported;
bool hand_tracking_supported;
bool force_feedback_supported;
bool form_factor_check_supported;
};
/*!

View file

@ -252,5 +252,15 @@
{"name": "name", "type": "enum xrt_output_name"},
{"name": "value", "type": "union xrt_output_value"}
]
},
"device_is_form_factor_available": {
"in": [
{"name": "id", "type": "uint32_t"},
{"name": "form_factor", "type": "enum xrt_form_factor"}
],
"out": [
{"name": "available", "type": "bool"}
]
}
}