summaryrefslogtreecommitdiffhomepage
path: root/tracker-steamvr/steamvr.hpp
blob: 1adb40b13600a535a5b51f18b2980184c8ccea26 (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
#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;

using quat = Mat<float, 4, 1>;

struct settings : opts
{
    settings() : opts("valve-steamvr") {}
};

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;

    static quat get_quaternion(const vr::HmdMatrix34_t& r);
    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"); }
};