Monado OpenXR Runtime
settings.hpp
Go to the documentation of this file.
1// Copyright 2023, Shawn Wallace
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief OpenVR IVRSettings interface header.
6 * @author Shawn Wallace <yungwallace@live.com>
7 * @ingroup drv_steamvr_lh
8 */
9
10#pragma once
11
12#include "openvr_driver.h"
13#include "util/u_json.hpp"
14
15class Context;
16
17class Settings : public vr::IVRSettings
18{
19private:
20 const xrt::auxiliary::util::json::JSONNode steamvr_settings;
21 const xrt::auxiliary::util::json::JSONNode driver_defaults;
22
23 Context *context;
24
25 float analog_gain;
26
27public:
28 Settings(const std::string &steam_install, const std::string &steamvr_install, Context *context);
29
30 const char *
31 GetSettingsErrorNameFromEnum(vr::EVRSettingsError eError) override;
32
33 void
34 SetBool(const char *pchSection,
35 const char *pchSettingsKey,
36 bool bValue,
37 vr::EVRSettingsError *peError = nullptr) override;
38 void
39 SetInt32(const char *pchSection,
40 const char *pchSettingsKey,
41 int32_t nValue,
42 vr::EVRSettingsError *peError = nullptr) override;
43 void
44 SetFloat(const char *pchSection,
45 const char *pchSettingsKey,
46 float flValue,
47 vr::EVRSettingsError *peError = nullptr) override;
48 void
49 SetString(const char *pchSection,
50 const char *pchSettingsKey,
51 const char *pchValue,
52 vr::EVRSettingsError *peError = nullptr) override;
53
54 // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/
55 // directory of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or
56 // ""
57 bool
58 GetBool(const char *pchSection, const char *pchSettingsKey, vr::EVRSettingsError *peError = nullptr) override;
59 int32_t
60 GetInt32(const char *pchSection, const char *pchSettingsKey, vr::EVRSettingsError *peError = nullptr) override;
61 float
62 GetFloat(const char *pchSection, const char *pchSettingsKey, vr::EVRSettingsError *peError = nullptr) override;
63 void
64 GetString(const char *pchSection,
65 const char *pchSettingsKey,
66 VR_OUT_STRING() char *pchValue,
67 uint32_t unValueLen,
68 vr::EVRSettingsError *peError = nullptr) override;
69
70 void
71 RemoveSection(const char *pchSection, vr::EVRSettingsError *peError = nullptr) override;
72 void
73 RemoveKeyInSection(const char *pchSection,
74 const char *pchSettingsKey,
75 vr::EVRSettingsError *peError = nullptr) override;
76};
Definition: context.hpp:57
Definition: settings.hpp:18
A JSONNode wraps a cJSON object and presents useful functions for accessing the different properties ...
Definition: u_json.hpp:75
C++ wrapper for cJSON.