summaryrefslogtreecommitdiffhomepage
path: root/logic/main-settings.hpp
blob: c5c00a4eabd83a8330784599e4ab4c748c702877 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* Copyright (c) 2015, Stanislaw Halik <sthalik@misaki.pl>

 * 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 <QString>
#include "options/options.hpp"
#include "api/plugin-api.hpp"

using namespace options;

#include "export.hpp"

namespace axis_clamp_opts
{

} // ns axis-clamp-opts

struct axis_opts final
{
    enum max_clamp
    {
        r180 = 180,
        r90 = 90,
        r60 = 60,
        r45 = 45,
        r30 = 30,
        r25 = 25,
        r20 = 20,
        r15 = 15,
        r10 = 10,

        t30 = 30,
        t20 = 20,
        t15 = 15,
        t10 = 10,
    };

    // note, these two bundles can be the same value with no issues
    bundle b_settings_window, b_mapping_window;
    value<double> zero;
    int src;
    bool invert;
    bool altp;
    max_clamp clamp;
    axis_opts(bundle b_settings_window, bundle b_mapping_window, QString pfx, Axis idx) :
        b_settings_window(b_settings_window),
        b_mapping_window(b_mapping_window),
        zero(b_settings_window, n(pfx, "zero-pos"), 0),
        src(idx),
        invert(false),
        altp(false),
        clamp(idx >= Yaw ? r180 : t30)
    {}
private:
    static inline QString n(QString pfx, QString name)
    {
        return QString("%1-%2").arg(pfx, name);
    }
};

struct key_opts
{
    value<QString> keycode, guid;
    value<int> button;

    key_opts(bundle b, const QString& name) :
        keycode(b, QString("keycode-%1").arg(name), ""),
        guid(b, QString("guid-%1").arg(name), ""),
        button(b, QString("button-%1").arg(name), -1)
    {}
};

struct module_settings
{
    bundle b;
    value<QString> tracker_dll, filter_dll, protocol_dll;
    module_settings() :
        b(make_bundle("modules")),
        tracker_dll(b, "tracker-dll", "PointTracker 1.1"),
        filter_dll(b, "filter-dll", "Accela"),
        protocol_dll(b, "protocol-dll", "freetrack 2.0 Enhanced")
    {
    }
};

struct main_settings
{
    bundle b, b_map;
    axis_opts a_x, a_y, a_z;
    axis_opts a_yaw, a_pitch, a_roll;
    value<bool> tray_enabled, tray_start;
    key_opts key_start_tracking1, key_start_tracking2;
    key_opts key_stop_tracking1, key_stop_tracking2;
    key_opts key_toggle_tracking1, key_toggle_tracking2;
    key_opts key_restart_tracking1, key_restart_tracking2;
    key_opts key_center1, key_center2;
    key_opts key_toggle1, key_toggle2;
    main_settings() :
        b(make_bundle("opentrack-ui")),
        b_map(make_bundle("opentrack-mappings")),
        a_x(b, b_map, "x", TX),
        a_y(b, b_map, "y", TY),
        a_z(b, b_map, "z", TZ),
        a_yaw(b, b_map, "yaw", Yaw),
        a_pitch(b, b_map, "pitch", Pitch),
        a_roll(b, b_map, "roll", Roll),
        tray_enabled(b, "use-system-tray", false),
        tray_start(b, "start-in-tray", false),
        key_start_tracking1(b, "start-tracking"),
        key_start_tracking2(b, "start-tracking-alt"),
        key_stop_tracking1(b, "stop-tracking"),
        key_stop_tracking2(b, "stop-tracking-alt"),
        key_toggle_tracking1(b, "toggle-tracking"),
        key_toggle_tracking2(b, "toggle-tracking-alt"),
        key_restart_tracking1(b, "restart-tracking"),
        key_restart_tracking2(b, "restart-tracking-alt"),
        key_center1(b, "center"),
        key_center2(b, "center-alt"),
        key_toggle1(b, "toggle"),
        key_toggle2(b, "toggle-alt")
    {
    }
};