The open source OpenXR runtime
0
fork

Configure Feed

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

d/psvr: Switch to logging API

+18 -50
+7 -9
src/xrt/drivers/psvr/psvr_device.c
··· 42 42 */ 43 43 44 44 DEBUG_GET_ONCE_BOOL_OPTION(psvr_disco, "PSVR_DISCO", false) 45 + #define PSVR_DEBUG(p, ...) U_LOG_XDEV_IFL_D(&p->base, p->log_level, __VA_ARGS__) 46 + #define PSVR_ERROR(p, ...) U_LOG_XDEV_IFL_E(&p->base, p->log_level, __VA_ARGS__) 45 47 46 48 #define FEATURE_BUFFER_SIZE 256 47 49 ··· 85 87 bool powered_on; 86 88 bool in_vr_mode; 87 89 88 - bool print_spew; 89 - bool print_debug; 90 + enum u_logging_level log_level; 90 91 91 92 struct 92 93 { ··· 1010 1011 psvr_device_create(struct hid_device_info *hmd_handle_info, 1011 1012 struct hid_device_info *hmd_control_info, 1012 1013 struct xrt_prober *xp, 1013 - bool print_spew, 1014 - bool print_debug) 1014 + enum u_logging_level log_level) 1015 1015 { 1016 1016 enum u_device_alloc_flags flags = (enum u_device_alloc_flags)( 1017 1017 U_DEVICE_ALLOC_HMD | U_DEVICE_ALLOC_TRACKING_NONE); ··· 1019 1019 U_DEVICE_ALLOCATE(struct psvr_device, flags, 1, 0); 1020 1020 int ret; 1021 1021 1022 - psvr->print_spew = print_spew; 1023 - psvr->print_debug = print_debug; 1022 + psvr->log_level = log_level; 1024 1023 psvr->base.update_inputs = psvr_device_update_inputs; 1025 1024 psvr->base.get_tracked_pose = psvr_device_get_tracked_pose; 1026 1025 psvr->base.get_view_pose = psvr_device_get_view_pose; ··· 1136 1135 u_var_add_u8(psvr, &psvr->wants.leds[6], "Led G"); 1137 1136 u_var_add_u8(psvr, &psvr->wants.leds[7], "Led H"); 1138 1137 u_var_add_u8(psvr, &psvr->wants.leds[8], "Led I"); 1139 - u_var_add_bool(psvr, &psvr->print_debug, "Debug"); 1140 - u_var_add_bool(psvr, &psvr->print_spew, "Spew"); 1138 + u_var_add_log_level(psvr, &psvr->log_level, "Log level"); 1141 1139 // clang-format on 1142 1140 1143 1141 /* 1144 1142 * Finishing touches. 1145 1143 */ 1146 1144 1147 - if (psvr->print_debug) { 1145 + if (psvr->log_level <= U_LOGGING_DEBUG) { 1148 1146 u_device_dump_config(&psvr->base, __func__, "Sony PSVR"); 1149 1147 } 1150 1148
+3 -33
src/xrt/drivers/psvr/psvr_device.h
··· 15 15 #include "xrt/xrt_device.h" 16 16 #include "xrt/xrt_prober.h" 17 17 18 + #include "util/u_logging.h" 19 + 18 20 #include <hidapi.h> 19 21 20 22 ··· 125 127 psvr_device_create(struct hid_device_info *hmd_handle_info, 126 128 struct hid_device_info *hmd_control_info, 127 129 struct xrt_prober *xp, 128 - bool print_spew, 129 - bool print_debug); 130 + enum u_logging_level log_level); 130 131 131 132 bool 132 133 psvr_parse_sensor_packet(struct psvr_parsed_sensor *sensor, ··· 137 138 psvr_parse_status_packet(struct psvr_parsed_status *status, 138 139 const uint8_t *buffer, 139 140 int size); 140 - 141 - 142 - /* 143 - * 144 - * Printing functions. 145 - * 146 - */ 147 - 148 - #define PSVR_SPEW(p, ...) \ 149 - do { \ 150 - if (p->print_spew) { \ 151 - fprintf(stderr, "%s - ", __func__); \ 152 - fprintf(stderr, __VA_ARGS__); \ 153 - fprintf(stderr, "\n"); \ 154 - } \ 155 - } while (false) 156 - #define PSVR_DEBUG(p, ...) \ 157 - do { \ 158 - if (p->print_debug) { \ 159 - fprintf(stderr, "%s - ", __func__); \ 160 - fprintf(stderr, __VA_ARGS__); \ 161 - fprintf(stderr, "\n"); \ 162 - } \ 163 - } while (false) 164 - 165 - #define PSVR_ERROR(p, ...) \ 166 - do { \ 167 - fprintf(stderr, "%s - ", __func__); \ 168 - fprintf(stderr, __VA_ARGS__); \ 169 - fprintf(stderr, "\n"); \ 170 - } while (false) 171 141 172 142 173 143 #ifdef __cplusplus
+8 -8
src/xrt/drivers/psvr/psvr_prober.c
··· 17 17 18 18 #include "util/u_misc.h" 19 19 #include "util/u_debug.h" 20 + #include "util/u_logging.h" 20 21 21 22 #include "psvr_interface.h" 22 23 #include "psvr_device.h" ··· 30 31 31 32 // Should the experimental PSVR driver be enabled. 32 33 DEBUG_GET_ONCE_BOOL_OPTION(psvr_enable, "PSVR_ENABLE", true) 33 - DEBUG_GET_ONCE_BOOL_OPTION(psvr_spew, "PSVR_PRINT_SPEW", false) 34 - DEBUG_GET_ONCE_BOOL_OPTION(psvr_debug, "PSVR_PRINT_DEBUG", false) 34 + DEBUG_GET_ONCE_LOG_OPTION(psvr_log, "DUMMY_LOG", U_LOGGING_WARN) 35 + 36 + #define PSVR_DEBUG(p, ...) U_LOG_IFL_D(p->log_level, __VA_ARGS__) 35 37 36 38 /*! 37 39 * PSVR prober struct. ··· 43 45 { 44 46 struct xrt_auto_prober base; 45 47 46 - bool print_spew; 47 - bool print_debug; 48 48 bool enabled; 49 + 50 + enum u_logging_level log_level; 49 51 }; 50 52 51 53 ··· 104 106 if (info_control != NULL && info_handle != NULL) { 105 107 if (ppsvr->enabled) { 106 108 dev = psvr_device_create(info_handle, info_control, xp, 107 - ppsvr->print_spew, 108 - ppsvr->print_debug); 109 + ppsvr->log_level); 109 110 } else { 110 111 PSVR_DEBUG(ppsvr, 111 112 "Found a PSVR hmd but driver is disabled"); ··· 132 133 ppsvr->base.destroy = psvr_prober_destroy; 133 134 ppsvr->base.lelo_dallas_autoprobe = psvr_prober_autoprobe; 134 135 ppsvr->enabled = debug_get_bool_option_psvr_enable(); 135 - ppsvr->print_spew = debug_get_bool_option_psvr_spew(); 136 - ppsvr->print_debug = debug_get_bool_option_psvr_debug(); 136 + ppsvr->log_level = debug_get_log_option_psvr_log(); 137 137 138 138 return &ppsvr->base; 139 139 }