summaryrefslogtreecommitdiffhomepage
path: root/tracker-steamvr/steamvr.hpp
blob: 4a2bd117783170850bbd6059330d67eddbbdd148 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include "api/plugin-api.hpp"
#include "ui_dialog.h"
#include "compat/util.hpp"
#include "options/options.hpp"

#include "compat/euler.hpp"

#include <openvr.h>

#include <atomic>
#include <cmath>
#include <memory>

#include <QString>
#include <QMutex>
#include <QMutexLocker>

using namespace options;

struct settings : opts
{
    value<int> order;
    settings() :
        opts("valve-steamvr"),
        order(b, "rotation-order", 0)
    {}
};

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

    using error_t = vr::EVRInitError;
    using vr_t = vr::IVRSystem*;

    vr_t vr;

    settings s;

    using rmat = euler::rmat;
    using euler_t = euler::euler_t;

    static void vr_deleter();
    static vr_t vr_init(error_t& error);
    static QString strerror(error_t error);
};

class steamvr_dialog : public ITrackerDialog
{
    Q_OBJECT
public:
    steamvr_dialog();

    void register_tracker(ITracker *) override;
    void unregister_tracker() override;
private:
    Ui::dialog ui;
    settings s;
    vr::IVRSystem* vr;
private slots:
    void doOK();
    void doCancel();
};

class steamvr_metadata : public Metadata
{
public:
    QString name() { return QString(QCoreApplication::translate("steamvr_metadata", "Valve SteamVR")); }
    QIcon icon() { return QIcon(":/images/rift_tiny.png"); }
};