Files
fs2open.github.com/code/headtracking/trackir.cpp
T
asarium 60afa1431a Add improved head tracking code
This adds an abstraction layer over the previous TrackIR implementation
and also adds an interface for the FreeTrack protocol.
2016-08-13 21:43:23 +02:00

50 lines
1.0 KiB
C++

#include "headtracking/trackir.h"
#include "headtracking/trackirpublic.h"
#include "osapi/osapi.h"
#include <SDL_syswm.h>
namespace headtracking
{
namespace trackir
{
TrackIRProvider::TrackIRProvider()
{
// calling the function that will init all the function pointers for TrackIR stuff (Swifty)
int trackIrInitResult = _trackIRDll.Init(os_get_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";
}
}
}