diff options
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 5 | ||||
-rw-r--r-- | ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_fg/ftnoir_protocol_fg.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_ft/ftnoir_protocol_ft.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 5 | ||||
-rw-r--r-- | ftnoir_protocol_sc/ftnoir_protocol_sc.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_ht/ftnoir_tracker_ht.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_rift/ftnoir_tracker_rift.h | 5 | ||||
-rw-r--r-- | ftnoir_tracker_udp/ftnoir_tracker_udp.h | 5 | ||||
-rw-r--r-- | opentrack/main-settings.hpp | 5 | ||||
-rw-r--r-- | opentrack/options.hpp | 24 | ||||
-rw-r--r-- | opentrack/shortcuts.h | 5 |
19 files changed, 59 insertions, 55 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 6efe05f7..c1a19d96 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -9,11 +9,10 @@ using namespace options; #include "opentrack/timer.hpp" -struct settings { - pbundle b; +struct settings : opts { value<int> rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone; settings() : - b(bundle("Accela")), + opts("Accela"), rot_threshold(b, "rotation-threshold", 30), trans_threshold(b, "translation-threshold", 50), ewma(b, "ewma", 2), diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 73c0df99..9f603b25 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -8,12 +8,11 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { // these are sadly sliders for now due to int/double mismatch -sh value<int> kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve; settings() : - b(bundle("ewma-filter")), + opts("ewma-filter"), kMinSmoothing(b, "min-smoothing", 15), kMaxSmoothing(b, "max-smoothing", 50), kSmoothingScaleCurve(b, "smoothing-scale-curve", 10) diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 36768fd5..88b24a09 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -35,12 +35,11 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> ip1, ip2, ip3, ip4; value<int> port; settings() : - b(bundle("flightgear-proto")), + opts("flightgear-proto"), ip1(b, "ip1", 192), ip2(b, "ip2", 168), ip3(b, "ip3", 0), diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 006c93de..f477ee2a 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -45,11 +45,10 @@ using namespace options; #define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" -struct settings { - pbundle b; +struct settings : opts { value<QString> LocationOfDLL; settings() : - b(bundle("proto-fsuipc")), + opts("proto-fsuipc"), LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) {} }; diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 6bbf1bd3..ade6ac75 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -41,12 +41,11 @@ #include "../freetrackclient/fttypes.h" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> intUsedInterface; value<bool> useTIRViews; settings() : - b(bundle("proto-freetrack")), + opts("proto-freetrack"), intUsedInterface(b, "used-interfaces", 0), useTIRViews(b, "use-memory-hacks", false) {} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index c9b7ace6..1c204abf 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -36,11 +36,10 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> ip1, ip2, ip3, ip4, port; settings() : - b(bundle("udp-proto")), + opts("udp-proto"), ip1(b, "ip1", 192), ip2(b, "ip2", 168), ip3(b, "ip3", 0), diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 9f76571b..0738278a 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -43,11 +43,10 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> Mouse_X, Mouse_Y; settings() : - b(bundle("mouse-proto")), + opts("mouse-proto"), Mouse_X(b, "mouse-x", 0), Mouse_Y(b, "mouse-y", 0) {} diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 39544aab..f8db519b 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -75,11 +75,10 @@ enum INPUT_ID INPUT0=0, }; -struct settings { - pbundle b; +struct settings : opts { value<int> sxs_manifest; settings() : - b(bundle("proto-simconnect")), + opts("proto-simconnect"), sxs_manifest(b, "sxs-manifest-version", 0) {} }; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index ad10f04a..0cb8fd8f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -24,12 +24,11 @@ using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<double> fov, headpos_x, headpos_y, headpos_z; value<int> camera_index, force_fps, resolution; settings() : - b(bundle("aruco-tracker")), + opts("aruco-tracker"), fov(b, "field-of-view", 56), headpos_x(b, "headpos-x", 0), headpos_y(b, "headpos-y", 0), diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h index 0567beae..5a70026c 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h @@ -13,12 +13,11 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> port, idx_x, idx_y, idx_z; value<int> add_yaw, add_pitch, add_roll; settings() : - b(bundle("freepie-udp-tracker")), + opts("freepie-udp-tracker"), port(b, "port", 5555), idx_x(b, "axis-index-x", 0), idx_y(b, "axis-index-y", 1), diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 6a19477e..ce264b8c 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -18,12 +18,11 @@ #include "opentrack/plugin-api.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<double> fov; value<int> fps, camera_idx, resolution; settings() : - b(bundle("HT-Tracker")), + opts("HT-Tracker"), fov(b, "fov", 56), fps(b, "fps", 0), camera_idx(b, "camera-index", 0), diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 87d572d7..47a1eb9a 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -3,10 +3,9 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { settings() : - b(bundle("tracker-hydra")) + opts("tracker-hydra") {} }; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 7fb26dfd..0958246a 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -29,12 +29,11 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<QString> joyid; value<int> joy_1, joy_2, joy_3, joy_4, joy_5, joy_6; settings() : - b(bundle("tracker-joystick")), + opts("tracker-joystick"), joyid(b, "joy-id", ""), joy_1(b, "axis-map-1", 1), joy_2(b, "axis-map-2", 2), diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 57752ed6..f3b21b50 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -13,9 +13,8 @@ #include "opentrack/options.hpp" using namespace options; -struct settings +struct settings : opts { - pbundle b; value<int> cam_index, cam_res_x, cam_res_y, @@ -38,7 +37,7 @@ struct settings value<bool> dynamic_pose; settings() : - b(bundle("tracker-pt")), + opts("tracker-pt"), cam_index(b, "camera-index", 0), cam_res_x(b, "camera-res-width", 640), cam_res_y(b, "camera-res-height", 480), diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 179125f8..231648dd 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -9,12 +9,11 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<bool> useYawSpring; value<double> constant_drift, persistence, deadzone; settings() : - b(bundle("Rift")), + opts("Rift"), useYawSpring(b, "yaw-spring", false), constant_drift(b, "constant-drift", 0.000005), persistence(b, "persistence", 0.99999), diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 96f07177..51b5d9ab 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -7,11 +7,10 @@ #include "opentrack/options.hpp" using namespace options; -struct settings { - pbundle b; +struct settings : opts { value<int> port; settings() : - b(bundle("udp-tracker")), + opts("udp-tracker"), port(b, "port", 4242) {} }; diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index 0468aeb1..27f9ee06 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -22,8 +22,7 @@ private: } }; -struct main_settings { - pbundle b; +struct main_settings : opts { value<QString> tracker_dll, tracker2_dll, filter_dll, protocol_dll; axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; value<bool> tcomp_p, tcomp_tz; @@ -31,7 +30,7 @@ struct main_settings { value<int> camera_yaw, camera_pitch; value<bool> center_at_startup; main_settings() : - b(bundle("opentrack-ui")), + opts("opentrack-ui"), tracker_dll(b, "tracker-dll", ""), tracker2_dll(b, "tracker2-dll", ""), filter_dll(b, "filter-dll", ""), diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 23ce6f7b..c33c2f53 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -28,6 +28,8 @@ #include <QLabel> #include <QTabWidget> #include <QCoreApplication> +#include <QFileInfo> +#include <QDir> #include <cinttypes> @@ -135,6 +137,14 @@ namespace options { QSettings settings(group::org); return settings.value(filename_key, QCoreApplication::applicationDirPath() + default_path).toString(); } + + static const QStringList ini_list() + { + QFileInfo info(group::ini_pathname()); + QDir settings_dir(info.dir()); + return settings_dir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); + } + static const mem<QSettings> ini_file() { return std::make_shared<QSettings>(ini_pathname(), QSettings::IniFormat); @@ -351,7 +361,19 @@ namespace options { *this = static_cast<t>(*this); } }; - + + struct opts + { + pbundle b; + + opts(const std::string& name) : b(bundle(name)) {} + + ~opts() + { + b->reload(); + } + }; + template<typename t, typename q> inline void tie_setting(value<t>&, q*); diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index 4d4b19d3..d0aedec0 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -104,12 +104,11 @@ public: mem<KeybindingWorker> keybindingWorker; #endif - struct settings { - pbundle b; + struct settings : opts { key_opts center, toggle, zero; main_settings s_main; settings() : - b(bundle("keyboard-shortcuts")), + opts("keyboard-shortcuts"), center(b, "center"), toggle(b, "toggle"), zero(b, "zero") |