GeekIMU/4.Software/GeekIMU Manager GUI 1.2/GeekIMUDriver 1.2/Src/PipeHMD.cpp

84 lines
1.9 KiB
C++

#include <string>
#include <Windows.h>
#include <stdio.h>
#include <conio.h>
#include "PipeHMD.h"
#include "OVR_CAPI.h"
#include <time.h>
using namespace std;
namespace DMPipe
{
PipeHMD::PipeHMD(string sname) :m_hPipe(INVALID_HANDLE_VALUE)
{
this->name = sname;
}
PipeHMD::~PipeHMD()
{
PipeHMD::Free();
}
BOOL PipeHMD::IsOpen()
{
unsigned int* temp_uint;
memset(reciveBuf, 0, sizeof(BOOL));
BOOL * result = (BOOL *)&reciveBuf[0];
result[0] = FALSE;
temp_uint = (unsigned int*)&writeBuf[0];
temp_uint[0] = COMMAND_DEVICE_IS_OPEN;
temp_uint[1] = 0;
temp_uint[2] = 0;
PipeProcess(sizeof(BOOL));
return result[0];
}
ovrSensorState PipeHMD::GetSensorData()
{
unsigned int* temp_uint;
memset(reciveBuf, 0, sizeof(BOOL));
ovrSensorState * result = (ovrSensorState *)&reciveBuf[0];
temp_uint = (unsigned int*)&writeBuf[0];
temp_uint[0] = COMMAND_GET_DATA;
temp_uint[1] = 0;
temp_uint[2] = 0;
PipeProcess(sizeof(ovrSensorState));
return result[0];
}
SensorPureData PipeHMD::GetPureSensorData()
{
memset(reciveBuf, 0, sizeof(BOOL));
SensorPureData * result = (SensorPureData *)&reciveBuf[0];
return result[0];
}
BOOL PipeHMD::EnterDFUMode()
{
unsigned int* temp_uint;
memset(reciveBuf, 0, sizeof(BOOL));
BOOL * result = (BOOL *)&reciveBuf[0];
result[0] = FALSE;
temp_uint = (unsigned int*)&writeBuf[0];
temp_uint[0] = COMMAND_DEVICE_ENTER_DFU_MODE;
temp_uint[1] = 0;
temp_uint[2] = 0;
PipeProcess(sizeof(BOOL));
return result[0];
}
BOOL PipeHMD::Calibration()
{
unsigned int* temp_uint;
memset(reciveBuf, 0, sizeof(BOOL));
BOOL * result = (BOOL *)&reciveBuf[0];
result[0] = FALSE;
temp_uint = (unsigned int*)&writeBuf[0];
temp_uint[0] = COMMAND_DEVICE_CALIBRATION;
temp_uint[1] = 0;
temp_uint[2] = 0;
PipeProcess(sizeof(BOOL));
return result[0];
}
void PipeHMD::SetName(string sname)
{
this->name = sname;
}
}