d/qwerty: Add helper create function

This commit is contained in:
Jakob Bornecrantz 2023-04-19 22:02:45 +01:00
parent ef59d8e85d
commit 76c5d677d7
2 changed files with 43 additions and 2 deletions
src/xrt/drivers/qwerty

View file

@ -55,6 +55,17 @@ qwerty_create_auto_prober(void);
void
qwerty_process_event(struct xrt_device **xdevs, size_t xdev_count, SDL_Event event);
/*!
* Create all qwerty devices.
*
* @ingroup drv_qwerty
*/
xrt_result_t
qwerty_create_devices(enum u_logging_level log_level,
struct xrt_device **out_hmd,
struct xrt_device **out_left,
struct xrt_device **out_right);
#ifdef __cplusplus
}

View file

@ -7,11 +7,15 @@
* @ingroup drv_qwerty
*/
#include "qwerty_device.h"
#include "xrt/xrt_prober.h"
#include "util/u_misc.h"
#include "util/u_debug.h"
#include "util/u_logging.h"
#include "xrt/xrt_prober.h"
#include "qwerty_device.h"
#include "qwerty_interface.h"
// Using INFO as default to inform events real devices could report physically
DEBUG_GET_ONCE_LOG_OPTION(qwerty_log, "QWERTY_LOG", U_LOGGING_INFO)
@ -72,6 +76,13 @@ qwerty_prober_autoprobe(struct xrt_auto_prober *xap,
return num_qwerty_devices;
}
/*
*
* 'Exported' functions.
*
*/
struct xrt_auto_prober *
qwerty_create_auto_prober(void)
{
@ -82,3 +93,22 @@ qwerty_create_auto_prober(void)
return &qp->base;
}
xrt_result_t
qwerty_create_devices(enum u_logging_level log_level,
struct xrt_device **out_hmd,
struct xrt_device **out_left,
struct xrt_device **out_right)
{
struct qwerty_hmd *qhmd = qwerty_hmd_create();
struct qwerty_controller *qleft = qwerty_controller_create(true, qhmd);
struct qwerty_controller *qright = qwerty_controller_create(false, qhmd);
qwerty_system_create(qhmd, qleft, qright, log_level);
*out_hmd = &qhmd->base.base;
*out_left = &qleft->base.base;
*out_right = &qright->base.base;
return XRT_SUCCESS;
}