diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 17:53:21 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-10-20 17:53:21 +0200 |
commit | 39e209983bd1f04fb0beefef754d7430c8b7fb9f (patch) | |
tree | ec41545dda2d33d316adc6466f21138a280db6a8 /logic | |
parent | 092e2910ae8f6c2e188e930b9540d58e145c9142 (diff) |
logic, spline: more spline work/fixes
- mapping window clamps are now value<max_clamp> in
spline
- clamp won't mess up saved spline content
- clean up artifacts on spline widget
Diffstat (limited to 'logic')
-rw-r--r-- | logic/main-settings.cpp | 39 | ||||
-rw-r--r-- | logic/main-settings.hpp | 45 | ||||
-rw-r--r-- | logic/mappings.cpp | 27 | ||||
-rw-r--r-- | logic/mappings.hpp | 4 |
4 files changed, 21 insertions, 94 deletions
diff --git a/logic/main-settings.cpp b/logic/main-settings.cpp index b1b9a132..e2d1b41f 100644 --- a/logic/main-settings.cpp +++ b/logic/main-settings.cpp @@ -3,12 +3,12 @@ main_settings::main_settings() : b(make_bundle("opentrack-ui")), b_map(make_bundle("opentrack-mappings")), - a_x(b, b_map, "x", TX), - a_y(b, b_map, "y", TY), - a_z(b, b_map, "z", TZ), - a_yaw(b, b_map, "yaw", Yaw), - a_pitch(b, b_map, "pitch", Pitch), - a_roll(b, b_map, "roll", Roll), + a_x("x", TX), + a_y("y", TY), + a_z("z", TZ), + a_yaw("yaw", Yaw), + a_pitch("pitch", Pitch), + a_roll("roll", Roll), all_axis_opts { &a_x, &a_y, &a_z, &a_yaw, &a_pitch, &a_roll }, tcomp_p(b, "compensate-translation", false), tcomp_disable_tx(b, "compensate-translation-disable-x-axis", false), @@ -59,30 +59,3 @@ key_opts::key_opts(bundle b, const QString& name) : guid(b, QString("guid-%1").arg(name), ""), button(b, QString("button-%1").arg(name), -1) {} - -using max_clamp = axis_opts::max_clamp; - -static max_clamp get_max_x(Axis k) -{ - if (k == Pitch) - return max_clamp::r90; - if (k >= Yaw) - return max_clamp::r180; - return max_clamp::t30; -} - -axis_opts::axis_opts(bundle b_settings_window, bundle b_mapping_window, QString pfx, Axis idx) : - b_settings_window(b_settings_window), - b_mapping_window(b_mapping_window), - zero(b_settings_window, n(pfx, "zero-pos"), 0), - src(b_settings_window, n(pfx, "source-index"), idx), - invert(b_settings_window, n(pfx, "invert-sign"), false), - altp(b_mapping_window, n(pfx, "alt-axis-sign"), false), - clamp_x(b_mapping_window, n(pfx, "max-value"), get_max_x(idx)), - clamp_y(b_mapping_window, n(pfx, "max-output-value"), idx >= Yaw ? o_r90 : o_t75) -{} - -QString axis_opts::n(QString pfx, QString name) -{ - return QString("%1-%2").arg(pfx, name); -} diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp index 4b29157f..29f401ab 100644 --- a/logic/main-settings.hpp +++ b/logic/main-settings.hpp @@ -10,53 +10,12 @@ #include <QString> #include "options/options.hpp" -#include "api/plugin-api.hpp" - using namespace options; +#include "api/plugin-api.hpp" +#include "spline/axis-opts.hpp" #include "export.hpp" -namespace axis_clamp_opts -{ - -} // ns axis-clamp-opts - -struct OTR_LOGIC_EXPORT axis_opts final -{ - enum max_clamp - { - r180 = 180, - r90 = 90, - r60 = 60, - r45 = 45, - r30 = 30, - r25 = 25, - r20 = 20, - r15 = 15, - r10 = 10, - - t100 = 100, - t30 = 30, - t20 = 20, - t15 = 15, - t10 = 10, - - o_r180 = -180, - o_r90 = -90, - o_t75 = -75, - }; - - // note, these two bundles can be the same value with no issues - bundle b_settings_window, b_mapping_window; - value<double> zero; - value<int> src; - value<bool> invert, altp; - value<max_clamp> clamp_x, clamp_y; - axis_opts(bundle b_settings_window, bundle b_mapping_window, QString pfx, Axis idx); -private: - static inline QString n(QString pfx, QString name); -}; - struct OTR_LOGIC_EXPORT key_opts { value<QString> keycode, guid; diff --git a/logic/mappings.cpp b/logic/mappings.cpp index 9e81bb01..8144f9b4 100644 --- a/logic/mappings.cpp +++ b/logic/mappings.cpp @@ -2,18 +2,13 @@ #include <utility> -Map::Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts) : +Map::Map(const QString& spline_name, const QString& alt_spline_name, axis_opts& opts) : opts(opts), - name1(primary), - name2(secondary), - spline_main(max_x, max_y, primary), - spline_alt(max_x, max_y, secondary) + name(spline_name), + alt_name(alt_spline_name), + spline_main(spline_name, opts.prefix(), opts.axis()), + spline_alt(alt_spline_name, opts.prefix(), opts.axis()) { - spline_main.set_max_input(max_x); - spline_alt.set_max_input(max_x); - - spline_main.set_max_output(max_y); - spline_alt.set_max_output(max_y); } void Map::save() @@ -30,11 +25,11 @@ void Map::load() Mappings::Mappings(std::vector<axis_opts*> opts) : axes { - Map("spline-X", "alt-spline-X", 100, 75, *opts[TX]), - Map("spline-Y", "alt-spline-Y", 100, 75, *opts[TY]), - Map("spline-Z", "alt-spline-Z", 100, 75, *opts[TZ]), - Map("spline-yaw", "alt-spline-yaw", 180, 180, *opts[Yaw]), - Map("spline-pitch", "alt-spline-pitch", 180, std::abs((int)opts[Pitch]->clamp_y), *opts[Pitch]), - Map("spline-roll", "alt-spline-roll", 180, 180, *opts[Roll]) + Map("spline-X", "alt-spline-X", *opts[TX]), + Map("spline-Y", "alt-spline-Y", *opts[TY]), + Map("spline-Z", "alt-spline-Z", *opts[TZ]), + Map("spline-yaw", "alt-spline-yaw", *opts[Yaw]), + Map("spline-pitch", "alt-spline-pitch", *opts[Pitch]), + Map("spline-roll", "alt-spline-roll", *opts[Roll]) } {} diff --git a/logic/mappings.hpp b/logic/mappings.hpp index b3587749..4b71e9c5 100644 --- a/logic/mappings.hpp +++ b/logic/mappings.hpp @@ -15,13 +15,13 @@ using namespace options; struct OTR_LOGIC_EXPORT Map final { - Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts); + Map(const QString& spline_name, const QString& alt_spline_name, axis_opts& opts); void save(); void load(); axis_opts& opts; - QString name1, name2; + QString name, alt_name; spline spline_main, spline_alt; }; |