mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
st/oxr: Carry around extra xrt_devices
Pretty much only used for enabling 3 PS Move Controllers right now.
This commit is contained in:
parent
2abc98dbec
commit
962de77ca0
|
@ -664,9 +664,11 @@ oxr_action_sync_data(struct oxr_logger* log,
|
|||
// Synchronize outputs to this time.
|
||||
int64_t now = time_state_get_now(sess->sys->inst->timekeeping);
|
||||
|
||||
oxr_xdev_update(sess->sys->head, sess->sys->inst->timekeeping);
|
||||
oxr_xdev_update(sess->sys->left, sess->sys->inst->timekeeping);
|
||||
oxr_xdev_update(sess->sys->right, sess->sys->inst->timekeeping);
|
||||
// Loop over all xdev devices.
|
||||
for (size_t i = 0; i < sess->sys->num_xdevs; i++) {
|
||||
oxr_xdev_update(sess->sys->xdevs[i],
|
||||
sess->sys->inst->timekeeping);
|
||||
}
|
||||
|
||||
//! @todo These semantics below are all wrong!
|
||||
|
||||
|
|
|
@ -36,19 +36,6 @@ radtodeg_for_display(float radians)
|
|||
return (int32_t)(radians * 180 * M_1_PI);
|
||||
}
|
||||
|
||||
static inline void
|
||||
xdev_destroy(struct xrt_device **xdev_ptr)
|
||||
{
|
||||
struct xrt_device *xdev = *xdev_ptr;
|
||||
|
||||
if (xdev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
xdev->destroy(xdev);
|
||||
*xdev_ptr = NULL;
|
||||
}
|
||||
|
||||
static XrResult
|
||||
oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
||||
{
|
||||
|
@ -62,9 +49,9 @@ oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
|||
u_hashset_destroy(&inst->path_store);
|
||||
}
|
||||
|
||||
xdev_destroy(&inst->system.head);
|
||||
xdev_destroy(&inst->system.left);
|
||||
xdev_destroy(&inst->system.right);
|
||||
for (size_t i = 0; i < inst->system.num_xdevs; i++) {
|
||||
oxr_xdev_destroy(&inst->system.xdevs[i]);
|
||||
}
|
||||
|
||||
xrt_prober_destroy(&inst->prober);
|
||||
|
||||
|
@ -85,13 +72,15 @@ cache_path(struct oxr_logger *log,
|
|||
oxr_path_get_or_create(log, inst, str, strlen(str), out_path);
|
||||
}
|
||||
|
||||
#define NUM_XDEVS 16
|
||||
|
||||
XrResult
|
||||
oxr_instance_create(struct oxr_logger *log,
|
||||
const XrInstanceCreateInfo *createInfo,
|
||||
struct oxr_instance **out_instance)
|
||||
{
|
||||
struct oxr_instance *inst = NULL;
|
||||
struct xrt_device *xdevs[3] = {0};
|
||||
struct xrt_device *xdevs[NUM_XDEVS] = {0};
|
||||
int h_ret, p_ret;
|
||||
|
||||
OXR_ALLOCATE_HANDLE_OR_RETURN(log, inst, OXR_XR_DEBUG_INSTANCE,
|
||||
|
@ -125,7 +114,7 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
"Failed to probe device(s)");
|
||||
}
|
||||
|
||||
p_ret = xrt_prober_select(inst->prober, xdevs, 3);
|
||||
p_ret = xrt_prober_select(inst->prober, xdevs, NUM_XDEVS);
|
||||
if (p_ret != 0) {
|
||||
xrt_prober_destroy(&inst->prober);
|
||||
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
||||
|
@ -173,8 +162,7 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
dev->hmd->views[1].fov.angle_down = down_override;
|
||||
}
|
||||
|
||||
oxr_system_fill_in(log, inst, 1, &inst->system, xdevs[0], xdevs[1],
|
||||
xdevs[2]);
|
||||
oxr_system_fill_in(log, inst, 1, &inst->system, xdevs, NUM_XDEVS);
|
||||
|
||||
inst->timekeeping = time_state_create();
|
||||
|
||||
|
|
|
@ -535,9 +535,8 @@ oxr_system_fill_in(struct oxr_logger *log,
|
|||
struct oxr_instance *inst,
|
||||
XrSystemId systemId,
|
||||
struct oxr_system *sys,
|
||||
struct xrt_device *head,
|
||||
struct xrt_device *left,
|
||||
struct xrt_device *right);
|
||||
struct xrt_device **xdevs,
|
||||
size_t num_xdevs);
|
||||
|
||||
XrResult
|
||||
oxr_system_verify_id(struct oxr_logger *log,
|
||||
|
@ -612,6 +611,9 @@ oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
|
|||
*
|
||||
*/
|
||||
|
||||
void
|
||||
oxr_xdev_destroy(struct xrt_device **xdev_ptr);
|
||||
|
||||
void
|
||||
oxr_xdev_update(struct xrt_device *xdev, struct time_state *timekeeping);
|
||||
|
||||
|
@ -765,9 +767,16 @@ struct oxr_system
|
|||
{
|
||||
struct oxr_instance *inst;
|
||||
|
||||
struct xrt_device *head;
|
||||
struct xrt_device *left;
|
||||
struct xrt_device *right;
|
||||
union {
|
||||
struct
|
||||
{
|
||||
struct xrt_device *head;
|
||||
struct xrt_device *left;
|
||||
struct xrt_device *right;
|
||||
};
|
||||
struct xrt_device *xdevs[16];
|
||||
};
|
||||
size_t num_xdevs;
|
||||
|
||||
XrSystemId systemId;
|
||||
|
||||
|
|
|
@ -93,10 +93,21 @@ oxr_system_fill_in(struct oxr_logger *log,
|
|||
struct oxr_instance *inst,
|
||||
XrSystemId systemId,
|
||||
struct oxr_system *sys,
|
||||
struct xrt_device *head,
|
||||
struct xrt_device *left,
|
||||
struct xrt_device *right)
|
||||
struct xrt_device **xdevs,
|
||||
size_t num_xdevs)
|
||||
{
|
||||
|
||||
for (uint32_t i = 4; i < ARRAY_SIZE(sys->xdevs); i++) {
|
||||
sys->xdevs[i] = xdevs[i];
|
||||
}
|
||||
for (size_t i = ARRAY_SIZE(sys->xdevs); i < num_xdevs; i++) {
|
||||
oxr_xdev_destroy(&xdevs[i]);
|
||||
}
|
||||
|
||||
struct xrt_device *head = sys->head;
|
||||
struct xrt_device *left = sys->left;
|
||||
struct xrt_device *right = sys->right;
|
||||
|
||||
if (head == NULL) {
|
||||
return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED,
|
||||
" failed to probe device");
|
||||
|
@ -122,9 +133,6 @@ oxr_system_fill_in(struct oxr_logger *log,
|
|||
}
|
||||
|
||||
// clang-format off
|
||||
sys->head = head;
|
||||
sys->left = left;
|
||||
sys->right = right;
|
||||
sys->inst = inst;
|
||||
sys->systemId = systemId;
|
||||
sys->form_factor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
||||
|
|
|
@ -13,6 +13,19 @@
|
|||
#include "oxr_objects.h"
|
||||
|
||||
|
||||
void
|
||||
oxr_xdev_destroy(struct xrt_device **xdev_ptr)
|
||||
{
|
||||
struct xrt_device *xdev = *xdev_ptr;
|
||||
|
||||
if (xdev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
xdev->destroy(xdev);
|
||||
*xdev_ptr = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
oxr_xdev_update(struct xrt_device *xdev, struct time_state *timekeeping)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue