diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-03-25 09:22:51 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-03-25 09:33:20 +0100 |
commit | 8ed5c071f577cc90a93c6077545cf25b1ad62ee3 (patch) | |
tree | 5fed9145b0defa180b535f65f6e098d1414f58b3 /logic | |
parent | c2446776853ff61f17574d32bb486eaa6535a258 (diff) |
logic/mappings: move from header
Diffstat (limited to 'logic')
-rw-r--r-- | logic/mappings.cpp | 37 | ||||
-rw-r--r-- | logic/mappings.hpp | 54 |
2 files changed, 48 insertions, 43 deletions
diff --git a/logic/mappings.cpp b/logic/mappings.cpp new file mode 100644 index 00000000..115e9083 --- /dev/null +++ b/logic/mappings.cpp @@ -0,0 +1,37 @@ +#pragma once + +#include "mappings.hpp" + +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(opts.clamp); + spline_alt.set_max_input(opts.clamp); +} + +void Map::save(QSettings& s) +{ + spline_main.save(s); + spline_alt.save(s); +} + +void Map::load() +{ + spline_main.reload(); + spline_alt.reload(); +} + +Mappings::Mappings(std::vector<axis_opts*> opts) : + axes { + Map("spline-X", "alt-spline-X", 30, 75, *opts[TX]), + Map("spline-Y", "alt-spline-Y", 30, 75, *opts[TY]), + Map("spline-Z", "alt-spline-Z", 30, 75, *opts[TZ]), + Map("spline-yaw", "alt-spline-yaw", 180, 180, *opts[Yaw]), + Map("spline-pitch", "alt-spline-pitch", 180, 180, *opts[Pitch]), + Map("spline-roll", "alt-spline-roll", 180, 180, *opts[Roll]) + } +{} diff --git a/logic/mappings.hpp b/logic/mappings.hpp index cd3bddeb..fdbac460 100644 --- a/logic/mappings.hpp +++ b/logic/mappings.hpp @@ -7,71 +7,39 @@ #pragma once +#include "export.hpp" #include "options/options.hpp" using namespace options; #include "spline-widget/spline.hpp" #include "main-settings.hpp" -struct Map final +struct OPENTRACK_LOGIC_EXPORT Map final { - 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(opts.clamp); - spline_alt.set_max_input(opts.clamp); - } + Map(QString primary, QString secondary, int max_x, int max_y, axis_opts& opts); - void save(QSettings& s) - { - spline_main.save(s); - spline_alt.save(s); - } - - void load() - { - spline_main.reload(); - spline_alt.reload(); - } + void save(QSettings& s); + void load(); axis_opts& opts; QString name1, name2; spline spline_main, spline_alt; }; -class Mappings +class OPENTRACK_LOGIC_EXPORT Mappings final { private: Map axes[6]; public: - Mappings(std::vector<axis_opts*> opts) : - axes { - Map("spline-X", "alt-spline-X", 30, 75, *opts[TX]), - Map("spline-Y", "alt-spline-Y", 30, 75, *opts[TY]), - Map("spline-Z", "alt-spline-Z", 30, 75, *opts[TZ]), - Map("spline-yaw", "alt-spline-yaw", 180, 180, *opts[Yaw]), - Map("spline-pitch", "alt-spline-pitch", 180, 180, *opts[Pitch]), - Map("spline-roll", "alt-spline-roll", 180, 180, *opts[Roll]) - } - {} + Mappings(std::vector<axis_opts*> opts); - inline Map& operator()(int i) { return axes[i]; } - inline const Map& operator()(int i) const { return axes[i]; } - inline Map& operator()(unsigned i) { return axes[i]; } - inline const Map& operator()(unsigned i) const { return axes[i]; } + 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]); - } } }; |