The open source OpenXR runtime

d/steamvr_lh: Determine whether we're a vive pro 2, and flip the distortion map

Vive Pro 2 for some reason has this flipped, so we need to do our own flip to rectify that.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2568>

+14
+12
src/xrt/drivers/steamvr_lh/device.cpp
··· 630 630 xrt_result_t 631 631 HmdDevice::compute_distortion(uint32_t view, float u, float v, xrt_uv_triplet *out_result) 632 632 { 633 + // Vive Pro 2 has a vertically flipped distortion map. 634 + if (this->variant == VIVE_VARIANT_PRO2) { 635 + v = 1.0f - v; 636 + } 637 + 633 638 vr::EVREye eye = (view == 0) ? vr::Eye_Left : vr::Eye_Right; 634 639 vr::DistortionCoordinates_t coords = this->hmd_parts->display->ComputeDistortion(eye, u, v); 635 640 out_result->r = {coords.rfRed[0], coords.rfRed[1]}; ··· 929 934 HmdDevice::handle_property_write(const vr::PropertyWrite_t &prop) 930 935 { 931 936 switch (prop.prop) { 937 + case vr::Prop_ModelNumber_String: { 938 + auto model_number = std::string(static_cast<char *>(prop.pvBuffer), prop.unBufferSize); 939 + 940 + this->variant = vive_determine_variant(model_number.c_str()); 941 + 942 + return Device::handle_property_write(prop); 943 + } 932 944 case vr::Prop_DisplayFrequency_Float: { 933 945 assert(prop.unBufferSize == sizeof(float)); 934 946 float freq = *static_cast<float *>(prop.pvBuffer);
+2
src/xrt/drivers/steamvr_lh/device.hpp
··· 19 19 #include "math/m_relation_history.h" 20 20 #include "xrt/xrt_device.h" 21 21 #include "openvr_driver.h" 22 + #include "vive/vive_common.h" 22 23 23 24 class Context; 24 25 struct InputClass; ··· 186 187 std::mutex hmd_parts_mut; 187 188 float brightness{1.0f}; 188 189 AnalogGainRange analog_gain_range{}; 190 + VIVE_VARIANT variant{VIVE_UNKNOWN}; 189 191 }; 190 192 191 193 class ControllerDevice : public Device