diff options
-rw-r--r-- | tracker-tobii-eyex/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tracker-tobii-eyex/head-tracking.cpp | 2 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/nl_NL.ts | 7 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/ru_RU.ts | 7 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/stub.ts | 7 | ||||
-rw-r--r-- | tracker-tobii-eyex/lang/zh_CN.ts | 7 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex.cpp | 64 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-eyex.hpp | 8 | ||||
-rw-r--r-- | tracker-tobii-eyex/tobii-settings.hpp | 6 |
9 files changed, 75 insertions, 39 deletions
diff --git a/tracker-tobii-eyex/CMakeLists.txt b/tracker-tobii-eyex/CMakeLists.txt index eead67bf..b1dcb056 100644 --- a/tracker-tobii-eyex/CMakeLists.txt +++ b/tracker-tobii-eyex/CMakeLists.txt @@ -1,13 +1,13 @@ if(WIN32) set(SDK_TOBII_EYEX "" CACHE PATH "") if(SDK_TOBII_EYEX) - otr_module(tracker-tobii) + 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(opentrack-tracker-tobii "${tobii-libdir}/Tobii.EyeX.Client.lib") + 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(opentrack-tracker-tobii SYSTEM PUBLIC "${SDK_TOBII_EYEX}/include/eyex") + 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") diff --git a/tracker-tobii-eyex/head-tracking.cpp b/tracker-tobii-eyex/head-tracking.cpp index 8973293d..77394f11 100644 --- a/tracker-tobii-eyex/head-tracking.cpp +++ b/tracker-tobii-eyex/head-tracking.cpp @@ -5,7 +5,7 @@ real tobii_eyex_tracker::gain(real x) { // simple sigmoid - x = clamp(x * 12 - 6, -6, 6); + x = clamp(x * 6, -6, 6); x = 1 / (1 + exp(-x)); x = x * 2 - 1; return clamp(x, -1, 1); diff --git a/tracker-tobii-eyex/lang/nl_NL.ts b/tracker-tobii-eyex/lang/nl_NL.ts index 47076f04..c14cd970 100644 --- a/tracker-tobii-eyex/lang/nl_NL.ts +++ b/tracker-tobii-eyex/lang/nl_NL.ts @@ -9,6 +9,13 @@ </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> diff --git a/tracker-tobii-eyex/lang/ru_RU.ts b/tracker-tobii-eyex/lang/ru_RU.ts index 65ec8ca5..73e7b92b 100644 --- a/tracker-tobii-eyex/lang/ru_RU.ts +++ b/tracker-tobii-eyex/lang/ru_RU.ts @@ -9,6 +9,13 @@ </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> diff --git a/tracker-tobii-eyex/lang/stub.ts b/tracker-tobii-eyex/lang/stub.ts index 6e4c7d1a..8a16308d 100644 --- a/tracker-tobii-eyex/lang/stub.ts +++ b/tracker-tobii-eyex/lang/stub.ts @@ -9,6 +9,13 @@ </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> diff --git a/tracker-tobii-eyex/lang/zh_CN.ts b/tracker-tobii-eyex/lang/zh_CN.ts index 6e4c7d1a..8a16308d 100644 --- a/tracker-tobii-eyex/lang/zh_CN.ts +++ b/tracker-tobii-eyex/lang/zh_CN.ts @@ -9,6 +9,13 @@ </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> diff --git a/tracker-tobii-eyex/tobii-eyex.cpp b/tracker-tobii-eyex/tobii-eyex.cpp index af0d0c05..59a80258 100644 --- a/tracker-tobii-eyex/tobii-eyex.cpp +++ b/tracker-tobii-eyex/tobii-eyex.cpp @@ -15,13 +15,19 @@ #ifdef TOBII_EYEX_VERBOSE_PRINTF # define dbg_verbose(msg) (qDebug() << "tobii-eyex:" << (msg)) #else -# define dbg_verbose(msg) (QMessageLogger().noDebug() << (msg)) +# define dbg_verbose(msg) (void)0 #endif -#ifdef TOBII_EYEX_DEBUG_PRINTF +#ifdef TOBII_EYEX_DEBUG2_PRINTF # define dbg_debug(msg) (qDebug() << "tobii-eyex:" << (msg)) #else -# define dbg_debug(msg) (QMessageLogger().noDebug() << (msg)) +# 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)) @@ -159,35 +165,31 @@ void tobii_eyex_tracker::gaze_data_handler(TX_HANDLE gaze_data_handle) 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) { - 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_DEBUG_PRINTF - char buf[256] = {0}; - (void) std::sprintf(buf, "gaze data: (%.1f, %.1f)", params.X, params.Y); - dbg_debug(buf); + 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; - } + dev_state.fresh = true; } } else - { - dbg_notice("failed to interpret gaze data event packet"); - } + dbg_notice("failed to process gaze data event packet"); } void tobii_eyex_tracker::event_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param) @@ -215,9 +217,15 @@ module_status tobii_eyex_tracker::start_tracker(QFrame*) 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_changed_ticket, state_change_handler, (TX_USERPARAM)this) == TX_RESULT_OK; - status &= txRegisterEventHandler(ctx, &event_handler_ticket, event_handler, (TX_USERPARAM)this) == TX_RESULT_OK; + 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?")); diff --git a/tracker-tobii-eyex/tobii-eyex.hpp b/tracker-tobii-eyex/tobii-eyex.hpp index def2ea2e..a3e9c1f2 100644 --- a/tracker-tobii-eyex/tobii-eyex.hpp +++ b/tracker-tobii-eyex/tobii-eyex.hpp @@ -61,14 +61,14 @@ private: static void TX_CALLCONVENTION display_state_handler(TX_CONSTHANDLE async_data_handle, TX_USERPARAM param); void process_display_state(TX_HANDLE display_state_handle); - real gain(real x); + static real gain(real x); state dev_state; real yaw = 0, pitch = 0; TX_CONTEXTHANDLE ctx = TX_EMPTY_HANDLE; - TX_TICKET state_changed_ticket = TX_INVALID_TICKET; - TX_TICKET event_handler_ticket = TX_INVALID_TICKET; + 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; @@ -83,7 +83,7 @@ class tobii_eyex_metadata : public Metadata { Q_OBJECT - QString name() override { return QString("Tobii EyeX"); } + 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 index 6101a28f..138faa54 100644 --- a/tracker-tobii-eyex/tobii-settings.hpp +++ b/tracker-tobii-eyex/tobii-settings.hpp @@ -34,10 +34,10 @@ struct settings final : public opts 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, .3 } }; + value<slider_value> acc_dz { b, "acc-deadzone", { .15, .0, .5 } }; - value<slider_value> acc_max_yaw { b, "acc-max-yaw", { 30, 15, 45} }, - acc_max_pitch { b, "acc-max-pitch", { 30, 15, 45 } }; + value<slider_value> acc_max_yaw { b, "acc-max-yaw", { 45, 15, 60} }, + acc_max_pitch { b, "acc-max-pitch", { 45, 15, 60 } }; settings(); }; |