summaryrefslogtreecommitdiffhomepage
path: root/tracker-tobii/ftnoir_tracker_tobii.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2020-11-20 02:23:26 +0000
committerGitHub <noreply@github.com>2020-11-20 02:23:26 +0000
commit058942f40e17e091b91df5436d771d61203ccc73 (patch)
tree2562bb275b5ee9d5eed1cd383642d587aaf07ad2 /tracker-tobii/ftnoir_tracker_tobii.cpp
parentf0e7870d66bbaf42ec0f1cd03dcc2da0dee6dd56 (diff)
parentcf89cd0ee392a73c7b92d0220b3963f1901908ae (diff)
Merge pull request #1037 from ballista-milsim/tracker-tobii
WIP Tobii Eye tracker support.
Diffstat (limited to 'tracker-tobii/ftnoir_tracker_tobii.cpp')
-rw-r--r--tracker-tobii/ftnoir_tracker_tobii.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/tracker-tobii/ftnoir_tracker_tobii.cpp b/tracker-tobii/ftnoir_tracker_tobii.cpp
new file mode 100644
index 00000000..43cb1662
--- /dev/null
+++ b/tracker-tobii/ftnoir_tracker_tobii.cpp
@@ -0,0 +1,65 @@
+#include "ftnoir_tracker_tobii.h"
+#include "api/plugin-api.hpp"
+#include "compat/math.hpp"
+
+tobii::~tobii() = default;
+
+module_status tobii::start_tracker(QFrame*)
+{
+ t.start();
+ return status_ok();
+}
+
+void tobii::data(double *data)
+{
+ if (t.head_pose) {
+ tobii_head_pose_t p = *t.head_pose;
+ if (p.position_validity == TOBII_VALIDITY_VALID) {
+ if (center_pose.position_validity == TOBII_VALIDITY_VALID) {
+ p.position_xyz[0] = p.position_xyz[0] - center_pose.position_xyz[0];
+ p.position_xyz[1] = p.position_xyz[1] - center_pose.position_xyz[1];
+ p.position_xyz[2] = p.position_xyz[2] - center_pose.position_xyz[2];
+ }
+ else {
+ center_pose = p;
+ }
+ data[0] = clamp(p.position_xyz[0] * 30.0 / 300.0, -30.0, 30.0);
+ data[1] = clamp(p.position_xyz[1] * 30.0 / 300.0, -30.0, 30.0);
+ data[2] = clamp(p.position_xyz[2] * 30.0 / 300.0, -30.0, 30.0);
+ }
+
+ double max_yaw = 90.0;
+ if (p.rotation_validity_xyz[1] == TOBII_VALIDITY_VALID) {
+ if (center_pose.rotation_validity_xyz[1] == TOBII_VALIDITY_VALID) {
+ p.rotation_xyz[1] = p.rotation_xyz[1] - center_pose.rotation_xyz[1];
+ }
+ data[3] = clamp(p.rotation_xyz[1] * 100.0 * max_yaw / 90.0, -max_yaw, max_yaw);
+ }
+
+ double max_pitch = 90.0;
+ if (p.rotation_validity_xyz[0] == TOBII_VALIDITY_VALID) {
+ if (center_pose.rotation_validity_xyz[0] == TOBII_VALIDITY_VALID) {
+ p.rotation_xyz[0] = p.rotation_xyz[0] - center_pose.rotation_xyz[0];
+ }
+ data[4] = clamp(p.rotation_xyz[0] * 100.0 * max_pitch / 90.0, -max_pitch, max_pitch);
+ }
+
+ double max_roll = 90.0;
+ if (p.rotation_validity_xyz[2] == TOBII_VALIDITY_VALID) {
+ if (center_pose.rotation_validity_xyz[2] == TOBII_VALIDITY_VALID) {
+ p.rotation_xyz[2] = p.rotation_xyz[2] - center_pose.rotation_xyz[2];
+ }
+ data[5] = clamp(p.rotation_xyz[2] * 100.0 * max_roll / 90.0, -max_roll, max_roll);
+ }
+ }
+}
+
+bool tobii::center ()
+{
+ if (t.head_pose) {
+ center_pose = *t.head_pose;
+ }
+ return false;
+}
+
+OPENTRACK_DECLARE_TRACKER(tobii, dialog_tobii, tobiiDll)