The open source OpenXR runtime
0
fork

Configure Feed

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

d/steamvr_lh: Send event when analogGain setting is changed

For now, just the steamvr section, because that's what triggers the lighthouse
driver to reload video settings.

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

averyv f1079898 9dea5802

+35 -9
+6
src/xrt/drivers/steamvr_lh/interfaces/context.hpp
··· 140 140 add_haptic_event(vr::VREvent_HapticVibration_t event); 141 141 142 142 void 143 + add_vendor_event(vr::EVREventType type, const vr::VREvent_Data_t &data = {}) 144 + { 145 + VendorSpecificEvent(0, type, data, 0); 146 + } 147 + 148 + void 143 149 Log(const char *pchLogMessage) override; 144 150 145 151 /***** IVRDriverContext methods *****/
+21 -7
src/xrt/drivers/steamvr_lh/interfaces/settings.cpp
··· 7 7 * @ingroup drv_steamvr_lh 8 8 */ 9 9 10 + #include <openvr_driver.h> 10 11 #include <optional> 11 12 #include <cstring> 13 + #include <map> 14 + #include <string_view> 12 15 13 16 #include "settings.hpp" 17 + #include "context.hpp" 14 18 #include "util/u_json.hpp" 15 19 20 + using namespace std::string_view_literals; 21 + 22 + // Default to 100% brightness. 16 23 DEBUG_GET_ONCE_FLOAT_OPTION(lh_default_brightness, "LH_DEFAULT_BRIGHTNESS", 1.0) 17 24 18 25 using xrt::auxiliary::util::json::JSONNode; 19 26 20 - Settings::Settings(const std::string &steam_install, const std::string &steamvr_install) 27 + Settings::Settings(const std::string &steam_install, const std::string &steamvr_install, Context *context) 21 28 : steamvr_settings(JSONNode::loadFromFile(steam_install + "/config/steamvr.vrsettings")), 22 29 driver_defaults( 23 - JSONNode::loadFromFile(steamvr_install + "/drivers/lighthouse/resources/settings/default.vrsettings")) 24 - {} 30 + JSONNode::loadFromFile(steamvr_install + "/drivers/lighthouse/resources/settings/default.vrsettings")), 31 + context{context} 32 + { 33 + analog_gain = debug_get_float_option_lh_default_brightness(); 34 + } 25 35 26 36 // NOLINTBEGIN(bugprone-easily-swappable-parameters) 27 37 const char * ··· 40 50 41 51 void 42 52 Settings::SetFloat(const char *pchSection, const char *pchSettingsKey, float flValue, vr::EVRSettingsError *peError) 43 - {} 53 + { 54 + if (pchSection == std::string_view{vr::k_pch_SteamVR_Section} && pchSettingsKey == "analogGain"sv) { 55 + analog_gain = flValue; 56 + context->add_vendor_event(vr::VREvent_SteamVRSectionSettingChanged); 57 + } 58 + } 44 59 45 60 void 46 61 Settings::SetString(const char *pchSection, ··· 64 79 float 65 80 Settings::GetFloat(const char *pchSection, const char *pchSettingsKey, vr::EVRSettingsError *peError) 66 81 { 67 - if (!strcmp(pchSection, "steamvr")) { 82 + if (!strcmp(pchSection, vr::k_pch_SteamVR_Section)) { 68 83 if (!strcmp(pchSettingsKey, "analogGain")) { 69 - // Return 100% brightness. 70 - return debug_get_float_option_lh_default_brightness(); 84 + return analog_gain; 71 85 } 72 86 if (!strcmp(pchSettingsKey, "ipd")) { 73 87 // Inform the SteamVR driver we have 0 ipd (in case) it factors this into the eye matrix.
+7 -1
src/xrt/drivers/steamvr_lh/interfaces/settings.hpp
··· 12 12 #include "openvr_driver.h" 13 13 #include "util/u_json.hpp" 14 14 15 + class Context; 16 + 15 17 class Settings : public vr::IVRSettings 16 18 { 17 19 private: 18 20 const xrt::auxiliary::util::json::JSONNode steamvr_settings; 19 21 const xrt::auxiliary::util::json::JSONNode driver_defaults; 20 22 23 + Context *context; 24 + 25 + float analog_gain; 26 + 21 27 public: 22 - Settings(const std::string &steam_install, const std::string &steamvr_install); 28 + Settings(const std::string &steam_install, const std::string &steamvr_install, Context *context); 23 29 24 30 const char * 25 31 GetSettingsErrorNameFromEnum(vr::EVRSettingsError eError) override;
+1 -1
src/xrt/drivers/steamvr_lh/steamvr_lh.cpp
··· 125 125 } 126 126 127 127 Context::Context(const std::string &steam_install, const std::string &steamvr_install, u_logging_level level) 128 - : settings(steam_install, steamvr_install), resources(level, steamvr_install), log_level(level) 128 + : settings(steam_install, steamvr_install, this), resources(level, steamvr_install), log_level(level) 129 129 {} 130 130 131 131 Context::~Context()