Skip to content

Commit

Permalink
Merge pull request #3 from Dschadu/beta-0.2.2
Browse files Browse the repository at this point in the history
Changed to new OpenVR Version. Fixed Logging.
  • Loading branch information
Dschadu authored Dec 25, 2020
2 parents 36ad1f6 + e78ae80 commit b716811
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 141 deletions.
42 changes: 15 additions & 27 deletions motionPose/MotionPoseController.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "MotionPoseController.h"
#include "third-party/easylogging++/easylogging++.h"

INITIALIZE_EASYLOGGINGPP

namespace driver
{
CMotionPoseControllerDriver::CMotionPoseControllerDriver()
{
LOG(TRACE) << "CMotionPoseControllerDriver()";

m_unObjectId = vr::k_unTrackedDeviceIndexInvalid;
m_ulPropertyContainer = vr::k_ulInvalidPropertyContainer;

m_sSerialNumber = "MotionPoseVirtualController 0.2.1";
m_sSerialNumber = "MotionPoseVirtualController 0.2.2";
m_sModelNumber = "MotionPoseVirtualController";

rigYawOffset = 0;
Expand All @@ -34,12 +34,12 @@ namespace driver

CMotionPoseControllerDriver::~CMotionPoseControllerDriver()
{
LOG(TRACE) << "~CMotionPoseControllerDriver()";
}

vr::EVRInitError CMotionPoseControllerDriver::Activate(vr::TrackedDeviceIndex_t unObjectId)
{
init_logging();
LOG(INFO) << "Activate motionPoseController\n";
LOG(INFO) << "Activate motionPoseController";

m_unObjectId = unObjectId;
m_ulPropertyContainer = vr::VRProperties()->TrackedDeviceToPropertyContainer(m_unObjectId);
Expand All @@ -56,21 +56,6 @@ namespace driver
return vr::VRInitError_None;
}

void CMotionPoseControllerDriver::init_logging()
{
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
el::Configurations conf(logConfigFileName);
conf.parseFromText(logConfigDefault);
//conf.parseFromFile(logConfigFileName);
conf.setRemainingToDefault();
el::Loggers::reconfigureAllLoggers(conf);

LOG(INFO) << "|========================================================================================|";
LOG(INFO) << "motionPose dll loaded...";
LOG(TRACE) << "Trace messages enabled.";
LOG(DEBUG) << "Debug messages enabled.";
}

bool CMotionPoseControllerDriver::openMmf(HANDLE& MapFile, char*& mmfFile, LPCWSTR szName, int BufferSize, bool& Connected)
{
MapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, szName);
Expand All @@ -92,6 +77,8 @@ namespace driver

Connected = true;

LOG(INFO) << "Successfully connected to " << szName;

return true;
}

Expand Down Expand Up @@ -159,14 +146,12 @@ namespace driver
_pose.shouldApplyHeadModel = false;
_pose.willDriftInYaw = false;

vr::HmdQuaternion_t yaw = vrmath::quaternionFromRotationY(rigYawOffset);

// Create connection to OVRMC
if (!_ovrmcConnected)
{
if (openMmf(MapFile_OVRMC, mmfFile_OVRMC, L"Local\\OVRMC_MMFv1", 4096, _ovrmcConnected))
{
Data_OVRMC = (MMFstruct_OVRMC_v1*)mmfFile_OVRMC;
Data_OVRMC = (MMFstruct_OVRMC_v1*)mmfFile_OVRMC;
}
}
else if (Data_OVRMC != nullptr)
Expand Down Expand Up @@ -210,6 +195,7 @@ namespace driver
_pose.poseIsValid = true;
_pose.result = vr::TrackingResult_Running_OK;
}

