summaryrefslogtreecommitdiffhomepage
path: root/logic/mappings.hpp
blob: fdbac4606ac4f38ef54e6c8c50b6e6fa43311f21 (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
/* Copyright (c) 2014-2015 Stanislaw Halik
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#pragma once

#include "export.hpp"
#include "options/options.hpp"
using namespace options;
#include "spline-widget/spline.hpp"
#include "main-settings.hpp"

struct OPENTRACK_LOGIC_EXPORT Map final
{
    Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts);

    void save(QSettings& s);
    void load();

    axis_opts& opts;
    QString name1, name2;
    spline spline_main, spline_alt;
};

class OPENTRACK_LOGIC_EXPORT Mappings final
{
private:
    Map axes[6];
public:
    Mappings(std::vector<axis_opts*> opts);

    Map& operator()(int i) { return axes[i]; }
    const Map& operator()(int i) const { return axes[i]; }
    Map& operator()(unsigned i) { return axes[i]; }
    const Map& operator()(unsigned  i) const { return axes[i]; }

    template<typename f> void forall(f&& fun)
    {
        for (unsigned i = 0; i < 6; i++)
            fun(axes[i]);
    }
};