···301301 * We unpack them in the higher 21 bit values first and then shift
302302 * them down to the lower in order to get the sign bits correct.
303303 *
304304- * Code taken/reformated from OpenHMD's rift driver
304304+ * Code taken/reformatted from OpenHMD's rift driver
305305 */
306306static void
307307rift_decode_sample(const uint8_t *in, int32_t *out)
···384384 remote_sample_timestamp_ns);
385385386386 int64_t local_timestamp_ns;
387387- // if we havent synchronized our clocks, just do nothing
387387+ // if we haven't synchronized our clocks, just do nothing
388388 if (!m_clock_windowed_skew_tracker_to_local(hmd->clock_tracker, remote_sample_timestamp_ns,
389389 &local_timestamp_ns)) {
390390 return 0;
···467467 HMD_ERROR(hmd, "Failed to get device config, reason %d", result);
468468 goto error;
469469 }
470470- HMD_INFO(hmd, "Got display info from hmd, res: %dx%d", hmd->display_info.resolution_x,
471471- hmd->display_info.resolution_y);
470470+ HMD_DEBUG(hmd, "Got display info from hmd, res: %dx%d", hmd->display_info.resolution_x,
471471+ hmd->display_info.resolution_y);
472472473473 result = rift_get_config(hmd, &hmd->config);
474474 if (result < 0) {
475475 HMD_ERROR(hmd, "Failed to get device config, reason %d", result);
476476 goto error;
477477 }
478478- HMD_INFO(hmd, "Got config from hmd, config flags: %X", hmd->config.config_flags);
478478+ HMD_DEBUG(hmd, "Got config from hmd, config flags: %X", hmd->config.config_flags);
479479480480 if (getenv("RIFT_POWER_OVERRIDE") != NULL) {
481481 hmd->config.config_flags |= RIFT_CONFIG_REPORT_OVERRIDE_POWER;
482482- HMD_INFO(hmd, "Force-enabling the override power config flag.");
482482+ HMD_INFO(hmd, "Enabling the override power config flag.");
483483+ } else {
484484+ hmd->config.config_flags &= ~RIFT_CONFIG_REPORT_OVERRIDE_POWER;
485485+ HMD_DEBUG(hmd, "Disabling the override power config flag.");
483486 }
484487485488 // force enable calibration use and auto calibration
···503506 HMD_ERROR(hmd, "Failed to set the device config, reason %d", result);
504507 goto error;
505508 }
506506- HMD_INFO(hmd, "After writing, HMD has config flags: %X", hmd->config.config_flags);
509509+ HMD_DEBUG(hmd, "After writing, HMD has config flags: %X", hmd->config.config_flags);
507510508511 if (getenv("RIFT_USE_FIRMWARE_DISTORTION") != NULL) {
509512 // get the lens distortions
···555558 hmd->extra_display_info.eye_to_source_uv =
556559 rift_calculate_uv_scale_and_offset_from_ndc_scale_and_offset(hmd->extra_display_info.eye_to_source_ndc);
557560558558- // This list should be ordered, most preferred first.
559561 size_t idx = 0;
560562 hmd->base.hmd->blend_modes[idx++] = XRT_BLEND_MODE_OPAQUE;
561563 hmd->base.hmd->blend_mode_count = idx;
···566568 hmd->base.get_visibility_mask = rift_hmd_get_visibility_mask;
567569 hmd->base.destroy = rift_hmd_destroy;
568570571571+ hmd->base.hmd->distortion.models = XRT_DISTORTION_MODEL_COMPUTE;
572572+ hmd->base.hmd->distortion.preferred = XRT_DISTORTION_MODEL_COMPUTE;
569573 hmd->base.compute_distortion = rift_hmd_compute_distortion;
574574+ u_distortion_mesh_fill_in_compute(&hmd->base);
570575571576 hmd->pose = (struct xrt_pose)XRT_POSE_IDENTITY;
572577 hmd->log_level = debug_get_log_option_rift_log();
···582587 hmd->base.device_type = XRT_DEVICE_TYPE_HMD;
583588 hmd->base.inputs[0].name = XRT_INPUT_GENERIC_HEAD_POSE;
584589 hmd->base.supported.orientation_tracking = true;
585585- hmd->base.supported.position_tracking = false;
590590+ hmd->base.supported.position_tracking = false; // set to true once we are trying to get the sensor 6dof to work
586591587592 // Set up display details
588588- // refresh rate
589593 hmd->base.hmd->screens[0].nominal_frame_interval_ns = time_s_to_ns(1.0f / 75.0f);
590594591591- struct u_device_simple_info info;
592592- info.display.w_pixels = hmd->display_info.resolution_x;
593593- info.display.h_pixels = hmd->display_info.resolution_y;
594594- info.display.w_meters = MICROMETERS_TO_METERS(hmd->display_info.display_width);
595595- info.display.h_meters = MICROMETERS_TO_METERS(hmd->display_info.display_height);
596596-597597- info.lens_horizontal_separation_meters = MICROMETERS_TO_METERS(hmd->display_info.lens_separation);
598598- info.lens_vertical_position_meters = MICROMETERS_TO_METERS(hmd->display_info.center_v);
599599-600600- hmd->extra_display_info.icd = info.lens_horizontal_separation_meters;
601601-602602- // hardcode some "okay" values
603603- info.fov[0] = 93;
604604- info.fov[1] = 93;
595595+ hmd->extra_display_info.icd = MICROMETERS_TO_METERS(hmd->display_info.lens_separation);
605596606597 char *icd_str = getenv("RIFT_OVERRIDE_ICD");
607598 if (icd_str != NULL) {
···615606 } else {
616607 HMD_ERROR(hmd, "Failed to parse ICD override, expected float in millimeters, got %s", icd_str);
617608 }
609609+ } else {
610610+ HMD_DEBUG(hmd, "Using default ICD of %f", hmd->extra_display_info.icd);
618611 }
619612620620- if (!u_device_setup_split_side_by_side(&hmd->base, &info)) {
621621- HMD_ERROR(hmd, "Failed to setup basic device info");
622622- goto error;
613613+ // screen is rotated, so we need to undo that here
614614+ hmd->base.hmd->screens[0].h_pixels = hmd->display_info.resolution_x;
615615+ hmd->base.hmd->screens[0].w_pixels = hmd->display_info.resolution_y;
616616+617617+ // TODO: properly apply using rift_extra_display_info.screen_gap_meters, but this isn't necessary on DK2, where
618618+ // the gap is always 0
619619+ uint16_t view_width = hmd->display_info.resolution_x / 2;
620620+ uint16_t view_height = hmd->display_info.resolution_y;
621621+622622+ for (uint32_t i = 0; i < 2; ++i) {
623623+ hmd->base.hmd->views[i].display.w_pixels = view_width;
624624+ hmd->base.hmd->views[i].display.h_pixels = view_height;
625625+626626+ hmd->base.hmd->views[i].viewport.x_pixels = 0;
627627+ hmd->base.hmd->views[i].viewport.y_pixels = (1 - i) * (hmd->display_info.resolution_x / 2);
628628+ hmd->base.hmd->views[i].viewport.w_pixels = view_height; // screen is rotated, so swap w and h
629629+ hmd->base.hmd->views[i].viewport.h_pixels = view_width;
630630+ hmd->base.hmd->views[i].rot = u_device_rotation_left;
623631 }
624632625633 switch (hmd->variant) {
634634+ default:
626635 case RIFT_VARIANT_DK2:
627627- // TODO: figure out how to calculate this programatically, right now this is hardcoded with data dumped
628628- // from oculus' OpenXR runtime
636636+ // TODO: figure out how to calculate this programmatically, right now this is hardcoded with data dumped
637637+ // from oculus' OpenXR runtime, some of the math for this is in rift_distortion.c, used for
638638+ // calculating distortion
629639 hmd->base.hmd->distortion.fov[0].angle_up = 0.92667186;
630640 hmd->base.hmd->distortion.fov[0].angle_down = -0.92667186;
631641 hmd->base.hmd->distortion.fov[0].angle_left = -0.8138836;
···636646 hmd->base.hmd->distortion.fov[1].angle_left = -0.82951474;
637647 hmd->base.hmd->distortion.fov[1].angle_right = 0.8138836;
638648 break;
639639- default: break;
640649 }
641650642651 // Just put an initial identity value in the tracker
+1-1
src/xrt/drivers/rift/rift_interface.h
···8181 RIFT_CONFIG_REPORT_AUTO_CALIBRATION = 1 << 3,
8282 // stop sending IN reports when the device has stopped moving for Interval milliseconds
8383 RIFT_CONFIG_REPORT_MOTION_KEEP_ALIVE = 1 << 4,
8484- // stop sending IN reports when the device has stopped recieving feature reports for Interval milliseconds
8484+ // stop sending IN reports when the device has stopped receiving feature reports for Interval milliseconds
8585 RIFT_CONFIG_REPORT_COMMAND_KEEP_ALIVE = 1 << 5,
8686 // output the IN report data in the coordinate system used by LibOVR relative to the tracker, otherwise, report
8787 // in the coordinate system of the device
+1-1
src/xrt/drivers/rift/rift_prober.c
···4545 return -1;
4646 }
47474848- // Some non-oculus devices (VR-Tek HMDs) re-use the same USB IDs as the oculus headsets, so we should check the
4848+ // Some non-oculus devices (VR-Tek HMDs) reuse the same USB IDs as the oculus headsets, so we should check the
4949 // manufacturer
5050 if (strncmp((const char *)manufacturer, "Oculus VR, Inc.", sizeof(manufacturer)) != 0) {
5151 return -1;