The open source OpenXR runtime
0
fork

Configure Feed

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

d/vive/protocol: Port to u_logging.

+18 -25
+18 -25
src/xrt/drivers/vive/vive_protocol.c
··· 19 19 #include "util/u_debug.h" 20 20 #include "util/u_misc.h" 21 21 #include "util/u_json.h" 22 - 23 - #define VIVE_ERROR(...) \ 24 - do { \ 25 - fprintf(stderr, "%s - ", __func__); \ 26 - fprintf(stderr, __VA_ARGS__); \ 27 - fprintf(stderr, "\n"); \ 28 - } while (false) 22 + #include "util/u_logging.h" 29 23 30 24 const struct vive_headset_power_report power_on_report = { 31 25 .id = VIVE_HEADSET_POWER_REPORT_ID, ··· 76 70 int ret = os_hid_get_feature_timeout(hid_dev, &start_report, 77 71 sizeof(start_report), 100); 78 72 if (ret < 0) { 79 - VIVE_ERROR("Could not get config start report."); 73 + U_LOG_E("Could not get config start report."); 80 74 return NULL; 81 75 } 82 76 ··· 91 85 ret = os_hid_get_feature_timeout(hid_dev, &report, 92 86 sizeof(report), 100); 93 87 if (ret < 0) { 94 - VIVE_ERROR("Read error after %d bytes: %d", count, ret); 88 + U_LOG_E("Read error after %d bytes: %d", count, ret); 95 89 free(config_z); 96 90 return NULL; 97 91 } 98 92 99 93 if (report.len > 62) { 100 - VIVE_ERROR("Invalid configuration data at %d", count); 94 + U_LOG_E("Invalid configuration data at %d", count); 101 95 free(config_z); 102 96 return NULL; 103 97 } 104 98 105 99 if (count + report.len > 4096) { 106 - VIVE_ERROR("Configuration data too large"); 100 + U_LOG_E("Configuration data too large"); 107 101 free(config_z); 108 102 return NULL; 109 103 } ··· 126 120 127 121 ret = inflateInit(&strm); 128 122 if (ret != Z_OK) { 129 - VIVE_ERROR("inflate_init failed: %d", ret); 123 + U_LOG_E("inflate_init failed: %d", ret); 130 124 free(config_z); 131 125 free(config_json); 132 126 return NULL; ··· 135 129 ret = inflate(&strm, Z_FINISH); 136 130 free(config_z); 137 131 if (ret != Z_STREAM_END) { 138 - VIVE_ERROR("Failed to inflate configuration data: %d", ret); 132 + U_LOG_E("Failed to inflate configuration data: %d", ret); 139 133 free(config_json); 140 134 return NULL; 141 135 } ··· 158 152 159 153 ret = os_hid_get_feature_timeout(hid_dev, &report, sizeof(report), 100); 160 154 if (ret < 0) { 161 - printf("Could not get range report!\n"); 155 + U_LOG_E("Could not get range report!"); 162 156 return ret; 163 157 } 164 158 165 159 if (!report.gyro_range || !report.accel_range) { 166 - VIVE_ERROR( 167 - "Invalid gyroscope and accelerometer data. Trying to fetch " 168 - "again."); 160 + U_LOG_W( 161 + "Invalid gyroscope and accelerometer data." 162 + "Trying to fetch again."); 169 163 ret = os_hid_get_feature(hid_dev, report.id, (uint8_t *)&report, 170 164 sizeof(report)); 171 165 if (ret < 0) { 172 - VIVE_ERROR("Could not get feature report %d.", 173 - report.id); 166 + U_LOG_E("Could not get feature report %d.", report.id); 174 167 return ret; 175 168 } 176 169 177 170 if (!report.gyro_range || !report.accel_range) { 178 - VIVE_ERROR( 179 - "Unexpected range mode report: %02x %02x %02x", 180 - report.id, report.gyro_range, report.accel_range); 171 + U_LOG_E("Unexpected range mode report: %02x %02x %02x", 172 + report.id, report.gyro_range, 173 + report.accel_range); 181 174 for (int i = 0; i < 61; i++) 182 175 printf(" %02x", report.unknown[i]); 183 176 printf("\n"); ··· 186 179 } 187 180 188 181 if (report.gyro_range > 4 || report.accel_range > 4) { 189 - VIVE_ERROR("Gyroscope or accelerometer range too large."); 190 - VIVE_ERROR("Gyroscope: %d", report.gyro_range); 191 - VIVE_ERROR("Accelerometer: %d", report.accel_range); 182 + U_LOG_W("Gyroscope or accelerometer range too large."); 183 + U_LOG_W("Gyroscope: %d", report.gyro_range); 184 + U_LOG_W("Accelerometer: %d", report.accel_range); 192 185 return -1; 193 186 } 194 187