diff options
Diffstat (limited to 'spline/axis-opts.cpp')
-rw-r--r-- | spline/axis-opts.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spline/axis-opts.cpp b/spline/axis-opts.cpp new file mode 100644 index 00000000..52fe20f5 --- /dev/null +++ b/spline/axis-opts.cpp @@ -0,0 +1,47 @@ +#include "axis-opts.hpp" + +using max_clamp = axis_opts::max_clamp; + +static max_clamp get_max_x(Axis k) +{ + if (k == Axis(-1)) + return max_clamp::x1000; + if (k == Pitch) + return max_clamp::r90; + if (k >= Yaw) + return max_clamp::r180; + return max_clamp::t30; +} + +static max_clamp get_max_y(Axis k) +{ + if (k == Axis(-1)) + return max_clamp::x1000; + if (k == Axis::Pitch) + return max_clamp::o_r90; + if (k >= Axis::Yaw) + return max_clamp::o_r180; + return max_clamp::o_t75; +} + +axis_opts::axis_opts(QString pfx, Axis idx) : + b_settings_window(make_bundle("opentrack-ui")), + b_mapping_window(make_bundle("opentrack-mappings")), + 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"), get_max_y(idx)), + prefix_(pfx), + axis_(idx) +{} + +QString const& axis_opts::prefix() const { return prefix_; } + +Axis axis_opts::axis() const { return axis_; } + +QString axis_opts::n(QString pfx, QString name) +{ + return QString("%1-%2").arg(pfx, name); +} |