summaryrefslogtreecommitdiffhomepage
path: root/opentrack/mappings.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'opentrack/mappings.hpp')
-rw-r--r--opentrack/mappings.hpp49
1 files changed, 20 insertions, 29 deletions
diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp
index 86126db9..3336dcd8 100644
--- a/opentrack/mappings.hpp
+++ b/opentrack/mappings.hpp
@@ -10,23 +10,18 @@ class Mapping {
public:
Mapping(QString primary,
QString secondary,
- int maxInput1,
- int maxOutput1,
- int maxInput2,
- int maxOutput2,
+ int max_x,
+ int max_y,
axis_opts& opts) :
- curve(maxInput1, maxOutput1),
- curveAlt(maxInput2, maxOutput2),
+ curve(max_x, max_y),
+ curveAlt(max_x, max_y),
opts(opts),
name1(primary),
name2(secondary)
{
- // XXX TODO move all this qsettings boilerplate into a single header -sh 20141004
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile(currentFile, QSettings::IniFormat);
- curve.loadSettings(iniFile, primary);
- curveAlt.loadSettings(iniFile, secondary);
+ mem<QSettings> iniFile = group::ini_file();
+ curve.loadSettings(*iniFile, primary);
+ curveAlt.loadSettings(*iniFile, secondary);
}
Map curve;
Map curveAlt;
@@ -40,12 +35,12 @@ private:
public:
Mappings(std::vector<axis_opts*> opts) :
axes {
- Mapping("tx","tx_alt", 100, 100, 100, 100, *opts[TX]),
- Mapping("ty","ty_alt", 100, 100, 100, 100, *opts[TY]),
- Mapping("tz","tz_alt", 100, 100, 100, 100, *opts[TZ]),
- Mapping("rx", "rx_alt", 180, 180, 180, 180, *opts[Yaw]),
- Mapping("ry", "ry_alt", 180, 180, 180, 180, *opts[Pitch]),
- Mapping("rz", "rz_alt", 180, 180, 180, 180, *opts[Roll])
+ Mapping("tx","tx_alt", 100, 100, *opts[TX]),
+ Mapping("ty","ty_alt", 100, 100, *opts[TY]),
+ Mapping("tz","tz_alt", 100, 100, *opts[TZ]),
+ Mapping("rx", "rx_alt", 180, 180, *opts[Yaw]),
+ Mapping("ry", "ry_alt", 180, 180, *opts[Pitch]),
+ Mapping("rz", "rz_alt", 180, 180, *opts[Roll])
}
{}
@@ -54,29 +49,25 @@ public:
void load_mappings()
{
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
+ mem<QSettings> iniFile = group::ini_file();
for (int i = 0; i < 6; i++)
{
- axes[i].curve.loadSettings(iniFile, axes[i].name1);
- axes[i].curveAlt.loadSettings(iniFile, axes[i].name2);
+ axes[i].curve.loadSettings(*iniFile, axes[i].name1);
+ axes[i].curveAlt.loadSettings(*iniFile, axes[i].name2);
}
}
void save_mappings()
{
- QSettings settings("opentrack");
- QString currentFile = settings.value("SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini").toString();
- QSettings iniFile(currentFile, QSettings::IniFormat);
+ mem<QSettings> iniFile = group::ini_file();
for (int i = 0; i < 6; i++)
{
- axes[i].curve.saveSettings(iniFile, axes[i].name1);
- axes[i].curveAlt.saveSettings(iniFile, axes[i].name2);
+ axes[i].curve.saveSettings(*iniFile, axes[i].name1);
+ axes[i].curveAlt.saveSettings(*iniFile, axes[i].name2);
}
}
-
+
void invalidate_unsaved()
{
for (int i = 0; i < 6; i++)