The open source OpenXR runtime
0
fork

Configure Feed

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

d/rs: Tidy code (NFC)

+56 -29
+56 -29
src/xrt/drivers/realsense/rs_6dof.c
··· 342 342 return NULL; 343 343 } 344 344 345 + static bool 346 + load_config(struct rs_6dof *rs) 347 + { 348 + struct u_config_json config_json = {0}; 349 + 350 + u_config_json_open_or_create_main_file(&config_json); 351 + if (!config_json.file_loaded) { 352 + return false; 353 + } 354 + 355 + const cJSON *realsense_config_json = u_json_get(config_json.root, "config_realsense"); 356 + if (realsense_config_json == NULL) { 357 + return false; 358 + } 359 + 360 + const cJSON *mapping = u_json_get(realsense_config_json, "enable_mapping"); 361 + const cJSON *pose_jumping = u_json_get(realsense_config_json, "enable_pose_jumping"); 362 + const cJSON *relocalization = u_json_get(realsense_config_json, "enable_relocalization"); 363 + const cJSON *pose_prediction = u_json_get(realsense_config_json, "enable_pose_prediction"); 364 + const cJSON *pose_filtering = u_json_get(realsense_config_json, "enable_pose_filtering"); 365 + 366 + // if json key isn't in the json, default to true. if it is in there, use json value 367 + if (mapping != NULL) { 368 + rs->enable_mapping = cJSON_IsTrue(mapping); 369 + } 370 + if (pose_jumping != NULL) { 371 + rs->enable_pose_jumping = cJSON_IsTrue(pose_jumping); 372 + } 373 + if (relocalization != NULL) { 374 + rs->enable_relocalization = cJSON_IsTrue(relocalization); 375 + } 376 + if (pose_prediction != NULL) { 377 + rs->enable_pose_prediction = cJSON_IsTrue(pose_prediction); 378 + } 379 + if (pose_filtering != NULL) { 380 + rs->enable_pose_filtering = cJSON_IsTrue(pose_filtering); 381 + } 382 + 383 + return true; 384 + } 385 + 386 + 387 + /* 388 + * 389 + * Device functions. 390 + * 391 + */ 392 + 345 393 static void 346 394 rs_6dof_update_inputs(struct xrt_device *xdev) 347 395 { ··· 398 446 free(rs); 399 447 } 400 448 449 + 450 + /* 451 + * 452 + * 'Exported' functions. 453 + * 454 + */ 455 + 401 456 struct xrt_device * 402 457 rs_6dof_create(void) 403 458 { ··· 409 464 rs->enable_pose_prediction = true; 410 465 rs->enable_pose_filtering = true; 411 466 412 - struct u_config_json config_json = {0}; 413 - 414 - u_config_json_open_or_create_main_file(&config_json); 415 - if (config_json.file_loaded) { 416 - const cJSON *realsense_config_json = u_json_get(config_json.root, "config_realsense"); 417 - if (realsense_config_json != NULL) { 418 - const cJSON *mapping = u_json_get(realsense_config_json, "enable_mapping"); 419 - const cJSON *pose_jumping = u_json_get(realsense_config_json, "enable_pose_jumping"); 420 - const cJSON *relocalization = u_json_get(realsense_config_json, "enable_relocalization"); 421 - const cJSON *pose_prediction = u_json_get(realsense_config_json, "enable_pose_prediction"); 422 - const cJSON *pose_filtering = u_json_get(realsense_config_json, "enable_pose_filtering"); 423 - 424 - // if json key isn't in the json, default to true. if it is in there, use json value 425 - if (mapping != NULL) { 426 - rs->enable_mapping = cJSON_IsTrue(mapping); 427 - } 428 - if (pose_jumping != NULL) { 429 - rs->enable_pose_jumping = cJSON_IsTrue(pose_jumping); 430 - } 431 - if (relocalization != NULL) { 432 - rs->enable_relocalization = cJSON_IsTrue(relocalization); 433 - } 434 - if (pose_prediction != NULL) { 435 - rs->enable_pose_prediction = cJSON_IsTrue(pose_prediction); 436 - } 437 - if (pose_filtering != NULL) { 438 - rs->enable_pose_filtering = cJSON_IsTrue(pose_filtering); 439 - } 440 - } 467 + if (load_config(rs)) { 441 468 U_LOG_D("Used config file"); 442 469 } else { 443 470 U_LOG_D("Did not use config file");