The open source OpenXR runtime
0
fork

Configure Feed

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

d/simulated: Rename the simulated device driver.

+180 -180
+3 -3
CMakeLists.txt
··· 280 280 option_with_deps(XRT_BUILD_DRIVER_VF "Build video frame driver (for video file support, uses gstreamer)" DEPENDS XRT_HAVE_GST) 281 281 option_with_deps(XRT_BUILD_DRIVER_VIVE "Enable driver for HTC Vive, Vive Pro, Valve Index, and their controllers" DEPENDS ZLIB_FOUND XRT_HAVE_LINUX) 282 282 option_with_deps(XRT_BUILD_DRIVER_WMR "Enable Windows Mixed Reality driver" DEPENDS "NOT WIN32") 283 - option(XRT_BUILD_DRIVER_DUMMY "Enable dummy driver" ON) 283 + option(XRT_BUILD_DRIVER_SIMULATED "Enable simulated driver" ON) 284 284 285 285 option(XRT_BUILD_SAMPLES "Enable compiling sample code implementations that will not be linked into any final targets" ON) 286 286 ··· 314 314 "ANDROID" 315 315 "ARDUINO" 316 316 "DAYDREAM" 317 - "DUMMY" 317 + "SIMULATED" 318 318 "HANDTRACKING" 319 319 "HDK" 320 320 "HYDRA" ··· 477 477 message(STATUS "# DRIVER_ARDUINO: ${XRT_BUILD_DRIVER_ARDUINO}") 478 478 message(STATUS "# DRIVER_DAYDREAM: ${XRT_BUILD_DRIVER_DAYDREAM}") 479 479 message(STATUS "# DRIVER_DEPTHAI: ${XRT_BUILD_DRIVER_DEPTHAI}") 480 - message(STATUS "# DRIVER_DUMMY: ${XRT_BUILD_DRIVER_DUMMY}") 480 + message(STATUS "# DRIVER_SIMULATED: ${XRT_BUILD_DRIVER_SIMULATED}") 481 481 message(STATUS "# DRIVER_EUROC: ${XRT_BUILD_DRIVER_EUROC}") 482 482 message(STATUS "# DRIVER_HANDTRACKING: ${XRT_BUILD_DRIVER_HANDTRACKING}") 483 483 message(STATUS "# DRIVER_HDK: ${XRT_BUILD_DRIVER_HDK}")
+4 -4
src/xrt/drivers/CMakeLists.txt
··· 43 43 list(APPEND ENABLED_DRIVERS depthai) 44 44 endif() 45 45 46 - if(XRT_BUILD_DRIVER_DUMMY) 47 - add_library(drv_dummy STATIC dummy/dummy_hmd.c dummy/dummy_interface.h dummy/dummy_prober.c) 48 - target_link_libraries(drv_dummy PRIVATE xrt-interfaces aux_util) 49 - list(APPEND ENABLED_HEADSET_DRIVERS dummy) 46 + if(XRT_BUILD_DRIVER_SIMULATED) 47 + add_library(drv_simulated STATIC simulated/simulated_hmd.c simulated/simulated_interface.h simulated/simulated_prober.c) 48 + target_link_libraries(drv_simulated PRIVATE xrt-interfaces aux_util) 49 + list(APPEND ENABLED_HEADSET_DRIVERS simulated) 50 50 endif() 51 51 52 52 if(XRT_BUILD_DRIVER_QWERTY)
+43 -43
src/xrt/drivers/dummy/dummy_hmd.c src/xrt/drivers/simulated/simulated_hmd.c
··· 2 2 // SPDX-License-Identifier: BSL-1.0 3 3 /*! 4 4 * @file 5 - * @brief Dummy HMD device. 5 + * @brief Simulated HMD device. 6 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 - * @ingroup drv_dummy 7 + * @ingroup drv_simulated 8 8 */ 9 9 10 10 #include "xrt/xrt_device.h" ··· 31 31 * 32 32 */ 33 33 34 - enum dummy_movement 34 + enum simulated_movement 35 35 { 36 - DUMMY_WOBBLE, 37 - DUMMY_ROTATE, 36 + SIMULATED_WOBBLE, 37 + SIMULATED_ROTATE, 38 38 }; 39 39 40 40 ··· 43 43 * 44 44 * @implements xrt_device 45 45 */ 46 - struct dummy_hmd 46 + struct simulated_hmd 47 47 { 48 48 struct xrt_device base; 49 49 ··· 54 54 float diameter_m; 55 55 56 56 enum u_logging_level log_level; 57 - enum dummy_movement movement; 57 + enum simulated_movement movement; 58 58 }; 59 59 60 60 ··· 64 64 * 65 65 */ 66 66 67 - static inline struct dummy_hmd * 68 - dummy_hmd(struct xrt_device *xdev) 67 + static inline struct simulated_hmd * 68 + simulated_hmd(struct xrt_device *xdev) 69 69 { 70 - return (struct dummy_hmd *)xdev; 70 + return (struct simulated_hmd *)xdev; 71 71 } 72 72 73 - DEBUG_GET_ONCE_LOG_OPTION(dummy_log, "DUMMY_LOG", U_LOGGING_WARN) 74 - DEBUG_GET_ONCE_BOOL_OPTION(dummy_rotate, "DUMMY_ROTATE", false) 73 + DEBUG_GET_ONCE_LOG_OPTION(simulated_log, "SIMULATED_LOG", U_LOGGING_WARN) 74 + DEBUG_GET_ONCE_BOOL_OPTION(simulated_rotate, "SIMULATED_ROTATE", false) 75 75 76 76 #define DH_TRACE(p, ...) U_LOG_XDEV_IFL_T(&dh->base, dh->log_level, __VA_ARGS__) 77 77 #define DH_DEBUG(p, ...) U_LOG_XDEV_IFL_D(&dh->base, dh->log_level, __VA_ARGS__) 78 78 #define DH_ERROR(p, ...) U_LOG_XDEV_IFL_E(&dh->base, dh->log_level, __VA_ARGS__) 79 79 80 80 static void 81 - dummy_hmd_destroy(struct xrt_device *xdev) 81 + simulated_hmd_destroy(struct xrt_device *xdev) 82 82 { 83 - struct dummy_hmd *dh = dummy_hmd(xdev); 83 + struct simulated_hmd *dh = simulated_hmd(xdev); 84 84 85 85 // Remove the variable tracking. 86 86 u_var_remove_root(dh); ··· 89 89 } 90 90 91 91 static void 92 - dummy_hmd_update_inputs(struct xrt_device *xdev) 92 + simulated_hmd_update_inputs(struct xrt_device *xdev) 93 93 { 94 94 // Empty, you should put code to update the attached inputs fields. 95 95 } 96 96 97 97 static void 98 - dummy_hmd_get_tracked_pose(struct xrt_device *xdev, 99 - enum xrt_input_name name, 100 - uint64_t at_timestamp_ns, 101 - struct xrt_space_relation *out_relation) 98 + simulated_hmd_get_tracked_pose(struct xrt_device *xdev, 99 + enum xrt_input_name name, 100 + uint64_t at_timestamp_ns, 101 + struct xrt_space_relation *out_relation) 102 102 { 103 - struct dummy_hmd *dh = dummy_hmd(xdev); 103 + struct simulated_hmd *dh = simulated_hmd(xdev); 104 104 105 105 if (name != XRT_INPUT_GENERIC_HEAD_POSE) { 106 106 DH_ERROR(dh, "unknown input name"); ··· 118 118 119 119 switch (dh->movement) { 120 120 default: 121 - case DUMMY_WOBBLE: 121 + case SIMULATED_WOBBLE: 122 122 // Wobble time. 123 123 dh->pose.position.x = dh->center.x + sin((time_s / t2) * M_PI) * d2 - d; 124 124 dh->pose.position.y = dh->center.y + sin((time_s / t) * M_PI) * d; ··· 128 128 dh->pose.orientation.w = 1; 129 129 math_quat_normalize(&dh->pose.orientation); 130 130 break; 131 - case DUMMY_ROTATE: 131 + case SIMULATED_ROTATE: 132 132 // Reset position. 133 133 dh->pose.position = dh->center; 134 134 ··· 144 144 } 145 145 146 146 static void 147 - dummy_hmd_get_view_poses(struct xrt_device *xdev, 148 - const struct xrt_vec3 *default_eye_relation, 149 - uint64_t at_timestamp_ns, 150 - uint32_t view_count, 151 - struct xrt_space_relation *out_head_relation, 152 - struct xrt_fov *out_fovs, 153 - struct xrt_pose *out_poses) 147 + simulated_hmd_get_view_poses(struct xrt_device *xdev, 148 + const struct xrt_vec3 *default_eye_relation, 149 + uint64_t at_timestamp_ns, 150 + uint32_t view_count, 151 + struct xrt_space_relation *out_head_relation, 152 + struct xrt_fov *out_fovs, 153 + struct xrt_pose *out_poses) 154 154 { 155 155 u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, out_fovs, 156 156 out_poses); 157 157 } 158 158 159 159 struct xrt_device * 160 - dummy_hmd_create(void) 160 + simulated_hmd_create(void) 161 161 { 162 162 enum u_device_alloc_flags flags = 163 163 (enum u_device_alloc_flags)(U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE); 164 - struct dummy_hmd *dh = U_DEVICE_ALLOCATE(struct dummy_hmd, flags, 1, 0); 165 - dh->base.update_inputs = dummy_hmd_update_inputs; 166 - dh->base.get_tracked_pose = dummy_hmd_get_tracked_pose; 167 - dh->base.get_view_poses = dummy_hmd_get_view_poses; 168 - dh->base.destroy = dummy_hmd_destroy; 164 + struct simulated_hmd *dh = U_DEVICE_ALLOCATE(struct simulated_hmd, flags, 1, 0); 165 + dh->base.update_inputs = simulated_hmd_update_inputs; 166 + dh->base.get_tracked_pose = simulated_hmd_get_tracked_pose; 167 + dh->base.get_view_poses = simulated_hmd_get_view_poses; 168 + dh->base.destroy = simulated_hmd_destroy; 169 169 dh->base.name = XRT_DEVICE_GENERIC_HMD; 170 170 dh->base.device_type = XRT_DEVICE_TYPE_HMD; 171 171 dh->pose.orientation.w = 1.0f; // All other values set to zero. 172 172 dh->created_ns = os_monotonic_get_ns(); 173 173 dh->diameter_m = 0.05f; 174 - dh->log_level = debug_get_log_option_dummy_log(); 174 + dh->log_level = debug_get_log_option_simulated_log(); 175 175 176 176 // Print name. 177 - snprintf(dh->base.str, XRT_DEVICE_NAME_LEN, "Dummy HMD"); 178 - snprintf(dh->base.serial, XRT_DEVICE_NAME_LEN, "Dummy HMD"); 177 + snprintf(dh->base.str, XRT_DEVICE_NAME_LEN, "Simulated HMD"); 178 + snprintf(dh->base.serial, XRT_DEVICE_NAME_LEN, "Simulated HMD"); 179 179 180 180 // Setup input. 181 181 dh->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE; ··· 193 193 194 194 if (!u_device_setup_split_side_by_side(&dh->base, &info)) { 195 195 DH_ERROR(dh, "Failed to setup basic device info"); 196 - dummy_hmd_destroy(&dh->base); 196 + simulated_hmd_destroy(&dh->base); 197 197 return NULL; 198 198 } 199 199 200 200 // Select the type of movement. 201 - dh->movement = DUMMY_WOBBLE; 202 - if (debug_get_bool_option_dummy_rotate()) { 203 - dh->movement = DUMMY_ROTATE; 201 + dh->movement = SIMULATED_WOBBLE; 202 + if (debug_get_bool_option_simulated_rotate()) { 203 + dh->movement = SIMULATED_ROTATE; 204 204 } 205 205 206 206 // Setup variable tracker. 207 - u_var_add_root(dh, "Dummy HMD", true); 207 + u_var_add_root(dh, "Simulated HMD", true); 208 208 u_var_add_pose(dh, &dh->pose, "pose"); 209 209 u_var_add_vec3_f32(dh, &dh->center, "center"); 210 210 u_var_add_f32(dh, &dh->diameter_m, "diameter_m");
-48
src/xrt/drivers/dummy/dummy_interface.h
··· 1 - // Copyright 2020, Collabora, Ltd. 2 - // SPDX-License-Identifier: BSL-1.0 3 - /*! 4 - * @file 5 - * @brief Interface to dummy driver. 6 - * @author Jakob Bornecrantz <jakob@collabora.com> 7 - * @ingroup drv_dummy 8 - */ 9 - 10 - #pragma once 11 - 12 - #ifdef __cplusplus 13 - extern "C" { 14 - #endif 15 - 16 - /*! 17 - * @defgroup drv_dummy Dummy driver 18 - * @ingroup drv 19 - * 20 - * @brief Simple do-nothing dummy driver. 21 - */ 22 - 23 - /*! 24 - * Create a auto prober for dummy devices. 25 - * 26 - * @ingroup drv_dummy 27 - */ 28 - struct xrt_auto_prober * 29 - dummy_create_auto_prober(void); 30 - 31 - /*! 32 - * Create a dummy hmd. 33 - * 34 - * @ingroup drv_dummy 35 - */ 36 - struct xrt_device * 37 - dummy_hmd_create(void); 38 - 39 - /*! 40 - * @dir drivers/dummy 41 - * 42 - * @brief @ref drv_dummy files. 43 - */ 44 - 45 - 46 - #ifdef __cplusplus 47 - } 48 - #endif
-73
src/xrt/drivers/dummy/dummy_prober.c
··· 1 - // Copyright 2020, Collabora, Ltd. 2 - // SPDX-License-Identifier: BSL-1.0 3 - /*! 4 - * @file 5 - * @brief Dummy prober code. 6 - * @author Jakob Bornecrantz <jakob@collabora.com> 7 - * @ingroup drv_dummy 8 - */ 9 - 10 - #include <stdio.h> 11 - #include <stdlib.h> 12 - 13 - #include "xrt/xrt_prober.h" 14 - 15 - #include "util/u_misc.h" 16 - #include "util/u_debug.h" 17 - 18 - #include "dummy_interface.h" 19 - 20 - /*! 21 - * @implements xrt_auto_prober 22 - */ 23 - struct dummy_prober 24 - { 25 - struct xrt_auto_prober base; 26 - }; 27 - 28 - //! @private @memberof dummy_prober 29 - static inline struct dummy_prober * 30 - dummy_prober(struct xrt_auto_prober *p) 31 - { 32 - return (struct dummy_prober *)p; 33 - } 34 - 35 - //! @public @memberof dummy_prober 36 - static void 37 - dummy_prober_destroy(struct xrt_auto_prober *p) 38 - { 39 - struct dummy_prober *dp = dummy_prober(p); 40 - 41 - free(dp); 42 - } 43 - 44 - //! @public @memberof dummy_prober 45 - static int 46 - dummy_prober_autoprobe(struct xrt_auto_prober *xap, 47 - cJSON *attached_data, 48 - bool no_hmds, 49 - struct xrt_prober *xp, 50 - struct xrt_device **out_xdevs) 51 - { 52 - struct dummy_prober *dp = dummy_prober(xap); 53 - (void)dp; 54 - 55 - // Do not create a dummy HMD if we are not looking for HMDs. 56 - if (no_hmds) { 57 - return 0; 58 - } 59 - 60 - out_xdevs[0] = dummy_hmd_create(); 61 - return 1; 62 - } 63 - 64 - struct xrt_auto_prober * 65 - dummy_create_auto_prober() 66 - { 67 - struct dummy_prober *dp = U_TYPED_CALLOC(struct dummy_prober); 68 - dp->base.name = "Dummy"; 69 - dp->base.destroy = dummy_prober_destroy; 70 - dp->base.lelo_dallas_autoprobe = dummy_prober_autoprobe; 71 - 72 - return &dp->base; 73 - }
+48
src/xrt/drivers/simulated/simulated_interface.h
··· 1 + // Copyright 2020, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Interface to simulated driver. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup drv_simulated 8 + */ 9 + 10 + #pragma once 11 + 12 + #ifdef __cplusplus 13 + extern "C" { 14 + #endif 15 + 16 + /*! 17 + * @defgroup drv_simulated Simulated driver 18 + * @ingroup drv 19 + * 20 + * @brief Simple do-nothing simulated driver. 21 + */ 22 + 23 + /*! 24 + * Create a auto prober for simulated devices. 25 + * 26 + * @ingroup drv_simulated 27 + */ 28 + struct xrt_auto_prober * 29 + simulated_create_auto_prober(void); 30 + 31 + /*! 32 + * Create a simulated hmd. 33 + * 34 + * @ingroup drv_simulated 35 + */ 36 + struct xrt_device * 37 + simulated_hmd_create(void); 38 + 39 + /*! 40 + * @dir drivers/simulated 41 + * 42 + * @brief @ref drv_simulated files. 43 + */ 44 + 45 + 46 + #ifdef __cplusplus 47 + } 48 + #endif
+73
src/xrt/drivers/simulated/simulated_prober.c
··· 1 + // Copyright 2020, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief Simulated prober code. 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @ingroup drv_simulated 8 + */ 9 + 10 + #include <stdio.h> 11 + #include <stdlib.h> 12 + 13 + #include "xrt/xrt_prober.h" 14 + 15 + #include "util/u_misc.h" 16 + #include "util/u_debug.h" 17 + 18 + #include "simulated_interface.h" 19 + 20 + /*! 21 + * @implements xrt_auto_prober 22 + */ 23 + struct simulated_prober 24 + { 25 + struct xrt_auto_prober base; 26 + }; 27 + 28 + //! @private @memberof simulated_prober 29 + static inline struct simulated_prober * 30 + simulated_prober(struct xrt_auto_prober *p) 31 + { 32 + return (struct simulated_prober *)p; 33 + } 34 + 35 + //! @public @memberof simulated_prober 36 + static void 37 + simulated_prober_destroy(struct xrt_auto_prober *p) 38 + { 39 + struct simulated_prober *dp = simulated_prober(p); 40 + 41 + free(dp); 42 + } 43 + 44 + //! @public @memberof simulated_prober 45 + static int 46 + simulated_prober_autoprobe(struct xrt_auto_prober *xap, 47 + cJSON *attached_data, 48 + bool no_hmds, 49 + struct xrt_prober *xp, 50 + struct xrt_device **out_xdevs) 51 + { 52 + struct simulated_prober *dp = simulated_prober(xap); 53 + (void)dp; 54 + 55 + // Do not create a simulated HMD if we are not looking for HMDs. 56 + if (no_hmds) { 57 + return 0; 58 + } 59 + 60 + out_xdevs[0] = simulated_hmd_create(); 61 + return 1; 62 + } 63 + 64 + struct xrt_auto_prober * 65 + simulated_create_auto_prober() 66 + { 67 + struct simulated_prober *dp = U_TYPED_CALLOC(struct simulated_prober); 68 + dp->base.name = "Simulated"; 69 + dp->base.destroy = simulated_prober_destroy; 70 + dp->base.lelo_dallas_autoprobe = simulated_prober_autoprobe; 71 + 72 + return &dp->base; 73 + }
+2 -2
src/xrt/targets/common/CMakeLists.txt
··· 30 30 target_link_libraries(target_lists PRIVATE drv_daydream) 31 31 endif() 32 32 33 - if(XRT_BUILD_DRIVER_DUMMY) 34 - target_link_libraries(target_lists PRIVATE drv_dummy) 33 + if(XRT_BUILD_DRIVER_SIMULATED) 34 + target_link_libraries(target_lists PRIVATE drv_simulated) 35 35 endif() 36 36 37 37 if(XRT_BUILD_DRIVER_HDK)
+2 -2
src/xrt/targets/common/target_builder_rgb_tracking.c
··· 24 24 25 25 #include "target_builder_interface.h" 26 26 27 - #include "dummy/dummy_interface.h" 27 + #include "simulated/simulated_interface.h" 28 28 29 29 #ifdef XRT_HAVE_OPENCV 30 30 #include "tracking/t_tracking.h" ··· 330 330 } 331 331 #endif 332 332 } else { 333 - head = dummy_hmd_create(); 333 + head = simulated_hmd_create(); 334 334 } 335 335 336 336
+5 -5
src/xrt/targets/common/target_lists.c
··· 16 16 #include "arduino/arduino_interface.h" 17 17 #endif 18 18 19 - #ifdef XRT_BUILD_DRIVER_DUMMY 20 - #include "dummy/dummy_interface.h" 19 + #ifdef XRT_BUILD_DRIVER_SIMULATED 20 + #include "simulated/simulated_interface.h" 21 21 #endif 22 22 23 23 #ifdef XRT_BUILD_DRIVER_HDK ··· 228 228 qwerty_create_auto_prober, 229 229 #endif 230 230 231 - #ifdef XRT_BUILD_DRIVER_DUMMY 232 - // Dummy headset driver last. 233 - dummy_create_auto_prober, 231 + #ifdef XRT_BUILD_DRIVER_SIMULATED 232 + // Simulated headset driver last. 233 + simulated_create_auto_prober, 234 234 #endif 235 235 236 236 #ifdef XRT_BUILD_DRIVER_HANDTRACKING