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
|
/* Copyright (c) 2012-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 "ui_ftnoir_accela_filtercontrols.h"
#include "opentrack/plugin-api.hpp"
#include "qfunctionconfigurator/functionconfig.h"
#include <atomic>
#include <QMutex>
#include <QTimer>
#include "opentrack/options.hpp"
using namespace options;
#include "opentrack/timer.hpp"
struct settings_accela : opts {
value<int> rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone;
static constexpr double mult_rot = 4. / 100.;
static constexpr double mult_trans = 4. / 100.;
static constexpr double mult_rot_dz = 2. / 100.;
static constexpr double mult_trans_dz = 2. / 100.;
static constexpr double mult_ewma = 1.25;
settings_accela() :
opts("Accela"),
rot_threshold(b, "rotation-threshold", 30),
trans_threshold(b, "translation-threshold", 50),
ewma(b, "ewma", 2),
rot_deadzone(b, "rotation-deadzone", 0),
trans_deadzone(b, "translation-deadzone", 0)
{}
};
class FTNoIR_Filter : public IFilter
{
public:
FTNoIR_Filter();
void filter(const double* input, double *output);
Map rot, trans;
private:
settings_accela s;
bool first_run;
double last_output[6];
double smoothed_input[6];
Timer t;
};
class FilterControls: public IFilterDialog
{
Q_OBJECT
public:
FilterControls();
void register_filter(IFilter* filter);
void unregister_filter();
private:
Ui::AccelaUICFilterControls ui;
void discard();
void save();
FTNoIR_Filter* accela_filter;
settings_accela s;
private slots:
void doOK();
void doCancel();
void update_ewma_display(int value);
void update_rot_display(int value);
void update_trans_display(int value);
void update_rot_dz_display(int value);
void update_trans_dz_display(int value);
};
class FTNoIR_FilterDll : public Metadata
{
public:
QString name() { return QString("Accela"); }
QIcon icon() { return QIcon(":/images/filter-16.png"); }
};
|