-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings_manager.h
More file actions
174 lines (133 loc) · 5.9 KB
/
settings_manager.h
File metadata and controls
174 lines (133 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#pragma once
#include "framework.h"
#include "SimpleIni.h"
struct Settings_Main
{
bool InterfaceConfigured = false;
bool EnableLights = true; // Transient
bool EnableLightsOnStartup = true;
bool StartWithSteamVR = false;
bool LockSampleRateToHMD = true;
int SampleRate = 120;
int NumLights = 18;
bool SwapLeftRight = false;
bool BottomToTopLeft = false;
bool BottomToTopRight = true;
float HeightFraction = 0.5f;
float WidthFraction = 0.35f;
float VerticalOffset = -0.02f;
float HorizontalOffset = 0.22f;
float VerticalAreaSize = 1.0f;
float Curvature = 0.12f;
float CurvatureShape = 0.12f;
int PreviewMode = 0; // Transient
float PreviewValue = 0.0f; // Transient
float Brightness = 1.0f;
float Contrast = 1.0f;
float Saturation = 1.0f;
float MinRed = 0.0f;
float MinGreen = 0.0f;
float MinBlue = 0.0f;
float MaxRed = 1.0f;
float MaxGreen = 1.0f;
float MaxBlue = 1.0f;
float GammaRed = 2.2f;
float GammaGreen = 2.2f;
float GammaBlue = 2.2f;
void ParseSettings(CSimpleIniA& ini, const char* section)
{
InterfaceConfigured = ini.GetBoolValue(section, "InterfaceConfigured", InterfaceConfigured);
EnableLightsOnStartup = ini.GetBoolValue(section, "EnableLightsOnStartup", EnableLightsOnStartup);
StartWithSteamVR = ini.GetBoolValue(section, "StartWithSteamVR", StartWithSteamVR);
LockSampleRateToHMD = ini.GetBoolValue(section, "LockSamplerateToHMD", LockSampleRateToHMD);
SampleRate = (int)ini.GetLongValue(section, "Samplerate", SampleRate);
NumLights = (int)ini.GetLongValue(section, "NumLights", NumLights);
SwapLeftRight = ini.GetBoolValue(section, "SwapLeftRight", SwapLeftRight);
BottomToTopLeft = ini.GetBoolValue(section, "BottomToTopLeft", BottomToTopLeft);
BottomToTopRight = ini.GetBoolValue(section, "BottomToTopRight", BottomToTopRight);
HeightFraction = (float)ini.GetDoubleValue(section, "HeightFraction", HeightFraction);
WidthFraction = (float)ini.GetDoubleValue(section, "WidthFraction", WidthFraction);
VerticalOffset = (float)ini.GetDoubleValue(section, "VerticalOffset", VerticalOffset);
HorizontalOffset = (float)ini.GetDoubleValue(section, "HorizontalOffset", HorizontalOffset);
VerticalAreaSize = (float)ini.GetDoubleValue(section, "VerticalAreaSize", VerticalAreaSize);
Curvature = (float)ini.GetDoubleValue(section, "Curvature", Curvature);
CurvatureShape = (float)ini.GetDoubleValue(section, "CurvatureShape", CurvatureShape);
Brightness = (float)ini.GetDoubleValue(section, "Brightness", Brightness);
Contrast = (float)ini.GetDoubleValue(section, "Contrast", Contrast);
Saturation = (float)ini.GetDoubleValue(section, "Saturation", Saturation);
MinRed = (float)ini.GetDoubleValue(section, "MinRed", MinRed);
MinGreen = (float)ini.GetDoubleValue(section, "MinGreen", MinGreen);
MinBlue = (float)ini.GetDoubleValue(section, "MinBlue", MinBlue);
MaxRed = (float)ini.GetDoubleValue(section, "MaxRed", MaxRed);
MaxGreen = (float)ini.GetDoubleValue(section, "MaxGreen", MaxGreen);
MaxBlue = (float)ini.GetDoubleValue(section, "MaxBlue", MaxBlue);
GammaRed = (float)ini.GetDoubleValue(section, "GammaRed", GammaRed);
GammaGreen = (float)ini.GetDoubleValue(section, "GammaGreen", GammaGreen);
GammaBlue = (float)ini.GetDoubleValue(section, "GammaBlue", GammaBlue);
}
void UpdateSettings(CSimpleIniA& ini, const char* section)
{
ini.SetBoolValue(section, "InterfaceConfigured", InterfaceConfigured);
ini.SetBoolValue(section, "EnableLightsOnStartup", EnableLightsOnStartup);
ini.SetBoolValue(section, "StartWithSteamVR", StartWithSteamVR);
ini.SetBoolValue(section, "LockSampleRateToHMD", LockSampleRateToHMD);
ini.SetLongValue(section, "SampleRate", SampleRate);
ini.SetLongValue(section, "NumLights", NumLights);
ini.SetBoolValue(section, "SwapLeftRight", SwapLeftRight);
ini.SetBoolValue(section, "BottomToTopLeft", BottomToTopLeft);
ini.SetBoolValue(section, "BottomToTopRight", BottomToTopRight);
ini.SetDoubleValue(section, "HeightFraction", HeightFraction);
ini.SetDoubleValue(section, "WidthFraction", WidthFraction);
ini.SetDoubleValue(section, "VerticalOffset", VerticalOffset);
ini.SetDoubleValue(section, "HorizontalOffset", HorizontalOffset);
ini.SetDoubleValue(section, "VerticalAreaSize", VerticalAreaSize);
ini.SetDoubleValue(section, "Curvature", Curvature);
ini.SetDoubleValue(section, "CurvatureShape", CurvatureShape);
ini.SetDoubleValue(section, "Brightness", Brightness);
ini.SetDoubleValue(section, "Contrast", Contrast);
ini.SetDoubleValue(section, "Saturation", Saturation);
ini.SetDoubleValue(section, "MinRed", MinRed);
ini.SetDoubleValue(section, "MinGreen", MinGreen);
ini.SetDoubleValue(section, "MinBlue", MinBlue);
ini.SetDoubleValue(section, "MaxRed", MaxRed);
ini.SetDoubleValue(section, "MaxGreen", MaxGreen);
ini.SetDoubleValue(section, "MaxBlue", MaxBlue);
ini.SetDoubleValue(section, "GammaRed", GammaRed);
ini.SetDoubleValue(section, "GammaGreen", GammaGreen);
ini.SetDoubleValue(section, "GammaBlue", GammaBlue);
}
};
struct Settings_AdaLight
{
std::string ComPort = "";
int BaudRate = 115200;
void ParseSettings(CSimpleIniA& ini, const char* section)
{
ComPort = ini.GetValue(section, "ComPort", ComPort.data());
BaudRate = (int)ini.GetLongValue(section, "BaudRate", BaudRate);
}
void UpdateSettings(CSimpleIniA& ini, const char* section)
{
ini.SetValue(section, "ComPort", ComPort.data());
ini.SetLongValue(section, "BaudRate", BaudRate);
}
};
class SettingsManager
{
public:
SettingsManager(std::wstring settingsFile);
~SettingsManager();
void ReadSettingsFile();
void SettingsUpdated();
void DispatchUpdate();
void ResetToDefaults();
Settings_Main& GetSettings_Main() { return m_settingsMain; }
Settings_AdaLight& GetSettings_AdaLight() { return m_settingsAdaLight; }
protected:
void UpdateSettingsFile();
std::wstring m_settingsFile;
CSimpleIniA m_iniData;
bool m_bSettingsUpdated = false;
Settings_Main m_settingsMain;
Settings_AdaLight m_settingsAdaLight;
};