mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
t/common: Add Qwerty builder
This commit is contained in:
parent
76c5d677d7
commit
be58024ffb
|
@ -50,6 +50,11 @@ if(XRT_BUILD_DRIVER_WMR)
|
|||
target_link_libraries(target_lists PRIVATE drv_wmr)
|
||||
endif()
|
||||
|
||||
if(XRT_BUILD_DRIVER_QWERTY)
|
||||
target_sources(target_lists PRIVATE target_builder_qwerty.c)
|
||||
target_link_libraries(target_lists PRIVATE drv_qwerty)
|
||||
endif()
|
||||
|
||||
###
|
||||
# Drivers
|
||||
#
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
#define T_BUILDER_REMOTE
|
||||
#endif
|
||||
|
||||
#if defined(XRT_BUILD_DRIVER_QWERTY) || defined(XRT_DOXYGEN)
|
||||
#define T_BUILDER_QWERTY
|
||||
#endif
|
||||
|
||||
#if defined(XRT_BUILD_DRIVER_PSMV) || defined(XRT_BUILD_DRIVER_PSVR) || defined(XRT_DOXYGEN)
|
||||
#define T_BUILDER_RGB_TRACKING
|
||||
#endif
|
||||
|
@ -78,6 +82,14 @@ struct xrt_builder *
|
|||
t_builder_north_star_create(void);
|
||||
#endif
|
||||
|
||||
#ifdef T_BUILDER_QWERTY
|
||||
/*!
|
||||
* The qwerty driver builder.
|
||||
*/
|
||||
struct xrt_builder *
|
||||
t_builder_qwerty_create(void);
|
||||
#endif
|
||||
|
||||
#ifdef T_BUILDER_REMOTE
|
||||
/*!
|
||||
* The remote driver builder.
|
||||
|
|
136
src/xrt/targets/common/target_builder_qwerty.c
Normal file
136
src/xrt/targets/common/target_builder_qwerty.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
// Copyright 2022-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Qwerty devices builder.
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup drv_qwerty
|
||||
*/
|
||||
|
||||
#include "xrt/xrt_config_drivers.h"
|
||||
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_builders.h"
|
||||
#include "util/u_system_helpers.h"
|
||||
|
||||
#include "target_builder_interface.h"
|
||||
|
||||
#include "qwerty/qwerty_interface.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifndef XRT_BUILD_DRIVER_QWERTY
|
||||
#error "Must only be built with XRT_BUILD_DRIVER_QWERTY set"
|
||||
#endif
|
||||
|
||||
// Using INFO as default to inform events real devices could report physically
|
||||
DEBUG_GET_ONCE_LOG_OPTION(qwerty_log, "QWERTY_LOG", U_LOGGING_INFO)
|
||||
|
||||
// Driver disabled by default for being experimental
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(enable_qwerty, "QWERTY_ENABLE", false)
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Helper functions.
|
||||
*
|
||||
*/
|
||||
|
||||
static const char *driver_list[] = {
|
||||
"qwerty",
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Member functions.
|
||||
*
|
||||
*/
|
||||
|
||||
static xrt_result_t
|
||||
qwerty_estimate_system(struct xrt_builder *xb,
|
||||
cJSON *config,
|
||||
struct xrt_prober *xp,
|
||||
struct xrt_builder_estimate *estimate)
|
||||
{
|
||||
if (!debug_get_bool_option_enable_qwerty()) {
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
estimate->certain.head = true;
|
||||
estimate->certain.left = true;
|
||||
estimate->certain.right = true;
|
||||
estimate->priority = -25;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
qwerty_open_system(struct xrt_builder *xb,
|
||||
cJSON *config,
|
||||
struct xrt_prober *xp,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso)
|
||||
{
|
||||
assert(out_xsysd != NULL);
|
||||
assert(*out_xsysd == NULL);
|
||||
|
||||
struct xrt_device *head = NULL;
|
||||
struct xrt_device *left = NULL;
|
||||
struct xrt_device *right = NULL;
|
||||
enum u_logging_level log_level = debug_get_log_option_qwerty_log();
|
||||
|
||||
xrt_result_t xret = qwerty_create_devices(log_level, &head, &left, &right);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
return xret;
|
||||
}
|
||||
|
||||
struct u_system_devices *usysd = u_system_devices_allocate();
|
||||
usysd->base.roles.head = head;
|
||||
usysd->base.roles.left = left;
|
||||
usysd->base.roles.right = right;
|
||||
|
||||
usysd->base.xdevs[usysd->base.xdev_count++] = head;
|
||||
if (left != NULL) {
|
||||
usysd->base.xdevs[usysd->base.xdev_count++] = left;
|
||||
}
|
||||
if (right != NULL) {
|
||||
usysd->base.xdevs[usysd->base.xdev_count++] = right;
|
||||
}
|
||||
|
||||
*out_xsysd = &usysd->base;
|
||||
u_builder_create_space_overseer(&usysd->base, out_xso);
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
qwerty_destroy(struct xrt_builder *xb)
|
||||
{
|
||||
free(xb);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* 'Exported' functions.
|
||||
*
|
||||
*/
|
||||
|
||||
struct xrt_builder *
|
||||
t_builder_qwerty_create(void)
|
||||
{
|
||||
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
|
||||
xb->estimate_system = qwerty_estimate_system;
|
||||
xb->open_system = qwerty_open_system;
|
||||
xb->destroy = qwerty_destroy;
|
||||
xb->identifier = "qwerty";
|
||||
xb->name = "Qwerty devices builder";
|
||||
xb->driver_identifiers = driver_list;
|
||||
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
|
||||
xb->exclude_from_automatic_discovery = !debug_get_bool_option_enable_qwerty();
|
||||
|
||||
return xb;
|
||||
}
|
|
@ -104,6 +104,10 @@ xrt_builder_create_func_t target_builder_list[] = {
|
|||
t_builder_rgb_tracking_create,
|
||||
#endif // T_BUILDER_RGB_TRACKING
|
||||
|
||||
#ifdef T_BUILDER_QWERTY
|
||||
t_builder_qwerty_create,
|
||||
#endif // T_BUILDER_QWERTY
|
||||
|
||||
#ifdef T_BUILDER_SIMULATED
|
||||
t_builder_simulated_create,
|
||||
#endif // T_BUILDER_SIMULATED
|
||||
|
|
Loading…
Reference in a new issue