summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
blob: 826cecaa228ccf3c81744989656983a4f36c738d (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
/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
#include "ftnoir_tracker_hydra.h"
#include "opentrack/plugin-api.hpp"
#include <cstdio>
#ifdef _WIN32
#   define SIXENSE_STATIC_LIB
#   define SIXENSE_UTILS_STATIC_LIB
#endif
#include <sixense.h>

Hydra_Tracker::Hydra_Tracker() : should_quit(false) {}

#include <sixense_math.hpp>

Hydra_Tracker::~Hydra_Tracker()
{
	
	sixenseExit();
}

void Hydra_Tracker::start_tracker(QFrame*)
{
	sixenseInit();
}

void Hydra_Tracker::data(double *data)
{
    
	sixenseSetActiveBase(0);
	sixenseAllControllerData acd;
	sixenseGetAllNewestData( &acd );
    sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);

	float ypr[3];
	
	mat.getEulerAngles().fill(ypr);
    data[TX] = acd.controllers[0].pos[0]/50.0;
    data[TY] = acd.controllers[0].pos[1]/50.0;
    data[TZ] = acd.controllers[0].pos[2]/50.0;
    static constexpr double r2d = 57.295781;
    data[Yaw] = ypr[0] * r2d;
    data[Pitch] = ypr[1] * r2d;
    data[Roll] = ypr[2] * r2d;
}

extern "C" OPENTRACK_EXPORT ITracker* GetConstructor()
{
    return new Hydra_Tracker;
}