return _pose;
}
__except (GetExceptionCode() == EXCEPTION_IN_PAGE_ERROR ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
Expand All @@ -220,9 +206,11 @@ namespace driver

void CMotionPoseControllerDriver::RunFrame()
{
vr::DriverPose_t newPose;

try
{
GetPose();
newPose = GetPose();
}
catch (std::exception& e)
{
Expand All @@ -245,11 +233,11 @@ namespace driver
_ovrmcConnected = false;

// Declare pose as invalid
_pose.poseIsValid = false;
_pose.result = vr::TrackingResult_Calibrating_InProgress;
newPose.poseIsValid = false;
newPose.result = vr::TrackingResult_Calibrating_InProgress;
}

vr::VRServerDriverHost()->TrackedDevicePoseUpdated(m_unObjectId, _pose, sizeof(vr::DriverPose_t));
vr::VRServerDriverHost()->TrackedDevicePoseUpdated(m_unObjectId, newPose, sizeof(vr::DriverPose_t));

}
};
17 changes: 0 additions & 17 deletions motionPose/MotionPoseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ namespace driver
MMFstruct_OVRMC_v1* Data_OVRMC = nullptr;
bool _ovrmcConnected = false;

// easylogging++ settings
const char* logConfigFileName = "logging.conf";

const char* logConfigDefault =
"* GLOBAL:\n"
" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n"
" FILENAME = \"driver_motionpose.log\"\n"
" ENABLED = true\n"
" TO_FILE = true\n"
" TO_STANDARD_OUTPUT = true\n"
" MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n"
"* TRACE:\n"
" ENABLED = false\n"
"* DEBUG:\n"
" ENABLED = true\n";

public:
CMotionPoseControllerDriver();
Expand All @@ -93,8 +78,6 @@ namespace driver

virtual vr::EVRInitError Activate(vr::TrackedDeviceIndex_t unObjectId);

void init_logging();

bool openMmf(HANDLE& MapFile, char*& mmfFile, LPCWSTR szName, int BufferSize, bool& Connected);

