summaryrefslogtreecommitdiffhomepage
path: root/tracker-tobii-eyex
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-07 12:19:20 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-19 15:11:00 +0200
commitfd86eebdd12158d80e4af190e7e7a474b410ce5a (patch)
tree1eefa4060ed1dcf1f8f21c183054ca963f7c8855 /tracker-tobii-eyex
parentb367b4c39090735ddf40df757ae381f4b4fe13cb (diff)
tracker/tobii: remove existing mapping code. maybe later revert this.
It doesn't work good enough. Try use splines instead.
Diffstat (limited to 'tracker-tobii-eyex')
-rw-r--r--tracker-tobii-eyex/CMakeLists.txt1
-rw-r--r--tracker-tobii-eyex/tobii-eyex.cpp108
-rw-r--r--tracker-tobii-eyex/tobii-eyex.hpp21
3 files changed, 48 insertions, 82 deletions
diff --git a/tracker-tobii-eyex/CMakeLists.txt b/tracker-tobii-eyex/CMakeLists.txt
index a5fb3404..465801ac 100644
--- a/tracker-tobii-eyex/CMakeLists.txt
+++ b/tracker-tobii-eyex/CMakeLists.txt
@@ -2,6 +2,7 @@ if(WIN32)
set(SDK_TOBII_EYEX "" CACHE PATH "")
if(SDK_TOBII_EYEX)
opentrack_boilerplate(opentrack-tracker-tobii-eyex)
+ target_link_libraries(opentrack-tracker-tobii-eyex opentrack-spline-widget)
set(tobii-libdir ${SDK_TOBII_EYEX}/lib/x86/)
set(tobii-dll ${tobii-libdir}/Tobii.EyeX.Client.dll)
# we only care about the .lib for MSVC++ build anyway
diff --git a/tracker-tobii-eyex/tobii-eyex.cpp b/tracker-tobii-eyex/tobii-eyex.cpp
index d668a4e2..709f1b8f 100644
--- a/tracker-tobii-eyex/tobii-eyex.cpp
+++ b/tracker-tobii-eyex/tobii-eyex.cpp
@@ -42,13 +42,46 @@ static constexpr t clamp(t datum, t min, t max)
return ((datum > max) ? max : ((datum < min) ? min : datum));
}
+void rel_settings::draw_spline()
+{
+ Map& spline = acc_mode_spline;
+
+ spline.removeAllPoints();
+
+ static constexpr float std_norm_expt = 1.f/3;
+ const float norm_expt = std_norm_expt * float(expt_norm.get());
+ static constexpr float std_norm_lin = 2.f/3;
+ const float norm_lin = clamp<float>((1-norm_expt) * lin_norm.get() * std_norm_lin, 0, 1);
+
+}
+
rel_settings::rel_settings() :
opts("tobii-eyex-relative-mode"),
speed(b, "speed", s(5, .1, 10)),
- dz_end_pt(b, "deadzone-length", s(.05, 0, .2)),
- expt_val(b, "exponent", s(1.75, 1.25, 2.25)),
- log_base(b, "logarithm-base", s(1.75, 1.1, 5))
-{}
+ dz_end_pt(b, "deadzone-length", s(4, 0, 15)),
+ expt_slope(b, "exponent-slope", s(1.5, 1.25, 3)),
+ expt_norm(b, "exponent-norm", s(1, .25, 4)),
+ lin_norm(b, "linear-norm", s(1, .25, 4)),
+ acc_mode_spline(100, 100)
+{
+ QObject::connect(&dz_end_pt,
+ static_cast<void(base_value::*)(const slider_value&)>(&base_value::valueChanged),
+ this,
+ &rel_settings::draw_spline);
+ QObject::connect(&expt_slope,
+ static_cast<void(base_value::*)(const slider_value&)>(&base_value::valueChanged),
+ this,
+ &rel_settings::draw_spline);
+ QObject::connect(&expt_norm,
+ static_cast<void(base_value::*)(const slider_value&)>(&base_value::valueChanged),
+ this,
+ &rel_settings::draw_spline);
+ QObject::connect(&lin_norm,
+ static_cast<void(base_value::*)(const slider_value&)>(&base_value::valueChanged),
+ this,
+ &rel_settings::draw_spline);
+ draw_spline();
+}
tobii_eyex_tracker::tobii_eyex_tracker() :
dev_ctx(TX_EMPTY_HANDLE),
@@ -310,74 +343,9 @@ plot_fn(lambda x: piecewise(x, [zero, f, g, h], [.05, .25, .7, 1.]))
*/
-template<typename funs_seq, typename bounds_seq>
-tobii_eyex_tracker::num tobii_eyex_tracker::piecewise(num x, const funs_seq& funs, const bounds_seq& bounds)
-{
- using fn = std::function<num(num)>;
-
- auto funs_it = std::begin(funs);
- auto bounds_it = std::begin(bounds);
-
- auto funs_end = std::end(funs);
- auto bounds_end = std::end(bounds);
-
- num norm = 0;
-
- for (const fn& f : funs)
- {
- norm += f(1);
- }
-
- norm = std::max(num(1e-4), norm);
-
- num last_bound = 0, y = 0;
-
- for (;
- bounds_it != bounds_end && funs_it != funs_end;
- bounds_it++, funs_it++)
- {
- const fn& fun = *funs_it;
- const num bound = *bounds_it;
-
- if (x > bound)
- {
- y += fun(1);
- last_bound = bound;
- }
- else
- {
- const num b = bound - last_bound;
- // rescale x to 0->1
- const num x_ = (x - last_bound) / b;
- y += fun(x_);
- break;
- }
- }
- return clamp(y / norm, num(0), num(1));
-}
-
tobii_eyex_tracker::num tobii_eyex_tracker::gain(num x_)
{
- const num x = std::fabs(x_);
-
- static const fun_t funs[] =
- {
- [](num) -> num { return num(0); },
- [](num x) -> num { return std::pow(x, 1.1)*.08; },
- [](num x) -> num { return x*.5; },
- };
-
- static constexpr num dz_l = .1, expt_l = .3;
-
- static constexpr num ends[] =
- {
- dz_l,
- expt_l,
- 1,
- };
-
- const num ret = piecewise(x, funs, ends);
- return std::copysign(clamp(ret, num(0), num(1)), x_);
+ return 1;
}
void tobii_eyex_tracker::data(double* data)
diff --git a/tracker-tobii-eyex/tobii-eyex.hpp b/tracker-tobii-eyex/tobii-eyex.hpp
index d8bb3606..f64f2495 100644
--- a/tracker-tobii-eyex/tobii-eyex.hpp
+++ b/tracker-tobii-eyex/tobii-eyex.hpp
@@ -16,7 +16,7 @@
using namespace options;
#include "opentrack-compat/timer.hpp"
#include "spline-widget/functionconfig.h"
-#include "spline-widget/qfunctionconfigurator.h"
+#include "qfunctionconfigurator.h"
#include <atomic>
#include <QObject>
@@ -28,17 +28,19 @@ enum tobii_mode
tobii_absolute,
};
-struct rel_settings : public QObject, public opts
+class rel_settings final : public QObject, public opts
{
+ Q_OBJECT
+public:
using s = slider_value;
- value<slider_value> speed, dz_end_pt, expt_val, log_base;
+ value<slider_value> speed, dz_end_pt, expt_slope, expt_norm, lin_norm;
+ Map acc_mode_spline;
rel_settings();
-private:
- // linear coefficient to be the same as exponent
- Map spline;
+private slots:
+ void draw_spline();
};
-struct settings : public opts
+struct settings final : public opts
{
value<tobii_mode> mode;
settings() :
@@ -75,11 +77,6 @@ private:
using num = double;
- template<typename funs_seq, typename bounds_seq>
- static num piecewise(num x, const funs_seq& funs, const bounds_seq& bounds);
-
- using fun_t = std::function<num(num)>;
-
num gain(num x);
settings s;