The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/common: Add Qwerty builder

+157
+5
src/xrt/targets/common/CMakeLists.txt
··· 50 50 target_link_libraries(target_lists PRIVATE drv_wmr) 51 51 endif() 52 52 53 + if(XRT_BUILD_DRIVER_QWERTY) 54 + target_sources(target_lists PRIVATE target_builder_qwerty.c) 55 + target_link_libraries(target_lists PRIVATE drv_qwerty) 56 + endif() 57 + 53 58 ### 54 59 # Drivers 55 60 #
+12
src/xrt/targets/common/target_builder_interface.h
··· 31 31 #define T_BUILDER_REMOTE 32 32 #endif 33 33 34 + #if defined(XRT_BUILD_DRIVER_QWERTY) || defined(XRT_DOXYGEN) 35 + #define T_BUILDER_QWERTY 36 + #endif 37 + 34 38 #if defined(XRT_BUILD_DRIVER_PSMV) || defined(XRT_BUILD_DRIVER_PSVR) || defined(XRT_DOXYGEN) 35 39 #define T_BUILDER_RGB_TRACKING 36 40 #endif ··· 76 80 */ 77 81 struct xrt_builder * 78 82 t_builder_north_star_create(void); 83 + #endif 84 + 85 + #ifdef T_BUILDER_QWERTY 86 + /*! 87 + * The qwerty driver builder. 88 + */ 89 + struct xrt_builder * 90 + t_builder_qwerty_create(void); 79 91 #endif 80 92 81 93 #ifdef T_BUILDER_REMOTE
+136
src/xrt/targets/common/target_builder_qwerty.c
··· 1 + // Copyright 2022-2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Qwerty devices builder. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup drv_qwerty 8 + */ 9 + 10 + #include "xrt/xrt_config_drivers.h" 11 + 12 + #include "util/u_misc.h" 13 + #include "util/u_debug.h" 14 + #include "util/u_builders.h" 15 + #include "util/u_system_helpers.h" 16 + 17 + #include "target_builder_interface.h" 18 + 19 + #include "qwerty/qwerty_interface.h" 20 + 21 + #include <assert.h> 22 + 23 + 24 + #ifndef XRT_BUILD_DRIVER_QWERTY 25 + #error "Must only be built with XRT_BUILD_DRIVER_QWERTY set" 26 + #endif 27 + 28 + // Using INFO as default to inform events real devices could report physically 29 + DEBUG_GET_ONCE_LOG_OPTION(qwerty_log, "QWERTY_LOG", U_LOGGING_INFO) 30 + 31 + // Driver disabled by default for being experimental 32 + DEBUG_GET_ONCE_BOOL_OPTION(enable_qwerty, "QWERTY_ENABLE", false) 33 + 34 + 35 + /* 36 + * 37 + * Helper functions. 38 + * 39 + */ 40 + 41 + static const char *driver_list[] = { 42 + "qwerty", 43 + }; 44 + 45 + 46 + /* 47 + * 48 + * Member functions. 49 + * 50 + */ 51 + 52 + static xrt_result_t 53 + qwerty_estimate_system(struct xrt_builder *xb, 54 + cJSON *config, 55 + struct xrt_prober *xp, 56 + struct xrt_builder_estimate *estimate) 57 + { 58 + if (!debug_get_bool_option_enable_qwerty()) { 59 + return XRT_SUCCESS; 60 + } 61 + 62 + estimate->certain.head = true; 63 + estimate->certain.left = true; 64 + estimate->certain.right = true; 65 + estimate->priority = -25; 66 + 67 + return XRT_SUCCESS; 68 + } 69 + 70 + static xrt_result_t 71 + qwerty_open_system(struct xrt_builder *xb, 72 + cJSON *config, 73 + struct xrt_prober *xp, 74 + struct xrt_system_devices **out_xsysd, 75 + struct xrt_space_overseer **out_xso) 76 + { 77 + assert(out_xsysd != NULL); 78 + assert(*out_xsysd == NULL); 79 + 80 + struct xrt_device *head = NULL; 81 + struct xrt_device *left = NULL; 82 + struct xrt_device *right = NULL; 83 + enum u_logging_level log_level = debug_get_log_option_qwerty_log(); 84 + 85 + xrt_result_t xret = qwerty_create_devices(log_level, &head, &left, &right); 86 + if (xret != XRT_SUCCESS) { 87 + return xret; 88 + } 89 + 90 + struct u_system_devices *usysd = u_system_devices_allocate(); 91 + usysd->base.roles.head = head; 92 + usysd->base.roles.left = left; 93 + usysd->base.roles.right = right; 94 + 95 + usysd->base.xdevs[usysd->base.xdev_count++] = head; 96 + if (left != NULL) { 97 + usysd->base.xdevs[usysd->base.xdev_count++] = left; 98 + } 99 + if (right != NULL) { 100 + usysd->base.xdevs[usysd->base.xdev_count++] = right; 101 + } 102 + 103 + *out_xsysd = &usysd->base; 104 + u_builder_create_space_overseer(&usysd->base, out_xso); 105 + 106 + return XRT_SUCCESS; 107 + } 108 + 109 + static void 110 + qwerty_destroy(struct xrt_builder *xb) 111 + { 112 + free(xb); 113 + } 114 + 115 + 116 + /* 117 + * 118 + * 'Exported' functions. 119 + * 120 + */ 121 + 122 + struct xrt_builder * 123 + t_builder_qwerty_create(void) 124 + { 125 + struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder); 126 + xb->estimate_system = qwerty_estimate_system; 127 + xb->open_system = qwerty_open_system; 128 + xb->destroy = qwerty_destroy; 129 + xb->identifier = "qwerty"; 130 + xb->name = "Qwerty devices builder"; 131 + xb->driver_identifiers = driver_list; 132 + xb->driver_identifier_count = ARRAY_SIZE(driver_list); 133 + xb->exclude_from_automatic_discovery = !debug_get_bool_option_enable_qwerty(); 134 + 135 + return xb; 136 + }
+4
src/xrt/targets/common/target_lists.c
··· 104 104 t_builder_rgb_tracking_create, 105 105 #endif // T_BUILDER_RGB_TRACKING 106 106 107 + #ifdef T_BUILDER_QWERTY 108 + t_builder_qwerty_create, 109 + #endif // T_BUILDER_QWERTY 110 + 107 111 #ifdef T_BUILDER_SIMULATED 108 112 t_builder_simulated_create, 109 113 #endif // T_BUILDER_SIMULATED