summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/mappings.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'facetracknoir/mappings.hpp')
-rw-r--r--facetracknoir/mappings.hpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/facetracknoir/mappings.hpp b/facetracknoir/mappings.hpp
new file mode 100644
index 00000000..4dae7a90
--- /dev/null
+++ b/facetracknoir/mappings.hpp
@@ -0,0 +1,79 @@
+#pragma once
+
+#include <QSettings>
+#include "options.h"
+using namespace options;
+#include "../qfunctionconfigurator/functionconfig.h"
+#include "main-settings.hpp"
+
+class Mapping {
+public:
+ Mapping(QString primary,
+ QString secondary,
+ int maxInput1,
+ int maxOutput1,
+ int maxInput2,
+ int maxOutput2,
+ axis_opts& opts) :
+ curve(maxInput1, maxOutput1),
+ curveAlt(maxInput2, maxOutput2),
+ 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);
+ }
+ Map curve;
+ Map curveAlt;
+ axis_opts& opts;
+ QString name1, name2;
+};
+
+class Mappings {
+private:
+ Mapping axes[6];
+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", 90, 90, 90, 90, *opts[Pitch]),
+ Mapping("rz", "rz_alt", 180, 180, 180, 180, *opts[Roll])
+ }
+ {}
+
+ inline Mapping& operator()(int i) { return axes[i]; }
+ inline const Mapping& operator()(int i) const { return axes[i]; }
+
+ void load_mappings()
+ {
+ QSettings settings("opentrack");
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat );
+
+ for (int i = 0; i < 6; i++)
+ {
+ 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);
+
+ for (int i = 0; i < 6; i++)
+ {
+ axes[i].curve.saveSettings(iniFile, axes[i].name1);
+ axes[i].curveAlt.saveSettings(iniFile, axes[i].name2);
+ }
+ }
+};