summaryrefslogtreecommitdiffhomepage
path: root/tracker-tobii/tobii.h
blob: 414f9f6492ee442a677a2804c7789e32c25ad938 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Copyright (c) 2023, Khoa Nguyen <khoanguyen@3forcom.com>

 * 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.
 */

#pragma once
#include "api/plugin-api.hpp"
#include "ui_tobii.h"

#include <tobii/tobii.h>
#include <tobii/tobii_streams.h>

#include <QMutex>

class tobii_tracker : public ITracker
{
public:
    tobii_tracker();
    ~tobii_tracker() override;
    module_status start_tracker(QFrame*) override;
    void data(double* data) override;

private:
    tobii_api_t* api = nullptr;
    tobii_device_t* device = nullptr;

    tobii_head_pose_t latest_head_pose{
        .timestamp_us = 0LL,
        .position_validity = TOBII_VALIDITY_INVALID,
        .position_xyz = { 0.f, 0.f, 0.f },
        .rotation_validity_xyz = { TOBII_VALIDITY_INVALID, TOBII_VALIDITY_INVALID, TOBII_VALIDITY_INVALID },
        .rotation_xyz = { 0.f, 0.f, 0.f },
    };

    QMutex mtx;
};

class tobii_dialog : public ITrackerDialog
{
    Q_OBJECT

    Ui::tobii_ui ui;

public:
    tobii_dialog();

private slots:
    void doOK();
    void doCancel();
};

class tobii_metadata : public Metadata
{
    Q_OBJECT

    QString name() override { return tr("Tobii Eye Tracker"); }
    QIcon icon() override { return QIcon(":/images/tobii_logo.png"); }
};