virtual void Deactivate();
Expand Down
2 changes: 0 additions & 2 deletions motionPose/ServerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
vr::EVRInitError CServerDriver_MotionPose::Init(vr::IVRDriverContext* pDriverContext)
{
VR_INIT_SERVER_DRIVER_CONTEXT(pDriverContext);
InitDriverLog(vr::VRDriverLog());

m_pController = new driver::CMotionPoseControllerDriver();
vr::VRServerDriverHost()->TrackedDeviceAdded(m_pController->GetSerialNumber().c_str(), vr::TrackedDeviceClass_Controller, m_pController);
Expand All @@ -16,7 +15,6 @@ vr::EVRInitError CServerDriver_MotionPose::Init(vr::IVRDriverContext* pDriverCon

void CServerDriver_MotionPose::Cleanup()
{
CleanupDriverLog();
delete m_pController;
m_pController = NULL;
}
Expand Down
1 change: 0 additions & 1 deletion motionPose/ServerDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "openvr_driver.h"
//#include "WatchdogProvider.h"
#include "openvr_math.h"
#include "driverlog.h"
#include "MotionPoseController.h"

class CServerDriver_MotionPose : public vr::IServerTrackedDeviceProvider
Expand Down
47 changes: 47 additions & 0 deletions motionPose/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "logging.h"

const char* logConfigFileName = "logging.conf";

const char* logConfigDefault =
"* GLOBAL:\n"
" FORMAT = \"[%level] %datetime{%Y-%M-%d %H:%m:%s}: %msg\"\n"
" FILENAME = \"driver_motionpose.log\"\n"
" ENABLED = true\n"
" TO_FILE = true\n"
" TO_STANDARD_OUTPUT = true\n"
" MAX_LOG_FILE_SIZE = 2097152 ## 2MB\n"
"* TRACE:\n"
" ENABLED = true\n"
"* DEBUG:\n"
" ENABLED = true\n";

INITIALIZE_EASYLOGGINGPP

void init_logging()
{
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
el::Configurations conf(logConfigFileName);
conf.parseFromText(logConfigDefault);
//conf.parseFromFile(logConfigFileName);
conf.setRemainingToDefault();
el::Loggers::reconfigureAllLoggers(conf);
}

BOOL APIENTRY DllMain(HMODULE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
init_logging();
LOG(INFO) << "|========================================================================================|";
LOG(INFO) << "motionPose dll loaded...";
LOG(TRACE) << "Trace messages enabled.";
LOG(DEBUG) << "Debug messages enabled.";
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
};
return TRUE;
}
60 changes: 0 additions & 60 deletions motionPose/driverlog.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions motionPose/driverlog.h

This file was deleted.

14 changes: 14 additions & 0 deletions motionPose/logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

// easylogging includes
#ifdef NDEBUG
#undef NDEBUG
#define ELPP_THREAD_SAFE
#define ELPP_NO_DEFAULT_LOG_FILE
#include <easylogging++.h>
#define NDEBUG
#else
#define ELPP_THREAD_SAFE
#define ELPP_NO_DEFAULT_LOG_FILE
#include <easylogging++.h>
#endif
4 changes: 2 additions & 2 deletions motionPose/motionPose.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="driver_motionPose.cpp" />
<ClCompile Include="driverlog.cpp" />
<ClCompile Include="MotionPoseController.cpp" />
<ClCompile Include="ServerDriver.cpp" />
<ClCompile Include="WatchdogProvider.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="driver_motionPose.h" />
<ClInclude Include="driverlog.h" />
<ClInclude Include="logging.h" />
<ClInclude Include="MotionPoseController.h" />
<ClInclude Include="ServerDriver.h" />
<ClInclude Include="openvr_math.h" />
Expand Down
12 changes: 6 additions & 6 deletions motionPose/motionPose.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="driverlog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WatchdogProvider.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -30,11 +27,11 @@
<ClCompile Include="MotionPoseController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="driverlog.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="openvr_math.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand All @@ -50,5 +47,8 @@
<ClInclude Include="MotionPoseController.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="logging.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion motionPose/openvr
Submodule openvr updated 45 files
+1 −1 README.md
+ bin/linux32/libopenvr_api.so
+ bin/linux32/libopenvr_api.so.dbg
+ bin/linux64/libopenvr_api.so
+ bin/linux64/libopenvr_api.so.dbg
+ bin/linuxarm64/libopenvr_api.so
+ bin/linuxarm64/libopenvr_api.so.dbg
+ bin/linuxarm64/libopenvr_api_unity.so
+ bin/linuxarm64/libopenvr_api_unity.so.dbg
+0 −20 bin/osx32/libopenvr_api.dylib.dSYM/Contents/Info.plist
+0 −1 bin/osx64/OpenVR.framework/Headers
+0 −1 bin/osx64/OpenVR.framework/OpenVR
+0 −1 bin/osx64/OpenVR.framework/Resources
+0 −3,777 bin/osx64/OpenVR.framework/Versions/A/Headers/openvr.h
+0 −5,052 bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_api.cs
+0 −3,923 bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_api.json
+0 −1,942 bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_capi.h
+0 −2,695 bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_driver.h
+ bin/osx64/OpenVR.framework/Versions/A/OpenVR
+0 −18 bin/osx64/OpenVR.framework/Versions/A/Resources/Info.plist
+0 −1 bin/osx64/OpenVR.framework/Versions/Current
+ bin/win32/openvr_api.dll
+ bin/win32/openvr_api.dll.sig
+ bin/win32/openvr_api.pdb
+ bin/win64/openvr_api.dll
+ bin/win64/openvr_api.dll.sig
+ bin/win64/openvr_api.pdb
+26 −20 headers/openvr.h
+40 −15 headers/openvr_api.cs
+24 −11 headers/openvr_api.json
+25 −7 headers/openvr_capi.h
+49 −24 headers/openvr_driver.h
+ lib/linux32/libopenvr_api.so
+ lib/linux64/libopenvr_api.so
+ lib/linuxarm64/libopenvr_api.so
+ lib/linuxarm64/libopenvr_api_unity.so
+ samples/bin/linux32/libopenvr_api.so
+ samples/bin/linux64/libopenvr_api.so
+ samples/bin/linuxarm64/libopenvr_api.so
+ samples/bin/osx32/libopenvr_api.dylib
+ samples/bin/win32/openvr_api.dll
+ samples/bin/win64/openvr_api.dll
+23 −3 src/vrcommon/sharedlibtools_public.cpp
+3 −1 src/vrcommon/sharedlibtools_public.h
+6 −0 src/vrcommon/strtools_public.cpp

0 comments on commit b716811

Please sign in to comment.