File: trackir.cpp

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (55 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (3)
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

#include "headtracking/trackir.h"

#include "headtracking/trackirpublic.h"

#include "osapi/osapi.h"

#include <SDL_syswm.h>

namespace headtracking
{
	namespace trackir
	{
		TrackIRProvider::TrackIRProvider()
		{
			auto window = os::getSDLMainWindow();
			if (window == nullptr)
			{
				throw internal::HeadTrackingException("TrackIR is only available with a valid window!");
			}

			// calling the function that will init all the function pointers for TrackIR stuff (Swifty)
			int trackIrInitResult = _trackIRDll.Init(window);
			if (trackIrInitResult != SCP_INITRESULT_SUCCESS)
			{
				mprintf(("TrackIR Init Failed - %d\n", trackIrInitResult));
				throw internal::HeadTrackingException("Failed to initialize TrackIR");
			}
		}

		TrackIRProvider::~TrackIRProvider()
		{
		}

		bool TrackIRProvider::query(HeadTrackingStatus* statusOut)
		{
			_trackIRDll.Query();

			statusOut->pitch = _trackIRDll.GetPitch();
			statusOut->roll = _trackIRDll.GetRoll();
			statusOut->yaw = _trackIRDll.GetYaw();

			statusOut->x = _trackIRDll.GetX();
			statusOut->y = _trackIRDll.GetY();
			statusOut->z = _trackIRDll.GetZ();

			return true;
		}

		SCP_string TrackIRProvider::getName()
		{
			return "TrackIR";
		}
	}
}