summaryrefslogtreecommitdiffhomepage
path: root/spline/axis-opts.cpp
blob: b5f11aaa455bd66d3bc3be8c49e40e9c0b02ebf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#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) :
    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 const& pfx, QString const& name)
{
    return QString("%1-%2").arg(pfx, name);
}