summaryrefslogtreecommitdiffhomepage
path: root/logic/mappings.cpp
blob: 9e81bb01afd67218433d320b4e7a16252de3657f (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
#include "mappings.hpp"

#include <utility>

Map::Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts) :
    opts(opts),
    name1(primary),
    name2(secondary),
    spline_main(max_x, max_y, primary),
    spline_alt(max_x, max_y, secondary)
{
    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()
{
    spline_main.save();
    spline_alt.save();
}

void Map::load()
{
    spline_main.reload();
    spline_alt.reload();
}

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])
    }
{}