From b367b4c39090735ddf40df757ae381f4b4fe13cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 May 2016 13:08:20 +0200 Subject: tracker/tobii-eyex: initial revision --- tracker-tobii-eyex/CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tracker-tobii-eyex/CMakeLists.txt (limited to 'tracker-tobii-eyex/CMakeLists.txt') diff --git a/tracker-tobii-eyex/CMakeLists.txt b/tracker-tobii-eyex/CMakeLists.txt new file mode 100644 index 00000000..a5fb3404 --- /dev/null +++ b/tracker-tobii-eyex/CMakeLists.txt @@ -0,0 +1,21 @@ +if(WIN32) + set(SDK_TOBII_EYEX "" CACHE PATH "") + if(SDK_TOBII_EYEX) + opentrack_boilerplate(opentrack-tracker-tobii-eyex) + 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 + set(tobii-link ${tobii-libdir}/Tobii.EyeX.Client.lib) + target_include_directories(opentrack-tracker-tobii-eyex PRIVATE ${CMAKE_SOURCE_DIR}/spline-widget) + target_link_libraries(opentrack-tracker-tobii-eyex ${tobii-link} opentrack-spline-widget) + # we only ever use the C headers due to Microsoft CRT ABI incompatibility with GNU + set(tobii-incdir ${SDK_TOBII_EYEX}/include/eyex) + target_include_directories(opentrack-tracker-tobii-eyex SYSTEM PUBLIC ${tobii-incdir}) + install(FILES ${tobii-dll} DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + if((CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") AND (CMAKE_SYSTEM_NAME STREQUAL "Windows")) + # let's assume 32-bit Windows host systems doesn't exist at all + install(FILES c:/windows/syswow64/msvcp110.dll DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + install(FILES c:/windows/syswow64/msvcr110.dll DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + endif() + endif() +endif() -- cgit v1.2.3 From fd86eebdd12158d80e4af190e7e7a474b410ce5a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 7 Aug 2016 12:19:20 +0200 Subject: tracker/tobii: remove existing mapping code. maybe later revert this. It doesn't work good enough. Try use splines instead. --- tracker-tobii-eyex/CMakeLists.txt | 1 + tracker-tobii-eyex/tobii-eyex.cpp | 108 ++++++++++++++------------------------ tracker-tobii-eyex/tobii-eyex.hpp | 21 ++++---- 3 files changed, 48 insertions(+), 82 deletions(-) (limited to 'tracker-tobii-eyex/CMakeLists.txt') 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((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(&base_value::valueChanged), + this, + &rel_settings::draw_spline); + QObject::connect(&expt_slope, + static_cast(&base_value::valueChanged), + this, + &rel_settings::draw_spline); + QObject::connect(&expt_norm, + static_cast(&base_value::valueChanged), + this, + &rel_settings::draw_spline); + QObject::connect(&lin_norm, + static_cast(&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 -tobii_eyex_tracker::num tobii_eyex_tracker::piecewise(num x, const funs_seq& funs, const bounds_seq& bounds) -{ - using fn = std::function; - - 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 #include @@ -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 speed, dz_end_pt, expt_val, log_base; + 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 mode; settings() : @@ -75,11 +77,6 @@ private: using num = double; - template - static num piecewise(num x, const funs_seq& funs, const bounds_seq& bounds); - - using fun_t = std::function; - num gain(num x); settings s; -- cgit v1.2.3 From 1f8f6f500d2d0ecebedebcae5fabb4bdac8c7760 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 19 Sep 2016 15:04:51 +0200 Subject: tracker/tobii: don't install. find dynamic CRT harder. --- tracker-tobii-eyex/CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'tracker-tobii-eyex/CMakeLists.txt') diff --git a/tracker-tobii-eyex/CMakeLists.txt b/tracker-tobii-eyex/CMakeLists.txt index 465801ac..9446072c 100644 --- a/tracker-tobii-eyex/CMakeLists.txt +++ b/tracker-tobii-eyex/CMakeLists.txt @@ -1,7 +1,7 @@ if(WIN32) set(SDK_TOBII_EYEX "" CACHE PATH "") if(SDK_TOBII_EYEX) - opentrack_boilerplate(opentrack-tracker-tobii-eyex) + opentrack_boilerplate(opentrack-tracker-tobii-eyex NO-INSTALL) 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) @@ -12,11 +12,21 @@ if(WIN32) # we only ever use the C headers due to Microsoft CRT ABI incompatibility with GNU set(tobii-incdir ${SDK_TOBII_EYEX}/include/eyex) target_include_directories(opentrack-tracker-tobii-eyex SYSTEM PUBLIC ${tobii-incdir}) - install(FILES ${tobii-dll} DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + + if(FALSE) + install(FILES ${tobii-dll} DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + endif() if((CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") AND (CMAKE_SYSTEM_NAME STREQUAL "Windows")) - # let's assume 32-bit Windows host systems doesn't exist at all - install(FILES c:/windows/syswow64/msvcp110.dll DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) - install(FILES c:/windows/syswow64/msvcr110.dll DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + file(TO_CMAKE_PATH "$ENV{SystemRoot}" sysroot) + if (IS_DIRECTORY "${sysroot}/SysWOW64") + set(src "${sysroot}/SysWOW64") + else() + set(src "${sysroot}/System32") + endif() + if(FALSE) + install(FILES "${src}/msvcp110.dll" DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + install(FILES "${src}/msvcr110.dll" DESTINATION ${opentrack-hier-pfx} ${opentrack-perms}) + endif() endif() endif() endif() -- cgit v1.2.3