diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-31 12:38:27 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-31 12:38:27 +0200 |
commit | 5b9ccf5164199804b6574b40914ee77baf0b6a78 (patch) | |
tree | 49659924d357c80d0ae22209bef3b0271c8e68a7 | |
parent | 1e108eb2fd484f62a55041a2d538b8e51bb297e7 (diff) |
tracker/tobii-eyex: remove obsolete code
The API is obsolete as well as the device.
-rw-r--r-- | tracker-tobii-eyex/CMakeLists.txt | 24 | ||||
-rw-r--r-- | tracker-tobii-eyex/head-tracking.cpp | 89 | ||||
-rw-r--r-- | tracker-tobii-eyex/images/tobii-eyex-logo.png | bin | 402 -> 0 bytes | |||
-rw-r--r-- | tracker-tobii-eyex/lang/nl_NL.ts | 25 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/ru_RU.ts | 25 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/stub.ts | 25 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/zh_CN.ts | 25 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex-dialog.cpp | 22 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex-dialog.hpp | 21 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex-dialog.ui | 47 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex-res.qrc | 5 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex.cpp | 248 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex.hpp | 89 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-settings.hpp | 43 |
14 files changed, 0 insertions, 688 deletions
diff --git a/tracker-tobii-eyex/CMakeLists.txt b/tracker-tobii-eyex/CMakeLists.txt deleted file mode 100644 index b1dcb056..00000000 --- a/tracker-tobii-eyex/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -if(WIN32) - set(SDK_TOBII_EYEX "" CACHE PATH "") - if(SDK_TOBII_EYEX) - otr_module(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 - target_link_libraries(${self} "${tobii-libdir}/Tobii.EyeX.Client.lib") - # we only ever use the C headers due to Microsoft CRT ABI incompatibility with GNU - target_include_directories(${self} SYSTEM PUBLIC "${SDK_TOBII_EYEX}/include/eyex") - - install(FILES "${tobii-dll}" DESTINATION "${opentrack-hier-pfx}" PERMISSIONS ${opentrack-perms-exec}) - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - file(TO_CMAKE_PATH "$ENV{SystemRoot}" sysroot) - if (IS_DIRECTORY "${sysroot}/SysWOW64") - set(src "${sysroot}/SysWOW64") - else() - set(src "${sysroot}/System32") - endif() - install(FILES "${src}/msvcp110.dll" DESTINATION ${opentrack-hier-pfx} PERMISSIONS ${opentrack-perms-exec}) - install(FILES "${src}/msvcr110.dll" DESTINATION ${opentrack-hier-pfx} PERMISSIONS ${opentrack-perms-exec}) - endif() - endif() -endif() diff --git a/tracker-tobii-eyex/head-tracking.cpp b/tracker-tobii-eyex/head-tracking.cpp deleted file mode 100644 index 77394f11..00000000 --- a/tracker-tobii-eyex/head-tracking.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "tobii-eyex.hpp" -#include "compat/math.hpp" -#include "compat/math-imports.hpp" - -real tobii_eyex_tracker::gain(real x) -{ - // simple sigmoid - x = clamp(x * 6, -6, 6); - x = 1 / (1 + exp(-x)); - x = x * 2 - 1; - return clamp(x, -1, 1); -} - -void tobii_eyex_tracker::data(double* data) -{ - real px, py, max_x, max_y; - bool fresh; - - { - QMutexLocker l(&global_state_mtx); - - if (!dev_state.is_valid()) - return; - - px = dev_state.px; - py = dev_state.py; - max_x = dev_state.display_res_x - 1; - max_y = dev_state.display_res_y - 1; - - fresh = dev_state.fresh; - dev_state.fresh = false; - } - - if (fresh) - { - real x = (2*px - max_x)/max_x; // (-1)->1 - real y = (2*py - max_y)/max_y; // idem - - data[TX] = x * 50; - data[TY] = y * -50; - - const double dt = t.elapsed_seconds(); - t.start(); - - const double max_yaw = *s.acc_max_yaw, max_pitch = *s.acc_max_pitch; - const double dz_ = *s.acc_dz; // closed set of 0->x, some arbitrary x < 1 - - for (auto* k_ : { &x, &y }) - { - real& k = *k_; - - if (std::fabs(k) < dz_) - k = 0; - else - { - // input has reduced dynamic range - k -= copysign(dz_, k); - k *= 1 + dz_; - } - } - - const double c = *s.acc_speed; - - // XXX check this for stability -sh 20180709 - const double yaw_delta = gain(x) * c * dt; - const double pitch_delta = gain(y) * c * dt; - - yaw += yaw_delta; - pitch += pitch_delta; - - yaw = clamp(yaw, -max_yaw, max_yaw); - pitch = clamp(pitch, -max_pitch, max_pitch); - } - - if (do_center) - { - do_center = false; - yaw = 0; - pitch = 0; - } - - data[Yaw] = yaw; - data[Pitch] = pitch; - data[Roll] = 0; - data[TZ] = 0; // XXX TODO - - // tan(x) in 0->.7 is almost linear. we don't need to adjust. - // .7 is 40 degrees which is already quite a lot from the monitor. -} diff --git a/tracker-tobii-eyex/images/tobii-eyex-logo.png b/tracker-tobii-eyex/images/tobii-eyex-logo.png Binary files differdeleted file mode 100644 index e01bc1ae..00000000 --- a/tracker-tobii-eyex/images/tobii-eyex-logo.png +++ /dev/null diff --git a/tracker-tobii-eyex/lang/nl_NL.ts b/tracker-tobii-eyex/lang/nl_NL.ts deleted file mode 100644 index c14cd970..00000000 --- a/tracker-tobii-eyex/lang/nl_NL.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="nl_NL"> -<context> - <name>tobii_eyex_dialog_widgets</name> - <message> - <source>Tracker options</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_metadata</name> - <message> - <source>Tobii EyeX</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_tracker</name> - <message> - <source>Connection can't be established. device missing?</source> - <translation type="unfinished"></translation> - </message> -</context> -</TS> diff --git a/tracker-tobii-eyex/lang/ru_RU.ts b/tracker-tobii-eyex/lang/ru_RU.ts deleted file mode 100644 index 73e7b92b..00000000 --- a/tracker-tobii-eyex/lang/ru_RU.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1" language="ru_RU"> -<context> - <name>tobii_eyex_dialog_widgets</name> - <message> - <source>Tracker options</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_metadata</name> - <message> - <source>Tobii EyeX</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_tracker</name> - <message> - <source>Connection can't be established. device missing?</source> - <translation type="unfinished"></translation> - </message> -</context> -</TS> diff --git a/tracker-tobii-eyex/lang/stub.ts b/tracker-tobii-eyex/lang/stub.ts deleted file mode 100644 index 8a16308d..00000000 --- a/tracker-tobii-eyex/lang/stub.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1"> -<context> - <name>tobii_eyex_dialog_widgets</name> - <message> - <source>Tracker options</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_metadata</name> - <message> - <source>Tobii EyeX</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_tracker</name> - <message> - <source>Connection can't be established. device missing?</source> - <translation type="unfinished"></translation> - </message> -</context> -</TS> diff --git a/tracker-tobii-eyex/lang/zh_CN.ts b/tracker-tobii-eyex/lang/zh_CN.ts deleted file mode 100644 index 8a16308d..00000000 --- a/tracker-tobii-eyex/lang/zh_CN.ts +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE TS> -<TS version="2.1"> -<context> - <name>tobii_eyex_dialog_widgets</name> - <message> - <source>Tracker options</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_metadata</name> - <message> - <source>Tobii EyeX</source> - <translation type="unfinished"></translation> - </message> -</context> -<context> - <name>tobii_eyex_tracker</name> - <message> - <source>Connection can't be established. device missing?</source> - <translation type="unfinished"></translation> - </message> -</context> -</TS> diff --git a/tracker-tobii-eyex/tobii-eyex-dialog.cpp b/tracker-tobii-eyex/tobii-eyex-dialog.cpp deleted file mode 100644 index 6ab916be..00000000 --- a/tracker-tobii-eyex/tobii-eyex-dialog.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "tobii-eyex-dialog.hpp" - -tobii_eyex_dialog::tobii_eyex_dialog() -{ - ui.setupUi(this); - - connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &tobii_eyex_dialog::do_ok); - connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &tobii_eyex_dialog::do_cancel); - - //tie_setting(s.mode, ui.tracking_mode); -} - -void tobii_eyex_dialog::do_ok() -{ - s.b->save(); - close(); -} - -void tobii_eyex_dialog::do_cancel() -{ - close(); -} diff --git a/tracker-tobii-eyex/tobii-eyex-dialog.hpp b/tracker-tobii-eyex/tobii-eyex-dialog.hpp deleted file mode 100644 index 67cab885..00000000 --- a/tracker-tobii-eyex/tobii-eyex-dialog.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "tobii-settings.hpp" - -#include "api/plugin-api.hpp" -#include "ui_tobii-eyex-dialog.h" -#include <QObject> - -class tobii_eyex_dialog final : public ITrackerDialog -{ - Q_OBJECT - Ui::tobii_eyex_dialog_widgets ui; - settings s; -private slots: - void do_ok(); - void do_cancel(); -public: - tobii_eyex_dialog(); - void register_tracker(ITracker*) override {} - void unregister_tracker() override {} -}; diff --git a/tracker-tobii-eyex/tobii-eyex-dialog.ui b/tracker-tobii-eyex/tobii-eyex-dialog.ui deleted file mode 100644 index 37451f06..00000000 --- a/tracker-tobii-eyex/tobii-eyex-dialog.ui +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>tobii_eyex_dialog_widgets</class> - <widget class="QWidget" name="tobii_eyex_dialog_widgets"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>184</width> - <height>35</height> - </rect> - </property> - <property name="windowTitle"> - <string>Tracker options</string> - </property> - <property name="windowIcon"> - <iconset resource="tobii-eyex-res.qrc"> - <normaloff>:/images/tobii-eyex-logo.png</normaloff>:/images/tobii-eyex-logo.png</iconset> - </property> - <layout class="QGridLayout" name="gridLayout_4"> - <property name="bottomMargin"> - <number>4</number> - </property> - <item row="0" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="tobii-eyex-res.qrc"/> - <include location="tobii-eyex-res.qrc"/> - <include location="tobii-eyex-res.qrc"/> - <include location="tobii-eyex-res.qrc"/> - <include location="tobii-eyex-res.qrc"/> - </resources> - <connections/> -</ui> diff --git a/tracker-tobii-eyex/tobii-eyex-res.qrc b/tracker-tobii-eyex/tobii-eyex-res.qrc deleted file mode 100644 index e3395df9..00000000 --- a/tracker-tobii-eyex/tobii-eyex-res.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>images/tobii-eyex-logo.png</file> - </qresource> -</RCC> diff --git a/tracker-tobii-eyex/tobii-eyex.cpp b/tracker-tobii-eyex/tobii-eyex.cpp deleted file mode 100644 index 59a80258..00000000 --- a/tracker-tobii-eyex/tobii-eyex.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "tobii-eyex.hpp" -#include "compat/math-imports.hpp" - -#include <tuple> -#include <cstdlib> -#include <cstdio> - -#include <QDebug> -#include <QMutexLocker> -#include <QMessageBox> - -//#define TOBII_EYEX_DEBUG_PRINTF -#define TOBII_EYEX_VERBOSE_PRINTF - -#ifdef TOBII_EYEX_VERBOSE_PRINTF -# define dbg_verbose(msg) (qDebug() << "tobii-eyex:" << (msg)) -#else -# define dbg_verbose(msg) (void)0 -#endif - -#ifdef TOBII_EYEX_DEBUG2_PRINTF -# define dbg_debug(msg) (qDebug() << "tobii-eyex:" << (msg)) -#else -# define dbg_debug(msg) (void)0 -#endif - -#ifdef TOBII_EYEX_DEBUG1_PRINTF -# define dbg_debug(msg) (qDebug() << "tobii-eyex:" << (msg)) -#else -# define dbg_debug(msg) (void)0 -#endif - -#define dbg_notice(msg) (qDebug() << "tobii-eyex:" << (msg)) - -std::atomic_flag tobii_eyex_tracker::atexit_done = ATOMIC_FLAG_INIT; - -static inline tobii_eyex_tracker& to_self(TX_USERPARAM param) -{ - return *reinterpret_cast<tobii_eyex_tracker*>(param); -} - -tobii_eyex_tracker::tobii_eyex_tracker() = default; - -void tobii_eyex_tracker::call_tx_deinit() -{ - dbg_notice("uninitialize in atexit at _fini time"); - (void) txUninitializeEyeX(); -} - -tobii_eyex_tracker::~tobii_eyex_tracker() -{ - dbg_verbose("dtor"); - - (void) txDisableConnection(ctx); - (void) txReleaseObject(&state_snapshot); - - bool status = true; - status &= txShutdownContext(ctx, TX_CLEANUPTIMEOUT_FORCEIMMEDIATE, TX_FALSE) == TX_RESULT_OK; - status &= txReleaseContext(&ctx) == TX_RESULT_OK; - - // the API cleanup function needs to be called exactly once over image lifetime. - // client software communicates with a service and a desktop program. - // API is ambiguous as to what happens if the image doesn't call it or crashes. - if (!atexit_done.test_and_set()) - std::atexit(call_tx_deinit); - - if (!status) - dbg_notice("tobii-eyex: can't shutdown properly"); -} - -bool tobii_eyex_tracker::register_state_snapshot(TX_CONTEXTHANDLE dev_ctx, TX_HANDLE* state_snapshot_ptr) -{ - TX_HANDLE handle = TX_EMPTY_HANDLE; - TX_GAZEPOINTDATAPARAMS params = { TX_GAZEPOINTDATAMODE_LIGHTLYFILTERED }; - - bool status = true; - - status &= txCreateGlobalInteractorSnapshot(dev_ctx, client_id, state_snapshot_ptr, &handle) == TX_RESULT_OK; - status &= txCreateGazePointDataBehavior(handle, ¶ms) == TX_RESULT_OK; - - (void) txReleaseObject(&handle); - - return status; -} - -void tobii_eyex_tracker::process_display_state(TX_HANDLE display_state_handle) -{ - TX_SIZE2 screen_res; - - if (txGetStateValueAsSize2(display_state_handle, TX_STATEPATH_EYETRACKINGSCREENBOUNDS, &screen_res) == TX_RESULT_OK) - { - dbg_verbose("got display resolution") << screen_res.Width << screen_res.Height; - - QMutexLocker l(&global_state_mtx); - - dev_state.display_res_x = screen_res.Width; - dev_state.display_res_y = screen_res.Height; - } - else - dbg_notice("can't get display resolution"); -} - -void tobii_eyex_tracker::display_state_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param) -{ - tobii_eyex_tracker& self = to_self(param); - - TX_RESULT result = TX_RESULT_UNKNOWN; - TX_HANDLE state = TX_EMPTY_HANDLE; - - if (txGetAsyncDataResultCode(async_data_handle, &result) == TX_RESULT_OK && - txGetAsyncDataContent(async_data_handle, &state) == TX_RESULT_OK) - { - self.process_display_state(state); - txReleaseObject(&state); - } - else - dbg_notice("error in display state handler"); -} - -void tobii_eyex_tracker::snapshot_committed_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM) -{ - TX_RESULT result = TX_RESULT_UNKNOWN; - txGetAsyncDataResultCode(async_data_handle, &result); - - if (!(result == TX_RESULT_OK || result == TX_RESULT_CANCELLED)) - dbg_notice("snapshot bad result code") << result; -} - -void tobii_eyex_tracker::state_change_handler(TX_CONNECTIONSTATE state, TX_USERPARAM param) -{ - tobii_eyex_tracker& self = to_self(param); - - switch (state) - { - case TX_CONNECTIONSTATE_CONNECTED: - { - bool status = txCommitSnapshotAsync(self.state_snapshot, snapshot_committed_handler, param) == TX_RESULT_OK; - if (!status) - dbg_notice("connected but failed to initialize data stream"); - else - { - txGetStateAsync(self.ctx, TX_STATEPATH_EYETRACKINGSCREENBOUNDS, display_state_handler, param); - dbg_notice("connected, data stream ok"); - } - } - break; - case TX_CONNECTIONSTATE_DISCONNECTED: - dbg_notice("connection state is now disconnected"); - break; - case TX_CONNECTIONSTATE_TRYINGTOCONNECT: - dbg_verbose("trying to establish connection"); - break; - case TX_CONNECTIONSTATE_SERVERVERSIONTOOLOW: - dbg_notice("installed driver version too low"); - break; - case TX_CONNECTIONSTATE_SERVERVERSIONTOOHIGH: - dbg_notice("new driver came up, we need to update sdk"); - break; - } -} - -void tobii_eyex_tracker::gaze_data_handler(TX_HANDLE gaze_data_handle) -{ - TX_GAZEPOINTDATAEVENTPARAMS params; - - if (txGetGazePointDataEventParams(gaze_data_handle, ¶ms) == TX_RESULT_OK) - { - QMutexLocker l(&global_state_mtx); - - if (params.Timestamp > dev_state.last_timestamp && - dev_state.display_res_x > 0 && - // the API allows for events outside screen bounds to e.g. detect looking at keyboard. - // closer to the screen bounds, the values get less accurate. - // ignore events outside the screen bounds. - params.X >= 0 && params.X < dev_state.display_res_x && - params.Y >= 0 && params.Y < dev_state.display_res_y) - { - dev_state.last_timestamp = params.Timestamp; - dev_state.px = params.X; - dev_state.py = params.Y; - -#ifdef TOBII_EYEX_DEBUG2_PRINTF - char buf[256] = {0}; - (void) std::sprintf(buf, "gaze data: (%.1f, %.1f)", params.X, params.Y); - dbg_debug(buf); -#endif - - dev_state.fresh = true; - } - } - else - dbg_notice("failed to process gaze data event packet"); -} - -void tobii_eyex_tracker::event_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param) -{ - tobii_eyex_tracker& self = to_self(param); - - TX_HANDLE event_handle = TX_EMPTY_HANDLE; - TX_HANDLE behavior_handle = TX_EMPTY_HANDLE; - - txGetAsyncDataContent(async_data_handle, &event_handle); - - if (txGetEventBehavior(event_handle, &behavior_handle, TX_BEHAVIORTYPE_GAZEPOINTDATA) == TX_RESULT_OK) - { - self.gaze_data_handler(behavior_handle); - txReleaseObject(&behavior_handle); - } - - txReleaseObject(&event_handle); -} - -module_status tobii_eyex_tracker::start_tracker(QFrame*) -{ - bool status = true; - - status &= txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, nullptr, nullptr, nullptr, nullptr) == TX_RESULT_OK; - status &= txCreateContext(&ctx, TX_FALSE) == TX_RESULT_OK; - status &= register_state_snapshot(ctx, &state_snapshot); - status &= txRegisterConnectionStateChangedHandler(ctx, &state_change_ticket, state_change_handler, (TX_USERPARAM)this) == TX_RESULT_OK; - status &= txRegisterEventHandler(ctx, &event_cookie, event_handler, (TX_USERPARAM)this) == TX_RESULT_OK; - status &= txEnableConnection(ctx) == TX_RESULT_OK; -#if 0 - // XXX check this - TX_CONNECTIONSTATE state; - status &= txGetConnectionState(ctx, &state) == TX_RESULT_OK; - status &= state == TX_CONNECTIONSTATE_CONNECTED || state == TX_CONNECTIONSTATE_TRYINGTOCONNECT; -#endif - - if (!status) - return error(tr("Connection can't be established. device missing?")); - else - return status_ok(); -} - -bool tobii_eyex_tracker::center() -{ - do_center = true; - return true; -} - -settings::settings() : opts("tobii-eyex") {} - -state::state() = default; - -#include "tobii-eyex-dialog.hpp" - -OPENTRACK_DECLARE_TRACKER(tobii_eyex_tracker, tobii_eyex_dialog, tobii_eyex_metadata) diff --git a/tracker-tobii-eyex/tobii-eyex.hpp b/tracker-tobii-eyex/tobii-eyex.hpp deleted file mode 100644 index a3e9c1f2..00000000 --- a/tracker-tobii-eyex/tobii-eyex.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once - -/* Copyright (c) 2016 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. - */ - -#include "tobii-settings.hpp" - -#include "api/plugin-api.hpp" -#include "options/options.hpp" -using namespace options; -#include "compat/timer.hpp" - -#include <EyeX.h> - -#include <functional> -#include <atomic> - -#include <QObject> -#include <QMutex> - -//using real = TX_REAL; -using real = double; - -struct state -{ - real display_res_x = -1, display_res_y = -1; - real px = -1, py = -1; - real last_timestamp = -1; - bool fresh = false; - - state(); - bool is_valid() const { return !(display_res_x < 0 || px < 0); } -}; - -class tobii_eyex_tracker : public TR, public ITracker -{ - Q_OBJECT - -public: - tobii_eyex_tracker(); - ~tobii_eyex_tracker() override; - module_status start_tracker(QFrame*) override; - void data(double *data) override; - bool center() override; -private: - static constexpr inline const char* const client_id = "opentrack-tobii-eyex"; - - static void call_tx_deinit(); - - static bool register_state_snapshot(TX_CONTEXTHANDLE ctx, TX_HANDLE* state_snapshot_ptr); - static std::atomic_flag atexit_done; - static void TX_CALLCONVENTION state_change_handler(TX_CONNECTIONSTATE state, TX_USERPARAM param); - static void TX_CALLCONVENTION event_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param); - void gaze_data_handler(TX_HANDLE gaze_data_handle); - static void TX_CALLCONVENTION snapshot_committed_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param); - static void TX_CALLCONVENTION display_state_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param); - void process_display_state(TX_HANDLE display_state_handle); - - static real gain(real x); - - state dev_state; - real yaw = 0, pitch = 0; - - TX_CONTEXTHANDLE ctx = TX_EMPTY_HANDLE; - TX_TICKET state_change_ticket = TX_INVALID_TICKET; - TX_TICKET event_cookie = TX_INVALID_TICKET; - TX_HANDLE state_snapshot = TX_EMPTY_HANDLE; - TX_HANDLE display_state = TX_EMPTY_HANDLE; - - QMutex global_state_mtx; - settings s; - Timer t; - - std::atomic<bool> do_center = false; -}; - -class tobii_eyex_metadata : public Metadata -{ - Q_OBJECT - - QString name() override { return tr("Tobii EyeX"); } - QIcon icon() override { return QIcon(":/images/tobii-eyex-logo.png"); } -}; - diff --git a/tracker-tobii-eyex/tobii-settings.hpp b/tracker-tobii-eyex/tobii-settings.hpp deleted file mode 100644 index 138faa54..00000000 --- a/tracker-tobii-eyex/tobii-settings.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include "options/options.hpp" -using namespace options; - -enum tobii_mode -{ - tobii_snap = 0xf00d, - tobii_acc = 0xacc, -}; - -enum max_yaw -{ - y10, y15, y20, y30, y45, -}; - -enum max_pitch -{ - p10, p15, p25, p35, -}; - -struct settings final : public opts -{ -#if 0 - value<tobii_mode> mode { b, "mode", tobii_snap }; - - value<slider_value> snap_speed {b, "snap-speed", { .1, .05, 1 }}, - snap_inv_dz {b, "snap-screen-edge-length", { .35, .1, .5 }}; - value<slider_value> acc_speed {b, "acc-speed", { .1, .05, 1 }}, - acc_dz_len {b, "acc-screen-edge-length", { .1, .1, 1 }}; - value<max_yaw> snap_yaw {b, "snap-max-yaw", y20}, - value<max_pitch> snap_pitch {b, "snap-max-pitch", p15}, - acc_pitch {b, "acc-max-pitch", p15}; - acc_yaw {b, "acc-max-yaw", y20}; -#endif - value<slider_value> acc_speed { b, "acc-max-speed-deg", { 3, 1, 10 } }; - value<slider_value> acc_dz { b, "acc-deadzone", { .15, .0, .5 } }; - - value<slider_value> acc_max_yaw { b, "acc-max-yaw", { 45, 15, 60} }, - acc_max_pitch { b, "acc-max-pitch", { 45, 15, 60 } }; - - settings(); -}; |